mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 12:46:42 +01:00
wip: down to 25 errors woo
This commit is contained in:
parent
89288f2920
commit
6ce83fb27a
25 changed files with 688 additions and 620 deletions
|
|
@ -35,6 +35,8 @@ pub struct Arrangement {
|
|||
pub arranger: Arc<RwLock<Buffer>>,
|
||||
/// Display size
|
||||
pub size: Measure<TuiOut>,
|
||||
/// Jack client handle
|
||||
pub jack: Jack,
|
||||
}
|
||||
|
||||
has!(Option<Selection>: |self: Arrangement|self.selected);
|
||||
|
|
@ -42,33 +44,73 @@ has!(Vec<JackMidiIn>: |self: Arrangement|self.midi_ins);
|
|||
has!(Vec<JackMidiOut>: |self: Arrangement|self.midi_outs);
|
||||
has!(Vec<Scene>: |self: Arrangement|self.scenes);
|
||||
has!(Vec<Track>: |self: Arrangement|self.tracks);
|
||||
has!(Jack: |self: Arrangement|self.jack);
|
||||
|
||||
impl Has<Option<Track>> for Arrangement {
|
||||
fn get (&self) -> &Option<Track> {
|
||||
Has::<Selection>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Track>>::get(self).get(index))
|
||||
.flatten()
|
||||
impl Arrangement {
|
||||
/// Width of display
|
||||
pub(crate) fn w (&self) -> u16 {
|
||||
self.size.w() as u16
|
||||
}
|
||||
fn get_mut (&mut self) -> &mut Option<Track> {
|
||||
Has::<Selection>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Track>>::get_mut(self).get_mut(index))
|
||||
.flatten()
|
||||
}
|
||||
}
|
||||
|
||||
impl Has<Option<Scene>> for Arrangement {
|
||||
fn get (&self) -> &Option<Scene> {
|
||||
Has::<Selection>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Scene>>::get(self).get(index))
|
||||
.flatten()
|
||||
}
|
||||
fn get_mut (&mut self) -> &mut Option<Scene> {
|
||||
Has::<Selection>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Scene>>::get_mut(self).get_mut(index))
|
||||
.flatten()
|
||||
/// Width allocated for sidebar.
|
||||
pub(crate) fn w_sidebar (&self, is_editing: bool) -> u16 {
|
||||
self.w() / if is_editing { 16 } else { 8 } as u16
|
||||
}
|
||||
/// Width taken by all tracks.
|
||||
pub(crate) fn w_tracks (&self) -> u16 {
|
||||
self.tracks_with_sizes().last().map(|(_, _, _, x)|x as u16).unwrap_or(0)
|
||||
}
|
||||
/// Width available to display tracks.
|
||||
pub(crate) fn w_tracks_area (&self, is_editing: bool) -> u16 {
|
||||
self.w().saturating_sub(2 * self.w_sidebar(is_editing))
|
||||
}
|
||||
/// Height of display
|
||||
pub(crate) fn h (&self) -> u16 {
|
||||
self.size.h() as u16
|
||||
}
|
||||
/// Height available to display track headers.
|
||||
pub(crate) fn h_tracks_area (&self) -> u16 {
|
||||
5 // FIXME
|
||||
//self.h().saturating_sub(self.h_inputs() + self.h_outputs())
|
||||
}
|
||||
/// Height available to display tracks.
|
||||
pub(crate) fn h_scenes_area (&self) -> u16 {
|
||||
//15
|
||||
self.h().saturating_sub(
|
||||
self.h_inputs() +
|
||||
self.h_outputs() +
|
||||
self.h_devices() +
|
||||
13 // FIXME
|
||||
)
|
||||
}
|
||||
/// Height taken by all scenes.
|
||||
pub(crate) fn h_scenes (&self, is_editing: bool) -> u16 {
|
||||
let (selected_track, selected_scene) = match Has::<Option<Selection>>::get(self) {
|
||||
Some(Selection::Track(t)) => (Some(*t), None),
|
||||
Some(Selection::Scene(s)) => (None, Some(*s)),
|
||||
Some(Selection::TrackClip { track, scene }) => (Some(*track), Some(*scene)),
|
||||
_ => (None, None)
|
||||
};
|
||||
self.scenes_with_sizes(
|
||||
is_editing,
|
||||
ArrangerView::H_SCENE,
|
||||
ArrangerView::H_EDITOR,
|
||||
selected_track,
|
||||
selected_scene
|
||||
)
|
||||
.last()
|
||||
.map(|(_, _, _, y)|y as u16).unwrap_or(0)
|
||||
}
|
||||
/// Height taken by all inputs.
|
||||
pub(crate) fn h_inputs (&self) -> u16 {
|
||||
self.midi_ins_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
|
||||
}
|
||||
/// Height taken by all outputs.
|
||||
pub(crate) fn h_outputs (&self) -> u16 {
|
||||
self.midi_outs_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
|
||||
}
|
||||
/// Height taken by visible device slots.
|
||||
pub(crate) fn h_devices (&self) -> u16 {
|
||||
2
|
||||
//1 + self.devices_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue