add buttons
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-05-18 00:23:00 +03:00
parent 958e602577
commit baad8254a2
3 changed files with 55 additions and 16 deletions

View file

@ -13,24 +13,24 @@ impl Arrangement {
Bsp::w(Fixed::x(4, button_2("I", "+", false)), Bsp::w(Fixed::x(4, button_2("I", "+", false)),
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
for (index, track, x1, x2) in self.tracks_with_sizes() { for (index, track, x1, x2) in self.tracks_with_sizes() {
add(&Align::w(row!( add(&Tui::bg(track.color.dark.rgb, Align::w(Fixed::x(track.width as u16, row!(
Either(track.sequencer.monitoring, Tui::fg(Green, "mon "), "mon "), Either(track.sequencer.monitoring, Tui::fg(Green, "mon "), "mon "),
Either(track.sequencer.recording, Tui::fg(Red, "rec "), "rec "), Either(track.sequencer.recording, Tui::fg(Red, "rec "), "rec "),
Either(track.sequencer.overdub, Tui::fg(Yellow, "dub "), "dub "), Either(track.sequencer.overdub, Tui::fg(Yellow, "dub "), "dub "),
))) )))))
} }
}))))); })))));
for (index, port) in self.midi_ins().iter().enumerate() { for (index, port) in self.midi_ins().iter().enumerate() {
add(&Fixed::y(1, add(&Fixed::y(1, Bsp::e(
Bsp::e(Fixed::x(20, Align::w(format!(" ● i{index:02} {}", port.name()))), Fixed::x(20, Align::w(Bsp::e("", Tui::bold(true, Tui::fg(Rgb(255,255,255),port.name()))))),
Bsp::w(Fixed::x(4, ()), Bsp::w(Fixed::x(4, ()),
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
for (index, track, x1, x2) in self.tracks_with_sizes() { for (index, track, x1, x2) in self.tracks_with_sizes() {
add(&Align::w(row!( add(&Tui::bg(track.color.darker.rgb, Align::w(Fixed::x(track.width as u16, row!(
Either(track.sequencer.monitoring, Tui::fg(Green, ""), " · "), Either(track.sequencer.monitoring, Tui::fg(Green, ""), " · "),
Either(track.sequencer.recording, Tui::fg(Red, ""), " · "), Either(track.sequencer.recording, Tui::fg(Red, ""), " · "),
Either(track.sequencer.overdub, Tui::fg(Yellow, ""), " · "), Either(track.sequencer.overdub, Tui::fg(Yellow, ""), " · "),
))) )))))
} }
}))))); })))));
} }
@ -47,7 +47,7 @@ impl Arrangement {
Fixed::y(h - 1, Fill::xy(Align::nw(Stack::south(|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{ Fixed::y(h - 1, Fill::xy(Align::nw(Stack::south(|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
for (index, port) in self.midi_outs().iter().enumerate() { for (index, port) in self.midi_outs().iter().enumerate() {
add(&Fixed::y(1,Fill::x(Bsp::e( add(&Fixed::y(1,Fill::x(Bsp::e(
Align::w(Bsp::e(format!(" ● o{index:02} "), Tui::fg(Rgb(255,255,255),Tui::bold(true, port.name())))), Align::w(Bsp::e("", Tui::fg(Rgb(255,255,255),Tui::bold(true, port.name())))),
Fill::x(Align::e(format!("{}/{} ", Fill::x(Align::e(format!("{}/{} ",
port.port().get_connections().len(), port.port().get_connections().len(),
port.conn().len()))))))); port.conn().len())))))));

View file

@ -38,3 +38,42 @@ mod dialog; pub use self::dialog::*;
#[cfg(feature = "vst2")] mod vst2; #[cfg(feature = "vst2")] pub use self::vst2::*; #[cfg(feature = "vst2")] mod vst2; #[cfg(feature = "vst2")] pub use self::vst2::*;
#[cfg(feature = "vst3")] mod vst3; #[cfg(feature = "vst3")] pub use self::vst3::*; #[cfg(feature = "vst3")] mod vst3; #[cfg(feature = "vst3")] pub use self::vst3::*;
#[cfg(feature = "clap")] mod clap; #[cfg(feature = "clap")] pub use self::clap::*; #[cfg(feature = "clap")] mod clap; #[cfg(feature = "clap")] pub use self::clap::*;
pub fn button_2 <'a> (
key: impl Content<TuiOut> + 'a, label: impl Content<TuiOut> + 'a, editing: bool,
) -> impl Content<TuiOut> + 'a {
let key = Tui::fg_bg(Tui::orange(), Tui::g(0), Bsp::e(
Tui::fg(Tui::g(0), ""),
Bsp::e(key, Tui::fg(Tui::g(96), ""))
));
let label = When::new(!editing, Tui::fg_bg(Tui::g(255), Tui::g(96), label));
Tui::bold(true, Bsp::e(key, label))
}
pub fn button_3 <'a, K, L, V> (
key: K,
label: L,
value: V,
editing: bool,
) -> impl Content<TuiOut> + 'a where
K: Content<TuiOut> + 'a,
L: Content<TuiOut> + 'a,
V: Content<TuiOut> + 'a,
{
let key = Tui::fg_bg(Tui::orange(), Tui::g(0),
Bsp::e(Tui::fg(Tui::g(0), ""), Bsp::e(key, Tui::fg(if editing {
Tui::g(128)
} else {
Tui::g(96)
}, ""))));
let label = Bsp::e(
When::new(!editing, Bsp::e(
Tui::fg_bg(Tui::g(255), Tui::g(96), label),
Tui::fg_bg(Tui::g(128), Tui::g(96), ""),
)),
Bsp::e(
Tui::fg_bg(Tui::g(224), Tui::g(128), value),
Tui::fg_bg(Tui::g(128), Reset, ""),
));
Tui::bold(true, Bsp::e(key, label))
}

2
deps/tengri vendored

@ -1 +1 @@
Subproject commit 9a12e0c7bab24cb708d503e860d93677ae306961 Subproject commit 921378b6dbb38d4f301f688abd1cfef9bdc0f941