mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
60 lines
1.5 KiB
Rust
60 lines
1.5 KiB
Rust
use crate::*;
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
pub enum AppContainerCommand<T: std::fmt::Debug + Copy + Clone> {
|
|
Focus(FocusCommand),
|
|
App(T)
|
|
}
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
|
pub enum AppContainerFocus<F: std::fmt::Debug + Copy + Clone + PartialEq> {
|
|
Menu,
|
|
Content(F),
|
|
}
|
|
|
|
impl<T, C, U, A, S> FocusGrid for AppContainer<T, Tui, C, U, A, S>
|
|
where
|
|
T: Send + Sync,
|
|
C: Command<T>,
|
|
U: From<Arc<RwLock<T>>> + Widget<Engine = Tui> + Handle<Tui> + FocusGrid,
|
|
A: From<Arc<RwLock<T>>> + Audio,
|
|
S: From<Arc<RwLock<T>>> + StatusBar<Tui>
|
|
{
|
|
type Item = AppContainerFocus<<U as FocusGrid>::Item>;
|
|
fn cursor (&self) -> (usize, usize) {
|
|
self.cursor
|
|
}
|
|
fn cursor_mut (&mut self) -> &mut (usize, usize) {
|
|
&mut self.cursor
|
|
}
|
|
fn focus_enter (&mut self) {
|
|
let focused = self.focused();
|
|
if !self.entered {
|
|
self.entered = true;
|
|
// TODO
|
|
}
|
|
}
|
|
fn focus_exit (&mut self) {
|
|
if self.entered {
|
|
self.entered = false;
|
|
// TODO
|
|
}
|
|
}
|
|
fn entered (&self) -> Option<Self::Item> {
|
|
if self.entered {
|
|
Some(self.focused())
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
fn layout (&self) -> &[&[Self::Item]] {
|
|
&[
|
|
&[AppContainerFocus::Menu],
|
|
FocusGrid::layout(&self.ui)
|
|
//&[AppContainerFocus::Content(())],
|
|
]
|
|
}
|
|
fn update_focus (&mut self) {
|
|
// TODO
|
|
}
|
|
}
|