down to 48 ugly ones

This commit is contained in:
🪞👃🪞 2025-05-14 16:06:10 +03:00
parent 57eff50973
commit 4fe51b5267
9 changed files with 104 additions and 101 deletions

View file

@ -53,33 +53,33 @@ has!(Clock: |self: Arrangement|self.clock);
impl Arrangement {
/// Width of display
pub(crate) fn w (&self) -> u16 {
pub fn w (&self) -> u16 {
self.size.w() as u16
}
/// Width allocated for sidebar.
pub(crate) fn w_sidebar (&self, is_editing: bool) -> u16 {
pub 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 {
pub fn w_tracks (&self) -> u16 {
self.tracks_with_sizes(&self.selected, None).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 {
pub 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 {
pub fn h (&self) -> u16 {
self.size.h() as u16
}
/// Height available to display track headers.
pub(crate) fn h_tracks_area (&self) -> u16 {
pub 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 {
pub fn h_scenes_area (&self) -> u16 {
//15
self.h().saturating_sub(
self.h_inputs() +
@ -89,7 +89,7 @@ impl Arrangement {
)
}
/// Height taken by all scenes.
pub(crate) fn h_scenes (&self, is_editing: bool) -> u16 {
pub 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)),
@ -107,15 +107,15 @@ impl Arrangement {
.map(|(_, _, _, y)|y as u16).unwrap_or(0)
}
/// Height taken by all inputs.
pub(crate) fn h_inputs (&self) -> u16 {
pub 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 {
pub 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 {
pub fn h_devices (&self) -> u16 {
2
//1 + self.devices_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
}
@ -144,7 +144,7 @@ impl Arrangement {
self.get_scene()?.clips.get(self.selection()?.track()?)?.clone()
}
/// Put a clip in a slot
pub(crate) fn clip_put (
pub fn clip_put (
&mut self, track: usize, scene: usize, clip: Option<Arc<RwLock<MidiClip>>>
) -> Option<Arc<RwLock<MidiClip>>> {
let old = self.scenes[scene].clips[track].clone();
@ -152,7 +152,7 @@ impl Arrangement {
old
}
/// Change the color of a clip, returning the previous one
pub(crate) fn clip_set_color (&self, track: usize, scene: usize, color: ItemTheme)
pub fn clip_set_color (&self, track: usize, scene: usize, color: ItemTheme)
-> Option<ItemTheme>
{
self.scenes[scene].clips[track].as_ref().map(|clip|{
@ -164,7 +164,7 @@ impl Arrangement {
})
}
/// Toggle looping for the active clip
pub(crate) fn toggle_loop (&mut self) {
pub fn toggle_loop (&mut self) {
if let Some(clip) = self.get_clip() {
clip.write().unwrap().toggle_loop()
}

View file

@ -17,8 +17,11 @@ impl Arrangement {
/// Represents the current user selection in the arranger
#[derive(PartialEq, Clone, Copy, Debug, Default)]
pub enum Selection {
#[default]
/// Nothing is selected
Nothing,
/// The whole mix is selected
#[default] Mix,
Mix,
/// A MIDI input is selected.
Input(usize),
/// A MIDI output is selected.

View file

@ -1,6 +1,6 @@
use crate::*;
pub(crate) struct ArrangerView<'a> {
pub struct ArrangerView<'a> {
pub arrangement: &'a Arrangement,
pub is_editing: bool,

View file

@ -18,14 +18,14 @@ pub fn view_transport (
}
pub fn view_status (
sel: Arc<str>,
sel: Option<Arc<str>>,
sr: Arc<RwLock<String>>,
buf: Arc<RwLock<String>>,
lat: Arc<RwLock<String>>,
) -> impl Content<TuiOut> {
let theme = ItemTheme::G[96];
Tui::bg(Black, row!(Bsp::a(
Fill::xy(Align::w(FieldH(theme, "Selected", sel))),
Fill::xy(Align::w(sel.map(|sel|FieldH(theme, "Selected", sel)))),
Fill::xy(Align::e(row!(
FieldH(theme, "SR", sr),
FieldH(theme, "Buf", buf),

View file

@ -102,8 +102,8 @@ impl MidiViewer for MidiEditor {
}
pub trait HasEditor {
fn editor (&self) -> &Option<MidiEditor>;
fn editor_mut (&mut self) -> &Option<MidiEditor>;
fn editor (&self) -> Option<&MidiEditor>;
fn editor_mut (&mut self) -> Option<&mut MidiEditor>;
fn is_editing (&self) -> bool { true }
fn editor_w (&self) -> usize { 0 }
fn editor_h (&self) -> usize { 0 }
@ -117,17 +117,12 @@ pub trait HasEditor {
is_editing = $e3:expr;
}) => {
impl HasEditor for $Struct {
fn editor (&$self) -> &Option<MidiEditor> { &$e0 }
fn editor_mut (&mut $self) -> &Option<MidiEditor> { &mut $e0 }
fn editor (&$self) -> Option<&MidiEditor> { $e0.as_ref() }
fn editor_mut (&mut $self) -> Option<&mut MidiEditor> { $e0.as_mut() }
fn editor_w (&$self) -> usize { $e1 }
fn editor_h (&$self) -> usize { $e2 }
fn is_editing (&$self) -> bool { $e3 }
}
};
(|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?|$cb:expr) => {
impl $(<$($L),*$($T $(: $U)?),*>)? HasEditor for $Struct $(<$($L),*$($T),*>)? {
fn editor (&$self) -> &MidiEditor { &$cb }
}
};
}