spans now good (other than direction) + refactor

This commit is contained in:
2025-08-11 02:26:28 -04:00
parent 95a07786bb
commit fa930180c1

View File

@@ -1,7 +1,7 @@
use std::sync::Arc; use std::sync::Arc;
use app::App; use app::App;
use gui::{Dir, Rect, UI, UIColor, WidgetArrUtil, fixed, ratio, rel}; use gui::{Dir, Rect, UI, UIColor, WidgetArrUtil, WidgetUtil, fixed, ratio, rel};
use render::Renderer; use render::Renderer;
use winit::{event::WindowEvent, event_loop::ActiveEventLoop, window::Window}; use winit::{event::WindowEvent, event_loop::ActiveEventLoop, window::Window};
@@ -21,36 +21,30 @@ impl Client {
let mut renderer = Renderer::new(window); let mut renderer = Renderer::new(window);
let rect = Rect { let rect = Rect {
color: UIColor::WHITE, color: UIColor::WHITE,
radius: 50.0, radius: 20.0,
thickness: 0.0, thickness: 0.0,
inner_radius: 0.0, inner_radius: 0.0,
}; };
let mut ui = UI::build(); let mut ui = UI::build();
let blue = ui.add(rect.color(UIColor::BLUE)); let blue = ui.add(rect.color(UIColor::BLUE));
let handle = blue.handle(); let handle = blue.handle();
// let mut ui = ui.finish(
// (
// (
// blue,
// (
// rect.color(UIColor::RED).center((100.0, 100.0)),
// (
// rect.color(UIColor::ORANGE),
// rect.color(UIColor::LIME).pad(10.0),
// )
// .span(Axis::Y, [1, 1]),
// rect.color(UIColor::YELLOW),
// )
// .span(Axis::X, [2, 2, 1])
// .pad(10),
// )
// .span(Axis::X, [1, 3]),
// rect.color(UIColor::GREEN),
// )
// .span(Axis::Y, [3, 1])
// .pad(10),
// );
let mut ui = ui.finish( let mut ui = ui.finish(
(
(
blue,
(
rect.color(UIColor::RED).center((100.0, 100.0)),
(
rect.color(UIColor::ORANGE),
rect.color(UIColor::LIME).pad(10.0),
)
.span(Dir::RIGHT, [1, 1]),
rect.color(UIColor::YELLOW),
)
.span(Dir::RIGHT, [2, 2, 1])
.pad(10),
)
.span(Dir::RIGHT, [1, 3]),
( (
rect.color(UIColor::GREEN), rect.color(UIColor::GREEN),
rect.color(UIColor::ORANGE), rect.color(UIColor::ORANGE),
@@ -70,6 +64,9 @@ impl Client {
fixed(100), fixed(100),
], ],
), ),
)
.span(Dir::DOWN, [3, 1])
.pad(10),
); );
ui.widgets.get_mut(&handle).unwrap().color = UIColor::MAGENTA; ui.widgets.get_mut(&handle).unwrap().color = UIColor::MAGENTA;
renderer.update(&ui); renderer.update(&ui);