naked mode

This commit is contained in:
🪞👃🪞 2024-12-10 15:55:25 +01:00
parent 74a07d0e75
commit 0bd8df1e57
6 changed files with 101 additions and 93 deletions

View file

@ -3,6 +3,7 @@ use crate::*;
mod engine_focus; pub(crate) use engine_focus::*; mod engine_focus; pub(crate) use engine_focus::*;
mod engine_input; pub(crate) use engine_input::*; mod engine_input; pub(crate) use engine_input::*;
mod engine_style; pub(crate) use engine_style::*; mod engine_style; pub(crate) use engine_style::*;
mod engine_theme; pub(crate) use engine_theme::*;
mod engine_output; pub(crate) use engine_output::*; mod engine_output; pub(crate) use engine_output::*;
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////

View file

@ -116,35 +116,33 @@ render!(|self: TransportField<'a>|{
}); });
render!(|self: TransportView|{ render!(|self: TransportView|{
let bg = TuiTheme::border_bg(); let border_style = Style::default()
let border_style = Style::default().bg(bg).fg(TuiTheme::border_fg(false)); .bg(TuiTheme::bg())
.fg(TuiTheme::border_fg(true));
lay!(move|add|{ lay!(move|add|{
if self.focused { if self.focused {
add(&Tui::fill_x(Lozenge(border_style)))?; add(&Tui::fill_x(Lozenge(border_style)))?;
} }
add(&Tui::outset_x(1, row!([ add(&Tui::outset_x(2, row!([
col!(|add|{
if self.started {
add(&col!([Tui::fg(Color::Rgb(0, 255, 0), "▶ PLAYING "), ""]))
} else {
add(&col!(["", Tui::fg(Color::Rgb(255, 128, 0), "⏹ STOPPED ")]))
}
}),
" ",
row!([ row!([
TransportField("SR ", self.sr.as_str()), TransportField("Beat", "00X+0/0B+00/00P"),
" ", " ",
TransportField("BPM ", self.bpm.as_str()), TransportField("BPM ", self.bpm.as_str()),
" ", " ",
TransportField("PPQ ", self.ppq.as_str()),
]),
lay!(|add|{
if self.started {
add(&row!([
col!(["", Tui::fg(Color::Rgb(0, 255, 0), "▶ PLAYING ")]),
" ",
TransportField("Beat", "00X+0/0B+00/00P"),
" ",
TransportField("Second", self.current_second.as_str()), TransportField("Second", self.current_second.as_str()),
" ", " ",
TransportField("SR ", self.sr.as_str()),
" ",
TransportField("Sample", self.current_sample.as_str()), TransportField("Sample", self.current_sample.as_str()),
])) ]),
} else {
add(&col!([Tui::fg(Color::Rgb(255, 128, 0), "⏹ STOPPED "), ""]))
}
}),
]))) ])))
}) })
}); });

View file

