This commit is contained in:
2025-08-28 22:49:58 -04:00
parent 3df76d926c
commit 55bee4b25e
2 changed files with 23 additions and 20 deletions

View File

@@ -37,3 +37,7 @@ impl Widget for Rect {
});
}
}
pub fn rect(color: UiColor) -> Rect {
Rect::new(color)
}

View File

@@ -29,20 +29,18 @@ impl Client {
let renderer = Renderer::new(window);
let mut ui = Ui::new();
let rect = Rect {
color: Color::WHITE,
radius: 20.0,
thickness: 0.0,
inner_radius: 0.0,
};
let rrect = rect(Color::WHITE).radius(20);
let pad_test = ui.add_static(
(
rect.color(Color::BLUE),
rrect.color(Color::BLUE),
(
rect.color(Color::RED).size(100).center(),
(rect.color(Color::ORANGE), rect.color(Color::LIME).pad(10.0))
rrect.color(Color::RED).size(100).center(),
(
rrect.color(Color::ORANGE),
rrect.color(Color::LIME).pad(10.0),
)
.span(Dir::RIGHT, [1, 1]),
rect.color(Color::YELLOW),
rrect.color(Color::YELLOW),
)
.span(Dir::RIGHT, [2, 2, 1])
.pad(10),
@@ -51,12 +49,12 @@ impl Client {
);
let span_test = ui.add_static(
(
rect.color(Color::GREEN),
rect.color(Color::ORANGE),
rect.color(Color::CYAN),
rect.color(Color::BLUE),
rect.color(Color::MAGENTA),
rect.color(Color::RED),
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,
@@ -75,7 +73,7 @@ impl Client {
let main = ui.add_static(pad_test.pad(10));
let switch_button = |color, to, label| {
let rect = Rect::new(color)
let rect = rect(color)
.id_on(PRESS_START, move |id, ui| {
ui[main].inner.set_static(to);
ui[id].color = color.add_rgb(-0.2);
@@ -103,7 +101,8 @@ impl Client {
.align(Align::Top),
text("'").font_size(30).family(Family::Monospace),
text(":gamer mode").font_size(30).family(Family::Monospace),
Rect::new(Color::BLUE).size(100),
rect(Color::CYAN).size(10).center(),
rect(Color::RED).size(100).center(),
)
.span(Dir::RIGHT, sized())
.center(),
@@ -120,7 +119,7 @@ impl Client {
)
.span(Dir::RIGHT, ratio(1));
let add_button = Rect::new(Color::LIME)
let add_button = rect(Color::LIME)
.radius(30)
.on(PRESS_START, move |ui| {
let child = ui
@@ -131,7 +130,7 @@ impl Client {
.size(150)
.align(Align::BotRight);
let del_button = Rect::new(Color::RED)
let del_button = rect(Color::RED)
.radius(30)
.on(PRESS_START, move |ui| {
ui[span_add].children.pop();