From 5667416d896e9a430c4117894fd3364085e13ced Mon Sep 17 00:00:00 2001 From: unspeaker Date: Sun, 6 Oct 2024 07:47:56 +0300 Subject: [PATCH] fix disappearing phrase list --- crates/tek_core/src/space.rs | 23 +++++++++++++---------- crates/tek_sequencer/src/arranger_tui.rs | 14 -------------- crates/tek_sequencer/src/sequencer_tui.rs | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/crates/tek_core/src/space.rs b/crates/tek_core/src/space.rs index 87f6b626..f71d43a6 100644 --- a/crates/tek_core/src/space.rs +++ b/crates/tek_core/src/space.rs @@ -599,7 +599,7 @@ impl> Widget for Shrink { ], Self::Y(h, _) => [ to.w(), -if to.h() > h { to.h() - h } else { 0.into() } + if to.h() > h { to.h() - h } else { 0.into() } ], Self::XY(w, h, _) => [ if to.w() > w { to.w() - w } else { 0.into() }, @@ -651,11 +651,11 @@ impl> Widget for Inset { fn render (&self, to: &mut E::Output) -> Usually<()> { match *self { Self::X(x, ref inner) => - Push::X(x, Shrink::X(x, inner as &dyn Widget)), + (inner as &dyn Widget).shrink_x(x).push_x(x), Self::Y(y, ref inner) => - Push::Y(y, Shrink::Y(y, inner as &dyn Widget)), + (inner as &dyn Widget).shrink_y(y).push_y(y), Self::XY(x, y, ref inner) => - Push::XY(x, y, Shrink::XY(x, y, inner as &dyn Widget)), + (inner as &dyn Widget).shrink_xy(x, y).push_xy(x, y) }.render(to) } } @@ -664,19 +664,22 @@ impl> Widget for Outset { type Engine = E; fn layout (&self, to: E::Size) -> Perhaps { match *self { - Self::X(x, ref inner) => Grow::X(x + x, inner as &dyn Widget), - Self::Y(y, ref inner) => Grow::Y(y + y, inner as &dyn Widget), - Self::XY(x, y, ref inner) => Grow::XY(x + x, y + y, inner as &dyn Widget), + Self::X(x, ref inner) => + (inner as &dyn Widget).grow_x(x + x), + Self::Y(y, ref inner) => + (inner as &dyn Widget).grow_y(y + y), + Self::XY(x, y, ref inner) => + (inner as &dyn Widget).grow_xy(x + x, y + y), }.layout(to) } fn render (&self, to: &mut E::Output) -> Usually<()> { match *self { Self::X(x, ref inner) => - Push::X(x, inner as &dyn Widget), + (inner as &dyn Widget).push_x(x), Self::Y(y, ref inner) => - Push::Y(y, inner as &dyn Widget), + (inner as &dyn Widget).push_y(y), Self::XY(x, y, ref inner) => - Push::XY(x, y, inner as &dyn Widget), + (inner as &dyn Widget).push_xy(x, y), }.render(to) } } diff --git a/crates/tek_sequencer/src/arranger_tui.rs b/crates/tek_sequencer/src/arranger_tui.rs index 2a08e509..6a970616 100644 --- a/crates/tek_sequencer/src/arranger_tui.rs +++ b/crates/tek_sequencer/src/arranger_tui.rs @@ -727,17 +727,3 @@ impl Handle for ArrangerRenameModal { } } } - -impl Content for PhrasePool { - type Engine = Tui; - fn content (&self) -> impl Widget { - col!( - "Phrases:", - col!((i, phrase) in self.phrases.iter().enumerate() => format!("{i}")) - ) - .bg(Color::Rgb(28, 35, 25)) - .border(Lozenge(Style::default() - .bg(Color::Rgb(40, 50, 30)) - .fg(Color::Rgb(70, 80, 50)))) - } -} diff --git a/crates/tek_sequencer/src/sequencer_tui.rs b/crates/tek_sequencer/src/sequencer_tui.rs index c40baf5a..d3df9761 100644 --- a/crates/tek_sequencer/src/sequencer_tui.rs +++ b/crates/tek_sequencer/src/sequencer_tui.rs @@ -1,5 +1,20 @@ use crate::*; +impl Content for PhrasePool { + type Engine = Tui; + fn content (&self) -> impl Widget { + col!( + "Phrases:", + col!((i, phrase) in self.phrases.iter().enumerate() => format!("{i}")) + ) + .fill_xy() + .bg(Color::Rgb(28, 35, 25)) + .border(Lozenge(Style::default() + .bg(Color::Rgb(40, 50, 30)) + .fg(Color::Rgb(70, 80, 50)))) + } +} + impl Sequencer { const H_KEYS_OFFSET: usize = 5; /// Select which pattern to display. This pre-renders it to the buffer at full resolution.