Clean up shared UI runtime state
This commit is contained in:
1 parent
9b4c690916
commit
5ca244528f
27 files changed
+355
-499
No files matched your search
@@ -4,24 +4,24 @@ const ROWS: usize = 1000;
|
||||
const SETTLE_FRAMES: usize = 4;
|
||||
const FRAMES: usize = 6;
|
||||
|
||||
#[derive(DefaultUiState)]
|
||||
#[derive(DesktopUiState)]
|
||||
struct State {
|
||||
ui_state: DefaultUiState,
|
||||
ui_state: DesktopUiState,
|
||||
span: WeakWidget<Span>,
|
||||
frame: usize,
|
||||
appended: bool,
|
||||
}
|
||||
|
||||
impl DefaultAppState for State {
|
||||
impl DesktopAppState for State {
|
||||
fn new(
|
||||
mut ui_state: DefaultUiState,
|
||||
rsc: &mut DefaultRsc<Self>,
|
||||
mut ui_state: DesktopUiState,
|
||||
rsc: &mut DesktopRsc<Self>,
|
||||
_: Proxy<Self::Event>,
|
||||
) -> Self {
|
||||
let mut span = Span::empty(Dir::DOWN);
|
||||
for _ in 0..ROWS {
|
||||
let img = image::DynamicImage::new_rgba8(32, 32);
|
||||
let widget = image::<DefaultRsc<Self>>(img)(rsc);
|
||||
let widget = image::<DesktopRsc<Self>>(img)(rsc);
|
||||
let widget = rsc.ui.widgets.add_strong(widget);
|
||||
span.push(widget.any());
|
||||
}
|
||||
@@ -40,7 +40,7 @@ impl DefaultAppState for State {
|
||||
}
|
||||
}
|
||||
|
||||
fn window_event(&mut self, event: winit::event::WindowEvent, rsc: &mut DefaultRsc<Self>) {
|
||||
fn window_event(&mut self, event: winit::event::WindowEvent, rsc: &mut DesktopRsc<Self>) {
|
||||
if !matches!(event, winit::event::WindowEvent::RedrawRequested) {
|
||||
return;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ impl DefaultAppState for State {
|
||||
if self.frame == SETTLE_FRAMES && !self.appended {
|
||||
self.appended = true;
|
||||
let img = image::DynamicImage::new_rgba8(32, 32);
|
||||
let widget = image::<DefaultRsc<Self>>(img)(rsc);
|
||||
let widget = image::<DesktopRsc<Self>>(img)(rsc);
|
||||
let widget = rsc.ui.widgets.add_strong(widget);
|
||||
rsc.ui
|
||||
.widgets
|
||||
@@ -71,5 +71,5 @@ impl DefaultAppState for State {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
DefaultApp::<State>::run();
|
||||
DesktopApp::<State>::run();
|
||||
}
|
||||
@@ -2,12 +2,12 @@ use iris::prelude::*;
|
||||
use winit::{dpi::LogicalSize, window::WindowAttributes};
|
||||
|
||||
fn main() {
|
||||
DefaultApp::<State>::run();
|
||||
DesktopApp::<State>::run();
|
||||
}
|
||||
|
||||
#[derive(DefaultUiState)]
|
||||
#[derive(DesktopUiState)]
|
||||
struct State {
|
||||
ui_state: DefaultUiState,
|
||||
ui_state: DesktopUiState,
|
||||
}
|
||||
|
||||
const ROWS: usize = 800;
|
||||
@@ -58,14 +58,14 @@ fn build_row<Rsc: UiRsc + 'static>(rsc: &mut Rsc, i: usize) -> StrongWidget {
|
||||
}
|
||||
}
|
||||
|
||||
impl DefaultAppState for State {
|
||||
impl DesktopAppState for State {
|
||||
fn window_attributes() -> WindowAttributes {
|
||||
WindowAttributes::default().with_inner_size(LogicalSize::new(420.0, 900.0))
|
||||
}
|
||||
|
||||
fn new(
|
||||
mut ui_state: DefaultUiState,
|
||||
rsc: &mut DefaultRsc<Self>,
|
||||
mut ui_state: DesktopUiState,
|
||||
rsc: &mut DesktopRsc<Self>,
|
||||
_: Proxy<Self::Event>,
|
||||
) -> Self {
|
||||
let mut list = LazySpan::new(Dir::DOWN, Pin::End);
|
||||
|
||||
+6
-6
@@ -1,18 +1,18 @@
|
||||
use iris::prelude::*;
|
||||
|
||||
fn main() {
|
||||
DefaultApp::<State>::run();
|
||||
DesktopApp::<State>::run();
|
||||
}
|
||||
|
||||
#[derive(DefaultUiState)]
|
||||
#[derive(DesktopUiState)]
|
||||
struct State {
|
||||
ui_state: DefaultUiState,
|
||||
ui_state: DesktopUiState,
|
||||
}
|
||||
|
||||
impl DefaultAppState for State {
|
||||
impl DesktopAppState for State {
|
||||
fn new(
|
||||
mut ui_state: DefaultUiState,
|
||||
rsc: &mut DefaultRsc<Self>,
|
||||
mut ui_state: DesktopUiState,
|
||||
rsc: &mut DesktopRsc<Self>,
|
||||
_: Proxy<Self::Event>,
|
||||
) -> Self {
|
||||
rect(PaintId::RED).set_root(rsc, &mut ui_state);
|
||||
|
||||
@@ -2,19 +2,19 @@ use iris::prelude::*;
|
||||
use winit::event::WindowEvent;
|
||||
|
||||
fn main() {
|
||||
DefaultApp::<Client>::run();
|
||||
DesktopApp::<Client>::run();
|
||||
}
|
||||
|
||||
#[derive(DefaultUiState)]
|
||||
#[derive(DesktopUiState)]
|
||||
pub struct Client {
|
||||
ui_state: DefaultUiState,
|
||||
ui_state: DesktopUiState,
|
||||
info: WeakWidget<Text>,
|
||||
}
|
||||
|
||||
impl DefaultAppState for Client {
|
||||
impl DesktopAppState for Client {
|
||||
fn new(
|
||||
mut ui_state: DefaultUiState,
|
||||
rsc: &mut DefaultRsc<Self>,
|
||||
mut ui_state: DesktopUiState,
|
||||
rsc: &mut DesktopRsc<Self>,
|
||||
_: Proxy<Self::Event>,
|
||||
) -> Self {
|
||||
let widgets = tabs_ui::build(rsc, &mut ui_state);
|
||||
@@ -24,7 +24,7 @@ impl DefaultAppState for Client {
|
||||
}
|
||||
}
|
||||
|
||||
fn window_event(&mut self, _: WindowEvent, rsc: &mut DefaultRsc<Self>) {
|
||||
fn window_event(&mut self, _: WindowEvent, rsc: &mut DesktopRsc<Self>) {
|
||||
let render_state = rsc.ui.render_state();
|
||||
let new = format!(
|
||||
"widgets: {}\nactive: {}\nviews: {}",
|
||||
|
||||
+6
-6
@@ -2,18 +2,18 @@ use iris::prelude::*;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
DefaultApp::<State>::run();
|
||||
DesktopApp::<State>::run();
|
||||
}
|
||||
|
||||
#[derive(DefaultUiState)]
|
||||
#[derive(DesktopUiState)]
|
||||
struct State {
|
||||
ui_state: DefaultUiState,
|
||||
ui_state: DesktopUiState,
|
||||
}
|
||||
|
||||
impl DefaultAppState for State {
|
||||
impl DesktopAppState for State {
|
||||
fn new(
|
||||
mut ui_state: DefaultUiState,
|
||||
rsc: &mut DefaultRsc<Self>,
|
||||
mut ui_state: DesktopUiState,
|
||||
rsc: &mut DesktopRsc<Self>,
|
||||
_: Proxy<Self::Event>,
|
||||
) -> Self {
|
||||
let rect = rect(PaintId::RED).add(rsc);
|
||||
|
||||
+7
-7
@@ -1,15 +1,15 @@
|
||||
use iris::prelude::*;
|
||||
|
||||
fn main() {
|
||||
DefaultApp::<State>::run();
|
||||
DesktopApp::<State>::run();
|
||||
}
|
||||
|
||||
#[derive(DefaultUiState)]
|
||||
#[derive(DesktopUiState)]
|
||||
struct State {
|
||||
ui_state: DefaultUiState,
|
||||
ui_state: DesktopUiState,
|
||||
}
|
||||
|
||||
type Rsc = DefaultRsc<State>;
|
||||
type Rsc = DesktopRsc<State>;
|
||||
|
||||
#[derive(Clone, Copy, WidgetView)]
|
||||
struct Test {
|
||||
@@ -35,10 +35,10 @@ impl Test {
|
||||
}
|
||||
}
|
||||
|
||||
impl DefaultAppState for State {
|
||||
impl DesktopAppState for State {
|
||||
fn new(
|
||||
mut ui_state: DefaultUiState,
|
||||
rsc: &mut DefaultRsc<Self>,
|
||||
mut ui_state: DesktopUiState,
|
||||
rsc: &mut DesktopRsc<Self>,
|
||||
_: Proxy<Self::Event>,
|
||||
) -> Self {
|
||||
let test = Test::new(rsc);
|
||||
|
||||
Reference in new issue
Block a user