dash-frontend: tabs, other fixes (desc)
- set rustfmt line width to 120 columns by default for wgui - dashboard tabs - wgui: `remove_children`
This commit is contained in:
51
dash-frontend/src/tab/mod.rs
Normal file
51
dash-frontend/src/tab/mod.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use wgui::{
|
||||
components::button::ComponentButton,
|
||||
event::EventListenerCollection,
|
||||
globals::WguiGlobals,
|
||||
layout::{Layout, WidgetID},
|
||||
};
|
||||
|
||||
use crate::{FrontendTask, RcFrontend};
|
||||
|
||||
pub mod apps;
|
||||
pub mod games;
|
||||
pub mod home;
|
||||
pub mod monado;
|
||||
pub mod processes;
|
||||
pub mod settings;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum TabType {
|
||||
Home,
|
||||
Apps,
|
||||
Games,
|
||||
Monado,
|
||||
Processes,
|
||||
Settings,
|
||||
}
|
||||
|
||||
pub struct TabParams<'a> {
|
||||
pub globals: &'a WguiGlobals,
|
||||
pub layout: &'a mut Layout,
|
||||
pub parent_id: WidgetID,
|
||||
pub frontend: &'a RcFrontend,
|
||||
pub listeners: &'a mut EventListenerCollection<(), ()>,
|
||||
}
|
||||
|
||||
pub trait Tab {
|
||||
#[allow(dead_code)]
|
||||
fn get_type(&self) -> TabType;
|
||||
}
|
||||
|
||||
impl TabType {
|
||||
pub fn register_button(this_rc: RcFrontend, btn: &Rc<ComponentButton>, tab: TabType) {
|
||||
btn.on_click({
|
||||
Box::new(move |_evt| {
|
||||
this_rc.borrow_mut().push_task(FrontendTask::SetTab(tab));
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user