@ -83,35 +83,6 @@ impl<S: BorderStyle> Render<Tui> for Border<S> {
} }
} }
pub struct TuiTheme;
impl TuiTheme {
pub fn border_bg () -> Color {
Color::Rgb(40, 50, 30)
}
pub fn border_fg (focused: bool) -> Color {
if focused { Color::Rgb(100, 110, 40) } else { Color::Rgb(70, 80, 50) }
}
pub fn title_fg (focused: bool) -> Color {
if focused { Color::Rgb(150, 160, 90) } else { Color::Rgb(120, 130, 100) }
}
pub fn separator_fg (_: bool) -> Color {
Color::Rgb(0, 0, 0)
}
pub const fn hotkey_fg () -> Color {
Color::Rgb(255, 255, 0)
}
pub fn mode_bg () -> Color {
Color::Rgb(150, 160, 90)
}
pub fn mode_fg () -> Color {
Color::Rgb(255, 255, 255)
}
pub fn status_bar_bg () -> Color {
Color::Rgb(28, 35, 25)
}
}
pub struct Styled<T: Render<Tui>>(pub Option<Style>, pub T); pub struct Styled<T: Render<Tui>>(pub Option<Style>, pub T);
impl Render<Tui> for Styled<&str> { impl Render<Tui> for Styled<&str> {

View file

@ -0,0 +1,33 @@
use crate::*;
pub struct TuiTheme;
impl TuiTheme {
pub fn bg () -> Color {
Color::Rgb(28, 35, 25)
}
pub fn border_bg () -> Color {
Color::Rgb(40, 50, 30)
}
pub fn border_fg (focused: bool) -> Color {
if focused { Color::Rgb(100, 110, 40) } else { Color::Rgb(70, 80, 50) }
}
pub fn title_fg (focused: bool) -> Color {
if focused { Color::Rgb(150, 160, 90) } else { Color::Rgb(120, 130, 100) }
}
pub fn separator_fg (_: bool) -> Color {
Color::Rgb(0, 0, 0)
}
pub const fn hotkey_fg () -> Color {
Color::Rgb(255, 255, 0)
}
pub fn mode_bg () -> Color {
Color::Rgb(150, 160, 90)
}
pub fn mode_fg () -> Color {
Color::Rgb(255, 255, 255)
}
pub fn status_bar_bg () -> Color {
Color::Rgb(28, 35, 25)
}
}

View file

@ -126,9 +126,11 @@ render!(|self: PhraseListView<'a>|{
let title_color = if *focused {Color::Rgb(150, 160, 90)} else {Color::Rgb(120, 130, 100)}; let title_color = if *focused {Color::Rgb(150, 160, 90)} else {Color::Rgb(120, 130, 100)};
let upper_left = format!("[{}] {title}", if *entered {""} else {" "}); let upper_left = format!("[{}] {title}", if *entered {""} else {" "});
let upper_right = format!("({})", phrases.len()); let upper_right = format!("({})", phrases.len());
lay!([ lay!(move|add|{
Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color)) if *focused {
.wrap(Tui::bg(Color::Rgb(28, 35, 25), Tui::fill_xy(col!(move|add|match mode { add(&Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color)))?;
}
add(&Tui::inset_xy(1, 1, Tui::fill_xy(col!(move|add|match mode {
Some(PhrasesMode::Import(_, ref browser)) => { Some(PhrasesMode::Import(_, ref browser)) => {
add(browser) add(browser)
}, },
@ -164,10 +166,10 @@ render!(|self: PhraseListView<'a>|{
} }
Ok(()) Ok(())
} }
})))), }))))?;
Tui::fill_xy(Tui::at_nw(Tui::push_x(1, Tui::fg(title_color, upper_left.to_string())))), add(&Tui::fill_xy(Tui::at_nw(Tui::push_x(1, Tui::fg(title_color, upper_left.to_string())))))?;
Tui::fill_xy(Tui::at_ne(Tui::pull_x(1, Tui::fg(title_color, upper_right.to_string())))), add(&Tui::fill_xy(Tui::at_ne(Tui::pull_x(1, Tui::fg(title_color, upper_right.to_string())))))
]) })
}); });
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, PartialEq, Debug)]

View file

@ -40,8 +40,11 @@ render!(|self: PhraseSelector<'a>|{
let border_color = if *focused {Color::Rgb(100, 110, 40)} else {Color::Rgb(70, 80, 50)}; let border_color = if *focused {Color::Rgb(100, 110, 40)} else {Color::Rgb(70, 80, 50)};
let border = Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color)); let border = Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color));
let title_color = if *focused {Color::Rgb(150, 160, 90)} else {Color::Rgb(120, 130, 100)}; let title_color = if *focused {Color::Rgb(150, 160, 90)} else {Color::Rgb(120, 130, 100)};
Tui::fixed_y(4, lay!([ Tui::fixed_y(3, lay!(move|add|{
border.wrap(Tui::bg(Color::Rgb(28, 35, 25), Tui::fill_xy(Layers::new(move|add|{ if *focused {
add(&Tui::fill_x(border))?;
}
add(&Tui::fill_xy(Layers::new(move|add|{
if let Some((instant, Some(phrase))) = phrase { if let Some((instant, Some(phrase))) = phrase {
let Phrase { ref name, color, length, .. } = *phrase.read().unwrap(); let Phrase { ref name, color, length, .. } = *phrase.read().unwrap();
let length = PhraseLength::new(length, None); let length = PhraseLength::new(length, None);
@ -52,7 +55,7 @@ render!(|self: PhraseSelector<'a>|{
add(&Tui::bg(color.base.rgb, Tui::fill_x(col!([row1, row2]))))?; add(&Tui::bg(color.base.rgb, Tui::fill_x(col!([row1, row2]))))?;
} }
Ok(()) Ok(())
})))), })))?;
Tui::fill_xy(Tui::at_nw(Tui::push_x(1, Tui::fg(title_color, *title)))), add(&Tui::fill_xy(Tui::at_nw(Tui::push_x(1, Tui::fg(title_color, *title)))))
])) }))
}); });