refactor: borders

This commit is contained in:
🪞👃🪞 2024-08-20 15:10:55 +03:00
parent 5eeb47d996
commit bb0230b6e5
7 changed files with 87 additions and 84 deletions

View file

@ -52,4 +52,4 @@ impl Exit for SetupModal {
fn exit (&mut self) {
self.1 = true
}
t }
}

View file

@ -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.

View file

@ -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 {

View file

@ -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);
}

View file

@ -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:",

View file

@ -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)?;

View file

@ -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)?;