senses are now bitflags
This commit is contained in:
@@ -2,6 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use app::App;
|
||||
use render::Renderer;
|
||||
use senses::*;
|
||||
use ui::prelude::*;
|
||||
use winit::{event::WindowEvent, event_loop::ActiveEventLoop, window::Window};
|
||||
|
||||
@@ -29,22 +30,19 @@ impl Client {
|
||||
|
||||
let mut ui = Ui::new();
|
||||
let rect = Rect {
|
||||
color: UiColor::WHITE,
|
||||
color: Color::WHITE,
|
||||
radius: 20.0,
|
||||
thickness: 0.0,
|
||||
inner_radius: 0.0,
|
||||
};
|
||||
let pad_test = ui.add_static(
|
||||
(
|
||||
rect.color(UiColor::BLUE),
|
||||
rect.color(Color::BLUE),
|
||||
(
|
||||
rect.color(UiColor::RED).center((100.0, 100.0)),
|
||||
(
|
||||
rect.color(UiColor::ORANGE),
|
||||
rect.color(UiColor::LIME).pad(10.0),
|
||||
)
|
||||
rect.color(Color::RED).center((100.0, 100.0)),
|
||||
(rect.color(Color::ORANGE), rect.color(Color::LIME).pad(10.0))
|
||||
.span(Dir::RIGHT, [1, 1]),
|
||||
rect.color(UiColor::YELLOW),
|
||||
rect.color(Color::YELLOW),
|
||||
)
|
||||
.span(Dir::RIGHT, [2, 2, 1])
|
||||
.pad(10),
|
||||
@@ -53,12 +51,12 @@ impl Client {
|
||||
);
|
||||
let span_test = ui.add_static(
|
||||
(
|
||||
rect.color(UiColor::GREEN),
|
||||
rect.color(UiColor::ORANGE),
|
||||
rect.color(UiColor::CYAN),
|
||||
rect.color(UiColor::BLUE),
|
||||
rect.color(UiColor::MAGENTA),
|
||||
rect.color(UiColor::RED),
|
||||
rect.color(Color::GREEN),
|
||||
rect.color(Color::ORANGE),
|
||||
rect.color(Color::CYAN),
|
||||
rect.color(Color::BLUE),
|
||||
rect.color(Color::MAGENTA),
|
||||
rect.color(Color::RED),
|
||||
)
|
||||
.span(
|
||||
Dir::LEFT,
|
||||
@@ -77,17 +75,14 @@ impl Client {
|
||||
|
||||
let switch_button = |color, to, label| {
|
||||
let rect = Rect::new(color)
|
||||
.id_on(Sense::PressStart, 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(Sense::HoverStart, move |r| {
|
||||
.edit_on(HOVER_START | PRESS_END, move |r| {
|
||||
r.color = color.add_rgb(0.4);
|
||||
})
|
||||
.edit_on(Sense::PressEnd, move |r| {
|
||||
r.color = color.add_rgb(0.4);
|
||||
})
|
||||
.edit_on(Sense::HoverEnd, move |r| {
|
||||
.edit_on(HOVER_END, move |r| {
|
||||
r.color = color;
|
||||
});
|
||||
(rect, text(label).size(30)).stack()
|
||||
@@ -95,15 +90,15 @@ impl Client {
|
||||
|
||||
let tabs = ui.add(
|
||||
(
|
||||
switch_button(UiColor::RED, pad_test, "pad test"),
|
||||
switch_button(UiColor::GREEN, span_test, "span test"),
|
||||
switch_button(UiColor::BLUE, span_add, "span add test"),
|
||||
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"),
|
||||
)
|
||||
.span(Dir::RIGHT, [1, 1, 1]),
|
||||
);
|
||||
let add_button = Rect::new(Color::LIME)
|
||||
.radius(30)
|
||||
.on(Sense::PressStart, move |ui| {
|
||||
.on(PRESS_START, move |ui| {
|
||||
let child = ui
|
||||
.add(image(include_bytes!("assets/sungals.png")))
|
||||
.erase_type();
|
||||
@@ -117,7 +112,7 @@ impl Client {
|
||||
|
||||
let del_button = Rect::new(Color::RED)
|
||||
.radius(30)
|
||||
.on(Sense::PressStart, move |ui| {
|
||||
.on(PRESS_START, move |ui| {
|
||||
ui[span_add].children.pop();
|
||||
})
|
||||
.region(
|
||||
|
||||
Reference in New Issue
Block a user