use crate::*; pub struct AppContainer where T: Send + Sync, E: Engine, C: Command, U: From>> + Widget + Handle, A: From>> + Audio, S: From>> + StatusBar { pub cursor: (usize, usize), pub entered: bool, pub menu_bar: Option>, pub status_bar: Option, pub history: Vec, pub size: Measure, pub ui: U, pub audio: A, pub model: Arc>, } impl From for AppContainer where T: Send + Sync, E: Engine, C: Command, U: From>> + Widget + Handle, A: From>> + Audio, S: From>> + StatusBar { fn from (model: T) -> Self { let model = Arc::new(RwLock::new(model)); Self { cursor: (0, 0), entered: false, menu_bar: None, status_bar: None, history: vec![], size: Measure::new(), ui: U::from(model.clone()), audio: A::from(model.clone()), model, } } } impl Content for AppContainer where T: Send + Sync, C: Command, U: From>> + Widget + Handle, A: From>> + Audio, S: From>> + StatusBar { type Engine = Tui; fn content (&self) -> impl Widget { let menus = self.menu_bar.as_ref().map_or_else( ||&[] as &[Menu<_, _, _>], |m|m.menus.as_slice() ); Split::down( if self.menu_bar.is_some() { 1 } else { 0 }, row!(menu in menus.iter() => { row!(" ", menu.title.as_str(), " ") }), Split::up( if self.status_bar.is_some() { 1 } else { 0 }, widget(&self.status_bar), widget(&self.ui) ) ) } }