mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
document; refactor focus; highlight scene/track titles
This commit is contained in:
parent
d42512fc76
commit
267f9f61d5
6 changed files with 155 additions and 172 deletions
|
|
@ -1,11 +1,7 @@
|
|||
include!("lib.rs");
|
||||
|
||||
use tek_core::clap::{self, Parser};
|
||||
|
||||
pub fn main () -> Usually<()> {
|
||||
ArrangerCli::parse().run()
|
||||
}
|
||||
|
||||
pub fn main () -> Usually<()> { ArrangerCli::parse().run() }
|
||||
/// Parses CLI arguments to the `tek_arranger` invocation.
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct ArrangerCli {
|
||||
|
|
@ -25,8 +21,8 @@ pub struct ArrangerCli {
|
|||
#[arg(short, long, default_value_t = 8)]
|
||||
scenes: usize,
|
||||
}
|
||||
|
||||
impl ArrangerCli {
|
||||
/// Run the arranger TUI from CLI arguments.
|
||||
fn run (&self) -> Usually<()> {
|
||||
let mut arranger = Arranger::new("");
|
||||
let mut transport = self.transport.then_some(TransportToolbar::new(None));
|
||||
|
|
@ -57,7 +53,7 @@ impl ArrangerCli {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Root level object for standalone `tek_arranger`
|
||||
struct ArrangerStandalone<E: Engine> {
|
||||
/// Controls the JACK transport.
|
||||
transport: Option<TransportToolbar<E>>,
|
||||
|
|
@ -68,7 +64,7 @@ struct ArrangerStandalone<E: Engine> {
|
|||
///
|
||||
focus: usize,
|
||||
}
|
||||
|
||||
/// The standalone arranger consists of transport, clip grid, and sequencer.
|
||||
impl Content for ArrangerStandalone<Tui> {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
|
|
@ -95,7 +91,7 @@ impl Content for ArrangerStandalone<Tui> {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle top-level events in standalone arranger.
|
||||
impl Handle<Tui> for ArrangerStandalone<Tui> {
|
||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||
match from.event() {
|
||||
|
|
@ -113,9 +109,9 @@ impl Handle<Tui> for ArrangerStandalone<Tui> {
|
|||
self.focus_prev();
|
||||
},
|
||||
key!(KeyCode::Down) => {
|
||||
if self.focus == 0 || (
|
||||
self.focus == 1 && self.arranger.is_last_row()
|
||||
) {
|
||||
if self.focus == 0 {
|
||||
self.focus_next();
|
||||
} else if self.focus == 1 && self.arranger.is_last_row() {
|
||||
self.focus_next();
|
||||
} else {
|
||||
return self.focused_mut().handle(from)
|
||||
|
|
@ -133,7 +129,7 @@ impl Handle<Tui> for ArrangerStandalone<Tui> {
|
|||
Ok(Some(true))
|
||||
}
|
||||
}
|
||||
|
||||
/// Focusable items in standalone arranger.
|
||||
impl Focus<2, Tui> for ArrangerStandalone<Tui> {
|
||||
fn focus (&self) -> usize {
|
||||
self.focus
|
||||
|
|
@ -142,15 +138,9 @@ impl Focus<2, Tui> for ArrangerStandalone<Tui> {
|
|||
&mut self.focus
|
||||
}
|
||||
fn focusable (&self) -> [&dyn Focusable<Tui>;2] {
|
||||
[
|
||||
&self.transport as &dyn Focusable<Tui>,
|
||||
&self.arranger as &dyn Focusable<Tui>,
|
||||
]
|
||||
focusables!(self.transport, self.arranger)
|
||||
}
|
||||
fn focusable_mut (&mut self) -> [&mut dyn Focusable<Tui>;2] {
|
||||
[
|
||||
&mut self.transport as &mut dyn Focusable<Tui>,
|
||||
&mut self.arranger as &mut dyn Focusable<Tui>,
|
||||
]
|
||||
focusables_mut!(self.transport, self.arranger)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -683,8 +683,10 @@ impl<'a> Widget for VerticalArrangerCursor<'a> {
|
|||
to.render_in(clip_area, &CORNERS)?;
|
||||
to.fill_bg(clip_area, Color::Rgb(40, 50, 30));
|
||||
} else if let Some(track_area) = track_area {
|
||||
to.render_in(track_area.clip_h(2), &CORNERS)?;
|
||||
to.fill_bg(track_area, Color::Rgb(40, 50, 30));
|
||||
} else if let Some(scene_area) = scene_area {
|
||||
to.render_in(scene_area.clip_w(offset-1), &CORNERS)?;
|
||||
to.fill_bg(scene_area, Color::Rgb(40, 50, 30));
|
||||
}
|
||||
}
|
||||
|
|
@ -2000,22 +2002,10 @@ impl Focus<5, Tui> for TransportToolbar<Tui> {
|
|||
&mut self.focus
|
||||
}
|
||||
fn focusable (&self) -> [&dyn Focusable<Tui>;5] {
|
||||
[
|
||||
&self.playing as &dyn Focusable<Tui>,
|
||||
&self.bpm as &dyn Focusable<Tui>,
|
||||
&self.quant as &dyn Focusable<Tui>,
|
||||
&self.sync as &dyn Focusable<Tui>,
|
||||
&self.clock as &dyn Focusable<Tui>,
|
||||
]
|
||||
focusables!(self.playing, self.bpm, self.quant, self.sync, self.clock)
|
||||
}
|
||||
fn focusable_mut (&mut self) -> [&mut dyn Focusable<Tui>;5] {
|
||||
[
|
||||
&mut self.playing as &mut dyn Focusable<Tui>,
|
||||
&mut self.bpm as &mut dyn Focusable<Tui>,
|
||||
&mut self.quant as &mut dyn Focusable<Tui>,
|
||||
&mut self.sync as &mut dyn Focusable<Tui>,
|
||||
&mut self.clock as &mut dyn Focusable<Tui>,
|
||||
]
|
||||
focusables_mut!(self.playing, self.bpm, self.quant, self.sync, self.clock)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue