mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: refactor pt.24: 45 errors
This commit is contained in:
parent
ff4698d046
commit
da074eb5fa
5 changed files with 120 additions and 199 deletions
|
|
@ -52,63 +52,48 @@ submod! {
|
|||
tui_transport_foc
|
||||
}
|
||||
|
||||
pub struct AppContainer<E, M, V, C, A, S>
|
||||
pub struct AppView<E, A, C>
|
||||
where
|
||||
E: Engine,
|
||||
M: Send + Sync,
|
||||
V: Widget<Engine = E> + Handle<E>,
|
||||
C: Command<V>,
|
||||
A: Audio,
|
||||
S: StatusBar<E>
|
||||
A: Widget<Engine = E> + Handle<E> + Audio,
|
||||
C: Command<A>,
|
||||
{
|
||||
pub app: A,
|
||||
pub cursor: (usize, usize),
|
||||
pub entered: bool,
|
||||
pub menu_bar: Option<MenuBar<E, V, C>>,
|
||||
pub status_bar: Option<S>,
|
||||
pub menu_bar: Option<MenuBar<E, A, C>>,
|
||||
pub status_bar: Option<Box<dyn Widget<Engine = E>>>,
|
||||
pub history: Vec<C>,
|
||||
pub size: Measure<E>,
|
||||
pub model: Arc<RwLock<M>>,
|
||||
pub view: V,
|
||||
pub audio: A,
|
||||
}
|
||||
|
||||
impl<E, M, V, C, A, S> AppContainer<E, M, V, C, A, S>
|
||||
impl<E, A, C> AppView<E, A, C>
|
||||
where
|
||||
E: Engine,
|
||||
M: Send + Sync,
|
||||
V: Widget<Engine = E> + Handle<E>,
|
||||
C: Command<V>,
|
||||
A: Audio,
|
||||
S: StatusBar<E>
|
||||
A: Widget<Engine = E> + Handle<E> + Audio,
|
||||
C: Command<A>
|
||||
{
|
||||
pub fn new (
|
||||
model: &Arc<RwLock<M>>,
|
||||
view: V,
|
||||
audio: A,
|
||||
menu_bar: Option<MenuBar<E, V, C>>,
|
||||
status_bar: Option<S>,
|
||||
app: A,
|
||||
menu_bar: Option<MenuBar<E, A, C>>,
|
||||
status_bar: Option<Box<dyn Widget<Engine = E>>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
app,
|
||||
cursor: (0, 0),
|
||||
entered: false,
|
||||
history: vec![],
|
||||
size: Measure::new(),
|
||||
model: model.clone(),
|
||||
view,
|
||||
audio,
|
||||
menu_bar,
|
||||
status_bar,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<M, V, C, A, S> Content for AppContainer<Tui, M, V, C, A, S>
|
||||
impl<A, C> Content for AppView<Tui, A, C>
|
||||
where
|
||||
M: Send + Sync,
|
||||
V: Widget<Engine = Tui> + Handle<Tui>,
|
||||
C: Command<V>,
|
||||
A: Audio,
|
||||
S: StatusBar<Tui>,
|
||||
A: Widget<Engine = Tui> + Handle<Tui> + Audio,
|
||||
C: Command<A>
|
||||
{
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
|
|
@ -124,14 +109,14 @@ where
|
|||
Split::up(
|
||||
if self.status_bar.is_some() { 1 } else { 0 },
|
||||
widget(&self.status_bar),
|
||||
widget(&self.view)
|
||||
widget(&self.app)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum AppContainerCommand<T: std::fmt::Debug + Copy + Clone> {
|
||||
pub enum AppViewCommand<T: std::fmt::Debug + Copy + Clone> {
|
||||
Focus(FocusCommand),
|
||||
Undo,
|
||||
Redo,
|
||||
|
|
@ -139,20 +124,17 @@ pub enum AppContainerCommand<T: std::fmt::Debug + Copy + Clone> {
|
|||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub enum AppContainerFocus<F: std::fmt::Debug + Copy + Clone + PartialEq> {
|
||||
pub enum AppViewFocus<F: std::fmt::Debug + Copy + Clone + PartialEq> {
|
||||
Menu,
|
||||
Content(F),
|
||||
}
|
||||
|
||||
impl<T, U, C, A, S> FocusGrid for AppContainer<Tui, T, U, C, A, S>
|
||||
impl<A, C> FocusGrid for AppView<Tui, A, C>
|
||||
where
|
||||
T: Send + Sync,
|
||||
U: From<Arc<RwLock<T>>> + Widget<Engine = Tui> + Handle<Tui> + FocusGrid,
|
||||
C: Command<U>,
|
||||
A: From<Arc<RwLock<T>>> + Audio,
|
||||
S: From<Arc<RwLock<T>>> + StatusBar<Tui>
|
||||
A: Widget<Engine = Tui> + Handle<Tui> + Audio + FocusGrid,
|
||||
C: Command<A>
|
||||
{
|
||||
type Item = AppContainerFocus<<U as FocusGrid>::Item>;
|
||||
type Item = AppViewFocus<<A as FocusGrid>::Item>;
|
||||
fn cursor (&self) -> (usize, usize) {
|
||||
self.cursor
|
||||
}
|
||||
|
|
@ -181,9 +163,9 @@ where
|
|||
}
|
||||
fn layout (&self) -> &[&[Self::Item]] {
|
||||
&[
|
||||
&[AppContainerFocus::Menu],
|
||||
&[AppViewFocus::Menu],
|
||||
FocusGrid::layout(&self.ui)
|
||||
//&[AppContainerFocus::Content(())],
|
||||
//&[AppViewFocus::Content(())],
|
||||
]
|
||||
}
|
||||
fn update_focus (&mut self) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue