mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
remove Bar trait; update PhraseEditStatus
This commit is contained in:
parent
32c9654a0c
commit
d042285c80
3 changed files with 46 additions and 90 deletions
|
|
@ -216,6 +216,18 @@ input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|{
|
||||||
Selected::Scene(s) => return None,
|
Selected::Scene(s) => return None,
|
||||||
Selected::Clip(t, s) => return None,
|
Selected::Clip(t, s) => return None,
|
||||||
},
|
},
|
||||||
|
key_pat!(Char('g')) => match state.selected() {
|
||||||
|
Selected::Mix => return None,
|
||||||
|
Selected::Track(t) => return None,
|
||||||
|
Selected::Scene(s) => return None,
|
||||||
|
Selected::Clip(t, s) => return None,
|
||||||
|
},
|
||||||
|
key_pat!(Char('p')) => match state.selected() {
|
||||||
|
Selected::Mix => return None,
|
||||||
|
Selected::Track(t) => return None,
|
||||||
|
Selected::Scene(s) => return None,
|
||||||
|
Selected::Clip(t, s) => return None,
|
||||||
|
},
|
||||||
// Tab: Toggle visibility of phrase pool column
|
// Tab: Toggle visibility of phrase pool column
|
||||||
key_pat!(Tab) =>
|
key_pat!(Tab) =>
|
||||||
ShowPool(!state.show_pool),
|
ShowPool(!state.show_pool),
|
||||||
|
|
|
||||||
|
|
@ -223,48 +223,3 @@ impl std::fmt::Debug for PhraseEditorModel {
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PhraseEditStatus<'a>(pub &'a PhraseEditorModel);
|
|
||||||
render!(<Tui>|self:PhraseEditStatus<'a>|row!(|add|{
|
|
||||||
let (color, name, length, looped) = if let Some(phrase) = self.0.phrase().as_ref().map(|p|p.read().unwrap()) {
|
|
||||||
(phrase.color, phrase.name.clone(), phrase.length, phrase.looped)
|
|
||||||
} else {
|
|
||||||
(ItemPalette::from(TuiTheme::g(64)), String::new(), 0, false)
|
|
||||||
};
|
|
||||||
let bg = color.base.rgb;
|
|
||||||
let fg = color.lightest.rgb;
|
|
||||||
let field = move|x, y|row!([
|
|
||||||
Tui::fg_bg(color.lightest.rgb, Color::Reset, Tui::bold(true, x)),
|
|
||||||
Tui::fg_bg(color.lighter.rgb, Color::Reset, Tui::bold(true, "│")),
|
|
||||||
&y
|
|
||||||
]);
|
|
||||||
add(&Fill::w(Tui::fg_bg(fg, bg, row!(|add|{
|
|
||||||
add(&Fixed::wh(26, 3, col!(![
|
|
||||||
field(" Edit", format!("{name}")),
|
|
||||||
field(" Length", format!("{length}")),
|
|
||||||
field(" Loop", format!("{looped}")),
|
|
||||||
])))?;
|
|
||||||
add(&Fixed::wh(25, 3, col!(![
|
|
||||||
field(" Time", format!("{}",
|
|
||||||
self.0.time_point())),
|
|
||||||
field(" View", format!("{}-{} ({}*{})",
|
|
||||||
self.0.time_start().get(),
|
|
||||||
self.0.time_end(),
|
|
||||||
self.0.time_axis().get(),
|
|
||||||
self.0.time_zoom().get()))
|
|
||||||
])))?;
|
|
||||||
add(&Fixed::wh(25, 3, col!(![
|
|
||||||
field(" Note", format!("{:4} ({:3}) {:4}",
|
|
||||||
to_note_name(self.0.note_point()),
|
|
||||||
self.0.note_point(),
|
|
||||||
self.0.note_len())),
|
|
||||||
field(" View", format!("{}-{} ({})",
|
|
||||||
to_note_name(self.0.note_lo().get()),
|
|
||||||
to_note_name(self.0.note_hi()),
|
|
||||||
self.0.note_axis().get()))
|
|
||||||
])))?;
|
|
||||||
add(&Fixed::wh(16, 3, col!(![
|
|
||||||
row!(!["TimeLock ", Tui::bold(true, format!("{}", self.0.time_lock().get()))])])))?;
|
|
||||||
Ok(())
|
|
||||||
}))))
|
|
||||||
}));
|
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,33 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
pub trait Bar: Render<Tui> {
|
pub struct PhraseEditStatus<'a>(pub &'a PhraseEditorModel);
|
||||||
type State: Send + Sync;
|
render!(<Tui>|self:PhraseEditStatus<'a>|{
|
||||||
fn hotkey_fg () -> Color where Self: Sized;
|
let (color, name, length, looped) = if let Some(phrase) = self.0.phrase().as_ref().map(|p|p.read().unwrap()) {
|
||||||
fn update (&mut self, state: &Self::State) where Self: Sized;
|
(phrase.color, phrase.name.clone(), phrase.length, phrase.looped)
|
||||||
fn command (commands: &[[impl Render<Tui>;3]])
|
} else {
|
||||||
-> impl Render<Tui> + '_
|
(ItemPalette::from(TuiTheme::g(64)), String::new(), 0, false)
|
||||||
where
|
};
|
||||||
Self: Sized
|
let bg = color.darkest.rgb;
|
||||||
{
|
let fg = color.lightest.rgb;
|
||||||
let hotkey_fg = Self::hotkey_fg();
|
let field = move|x, y|row!([
|
||||||
row!([a, b, c] in commands.iter() => {
|
Tui::fg_bg(color.lighter.rgb, color.darker.rgb, Tui::bold(true, x)),
|
||||||
row!([a, Tui::fg(hotkey_fg, Tui::bold(true, b)), c])
|
Tui::fg_bg(color.light.rgb, color.darker.rgb, Tui::bold(true, "│")),
|
||||||
})
|
Fill::w(Tui::fg_bg(color.lightest.rgb, color.dark.rgb, &y)),
|
||||||
}
|
]);
|
||||||
|
Fill::w(Tui::fg_bg(fg, bg, row!([
|
||||||
fn with <'a> (state: &'a Self::State, content: impl Render<Tui>) -> impl Render<Tui>
|
Fixed::wh(26, 3, col!(![
|
||||||
where Self: Sized, &'a Self::State: Into<Self>
|
field(" Edit", format!("{name}")),
|
||||||
{
|
field(" Length", format!("{length}")),
|
||||||
Bsp::n(state.into(), content)
|
field(" Loop", format!("{looped}"))])),
|
||||||
}
|
Fixed::wh(30, 3, col!(![
|
||||||
}
|
field(" Time", format!("{}/{}-{} ({}*{}) {}",
|
||||||
|
self.0.time_point(), self.0.time_start().get(), self.0.time_end(),
|
||||||
|
self.0.time_axis().get(), self.0.time_zoom().get(),
|
||||||
|
if self.0.time_lock().get() { "[lock]" } else { " " })),
|
||||||
|
field(" Note", format!("{} ({}) {} | {}-{} ({})",
|
||||||
|
to_note_name(self.0.note_point()), self.0.note_point(), self.0.note_len(),
|
||||||
|
to_note_name(self.0.note_lo().get()), to_note_name(self.0.note_hi()),
|
||||||
|
self.0.note_axis().get()))]))])))});
|
||||||
|
|
||||||
/// Status bar for sequencer app
|
/// Status bar for sequencer app
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
@ -60,27 +67,18 @@ impl SequencerStatus {
|
||||||
]);
|
]);
|
||||||
Tui::fg_bg(TuiTheme::g(255), TuiTheme::g(50), row!([
|
Tui::fg_bg(TuiTheme::g(255), TuiTheme::g(50), row!([
|
||||||
single("SPACE", "play/pause"),
|
single("SPACE", "play/pause"),
|
||||||
double(("▲▼▶◀", "cursor"), ("C-✣", "scroll"), ),
|
double(("▲▼▶◀", "cursor"), ("Ctrl", "scroll"), ),
|
||||||
double(("a", "append"), ("s", "set note"),),
|
double(("a", "append"), ("s", "set note"),),
|
||||||
double((",.", "length"), ("<>", "triplet"), ),
|
double((",.", "length"), ("<>", "triplet"), ),
|
||||||
double(("[]", "phrase"), ("{}", "order"), ),
|
double(("[]", "phrase"), ("{}", "order"), ),
|
||||||
double(("q", "enqueue"), ("e", "edit"), ),
|
double(("q", "enqueue"), ("e", "edit"), ),
|
||||||
double(("c", "color"), ("", ""),),
|
double(("c", "color"), ("", ""),),
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
fn stats <'a> (&'a self) -> impl Render<Tui> + use<'a> {
|
fn stats <'a> (&'a self) -> impl Render<Tui> + use<'a> {
|
||||||
row!([&self.cpu, &self.res, &self.size])
|
row!([&self.cpu, &self.res, &self.size])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Bar for SequencerStatus {
|
|
||||||
type State = SequencerTui;
|
|
||||||
fn hotkey_fg () -> Color {
|
|
||||||
TuiTheme::HOTKEY_FG
|
|
||||||
}
|
|
||||||
fn update (&mut self, _: &SequencerTui) {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Status bar for arranger app
|
/// Status bar for arranger app
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
@ -133,12 +131,3 @@ impl ArrangerStatus {
|
||||||
row!([&self.cpu, &self.res, &self.size])
|
row!([&self.cpu, &self.res, &self.size])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Bar for ArrangerStatus {
|
|
||||||
type State = ArrangerTui;
|
|
||||||
fn hotkey_fg () -> Color {
|
|
||||||
TuiTheme::HOTKEY_FG
|
|
||||||
}
|
|
||||||
fn update (&mut self, _: &ArrangerTui) {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue