`WakeTaskQueue` becomes `TaskQueue`, which carries the update itself. Delivery and waking are then one act: the winit host sends it through the `EventLoopProxy` as a `DefaultEvent::Update`, so there is no channel beside the loop and nothing has to claim a redraw is needed in order to be looked at. `Window::request_redraw` is gone from this path; `event` applies the update and then asks the tree whether anything became dirty, which is the same question `window_event` already ended with -- now `schedule_redraw`, called from both. The loop's message type is `DefaultEvent<State>`, so `Proxy` becomes a wrapper that takes the application's own `Event` and requires it to be `Send`, since it now crosses to the task thread by that route. The harness supplies a channel-backed queue, which is what lets a test hold updates until it asks for them. Tests split by subject -- layout, pointer, scroll, tasks -- with the region helper in `tests/common`.
31 lines
828 B
Rust
31 lines
828 B
Rust
use iris::prelude::*;
|
|
use std::time::Duration;
|
|
|
|
fn main() {
|
|
DefaultApp::<State>::run();
|
|
}
|
|
|
|
#[derive(DefaultUiState)]
|
|
struct State {
|
|
ui_state: DefaultUiState,
|
|
}
|
|
|
|
impl DefaultAppState for State {
|
|
fn new(mut ui_state: DefaultUiState, rsc: &mut DefaultRsc<Self>, _: Proxy<Self>) -> Self {
|
|
let rect = rect(Color::RED).add(rsc);
|
|
rect.task_on(CursorSense::click(), async move |mut ctx| {
|
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
|
ctx.update(move |_, rsc| {
|
|
let rect = rect(rsc);
|
|
if rect.color == Color::RED {
|
|
rect.color = Color::BLUE;
|
|
} else {
|
|
rect.color = Color::RED;
|
|
}
|
|
});
|
|
})
|
|
.set_root(rsc, &mut ui_state);
|
|
Self { ui_state }
|
|
}
|
|
}
|