remove context generic

This commit is contained in:
2025-08-25 18:53:21 -04:00
parent d4b1a56467
commit e8b255c8f9
17 changed files with 167 additions and 217 deletions

View File

@@ -27,7 +27,7 @@ pub struct ClientUi {
}
impl Client {
pub fn create_ui() -> (Ui<Self>, ClientUi) {
pub fn create_ui() -> (Ui, ClientUi) {
let mut ui = Ui::new();
let rect = Rect {
color: UiColor::WHITE,
@@ -78,17 +78,17 @@ impl Client {
let switch_button = |color, to, label| {
let rect = Rect::new(color)
.id_on(Sense::PressStart, move |id, ctx| {
ctx.ui[main].inner.set_static(to);
ctx.ui[id].color = color.add_rgb(-0.2);
.id_on(Sense::PressStart, 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(Sense::HoverStart, move |r| {
r.color = color.add_rgb(0.4);
})
.edit_on(Sense::PressEnd, move |r, _| {
.edit_on(Sense::PressEnd, move |r| {
r.color = color.add_rgb(0.4);
})
.edit_on(Sense::HoverEnd, move |r, _| {
.edit_on(Sense::HoverEnd, move |r| {
r.color = color;
});
(rect, text(label).size(30)).stack()
@@ -104,12 +104,11 @@ impl Client {
);
let add_button = Rect::new(Color::LIME)
.radius(30)
.on(Sense::PressStart, move |ctx| {
let child = ctx
.ui
.on(Sense::PressStart, move |ui| {
let child = ui
.add(image(include_bytes!("assets/sungals.png")))
.erase_type();
ctx.ui[span_add].children.push((child, ratio(1)));
ui[span_add].children.push((child, ratio(1)));
})
.region(
UiPos::corner(Corner::BotRight)
@@ -119,8 +118,8 @@ impl Client {
let del_button = Rect::new(Color::RED)
.radius(30)
.on(Sense::PressStart, move |ctx| {
ctx.ui[span_add].children.pop();
.on(Sense::PressStart, move |ui| {
ui[span_add].children.pop();
})
.region(
UiPos::corner(Corner::BotLeft)
@@ -167,15 +166,15 @@ impl Client {
}
}
pub fn event(&mut self, event: WindowEvent, event_loop: &ActiveEventLoop, ui: &mut Ui<Self>) {
pub fn event(&mut self, event: WindowEvent, event_loop: &ActiveEventLoop, ui: &mut Ui) {
self.input.event(&event);
let cursor_state = self.cursor_state();
let window_size = self.window_size();
ui.run_sensors(self, &cursor_state, window_size);
ui.run_sensors(&cursor_state, window_size);
match event {
WindowEvent::CloseRequested => event_loop.exit(),
WindowEvent::RedrawRequested => {
ui.update(self);
ui.update();
self.renderer.update(ui);
self.renderer.draw()
}