Pattern mute and so on

This commit is contained in:
2026-02-02 16:27:11 +01:00
parent 7c14ce7634
commit 39ca7de169
29 changed files with 518 additions and 58 deletions

View File

@@ -3,8 +3,17 @@ use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::widgets::Widget;
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum MuteStatus {
Normal,
Muted,
Soloed,
EffectivelyMuted, // Solo active on another pattern
}
pub struct ActivePatterns<'a> {
patterns: &'a [(usize, usize, usize)], // (bank, pattern, iter)
mute_status: Option<&'a [MuteStatus]>,
current_step: Option<(usize, usize)>, // (current_step, total_steps)
}
@@ -12,6 +21,7 @@ impl<'a> ActivePatterns<'a> {
pub fn new(patterns: &'a [(usize, usize, usize)]) -> Self {
Self {
patterns,
mute_status: None,
current_step: None,
}
}
@@ -20,6 +30,11 @@ impl<'a> ActivePatterns<'a> {
self.current_step = Some((current, total));
self
}
pub fn with_mute_status(mut self, status: &'a [MuteStatus]) -> Self {
self.mute_status = Some(status);
self
}
}
impl Widget for ActivePatterns<'_> {
@@ -39,20 +54,36 @@ impl Widget for ActivePatterns<'_> {
if row >= max_pattern_rows {
break;
}
let text = format!("B{:02}:{:02} ({:02})", bank + 1, pattern + 1, iter.min(99));
let y = area.y + row as u16;
let bg = if row % 2 == 0 {
theme.table.row_even
} else {
theme.table.row_odd
let mute_status = self
.mute_status
.and_then(|s| s.get(row))
.copied()
.unwrap_or(MuteStatus::Normal);
let (prefix, fg, bg) = match mute_status {
MuteStatus::Soloed => ("S", theme.list.soloed_fg, theme.list.soloed_bg),
MuteStatus::Muted => ("M", theme.list.muted_fg, theme.list.muted_bg),
MuteStatus::EffectivelyMuted => (" ", theme.list.muted_fg, theme.list.muted_bg),
MuteStatus::Normal => {
let bg = if row % 2 == 0 {
theme.table.row_even
} else {
theme.table.row_odd
};
(" ", theme.ui.text_primary, bg)
}
};
let text = format!("{}B{:02}:{:02}({:02})", prefix, bank + 1, pattern + 1, iter.min(99));
let y = area.y + row as u16;
let mut chars = text.chars();
for col in 0..area.width as usize {
let ch = chars.next().unwrap_or(' ');
buf[(area.x + col as u16, y)]
.set_char(ch)
.set_fg(theme.ui.text_primary)
.set_fg(fg)
.set_bg(bg);
}
}

View File

@@ -13,7 +13,7 @@ mod text_input;
pub mod theme;
mod vu_meter;
pub use active_patterns::ActivePatterns;
pub use active_patterns::{ActivePatterns, MuteStatus};
pub use confirm::ConfirmModal;
pub use editor::{CompletionCandidate, Editor};
pub use file_browser::FileBrowserModal;

View File

