diff --git a/src/app.rs b/src/app.rs index a715555..3343021 100644 --- a/src/app.rs +++ b/src/app.rs @@ -148,12 +148,7 @@ impl App { pub fn step_up(&mut self) { let len = self.current_edit_pattern().length; - let num_rows = match len { - 0..=8 => 1, - 9..=16 => 2, - 17..=24 => 3, - _ => 4, - }; + let num_rows = len.div_ceil(8); let steps_per_row = len.div_ceil(num_rows); if self.editor_ctx.step >= steps_per_row { @@ -166,12 +161,7 @@ impl App { pub fn step_down(&mut self) { let len = self.current_edit_pattern().length; - let num_rows = match len { - 0..=8 => 1, - 9..=16 => 2, - 17..=24 => 3, - _ => 4, - }; + let num_rows = len.div_ceil(8); let steps_per_row = len.div_ceil(num_rows); self.editor_ctx.step = (self.editor_ctx.step + steps_per_row) % len; diff --git a/src/config.rs b/src/config.rs index 5f0fde7..d1ae8a4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,4 @@ pub const MAX_BANKS: usize = 16; pub const MAX_PATTERNS: usize = 16; -pub const MAX_STEPS: usize = 32; +pub const MAX_STEPS: usize = 128; pub const DEFAULT_LENGTH: usize = 16; diff --git a/src/model/project.rs b/src/model/project.rs index d603bc7..eaeb3a0 100644 --- a/src/model/project.rs +++ b/src/model/project.rs @@ -131,7 +131,7 @@ impl Pattern { } pub fn set_length(&mut self, length: usize) { - let length = length.clamp(2, MAX_STEPS); + let length = length.clamp(1, MAX_STEPS); while self.steps.len() < length { self.steps.push(Step::default()); } diff --git a/src/views/main_view.rs b/src/views/main_view.rs index eabad10..b49cbdf 100644 --- a/src/views/main_view.rs +++ b/src/views/main_view.rs @@ -41,12 +41,7 @@ fn render_sequencer(frame: &mut Frame, app: &App, snapshot: &SequencerSnapshot, let pattern = app.current_edit_pattern(); let length = pattern.length; - let num_rows = match length { - 0..=8 => 1, - 9..=16 => 2, - 17..=24 => 3, - _ => 4, - }; + let num_rows = length.div_ceil(8); let steps_per_row = length.div_ceil(num_rows); let spacing = num_rows.saturating_sub(1) as u16; @@ -110,12 +105,37 @@ fn render_tile( false }; + let link_color = step.and_then(|s| s.source).map(|src| { + const BRIGHT: [(u8, u8, u8); 5] = [ + (180, 140, 220), + (220, 140, 170), + (220, 180, 130), + (130, 180, 220), + (170, 220, 140), + ]; + const DIM: [(u8, u8, u8); 5] = [ + (90, 70, 120), + (120, 70, 85), + (120, 90, 65), + (65, 90, 120), + (85, 120, 70), + ]; + let i = src % 5; + (BRIGHT[i], DIM[i]) + }); + let (bg, fg) = match (is_playing, is_active, is_selected, is_linked) { (true, true, _, _) => (Color::Rgb(195, 85, 65), Color::White), (true, false, _, _) => (Color::Rgb(180, 120, 45), Color::Black), - (false, true, true, true) => (Color::Rgb(180, 140, 220), Color::Black), + (false, true, true, true) => { + let (r, g, b) = link_color.unwrap().0; + (Color::Rgb(r, g, b), Color::Black) + } (false, true, true, false) => (Color::Rgb(0, 220, 180), Color::Black), - (false, true, false, true) => (Color::Rgb(90, 70, 120), Color::White), + (false, true, false, true) => { + let (r, g, b) = link_color.unwrap().1; + (Color::Rgb(r, g, b), Color::White) + } (false, true, false, false) => (Color::Rgb(45, 106, 95), Color::White), (false, false, true, _) => (Color::Rgb(80, 180, 255), Color::Black), (false, false, false, _) => (Color::Rgb(45, 48, 55), Color::Rgb(120, 125, 135)), diff --git a/src/views/render.rs b/src/views/render.rs index ac67000..f155722 100644 --- a/src/views/render.rs +++ b/src/views/render.rs @@ -319,7 +319,7 @@ fn render_modal(frame: &mut Frame, app: &App, snapshot: &SequencerSnapshot, term } Modal::SetPattern { field, input } => { let (title, hint) = match field { - PatternField::Length => ("Set Length (2-32)", "Enter number"), + PatternField::Length => ("Set Length (1-128)", "Enter number"), PatternField::Speed => ("Set Speed", "1/8x, 1/4x, 1/2x, 1x, 2x, 4x, 8x"), }; TextInputModal::new(title, input)