1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- use patina::{
- prelude::*,
- ui::{UIControlMsg, UIHandle},
- widget,
- };
- struct TableWindow {
- root: widget::PlainGroup<Self>,
- }
- impl TableWindow {
- fn new(uih: &mut UIHandle) -> Self {
- let mut group = widget::PlainGroup::new_table(uih);
- group.extend(
- vec![
- Box::new(widget::Spacer::new(uih)) as Box<dyn Widget<Self>>,
- Box::new(widget::Spacer::new(uih)),
- ]
- .into_iter(),
- );
- Self { root: group }
- }
- }
- impl Component for TableWindow {
- type ParentMsg = UIControlMsg;
- type Msg = ();
- fn process(&mut self, _msg: Self::Msg) -> Vec<Self::ParentMsg> {
- vec![UIControlMsg::Terminate]
- }
- }
- impl WindowComponent for TableWindow {
- fn map_window_event(&self, we: patina::window::WindowEvent) -> Option<Self::Msg> {
- match we {
- patina::window::WindowEvent::CloseRequested => Some(()),
- _ => None,
- }
- }
- type RootWidget = widget::PlainGroup<Self>;
- fn root_widget(&self) -> &Self::RootWidget {
- &self.root
- }
- fn root_widget_mut(&mut self) -> &mut Self::RootWidget {
- &mut self.root
- }
- }
- fn main() {
- patina::ui::make_opinionated_ui(TableWindow::new).run();
- }
|