wip: trying focus traits and macros again

This commit is contained in:
🪞👃🪞 2024-08-31 23:19:42 +03:00
parent 9f358f8a21
commit 2106a7c044
4 changed files with 78 additions and 35 deletions

View file

@ -1,22 +1,20 @@
//! Clip launcher and arrangement editor.
use crate::*;
use tek_core::Direction;
/// Represents the tracks and scenes of the composition.
pub struct Arranger {
/// Name of arranger
pub name: Arc<RwLock<String>>,
pub name: Arc<RwLock<String>>,
/// Collection of tracks.
pub tracks: Vec<Sequencer>,
pub tracks: Vec<Sequencer>,
/// Collection of scenes.
pub scenes: Vec<Scene>,
pub scenes: Vec<Scene>,
/// Currently selected element.
pub selected: ArrangerFocus,
pub selected: ArrangerFocus,
/// Display mode of arranger
pub mode: ArrangerViewMode,
pub mode: ArrangerViewMode,
/// Slot for modal dialog displayed on top of app.
pub modal: Option<Box<dyn ExitableComponent>>,
pub modal: Option<Box<dyn ExitableComponent>>,
}
impl Arranger {

View file

@ -18,33 +18,7 @@ struct ArrangerStandalone {
focus: usize,
}
impl ArrangerStandalone {
fn focus_prev (&mut self) {
self.focus = if self.focus > 0 { 1 } else { self.focus - 1 };
}
fn focus_next (&mut self) {
self.focus = if self.focus < 1 { self.focus + 1 } else { 0 };
}
fn focused (&self) -> &dyn Render {
self.focusable()[self.focus]
}
fn focusable (&self) -> [&dyn Render;2] {
[
&self.transport as &dyn Render,
&self.arranger as &dyn Render,
]
}
fn focused_mut (&mut self) -> &mut dyn Handle {
let focus = self.focus;
self.focusable_mut()[focus]
}
fn focusable_mut (&mut self) -> [&mut dyn Handle;2] {
[
&mut self.transport as &mut dyn Handle,
&mut self.arranger as &mut dyn Handle
]
}
}
focus!(ArrangerStandalone (focus) : 2 => [ transport, arranger ]);
#[derive(Debug, Parser)]
#[command(version, about, long_about = None)]