From 83f840a412bfd42e6c6637b73d9c043737dac64b Mon Sep 17 00:00:00 2001 From: unspeaker Date: Fri, 3 Jan 2025 00:44:00 +0100 Subject: [PATCH] improve ui legibility immensely right after release --- src/field.rs | 35 ++++++++++++--------------------- src/groovebox/groovebox_tui.rs | 36 +++++++++++++++------------------- src/midi/midi_status.rs | 20 ++++++++----------- src/pool/clip_select.rs | 2 +- src/sampler/sampler_status.rs | 4 ++-- 5 files changed, 40 insertions(+), 57 deletions(-) diff --git a/src/field.rs b/src/field.rs index 070a3cf2..1f80e02b 100644 --- a/src/field.rs +++ b/src/field.rs @@ -7,16 +7,12 @@ impl Content for Field where T: AsRef + Send + Sync, U: AsRef + Send + Sync { fn content (&self) -> impl Content { + let ItemPalette { darkest, dark, lighter, lightest, .. } = self.0; row!( - Tui::bg(self.0.darkest.rgb, Tui::fg(self.0.darker.rgb, "▐")), - - Tui::bg(self.0.darker.rgb, Tui::fg(self.0.lighter.rgb, - Tui::bold(true, format!("{}", self.1.as_ref())))), - - Tui::bg(self.0.darkest.rgb, Tui::fg(self.0.darker.rgb, "▌")), - - Tui::bg(self.0.darkest.rgb, Tui::fg(self.0.lightest.rgb, - format!("{} ", self.2.as_ref()))) + Tui::fg_bg(dark.rgb, darkest.rgb, "▐"), + Tui::fg_bg(lighter.rgb, dark.rgb, Tui::bold(true, format!("{}", self.1.as_ref()))), + Tui::fg_bg(dark.rgb, darkest.rgb, "▌"), + Tui::fg_bg(lightest.rgb, darkest.rgb, format!("{} ", self.2.as_ref())) ) } } @@ -28,18 +24,13 @@ impl Content for FieldV where T: AsRef + Send + Sync, U: AsRef + Send + Sync { fn content (&self) -> impl Content { - Bsp::e( - Bsp::s( - row!( - Tui::bg(self.0.darkest.rgb, Tui::fg(self.0.darker.rgb, "▐")), - Tui::bg(self.0.darker.rgb, Tui::fg(self.0.lighter.rgb, - Tui::bold(true, format!("{}", self.1.as_ref())))), - Tui::bg(self.0.darkest.rgb, Tui::fg(self.0.darker.rgb, "▌")), - ), - Tui::bg(self.0.darkest.rgb, Tui::fg(self.0.lightest.rgb, - format!(" {}", self.2.as_ref()))) - ), - " " - ) + let ItemPalette { darkest, dark, lighter, lightest, .. } = self.0; + let sep1 = Tui::bg(darkest.rgb, Tui::fg(dark.rgb, "▐")); + let sep2 = Tui::bg(darkest.rgb, Tui::fg(dark.rgb, "▌")); + let name = Tui::bg(dark.rgb, Tui::fg(lighter.rgb, + Tui::bold(true, format!("{}", self.1.as_ref())))); + let value = Tui::bg(darkest.rgb, Tui::fg(lightest.rgb, + format!(" {} ", self.2.as_ref()))); + Bsp::e(Bsp::s(row!(sep1, name, sep2), value), " ") } } diff --git a/src/groovebox/groovebox_tui.rs b/src/groovebox/groovebox_tui.rs index 5e635095..0bd1601d 100644 --- a/src/groovebox/groovebox_tui.rs +++ b/src/groovebox/groovebox_tui.rs @@ -3,7 +3,7 @@ use super::*; render!(Tui: (self: Groovebox) => self.size.of( Bsp::s(self.toolbar_view(), - Bsp::s(self.selector_view(), + Bsp::n(self.selector_view(), Bsp::n(self.sample_view(), Bsp::n(self.status_view(), Bsp::w(self.pool_view(), Fill::xy(Bsp::e(self.sampler_view(), &self.editor))))))))); @@ -16,38 +16,34 @@ impl Groovebox { Align::x(TransportView::new(true, &self.player.clock)), ))) } - fn status_view (&self) -> impl Content + use<'_> { - let note_pt = self.editor.note_point(); - lay!( - Align::w(Fixed::y(1, SamplerStatus(&self.sampler, note_pt))), - Align::x(Fixed::y(1, MidiEditStatus(&self.editor))), + fn selector_view (&self) -> impl Content + use<'_> { + row!( + MidiEditClip(&self.editor), + MidiEditStatus(&self.editor), + ClipSelected::play_phrase(&self.player), + ClipSelected::next_phrase(&self.player), ) } - fn sampler_view (&self) -> impl Content + use<'_> { - let sampler_w = if !self.compact { 11 } else { 4 }; - let sampler_y = if self.compact { 1 } else { 0 }; - Fixed::x(sampler_w, Push::y(sampler_y, Fill::y( - SampleList::new(self.compact, &self.sampler, &self.editor)))) - } fn sample_view (&self) -> impl Content + use<'_> { let note_pt = self.editor.note_point(); let sample_h = if self.compact { 0 } else { 5 }; Max::y(sample_h, Fill::xy( SampleViewer::from_sampler(&self.sampler, note_pt))) } + fn status_view (&self) -> impl Content + use<'_> { + let note_pt = self.editor.note_point(); + Align::w(Fixed::y(1, SamplerStatus(&self.sampler, note_pt))) + } fn pool_view (&self) -> impl Content + use<'_> { let w = self.size.w(); let pool_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 }; Fixed::x(if self.compact { 5 } else { pool_w }, PoolView(self.compact, &self.pool)) } - fn selector_view (&self) -> impl Content + use<'_> { - lay!( - Align::w(MidiEditClip(&self.editor)), - Align::e(Bsp::e( - ClipSelected::play_phrase(&self.player), - ClipSelected::next_phrase(&self.player) - )) - ) + fn sampler_view (&self) -> impl Content + use<'_> { + let sampler_w = if self.compact { 4 } else { 11 }; + let sampler_y = if self.compact { 0 } else { 1 }; + Fixed::x(sampler_w, Push::y(sampler_y, Fill::y( + SampleList::new(self.compact, &self.sampler, &self.editor)))) } } diff --git a/src/midi/midi_status.rs b/src/midi/midi_status.rs index 4cb323cc..b8fda05c 100644 --- a/src/midi/midi_status.rs +++ b/src/midi/midi_status.rs @@ -7,11 +7,11 @@ render!(Tui: (self: MidiEditClip<'a>) => { } else { (ItemPalette::from(TuiTheme::g(64)), String::new(), 0, false) }; - Fixed::y(1, row!( - Field(color, "Edit", name.to_string()), - Field(color, "Length", length.to_string()), - Field(color, "Loop", looped.to_string()) - )) + row!( + FieldV(color, "Edit", name.to_string()), + FieldV(color, "Length", length.to_string()), + FieldV(color, "Loop", looped.to_string()) + ) }); pub struct MidiEditStatus<'a>(pub &'a MidiEditor); @@ -27,15 +27,11 @@ render!(Tui: (self: MidiEditStatus<'a>) => { let time_axis = self.0.time_axis().get(); let time_zoom = self.0.time_zoom().get(); let time_lock = if self.0.time_lock().get() { "[lock]" } else { " " }; - let time_field = Field(color, "Time", format!("{length}/{time_zoom}+{time_point} {time_lock}")); + let time_field = FieldV(color, "Time", format!("{length}/{time_zoom}+{time_point} {time_lock}")); let note_point = format!("{:>3}", self.0.note_point()); let note_name = format!("{:4}", Note::pitch_to_name(self.0.note_point())); let note_len = format!("{:>4}", self.0.note_len());;;; - let note_field = Field(color, "Note", format!("{note_name} {note_point} {note_len}")); - - Tui::bg(color.darkest.rgb, Fill::x(Tui::fg(color.lightest.rgb, Bsp::e( - time_field, - note_field, - )))) + let note_field = FieldV(color, "Note", format!("{note_name} {note_point} {note_len}")); + Bsp::e(time_field, note_field,) }); diff --git a/src/pool/clip_select.rs b/src/pool/clip_select.rs index b3f240f6..5c14a25c 100644 --- a/src/pool/clip_select.rs +++ b/src/pool/clip_select.rs @@ -8,7 +8,7 @@ pub struct ClipSelected { } render!(Tui: (self: ClipSelected) => - Field(self.color, self.title, format!("{} {}", self.time, self.name))); + FieldV(self.color, self.title, format!("{} {}", self.time, self.name))); impl ClipSelected { diff --git a/src/sampler/sampler_status.rs b/src/sampler/sampler_status.rs index a948dfb7..184d8c82 100644 --- a/src/sampler/sampler_status.rs +++ b/src/sampler/sampler_status.rs @@ -2,8 +2,8 @@ use crate::*; pub struct SamplerStatus<'a>(pub &'a Sampler, pub usize); -render!(Tui: (self: SamplerStatus<'a>) => self.0.mapped[self.1].as_ref().map(|sample|format!( +render!(Tui: (self: SamplerStatus<'a>) => Tui::bold(true, Tui::fg(TuiTheme::g(224), self.0.mapped[self.1].as_ref().map(|sample|format!( "Sample {}-{}", sample.read().unwrap().start, sample.read().unwrap().end, -)).unwrap_or_else(||"No sample".to_string())); +)).unwrap_or_else(||"No sample".to_string()))));