mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 12:46:42 +01:00
unified compact flag in groovebox
This commit is contained in:
parent
c9a79b1f29
commit
511ff91864
12 changed files with 129 additions and 188 deletions
27
src/pool/pool_tui.rs
Normal file
27
src/pool/pool_tui.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use crate::*;
|
||||
|
||||
pub struct PoolView<'a>(pub bool, pub &'a PoolModel);
|
||||
render!(Tui: (self: PoolView<'a>) => {
|
||||
let Self(compact, model) = self;
|
||||
let PoolModel { phrases, mode, .. } = self.1;
|
||||
let color = self.1.phrase().read().unwrap().color;
|
||||
Outer(
|
||||
Style::default().fg(color.dark.rgb).bg(color.darkest.rgb)
|
||||
).enclose(Tui::map(||model.phrases().iter(), |clip, i|{
|
||||
let item_height = 1;
|
||||
let item_offset = i as u16 * item_height;
|
||||
let selected = i == model.phrase_index();
|
||||
let offset = |a|Push::y(item_offset, Align::n(Fixed::y(item_height, Fill::x(a))));
|
||||
|
||||
let MidiClip { ref name, color, length, .. } = *clip.read().unwrap();
|
||||
let name = if *compact { format!(" {i:>3}") } else { format!(" {i:>3} {name}") };
|
||||
let length = if *compact { String::default() } else { format!("{length} ") };
|
||||
|
||||
offset(Tui::bg(if selected { color.light.rgb } else { color.base.rgb }, lay!(
|
||||
Align::w(Tui::fg(color.lightest.rgb, Tui::bold(selected, name))),
|
||||
Align::e(Tui::fg(color.lightest.rgb, Tui::bold(selected, length))),
|
||||
Align::w(Tui::when(selected, Tui::bold(true, Tui::fg(TuiTheme::g(255), "▶")))),
|
||||
Align::e(Tui::when(selected, Tui::bold(true, Tui::fg(TuiTheme::g(255), "◀")))),
|
||||
)))
|
||||
}))
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue