wip: modularize dialog

This commit is contained in:
🪞👃🪞 2025-05-18 18:32:39 +03:00
parent baad8254a2
commit 3e9545fe26
17 changed files with 171 additions and 173 deletions

View file

@ -39,18 +39,6 @@ pub enum Selection {
/// Focus identification methods
impl Selection {
pub fn is_mix (&self) -> bool {
matches!(self, Self::Mix)
}
pub fn is_track (&self) -> bool {
matches!(self, Self::Track(_))
}
pub fn is_scene (&self) -> bool {
matches!(self, Self::Scene(_))
}
pub fn is_clip (&self) -> bool {
matches!(self, Self::TrackClip {..})
}
pub fn track (&self) -> Option<usize> {
use Selection::*;
match self {
@ -62,7 +50,7 @@ impl Selection {
_ => None
}
}
pub fn track_header (&self, track_count: usize) -> Self {
pub fn select_track (&self, track_count: usize) -> Self {
use Selection::*;
match self {
Mix => Track(0),
@ -72,7 +60,7 @@ impl Selection {
_ => todo!(),
}
}
pub fn track_next (&self, len: usize) -> Self {
pub fn select_track_next (&self, len: usize) -> Self {
use Selection::*;
match self {
Mix => Track(0),
@ -90,7 +78,7 @@ impl Selection {
_ => todo!()
}
}
pub fn track_prev (&self) -> Self {
pub fn select_track_prev (&self) -> Self {
use Selection::*;
match self {
Mix => Mix,
@ -109,7 +97,16 @@ impl Selection {
_ => None
}
}
pub fn scene_next (&self, len: usize) -> Self {
pub fn select_scene (&self, scene_count: usize) -> Self {
use Selection::*;
match self {
Mix | Track(_) => Scene(0),
Scene(s) => Scene((s + 1) % scene_count),
TrackClip { scene, .. } => Track(*scene),
_ => todo!(),
}
}
pub fn select_scene_next (&self, len: usize) -> Self {
use Selection::*;
match self {
Mix => Scene(0),
@ -127,7 +124,7 @@ impl Selection {
_ => todo!()
}
}
pub fn scene_prev (&self) -> Self {
pub fn select_scene_prev (&self) -> Self {
use Selection::*;
match self {
Mix | Scene(0) => Mix,
@ -142,11 +139,9 @@ impl Selection {
use Selection::*;
format!("{}", match self {
Mix => "Everything".to_string(),
Scene(s) => scenes.get(*s)
.map(|scene|format!("S{s}: {}", &scene.name))
Scene(s) => scenes.get(*s).map(|scene|format!("S{s}: {}", &scene.name))
.unwrap_or_else(||"S??".into()),
Track(t) => tracks.get(*t)
.map(|track|format!("T{t}: {}", &track.name))
Track(t) => tracks.get(*t).map(|track|format!("T{t}: {}", &track.name))
.unwrap_or_else(||"T??".into()),
TrackClip { track, scene } => match (tracks.get(*track), scenes.get(*scene)) {
(Some(_), Some(s)) => match s.clip(*track) {
@ -159,6 +154,3 @@ impl Selection {
}).into()
}
}
impl Arrangement {
}

View file

@ -90,8 +90,11 @@ impl Arrangement {
for (index, track, x1, x2) in self.tracks_with_sizes() {
add(&Fixed::xy(self.track_width(index, track), h + 1,
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(2, move||0..h,
|_, index|Fixed::xy(track.width as u16, 2, Tui::bg(ItemTheme::G[32].base.rgb,
Align::nw(format!(" · {}", "--")))))))));
|_, index|Fixed::xy(track.width as u16, 2,
Tui::fg_bg(
ItemTheme::G[32].lightest.rgb,
ItemTheme::G[32].dark.rgb,
Align::nw(format!(" · {}", "--")))))))));
}
}))
}