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::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
|
||||
key_pat!(Tab) =>
|
||||
ShowPool(!state.show_pool),
|
||||
|
|
|
|||
|
|
@ -223,48 +223,3 @@ impl std::fmt::Debug for PhraseEditorModel {
|
|||
.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::*;
|
||||
|
||||
pub trait Bar: Render<Tui> {
|
||||
type State: Send + Sync;
|
||||
fn hotkey_fg () -> Color where Self: Sized;
|
||||
fn update (&mut self, state: &Self::State) where Self: Sized;
|
||||
fn command (commands: &[[impl Render<Tui>;3]])
|
||||
-> impl Render<Tui> + '_
|
||||
where
|
||||
Self: Sized
|
||||
{
|
||||
let hotkey_fg = Self::hotkey_fg();
|
||||
row!([a, b, c] in commands.iter() => {
|
||||
row!([a, Tui::fg(hotkey_fg, Tui::bold(true, b)), c])
|
||||
})
|
||||
}
|
||||
|
||||
fn with <'a> (state: &'a Self::State, content: impl Render<Tui>) -> impl Render<Tui>
|
||||
where Self: Sized, &'a Self::State: Into<Self>
|
||||
{
|
||||
Bsp::n(state.into(), content)
|
||||
}
|
||||
}
|
||||
pub struct PhraseEditStatus<'a>(pub &'a PhraseEditorModel);
|
||||
render!(<Tui>|self:PhraseEditStatus<'a>|{
|
||||
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.darkest.rgb;
|
||||
let fg = color.lightest.rgb;
|
||||
let field = move|x, y|row!([
|
||||
Tui::fg_bg(color.lighter.rgb, color.darker.rgb, Tui::bold(true, x)),
|
||||
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!([
|
||||
Fixed::wh(26, 3, col!(![
|
||||
field(" Edit", format!("{name}")),
|
||||
field(" Length", format!("{length}")),
|
||||
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
|
||||
#[derive(Clone)]
|
||||
|
|
@ -60,7 +67,7 @@ impl SequencerStatus {
|
|||
]);
|
||||
Tui::fg_bg(TuiTheme::g(255), TuiTheme::g(50), row!([
|
||||
single("SPACE", "play/pause"),
|
||||
double(("▲▼▶◀", "cursor"), ("C-✣", "scroll"), ),
|
||||
double(("▲▼▶◀", "cursor"), ("Ctrl", "scroll"), ),
|
||||
double(("a", "append"), ("s", "set note"),),
|
||||
double((",.", "length"), ("<>", "triplet"), ),
|
||||
double(("[]", "phrase"), ("{}", "order"), ),
|
||||
|
|
@ -72,15 +79,6 @@ impl SequencerStatus {
|
|||
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
|
||||
#[derive(Clone)]
|
||||
|
|
@ -133,12 +131,3 @@ impl ArrangerStatus {
|
|||
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