refactor sequencer styles

This commit is contained in:
🪞👃🪞 2024-09-19 00:19:05 +03:00
parent 6f988e5072
commit 6e81082c17
2 changed files with 48 additions and 77 deletions

View file

@ -652,3 +652,15 @@ impl Theme for Nord {
const PLAYING: Color = Color::Rgb(60, 100, 50); const PLAYING: Color = Color::Rgb(60, 100, 50);
const SEPARATOR: Color = Color::Rgb(0, 0, 0); const SEPARATOR: Color = Color::Rgb(0, 0, 0);
} }
#[macro_export] macro_rules! tui_style {
($NAME:ident = $fg:expr, $bg:expr, $ul:expr, $add:expr, $sub:expr) => {
pub const $NAME: Style = Style {
fg: $fg,
bg: $bg,
underline_color: $ul,
add_modifier: $add,
sub_modifier: $sub,
};
}
}

View file

@ -1,64 +1,23 @@
use crate::*; use crate::*;
const CORNERS: CornersTall = CornersTall( const CORNERS: CornersTall = CornersTall(NOT_DIM_GREEN);
NOT_DIM_GREEN
); tui_style!(GRAY_DIM =
pub const GRAY_DIM: Style = Style { Some(Color::Gray), None, None, Modifier::DIM, Modifier::empty());
fg: Some(Color::Gray), tui_style!(GRAY_NOT_DIM_BOLD =
bg: None, Some(Color::Gray), None, None, Modifier::BOLD, Modifier::DIM);
underline_color: None, tui_style!(NOT_DIM_BOLD =
add_modifier: Modifier::DIM, None, None, None, Modifier::BOLD, Modifier::DIM);
sub_modifier: Modifier::empty(), tui_style!(NOT_DIM_GREEN =
}; Some(Color::Rgb(96, 255, 32)), Some(COLOR_BG1), None, Modifier::empty(), Modifier::DIM);
pub const GRAY_NOT_DIM_BOLD: Style = Style { tui_style!(NOT_DIM =
fg: Some(Color::Gray), None, None, None, Modifier::empty(), Modifier::DIM);
bg: None, tui_style!(WHITE_NOT_DIM_BOLD =
underline_color: None, Some(Color::White), None, None, Modifier::BOLD, Modifier::DIM);
add_modifier: Modifier::BOLD, tui_style!(STYLE_LABEL =
sub_modifier: Modifier::DIM, Some(Color::Reset), None, None, Modifier::empty(), Modifier::BOLD);
}; tui_style!(STYLE_VALUE =
pub const NOT_DIM_BOLD: Style = Style { Some(Color::White), None, None, Modifier::BOLD, Modifier::DIM);
fg: None,
bg: None,
underline_color: None,
add_modifier: Modifier::BOLD,
sub_modifier: Modifier::DIM,
};
pub const NOT_DIM_GREEN: Style = Style {
fg: Some(Color::Rgb(96, 255, 32)),
bg: Some(COLOR_BG1),
underline_color: None,
add_modifier: Modifier::empty(),
sub_modifier: Modifier::DIM,
};
pub const NOT_DIM: Style = Style {
fg: None,
bg: None,
underline_color: None,
add_modifier: Modifier::empty(),
sub_modifier: Modifier::DIM,
};
pub const WHITE_NOT_DIM_BOLD: Style = Style {
fg: Some(Color::White),
bg: None,
underline_color: None,
add_modifier: Modifier::BOLD,
sub_modifier: Modifier::DIM,
};
const STYLE_LABEL: Option<Style> = Some(Style {
fg: Some(Color::Reset),
bg: None,
underline_color: None,
add_modifier: Modifier::empty(),
sub_modifier: Modifier::BOLD,
});
const STYLE_VALUE: Option<Style> = Some(Style {
fg: Some(Color::White),
bg: None,
underline_color: None,
add_modifier: Modifier::BOLD,
sub_modifier: Modifier::DIM,
});
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@ -2078,8 +2037,8 @@ impl<'a> Widget for SequenceName<'a> {
let [x, y, ..] = to.area(); let [x, y, ..] = to.area();
let frame = [x, y, 10, 4]; let frame = [x, y, 10, 4];
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?; Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
to.blit(&"Name:", x + 1, y + 1, STYLE_LABEL); to.blit(&"Name:", x + 1, y + 1, Some(STYLE_LABEL));
to.blit(&*self.0.name.read().unwrap(), x + 1, y + 2, STYLE_VALUE); to.blit(&*self.0.name.read().unwrap(), x + 1, y + 2, Some(STYLE_VALUE));
Ok(()) Ok(())
} }
} }
@ -2097,10 +2056,10 @@ impl Widget for SequenceRange {
let [x, y, ..] = to.area(); let [x, y, ..] = to.area();
let frame = [x, y, 10, 6]; let frame = [x, y, 10, 6];
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?; Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
to.blit(&"Start: ", x + 1, y + 1, STYLE_LABEL); to.blit(&"Start: ", x + 1, y + 1, Some(STYLE_LABEL));
to.blit(&" 1.1.1", x + 1, y + 2, STYLE_VALUE); to.blit(&" 1.1.1", x + 1, y + 2, Some(STYLE_VALUE));
to.blit(&"End: ", x + 1, y + 3, STYLE_LABEL); to.blit(&"End: ", x + 1, y + 3, Some(STYLE_LABEL));
to.blit(&" 2.1.1", x + 1, y + 4, STYLE_VALUE); to.blit(&" 2.1.1", x + 1, y + 4, Some(STYLE_VALUE));
Ok(()) Ok(())
} }
} }
@ -2118,11 +2077,11 @@ impl Widget for SequenceLoopRange {
let [x, y, ..] = to.area(); let [x, y, ..] = to.area();
let range = [x, y, 10, 7]; let range = [x, y, 10, 7];
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?; Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
to.blit(&"Loop [ ]", x + 1, y + 1, STYLE_LABEL); to.blit(&"Loop [ ]", x + 1, y + 1, Some(STYLE_LABEL));
to.blit(&"From: ", x + 1, y + 2, STYLE_LABEL); to.blit(&"From: ", x + 1, y + 2, Some(STYLE_LABEL));
to.blit(&" 1.1.1", x + 1, y + 3, STYLE_VALUE); to.blit(&" 1.1.1", x + 1, y + 3, Some(STYLE_VALUE));
to.blit(&"Length: ", x + 1, y + 4, STYLE_LABEL); to.blit(&"Length: ", x + 1, y + 4, Some(STYLE_LABEL));
to.blit(&" 1.0.0", x + 1, y + 5, STYLE_VALUE); to.blit(&" 1.0.0", x + 1, y + 5, Some(STYLE_VALUE));
Ok(()) Ok(())
} }
} }
@ -2140,13 +2099,13 @@ impl Widget for SequenceNoteRange {
let [x, y, ..] = to.area(); let [x, y, ..] = to.area();
let range = [x, y, 10, 9]; let range = [x, y, 10, 9];
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?; Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
to.blit(&"Notes: ", x + 1, y + 1, STYLE_LABEL); to.blit(&"Notes: ", x + 1, y + 1, Some(STYLE_LABEL));
to.blit(&"C#0-C#9 ", x + 1, y + 2, STYLE_VALUE); to.blit(&"C#0-C#9 ", x + 1, y + 2, Some(STYLE_VALUE));
to.blit(&"[ /2 ]", x + 1, y + 3, STYLE_LABEL); to.blit(&"[ /2 ]", x + 1, y + 3, Some(STYLE_LABEL));
to.blit(&"[ x2 ]", x + 1, y + 4, STYLE_LABEL); to.blit(&"[ x2 ]", x + 1, y + 4, Some(STYLE_LABEL));
to.blit(&"[ Rev ]", x + 1, y + 5, STYLE_LABEL); to.blit(&"[ Rev ]", x + 1, y + 5, Some(STYLE_LABEL));
to.blit(&"[ Inv ]", x + 1, y + 6, STYLE_LABEL); to.blit(&"[ Inv ]", x + 1, y + 6, Some(STYLE_LABEL));
to.blit(&"[ Dup ]", x + 1, y + 7, STYLE_LABEL); to.blit(&"[ Dup ]", x + 1, y + 7, Some(STYLE_LABEL));
Ok(()) Ok(())
} }
} }