@@ -123,6 +123,10 @@ pub fn theme() -> ThemeColors {
edit_fg: teal,
hover_bg: surface1,
hover_fg: text,
muted_bg: Color::Rgb(215, 215, 225),
muted_fg: overlay0,
soloed_bg: Color::Rgb(250, 235, 200),
soloed_fg: yellow,
},
link_status: LinkStatusColors {
disabled: red,

View File

@@ -123,6 +123,10 @@ pub fn theme() -> ThemeColors {
edit_fg: teal,
hover_bg: surface1,
hover_fg: text,
muted_bg: Color::Rgb(40, 40, 50),
muted_fg: overlay0,
soloed_bg: Color::Rgb(60, 55, 35),
soloed_fg: yellow,
},
link_status: LinkStatusColors {
disabled: red,

View File

@@ -117,6 +117,10 @@ pub fn theme() -> ThemeColors {
edit_fg: cyan,
hover_bg: lighter_bg,
hover_fg: foreground,
muted_bg: Color::Rgb(50, 52, 65),
muted_fg: comment,
soloed_bg: Color::Rgb(70, 70, 50),
soloed_fg: yellow,
},
link_status: LinkStatusColors {
disabled: red,

View File

@@ -118,6 +118,10 @@ pub fn theme() -> ThemeColors {
edit_fg: mint,
hover_bg: bg_lighter,
hover_fg: fg,
muted_bg: Color::Rgb(75, 70, 95),
muted_fg: muted,
soloed_bg: Color::Rgb(100, 95, 65),
soloed_fg: yellow,
},
link_status: LinkStatusColors {
disabled: coral,

View File

@@ -119,6 +119,10 @@ pub fn theme() -> ThemeColors {
edit_fg: aqua,
hover_bg: bg2,
hover_fg: fg,
muted_bg: Color::Rgb(50, 50, 55),
muted_fg: fg4,
soloed_bg: Color::Rgb(70, 65, 40),
soloed_fg: yellow,
},
link_status: LinkStatusColors {
disabled: red,

View File

@@ -114,6 +114,10 @@ pub fn theme() -> ThemeColors {
edit_fg: yellow,
hover_bg: Color::Rgb(230, 50, 50),
hover_fg: yellow,
muted_bg: darker_red,
muted_fg: dim_yellow,
soloed_bg: Color::Rgb(200, 200, 0),
soloed_fg: black,
},
link_status: LinkStatusColors {
disabled: white,

View File

@@ -119,6 +119,10 @@ pub fn theme() -> ThemeColors {
edit_fg: crystal_blue,
hover_bg: bg_lighter,
hover_fg: fg,
muted_bg: Color::Rgb(38, 38, 48),
muted_fg: comment,
soloed_bg: Color::Rgb(60, 55, 45),
soloed_fg: carp_yellow,
},
link_status: LinkStatusColors {
disabled: autumn_red,

View File

@@ -187,6 +187,10 @@ pub struct ListColors {
pub edit_fg: Color,
pub hover_bg: Color,
pub hover_fg: Color,
pub muted_bg: Color,
pub muted_fg: Color,
pub soloed_bg: Color,
pub soloed_fg: Color,
}
#[derive(Clone)]

View File

@@ -116,6 +116,10 @@ pub fn theme() -> ThemeColors {
edit_fg: bright,
hover_bg: surface2,
hover_fg: fg,
muted_bg: Color::Rgb(22, 22, 22),
muted_fg: dark,
soloed_bg: Color::Rgb(60, 60, 60),
soloed_fg: bright,
},
link_status: LinkStatusColors {
disabled: dim,

View File

@@ -116,6 +116,10 @@ pub fn theme() -> ThemeColors {
edit_fg: dark,
hover_bg: surface2,
hover_fg: fg,
muted_bg: Color::Rgb(235, 235, 235),
muted_fg: light,
soloed_bg: Color::Rgb(190, 190, 190),
soloed_fg: dark,
},
link_status: LinkStatusColors {
disabled: dim,

View File

@@ -117,6 +117,10 @@ pub fn theme() -> ThemeColors {
edit_fg: blue,
hover_bg: bg_lighter,
hover_fg: fg,
muted_bg: Color::Rgb(48, 50, 45),
muted_fg: comment,
soloed_bg: Color::Rgb(70, 65, 45),
soloed_fg: yellow,
},
link_status: LinkStatusColors {
disabled: pink,

View File

@@ -117,6 +117,10 @@ pub fn theme() -> ThemeColors {
edit_fg: frost0,
hover_bg: polar_night2,
hover_fg: snow_storm2,
muted_bg: Color::Rgb(55, 60, 70),
muted_fg: polar_night3,
soloed_bg: Color::Rgb(70, 65, 50),
soloed_fg: aurora_yellow,
},
link_status: LinkStatusColors {
disabled: aurora_red,

View File

@@ -118,6 +118,10 @@ pub fn theme() -> ThemeColors {
edit_fg: cyan,
hover_bg: surface2,
hover_fg: fg,
muted_bg: Color::Rgb(15, 15, 15),
muted_fg: fg_muted,
soloed_bg: Color::Rgb(45, 40, 15),
soloed_fg: yellow,
},
link_status: LinkStatusColors {
disabled: red,

View File

@@ -118,6 +118,10 @@ pub fn theme() -> ThemeColors {
edit_fg: foam,
hover_bg: bg_lighter,
hover_fg: fg,
muted_bg: Color::Rgb(32, 30, 42),
muted_fg: muted,
soloed_bg: Color::Rgb(60, 50, 40),
soloed_fg: gold,
},
link_status: LinkStatusColors {
disabled: love,

View File

@@ -118,6 +118,10 @@ pub fn theme() -> ThemeColors {
edit_fg: blue,
hover_bg: bg_lighter,
hover_fg: fg,
muted_bg: Color::Rgb(35, 38, 50),
muted_fg: comment,
soloed_bg: Color::Rgb(60, 55, 40),
soloed_fg: yellow,
},
link_status: LinkStatusColors {
disabled: red,

View File

@@ -183,6 +183,10 @@ pub fn rotate_theme(theme: ThemeColors, degrees: f32) -> ThemeColors {
edit_fg: rotate_color(theme.list.edit_fg, degrees),
hover_bg: rotate_color(theme.list.hover_bg, degrees),
hover_fg: rotate_color(theme.list.hover_fg, degrees),
muted_bg: rotate_color(theme.list.muted_bg, degrees),
muted_fg: rotate_color(theme.list.muted_fg, degrees),
soloed_bg: rotate_color(theme.list.soloed_bg, degrees),
soloed_fg: rotate_color(theme.list.soloed_fg, degrees),
},
link_status: LinkStatusColors {
disabled: rotate_color(theme.link_status.disabled, degrees),