preparation
This commit is contained in:
@@ -22,6 +22,7 @@ pub struct Client {
|
||||
input: Input,
|
||||
ui: Ui,
|
||||
info: WidgetId<Text>,
|
||||
selected: Option<WidgetId<Text>>,
|
||||
}
|
||||
|
||||
impl Client {
|
||||
@@ -30,58 +31,58 @@ impl Client {
|
||||
|
||||
let mut ui = Ui::new();
|
||||
let rrect = rect(Color::WHITE).radius(20);
|
||||
let pad_test = ui.add_static(
|
||||
let pad_test = (
|
||||
rrect.color(Color::BLUE),
|
||||
(
|
||||
rrect.color(Color::BLUE),
|
||||
rrect.color(Color::RED).size(100).center(),
|
||||
(
|
||||
rrect.color(Color::RED).size(100).center(),
|
||||
(
|
||||
rrect.color(Color::ORANGE),
|
||||
rrect.color(Color::LIME).pad(10.0),
|
||||
)
|
||||
.span(Dir::RIGHT, [1, 1]),
|
||||
rrect.color(Color::YELLOW),
|
||||
rrect.color(Color::ORANGE),
|
||||
rrect.color(Color::LIME).pad(10.0),
|
||||
)
|
||||
.span(Dir::RIGHT, [2, 2, 1])
|
||||
.pad(10),
|
||||
.span(Dir::RIGHT, [1, 1]),
|
||||
rrect.color(Color::YELLOW),
|
||||
)
|
||||
.span(Dir::RIGHT, [1, 3]),
|
||||
);
|
||||
let span_test = ui.add_static(
|
||||
(
|
||||
rrect.color(Color::GREEN),
|
||||
rrect.color(Color::ORANGE),
|
||||
rrect.color(Color::CYAN),
|
||||
rrect.color(Color::BLUE),
|
||||
rrect.color(Color::MAGENTA),
|
||||
rrect.color(Color::RED),
|
||||
)
|
||||
.span(
|
||||
Dir::LEFT,
|
||||
[
|
||||
fixed(100),
|
||||
ratio(1),
|
||||
ratio(1),
|
||||
relative(0.5),
|
||||
fixed(100),
|
||||
fixed(100),
|
||||
],
|
||||
),
|
||||
);
|
||||
let span_add = ui.add_static(Span::empty(Dir::RIGHT));
|
||||
.span(Dir::RIGHT, [2, 2, 1])
|
||||
.pad(10),
|
||||
)
|
||||
.span(Dir::RIGHT, [1, 3])
|
||||
.add_static(&mut ui);
|
||||
|
||||
let main = ui.add_static(pad_test.pad(10));
|
||||
let span_test = (
|
||||
rrect.color(Color::GREEN),
|
||||
rrect.color(Color::ORANGE),
|
||||
rrect.color(Color::CYAN),
|
||||
rrect.color(Color::BLUE),
|
||||
rrect.color(Color::MAGENTA),
|
||||
rrect.color(Color::RED),
|
||||
)
|
||||
.span(
|
||||
Dir::LEFT,
|
||||
[
|
||||
fixed(100),
|
||||
ratio(1),
|
||||
ratio(1),
|
||||
relative(0.5),
|
||||
fixed(100),
|
||||
fixed(100),
|
||||
],
|
||||
)
|
||||
.add_static(&mut ui);
|
||||
|
||||
let span_add = Span::empty(Dir::RIGHT).add_static(&mut ui);
|
||||
|
||||
let main = pad_test.pad(10).add_static(&mut ui);
|
||||
|
||||
let switch_button = |color, to, label| {
|
||||
let rect = rect(color)
|
||||
.id_on(PRESS_START, move |id, ui| {
|
||||
.id_on(PRESS_START, move |id, ui, _| {
|
||||
ui[main].inner.set_static(to);
|
||||
ui[id].color = color.add_rgb(-0.2);
|
||||
})
|
||||
.edit_on(HOVER_START | PRESS_END, move |r| {
|
||||
.edit_on(HOVER_START | PRESS_END, move |r, _| {
|
||||
r.color = color.add_rgb(0.4);
|
||||
})
|
||||
.edit_on(HOVER_END, move |r| {
|
||||
.edit_on(HOVER_END, move |r, _| {
|
||||
r.color = color;
|
||||
});
|
||||
(rect, text(label).font_size(30)).stack()
|
||||
@@ -89,38 +90,52 @@ impl Client {
|
||||
|
||||
let btext = |content| text(content).font_size(30);
|
||||
|
||||
let text_test = ui.add_static(
|
||||
let text_test = (
|
||||
btext("this is a").align(Align::Left),
|
||||
btext("teeeeeeeest").align(Align::Right),
|
||||
btext("okkk\nokkkkkk!").align(Align::Left),
|
||||
btext("hmm"),
|
||||
btext("a"),
|
||||
(
|
||||
btext("this is a").align(Align::Left),
|
||||
btext("teeeeeeeest").align(Align::Left),
|
||||
btext("okkk\nokkkkkk!").align(Align::Left),
|
||||
btext("hmm"),
|
||||
btext("a"),
|
||||
(
|
||||
btext("'").family(Family::Monospace).align(Align::Top),
|
||||
btext("'").family(Family::Monospace),
|
||||
btext(":gamer mode").family(Family::Monospace),
|
||||
rect(Color::CYAN).size(10).center(),
|
||||
rect(Color::RED).size(100).center(),
|
||||
)
|
||||
.span(Dir::RIGHT, sized())
|
||||
.center(),
|
||||
text("pretty cool right?").font_size(50),
|
||||
btext("'").family(Family::Monospace).align(Align::Top),
|
||||
btext("'").family(Family::Monospace),
|
||||
btext(":gamer mode").family(Family::Monospace),
|
||||
rect(Color::CYAN).size(10).center(),
|
||||
rect(Color::RED).size(100).center(),
|
||||
)
|
||||
.span(Dir::DOWN, sized()),
|
||||
);
|
||||
.span(Dir::RIGHT, sized())
|
||||
.center(),
|
||||
text("pretty cool right?").font_size(50),
|
||||
)
|
||||
.span(Dir::DOWN, sized())
|
||||
.add_static(&mut ui);
|
||||
|
||||
let texts = Span::empty(Dir::DOWN).add(&mut ui);
|
||||
let text_edit_scroll = (
|
||||
texts,
|
||||
text("add").font_size(30).edit_on(PRESS_START, |text, ctx| {
|
||||
text.select(ctx.cursor, ctx.size);
|
||||
}),
|
||||
)
|
||||
.span(Dir::DOWN, [ratio(1), fixed(40)])
|
||||
.add_static(&mut ui);
|
||||
|
||||
let tabs = (
|
||||
switch_button(Color::RED, pad_test, "pad test"),
|
||||
switch_button(Color::GREEN, span_test, "span test"),
|
||||
switch_button(Color::BLUE, span_add, "span add test"),
|
||||
switch_button(Color::MAGENTA, text_test, "text test"),
|
||||
switch_button(Color::RED, pad_test, "pad"),
|
||||
switch_button(Color::GREEN, span_test, "span"),
|
||||
switch_button(Color::BLUE, span_add, "image span"),
|
||||
switch_button(Color::MAGENTA, text_test, "text layout"),
|
||||
switch_button(
|
||||
Color::YELLOW.mul_rgb(0.5),
|
||||
text_edit_scroll,
|
||||
"text edit scroll",
|
||||
),
|
||||
)
|
||||
.span(Dir::RIGHT, ratio(1));
|
||||
|
||||
let add_button = rect(Color::LIME)
|
||||
.radius(30)
|
||||
.on(PRESS_START, move |ui| {
|
||||
.on(PRESS_START, move |ui, _| {
|
||||
let child = ui
|
||||
.add(image(include_bytes!("assets/sungals.png")).center())
|
||||
.erase_type();
|
||||
@@ -131,17 +146,15 @@ impl Client {
|
||||
|
||||
let del_button = rect(Color::RED)
|
||||
.radius(30)
|
||||
.on(PRESS_START, move |ui| {
|
||||
.on(PRESS_START, move |ui, _| {
|
||||
ui[span_add].children.pop();
|
||||
})
|
||||
.size(150)
|
||||
.align(Align::BotLeft);
|
||||
|
||||
let info = ui.add(text(""));
|
||||
let info_sect = info
|
||||
.clone()
|
||||
.region(Align::TopRight.pos().expand((150, 150)).shifted((-75, 0)));
|
||||
ui.set_base(
|
||||
let info = text("").add(&mut ui);
|
||||
let info_sect = info.clone().pad(10).align(Align::BotLeft);
|
||||
ui.set_root(
|
||||
(
|
||||
tabs.label("tabs"),
|
||||
(
|
||||
@@ -162,6 +175,7 @@ impl Client {
|
||||
input: Input::default(),
|
||||
ui,
|
||||
info,
|
||||
selected: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,8 +198,9 @@ impl Client {
|
||||
_ => (),
|
||||
}
|
||||
let new = format!(
|
||||
"widgets: {}\nviews: {}",
|
||||
"widgets: {}\nactive:{}\nviews: {}",
|
||||
self.ui.num_widgets(),
|
||||
self.ui.active_widgets(),
|
||||
self.renderer.ui.view_count()
|
||||
);
|
||||
if new != self.ui[&self.info].content {
|
||||
|
||||
Reference in New Issue
Block a user