mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
parent
cfd19062fd
commit
559d2fc4a1
7 changed files with 125 additions and 72 deletions
|
|
@ -31,12 +31,18 @@ pub struct App {
|
|||
/// Contains the currently edited musical arrangement
|
||||
pub project: Arrangement,
|
||||
}
|
||||
#[derive(Debug, Clone, Default, PartialEq)]
|
||||
pub struct Axis {
|
||||
min: usize,
|
||||
max: usize,
|
||||
step: usize,
|
||||
}
|
||||
/// Various possible dialog modes.
|
||||
#[derive(Debug, Clone, Default, PartialEq)]
|
||||
pub enum Dialog {
|
||||
#[default] None,
|
||||
Help(usize),
|
||||
Menu(usize, usize),
|
||||
Menu(usize, Arc<[Arc<str>]>),
|
||||
Device(usize),
|
||||
Message(Arc<str>),
|
||||
Browse(BrowseTarget, Arc<Browse>),
|
||||
|
|
@ -62,6 +68,25 @@ impl HasClipsSize for App { fn clips_size (&self) -> &Measure<TuiOut> { &self.
|
|||
impl HasTrackScroll for App { fn track_scroll (&self) -> usize { self.project.track_scroll() } }
|
||||
impl HasSceneScroll for App { fn scene_scroll (&self) -> usize { self.project.scene_scroll() } }
|
||||
impl Dialog {
|
||||
pub fn welcome () -> Self {
|
||||
Self::Menu(0, [
|
||||
"Continue session".into(),
|
||||
"Load old session".into(),
|
||||
"Begin new session".into(),
|
||||
].into())
|
||||
}
|
||||
pub fn menu_next (&self) -> Self {
|
||||
match self {
|
||||
Self::Menu(index, items) => Self::Menu(wrap_inc(*index, items.len()), items.clone()),
|
||||
_ => Self::None
|
||||
}
|
||||
}
|
||||
pub fn menu_prev (&self) -> Self {
|
||||
match self {
|
||||
Self::Menu(index, items) => Self::Menu(wrap_dec(*index, items.len()), items.clone()),
|
||||
_ => Self::None
|
||||
}
|
||||
}
|
||||
pub fn menu_selected (&self) -> Option<usize> {
|
||||
if let Self::Menu(selected, _) = self { Some(*selected) } else { None }
|
||||
}
|
||||
|
|
@ -166,7 +191,6 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fn wrap_dialog (dialog: impl Content<TuiOut>) -> impl Content<TuiOut> {
|
||||
Fixed::xy(70, 23, Tui::fg_bg(Rgb(255,255,255), Rgb(16,16,16), Bsp::b(
|
||||
Repeat(" "), Outer(true, Style::default().fg(Tui::g(96))).enclose(dialog))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue