use patina::{ prelude::*, window::{Window, WindowComponent}, }; struct SimpleWindow { widget: ::RootWidget, } impl Component for SimpleWindow { type ParentMsg = (); type Msg = (); fn process(&mut self, msg: Self::Msg) -> Vec { vec![()] } } impl WindowComponent for SimpleWindow { fn map_window_event(&self, we: patina::window::WindowEvent) -> Option { Some(()) } type RootWidget = patina::widget::Spacer; fn root_widget(&self) -> &Self::RootWidget { &self.widget } fn root_widget_mut(&mut self) -> &mut Self::RootWidget { &mut self.widget } } struct Simplest { main_window: Option>, } impl Component for Simplest { type ParentMsg = patina::UIControlMsg; type Msg = (); fn process(&mut self, msg: Self::Msg) -> Vec { vec![patina::UIControlMsg::Terminate] } } impl patina::UIComponent for Simplest { fn init<'l>(&mut self, mut ui_handle: patina::UIHandle<'_>) { let mut widget = patina::widget::Spacer::new(&ui_handle); widget.layout_node_mut().set_width_policy(patina::layout::SizePolicy { minimum: 0, desired: 0, slack_weight: 1 }); widget.layout_node_mut().set_height_policy(patina::layout::SizePolicy { minimum: 0, desired: 0, slack_weight: 1 }); self.main_window = Some(ui_handle.window_builder().build(|uih| SimpleWindow { widget })); } fn poll(&mut self) -> Vec { let Some(mw) = self.main_window.as_mut() else { return vec![] }; let evts = mw.poll(); self.process_all(evts.into_iter()) } } fn main() { let ui = patina::UI::::new(Simplest { main_window: None }); ui.run(); }