mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: refactor pt.17: 44 errors
This commit is contained in:
parent
78c2004282
commit
c2b290b3c5
8 changed files with 104 additions and 112 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::*;
|
||||
|
||||
/// Sections in the arranger app that may be focused
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum ArrangerViewFocus {
|
||||
/// The transport (toolbar) is focused
|
||||
Transport,
|
||||
|
|
@ -57,13 +57,11 @@ impl<E: Engine> FocusGrid for ArrangerView<E> {
|
|||
fn update_focus (&mut self) {
|
||||
use ArrangerViewFocus::*;
|
||||
let focused = self.focused();
|
||||
if let Some(transport) = self.transport.as_ref() {
|
||||
transport.write().unwrap().focused = focused == Transport
|
||||
}
|
||||
self.arrangement.focused = focused == Arrangement;
|
||||
self.phrases.write().unwrap().focused = focused == PhrasePool;
|
||||
self.editor.focused = focused == PhraseEditor;
|
||||
self.update_status();
|
||||
self.sequencer.transport.focused = focused == Transport;
|
||||
self.sequencer.phrases.focused = focused == PhrasePool;
|
||||
self.sequencer.editor.focused = focused == PhraseEditor;
|
||||
//self.update_status();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,62 +104,68 @@ impl ArrangementEditorFocus {
|
|||
}
|
||||
})
|
||||
}
|
||||
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 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<usize> {
|
||||
match self { Self::Clip(t, _) => Some(*t), Self::Track(t) => Some(*t), _ => None }
|
||||
}
|
||||
pub fn track_next (&mut self, last_track: usize) {
|
||||
*self = match self {
|
||||
Self::Mix =>
|
||||
Self::Track(0),
|
||||
Self::Track(t) =>
|
||||
Self::Track(last_track.min(*t + 1)),
|
||||
Self::Scene(s) =>
|
||||
Self::Clip(0, *s),
|
||||
Self::Clip(t, s) =>
|
||||
Self::Clip(last_track.min(*t + 1), *s),
|
||||
}
|
||||
}
|
||||
pub fn track_prev (&mut self) {
|
||||
*self = match self {
|
||||
Self::Mix =>
|
||||
Self::Mix,
|
||||
Self::Scene(s) =>
|
||||
Self::Scene(*s),
|
||||
Self::Track(t) =>
|
||||
if *t == 0 { Self::Mix } else { Self::Track(*t - 1) },
|
||||
Self::Clip(t, s) =>
|
||||
if *t == 0 { Self::Scene(*s) } else { Self::Clip(t.saturating_sub(1), *s) }
|
||||
use ArrangementEditorFocus::*;
|
||||
match self {
|
||||
Clip(t, _) => Some(*t),
|
||||
Track(t) => Some(*t),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
pub fn scene (&self) -> Option<usize> {
|
||||
match self { Self::Clip(_, s) => Some(*s), Self::Scene(s) => Some(*s), _ => None }
|
||||
}
|
||||
pub fn scene_next (&mut self, last_scene: usize) {
|
||||
*self = match self {
|
||||
Self::Mix =>
|
||||
Self::Scene(0),
|
||||
Self::Track(t) =>
|
||||
Self::Clip(*t, 0),
|
||||
Self::Scene(s) =>
|
||||
Self::Scene(last_scene.min(*s + 1)),
|
||||
Self::Clip(t, s) =>
|
||||
Self::Clip(*t, last_scene.min(*s + 1)),
|
||||
}
|
||||
}
|
||||
pub fn scene_prev (&mut self) {
|
||||
*self = match self {
|
||||
Self::Mix =>
|
||||
Self::Mix,
|
||||
Self::Track(t) =>
|
||||
Self::Track(*t),
|
||||
Self::Scene(s) =>
|
||||
if *s == 0 { Self::Mix } else { Self::Scene(*s - 1) },
|
||||
Self::Clip(t, s) =>
|
||||
if *s == 0 { Self::Track(*t) } else { Self::Clip(*t, s.saturating_sub(1)) }
|
||||
use ArrangementEditorFocus::*;
|
||||
match self {
|
||||
Clip(_, s) => Some(*s),
|
||||
Scene(s) => Some(*s),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
//pub fn track_next (&mut self, last_track: usize) {
|
||||
//use ArrangementEditorFocus::*;
|
||||
//*self = match self {
|
||||
//Mix => Track(0),
|
||||
//Track(t) => Track(last_track.min(*t + 1)),
|
||||
//Scene(s) => Clip(0, *s),
|
||||
//Clip(t, s) => Clip(last_track.min(*t + 1), *s),
|
||||
//}
|
||||
//}
|
||||
//pub fn track_prev (&mut self) {
|
||||
//use ArrangementEditorFocus::*;
|
||||
//*self = match self {
|
||||
//Mix => Mix,
|
||||
//Scene(s) => Scene(*s),
|
||||
//Track(t) => if *t == 0 { Mix } else { Track(*t - 1) },
|
||||
//Clip(t, s) => if *t == 0 { Scene(*s) } else { Clip(t.saturating_sub(1), *s) }
|
||||
//}
|
||||
//}
|
||||
//pub fn scene_next (&mut self, last_scene: usize) {
|
||||
//use ArrangementEditorFocus::*;
|
||||
//*self = match self {
|
||||
//Mix => Scene(0),
|
||||
//Track(t) => Clip(*t, 0),
|
||||
//Scene(s) => Scene(last_scene.min(*s + 1)),
|
||||
//Clip(t, s) => Clip(*t, last_scene.min(*s + 1)),
|
||||
//}
|
||||
//}
|
||||
//pub fn scene_prev (&mut self) {
|
||||
//use ArrangementEditorFocus::*;
|
||||
//*self = match self {
|
||||
//Mix => Mix,
|
||||
//Track(t) => Track(*t),
|
||||
//Scene(s) => if *s == 0 { Mix } else { Scene(*s - 1) },
|
||||
//Clip(t, s) => if *s == 0 { Track(*t) } else { Clip(*t, s.saturating_sub(1)) }
|
||||
//}
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue