spans now good (other than direction) + refactor
This commit is contained in:
@@ -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,55 +21,52 @@ 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(
|
||||||
(
|
(
|
||||||
rect.color(UIColor::GREEN),
|
(
|
||||||
rect.color(UIColor::ORANGE),
|
blue,
|
||||||
rect.color(UIColor::CYAN),
|
(
|
||||||
rect.color(UIColor::BLUE),
|
rect.color(UIColor::RED).center((100.0, 100.0)),
|
||||||
rect.color(UIColor::MAGENTA),
|
(
|
||||||
rect.color(UIColor::RED),
|
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::ORANGE),
|
||||||
|
rect.color(UIColor::CYAN),
|
||||||
|
rect.color(UIColor::BLUE),
|
||||||
|
rect.color(UIColor::MAGENTA),
|
||||||
|
rect.color(UIColor::RED),
|
||||||
|
)
|
||||||
|
.span(
|
||||||
|
Dir::RIGHT,
|
||||||
|
[
|
||||||
|
fixed(100),
|
||||||
|
ratio(1),
|
||||||
|
ratio(1),
|
||||||
|
rel(0.5),
|
||||||
|
fixed(100),
|
||||||
|
fixed(100),
|
||||||
|
],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.span(
|
.span(Dir::DOWN, [3, 1])
|
||||||
Dir::RIGHT,
|
.pad(10),
|
||||||
[
|
|
||||||
fixed(100),
|
|
||||||
ratio(1),
|
|
||||||
ratio(1),
|
|
||||||
rel(0.5),
|
|
||||||
fixed(100),
|
|
||||||
fixed(100),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
ui.widgets.get_mut(&handle).unwrap().color = UIColor::MAGENTA;
|
ui.widgets.get_mut(&handle).unwrap().color = UIColor::MAGENTA;
|
||||||
renderer.update(&ui);
|
renderer.update(&ui);
|
||||||
|
|||||||
Reference in New Issue
Block a user