use crate::*; #[derive(PartialEq, Clone, Copy, Debug)] /// Represents the current user selection in the arranger pub enum ArrangerSelection { /// The whole mix is selected Mix, /// A track is selected. Track(usize), /// A scene is selected. Scene(usize), /// A clip (track × scene) is selected. Clip(usize, usize), } /// Focus identification methods impl ArrangerSelection { pub fn description ( &self, tracks: &Vec, scenes: &Vec, ) -> String { format!("Selected: {}", match self { Self::Mix => format!("Everything"), Self::Track(t) => match tracks.get(*t) { Some(track) => format!("T{t}: {}", &track.name.read().unwrap()), None => format!("T??"), }, Self::Scene(s) => match scenes.get(*s) { Some(scene) => format!("S{s}: {}", &scene.name.read().unwrap()), None => format!("S??"), }, Self::Clip(t, s) => match (tracks.get(*t), scenes.get(*s)) { (Some(_), Some(scene)) => match scene.clip(*t) { Some(clip) => format!("T{t} S{s} C{}", &clip.read().unwrap().name), None => format!("T{t} S{s}: Empty") }, _ => format!("T{t} S{s}: Empty"), } }) } pub fn is_mix (&self) -> bool { match self { Self::Mix => true, _ => false } } pub fn is_track (&self) -> bool { match self { Self::Track(_) => true, _ => false } } pub fn is_scene (&self) -> bool { match self { Self::Scene(_) => true, _ => false } } pub fn is_clip (&self) -> bool { match self { Self::Clip(_, _) => true, _ => false } } pub fn track (&self) -> Option { use ArrangerSelection::*; match self { Clip(t, _) => Some(*t), Track(t) => Some(*t), _ => None } } pub fn scene (&self) -> Option { use ArrangerSelection::*; match self { Clip(_, s) => Some(*s), Scene(s) => Some(*s), _ => None } } }