diff --git a/crates/tek/src/setup.rs b/crates/tek/src/setup.rs index 60517a4f..666479c5 100644 --- a/crates/tek/src/setup.rs +++ b/crates/tek/src/setup.rs @@ -52,4 +52,4 @@ impl Exit for SetupModal { fn exit (&mut self) { self.1 = true } -t } +} diff --git a/crates/tek_core/src/lib.rs b/crates/tek_core/src/lib.rs index 2a3a4550..3b028d19 100644 --- a/crates/tek_core/src/lib.rs +++ b/crates/tek_core/src/lib.rs @@ -44,16 +44,17 @@ use crossterm::terminal::{ submod! { exit handle - render - render_split - render_border - time_base - time_note - time_tick jack_core jack_device jack_event jack_ports + render + render_border + render_split + render_theme + time_base + time_note + time_tick } /// EDN parsing helper. diff --git a/crates/tek_core/src/render.rs b/crates/tek_core/src/render.rs index 896c6c3e..64d81f51 100644 --- a/crates/tek_core/src/render.rs +++ b/crates/tek_core/src/render.rs @@ -241,76 +241,6 @@ impl<'a> Render for IfElse<'a> { } } -pub trait Theme { - const BG0: Color; - const BG1: Color; - const BG2: Color; - const BG3: Color; - const BG4: Color; - const RED: Color; - const YELLOW: Color; - const GREEN: Color; - - const PLAYING: Color; - const SEPARATOR: Color; - - fn bg_hier (focused: bool, entered: bool) -> Color { - if focused && entered { - Self::BG3 - } else if focused { - Self::BG2 - } else { - Self::BG1 - } - } - - fn bg_hi (focused: bool, entered: bool) -> Color { - if focused && entered { - Self::BG2 - } else if focused { - Self::BG1 - } else { - Self::BG0 - } - } - - fn bg_lo (focused: bool, entered: bool) -> Color { - if focused && entered { - Self::BG1 - } else if focused { - Self::BG0 - } else { - Color::Reset - } - } - - fn style_hi (focused: bool, highlight: bool) -> Style { - if highlight && focused { - Style::default().yellow().not_dim() - } else if highlight { - Style::default().yellow().dim() - } else { - Style::default() - } - } -} - -pub struct Nord; - -impl Theme for Nord { - const BG0: Color = Color::Rgb(41, 46, 57); - const BG1: Color = Color::Rgb(46, 52, 64); - const BG2: Color = Color::Rgb(59, 66, 82); - const BG3: Color = Color::Rgb(67, 76, 94); - const BG4: Color = Color::Rgb(76, 86, 106); - const RED: Color = Color::Rgb(191, 97, 106); - const YELLOW: Color = Color::Rgb(235, 203, 139); - const GREEN: Color = Color::Rgb(163, 190, 140); - - const PLAYING: Color = Color::Rgb(60, 100, 50); - const SEPARATOR: Color = Color::Rgb(0, 0, 0); -} - macro_rules! impl_axis_common { ($A:ident $T:ty) => { impl $A<$T> { pub fn start_inc (&mut self) -> $T { diff --git a/crates/tek_core/src/render_theme.rs b/crates/tek_core/src/render_theme.rs new file mode 100644 index 00000000..6f66e03e --- /dev/null +++ b/crates/tek_core/src/render_theme.rs @@ -0,0 +1,71 @@ +use crate::*; + +pub trait Theme { + const BG0: Color; + const BG1: Color; + const BG2: Color; + const BG3: Color; + const BG4: Color; + const RED: Color; + const YELLOW: Color; + const GREEN: Color; + + const PLAYING: Color; + const SEPARATOR: Color; + + fn bg_hier (focused: bool, entered: bool) -> Color { + if focused && entered { + Self::BG3 + } else if focused { + Self::BG2 + } else { + Self::BG1 + } + } + + fn bg_hi (focused: bool, entered: bool) -> Color { + if focused && entered { + Self::BG2 + } else if focused { + Self::BG1 + } else { + Self::BG0 + } + } + + fn bg_lo (focused: bool, entered: bool) -> Color { + if focused && entered { + Self::BG1 + } else if focused { + Self::BG0 + } else { + Color::Reset + } + } + + fn style_hi (focused: bool, highlight: bool) -> Style { + if highlight && focused { + Style::default().yellow().not_dim() + } else if highlight { + Style::default().yellow().dim() + } else { + Style::default() + } + } +} + +pub struct Nord; + +impl Theme for Nord { + const BG0: Color = Color::Rgb(41, 46, 57); + const BG1: Color = Color::Rgb(46, 52, 64); + const BG2: Color = Color::Rgb(59, 66, 82); + const BG3: Color = Color::Rgb(67, 76, 94); + const BG4: Color = Color::Rgb(76, 86, 106); + const RED: Color = Color::Rgb(191, 97, 106); + const YELLOW: Color = Color::Rgb(235, 203, 139); + const GREEN: Color = Color::Rgb(163, 190, 140); + + const PLAYING: Color = Color::Rgb(60, 100, 50); + const SEPARATOR: Color = Color::Rgb(0, 0, 0); +} diff --git a/crates/tek_sequencer/src/arranger_modal.rs b/crates/tek_sequencer/src/arranger_modal.rs index 896e07cd..fce11b5d 100644 --- a/crates/tek_sequencer/src/arranger_modal.rs +++ b/crates/tek_sequencer/src/arranger_modal.rs @@ -11,12 +11,14 @@ impl ArrangerRenameModal { render!(ArrangerRenameModal |self, buf, area| { let y = area.y + area.height / 2; - Lozenge(Style::default().bold().white().dim()).draw(buf, Rect { + let bg_area = Rect { x: 1, y: y - 1, width: area.width - 2, height: 3 - })?; + }; + fill_bg(buf, bg_area, Nord::BG0); + Lozenge(Style::default().bold().white().dim()).draw(buf, bg_area)?; let label = match self.1 { ArrangerFocus::Mix => "Rename project:", ArrangerFocus::Track(_) => "Rename track:", diff --git a/crates/tek_sequencer/src/arranger_view.rs b/crates/tek_sequencer/src/arranger_view.rs index 0c7fc983..9d97f386 100644 --- a/crates/tek_sequencer/src/arranger_view.rs +++ b/crates/tek_sequencer/src/arranger_view.rs @@ -41,7 +41,7 @@ render!(Arranger |self, buf, area| { y: area.y - 1, height: area.height + 2, }; - Lozenge(Style::default().fg(Nord::bg_hi(false, false))).draw(buf, area) + Lozenge(Style::default().fg(Nord::BG2)).draw(buf, area) }; let area = if let Some(direction) = self.show_sequencer { let arrangement = arrangement(buf, area)?; diff --git a/crates/tek_sequencer/src/sequencer_render.rs b/crates/tek_sequencer/src/sequencer_render.rs index c44121e2..dc9d4049 100644 --- a/crates/tek_sequencer/src/sequencer_render.rs +++ b/crates/tek_sequencer/src/sequencer_render.rs @@ -1,7 +1,6 @@ use crate::*; render!(Sequencer |self, buf, area| { - fill_bg(buf, area, Nord::bg_lo(self.focused, self.entered)); self.horizontal_draw(buf, area)?; if self.focused && self.entered { Corners(Style::default().green().not_dim()).draw(buf, area)?; @@ -58,20 +57,20 @@ impl Sequencer { const H_KEYS_OFFSET: usize = 5; fn horizontal_draw (&self, buf: &mut Buffer, mut area: Rect) -> Usually<()> { - Lozenge(Style::default().fg(Nord::bg_hi(false, false))).draw(buf, Rect { + Lozenge(Style::default().fg(Nord::BG2)).draw(buf, Rect { x: area.x, y: area.y + 1, width: 15, height: 4 })?; "Start 1.1.1".blit(buf, area.x + 1, area.y + 2, None)?; "End 2.1.1".blit(buf, area.x + 1, area.y + 3, None)?; - Lozenge(Style::default().fg(Nord::bg_hi(false, false))).draw(buf, Rect { + Lozenge(Style::default().fg(Nord::BG2)).draw(buf, Rect { x: area.x, y: area.y + 5, width: 15, height: 5 })?; "[ Loop off ] ".blit(buf, area.x + 1, area.y + 6, None)?; "Loop 1.1.1".blit(buf, area.x + 1, area.y + 7, None)?; "Length 1.0.0".blit(buf, area.x + 1, area.y + 8, None)?; - Lozenge(Style::default().fg(Nord::bg_hi(false, false))).draw(buf, Rect { + Lozenge(Style::default().fg(Nord::BG2)).draw(buf, Rect { x: area.x, y: area.y + 10, width: 15, height: 7 })?; "Notes -------".blit(buf, area.x + 1, area.y + 11, None)?;