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_input; pub(crate) use engine_input::*;
mod engine_style; pub(crate) use engine_style::*;
mod engine_theme; pub(crate) use engine_theme::*;
mod engine_output; pub(crate) use engine_output::*;
////////////////////////////////////////////////////////

View file

@ -116,35 +116,33 @@ render!(|self: TransportField<'a>|{
});
render!(|self: TransportView|{
let bg = TuiTheme::border_bg();
let border_style = Style::default().bg(bg).fg(TuiTheme::border_fg(false));
let border_style = Style::default()
.bg(TuiTheme::bg())
.fg(TuiTheme::border_fg(true));
lay!(move|add|{
if self.focused {
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!([
TransportField("SR ", self.sr.as_str()),
TransportField("Beat", "00X+0/0B+00/00P"),
" ",
TransportField("BPM ", self.bpm.as_str()),
" ",
TransportField("PPQ ", self.ppq.as_str()),
TransportField("Second", self.current_second.as_str()),
" ",
TransportField("SR ", self.sr.as_str()),
" ",
TransportField("Sample", self.current_sample.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("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);
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,48 +126,50 @@ render!(|self: PhraseListView<'a>|{
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_right = format!("({})", phrases.len());
lay!([
Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color))
.wrap(Tui::bg(Color::Rgb(28, 35, 25), Tui::fill_xy(col!(move|add|match mode {
Some(PhrasesMode::Import(_, ref browser)) => {
add(browser)
},
Some(PhrasesMode::Export(_, ref browser)) => {
add(browser)
},
_ => {
for (i, phrase) in phrases.iter().enumerate() {
add(&lay!(|add|{
let Phrase { ref name, color, length, .. } = *phrase.read().unwrap();
let mut length = PhraseLength::new(length, None);
if let Some(PhrasesMode::Length(phrase, new_length, focus)) = mode {
if *focused && i == *phrase {
length.pulses = *new_length;
length.focus = Some(*focus);
}
lay!(move|add|{
if *focused {
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)) => {
add(browser)
},
Some(PhrasesMode::Export(_, ref browser)) => {
add(browser)
},
_ => {
for (i, phrase) in phrases.iter().enumerate() {
add(&lay!(|add|{
let Phrase { ref name, color, length, .. } = *phrase.read().unwrap();
let mut length = PhraseLength::new(length, None);
if let Some(PhrasesMode::Length(phrase, new_length, focus)) = mode {
if *focused && i == *phrase {
length.pulses = *new_length;
length.focus = Some(*focus);
}
let length = Tui::fill_x(Tui::at_e(length));
let row1 = Tui::fill_x(lay!([Tui::fill_x(Tui::at_w(format!(" {i}"))), length]));
let mut row2 = format!(" {name}");
if let Some(PhrasesMode::Rename(phrase, _)) = mode {
if *focused && i == *phrase {
row2 = format!("{row2}");
}
};
let row2 = Tui::bold(true, row2);
add(&Tui::bg(color.base.rgb, Tui::fill_x(col!([row1, row2]))))?;
if *entered && i == *index {
add(&CORNERS)?;
}
let length = Tui::fill_x(Tui::at_e(length));
let row1 = Tui::fill_x(lay!([Tui::fill_x(Tui::at_w(format!(" {i}"))), length]));
let mut row2 = format!(" {name}");
if let Some(PhrasesMode::Rename(phrase, _)) = mode {
if *focused && i == *phrase {
row2 = format!("{row2}");
}
Ok(())
}))?;
}
Ok(())
};
let row2 = Tui::bold(true, row2);
add(&Tui::bg(color.base.rgb, Tui::fill_x(col!([row1, row2]))))?;
if *entered && i == *index {
add(&CORNERS)?;
}
Ok(())
}))?;
}
})))),
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())))),
])
Ok(())
}
}))))?;
add(&Tui::fill_xy(Tui::at_nw(Tui::push_x(1, Tui::fg(title_color, upper_left.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)]

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 = 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)};
Tui::fixed_y(4, lay!([
border.wrap(Tui::bg(Color::Rgb(28, 35, 25), Tui::fill_xy(Layers::new(move|add|{
Tui::fixed_y(3, lay!(move|add|{
if *focused {
add(&Tui::fill_x(border))?;
}
add(&Tui::fill_xy(Layers::new(move|add|{
if let Some((instant, Some(phrase))) = phrase {
let Phrase { ref name, color, length, .. } = *phrase.read().unwrap();
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]))))?;
}
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)))))
}))
});