convert to layout suffixes

This commit is contained in:
i do not exist 2026-07-07 16:35:52 +03:00
parent 2d64f63741
commit d8a767326c
6 changed files with 245 additions and 230 deletions

View file

@ -241,7 +241,7 @@ impl<'a> PoolView<'a> {
//let on_bg = |x|x;//below(Repeat(" "), bg(color.darkest.term, x));
//let border = |x|x;//Outer(Style::default().fg(color.dark.term).bg(color.darkest.term)).enclose(x);
//let height = pool.clips.read().unwrap().len() as u16;
w_exact(20, h_full(origin_n(iter(
origin_n(iter(
||pool.clips().clone().into_iter(),
move|clip: Arc<RwLock<MidiClip>>, i: usize|{
let MidiClip { ref name, color, length, .. } = *clip.read().unwrap();
@ -252,13 +252,13 @@ impl<'a> PoolView<'a> {
let f = color.lightest.term;
let name = if false { format!(" {i:>3}") } else { format!(" {i:>3} {name}") };
let length = if false { String::default() } else { format!("{length} ") };
h_exact(1, bg(b, below!(
w_full(origin_w(fg(f, bold(selected, name)))),
w_full(origin_e(fg(f, bold(selected, length)))),
w_full(origin_w(when(selected, bold(true, fg(g(255), ""))))),
w_full(origin_e(when(selected, bold(true, fg(g(255), ""))))),
)))
}))))
bg(b, below!(
origin_w(fg(f, bold(selected, name))).full_w(),
origin_e(fg(f, bold(selected, length))).full_w(),
origin_w(when(selected, bold(true, fg(g(255), "")))).full_w(),
origin_e(when(selected, bold(true, fg(g(255), "")))).full_w(),
)).exact_h(1)
})).full_h().exact_w(20)
}
}
@ -315,7 +315,7 @@ impl Browse {
impl Browse {
fn tui (&self) -> impl Draw<Tui> {
let item = |entry, _index|w_full(origin_w(entry));
let item = |entry, _index|origin_w(entry).full_w();
let iterate = ||EntriesIterator {
offset: 0,
index: 0,

View file

@ -98,17 +98,14 @@ impl MidiEditor {
let (_color, name, length, looped) = if let Some(clip) = self.clip().as_ref().map(|p|p.read().unwrap()) {
(clip.color, clip.name.clone(), clip.length, clip.looped)
} else { (ItemTheme::G[64], String::new().into(), 0, false) };
w_exact(20, south!(
w_full(origin_w(east(
button_2("f2", "name ", false),
w_full(origin_e(fg(Rgb(255, 255, 255), format!("{name} "))))))),
w_full(origin_w(east(
button_2("l", "ength ", false),
w_full(origin_e(fg(Rgb(255, 255, 255), format!("{length} "))))))),
w_full(origin_w(east(
button_2("r", "epeat ", false),
w_full(origin_e(fg(Rgb(255, 255, 255), format!("{looped} "))))))),
))
south!(
origin_w(east(button_2("f2", "name ", false),
origin_e(fg(Rgb(255, 255, 255), format!("{name} "))).full_w())).full_w(),
origin_w(east(button_2("l", "ength ", false),
origin_e(fg(Rgb(255, 255, 255), format!("{length} "))).full_w())).full_w(),
origin_w(east(button_2("r", "epeat ", false),
origin_e(fg(Rgb(255, 255, 255), format!("{looped} "))).full_w())).full_w(),
).exact_w(20)
}
pub fn edit_status (&self) -> impl Draw<Tui> + '_ {
let (_color, length) = if let Some(clip) = self.clip().as_ref().map(|p|p.read().unwrap()) {
@ -121,20 +118,17 @@ impl MidiEditor {
let note_name = format!("{:4}", note_pitch_to_name(note_pos));
let note_pos = format!("{:>3}", note_pos);
let note_len = format!("{:>4}", self.get_note_len());
w_exact(20, south!(
w_full(origin_w(east(
button_2("t", "ime ", false),
w_full(origin_e(fg(Rgb(255, 255, 255),
format!("{length} /{time_zoom} +{time_pos} "))))))),
w_full(origin_w(east(
button_2("z", "lock ", false),
w_full(origin_e(fg(Rgb(255, 255, 255),
format!("{time_lock}"))))))),
w_full(origin_w(east(
button_2("x", "note ", false),
w_full(origin_e(fg(Rgb(255, 255, 255),
format!("{note_name} {note_pos} {note_len}"))))))),
))
south!(
origin_w(east(button_2("t", "ime ", false),
origin_e(fg(Rgb(255, 255, 255),
format!("{length} /{time_zoom} +{time_pos} "))).full_w())).full_w(),
origin_w(east(button_2("z", "lock ", false),
origin_e(fg(Rgb(255, 255, 255),
format!("{time_lock}"))).full_w())).full_w(),
origin_w(east(button_2("x", "note ", false),
origin_e(fg(Rgb(255, 255, 255),
format!("{note_name} {note_pos} {note_len}"))).full_w())).full_w(),
).exact_w(20)
}
}

View file

@ -27,8 +27,14 @@ impl_has!(Sizer: |self: PianoHorizontal| self.size);
impl View<Tui> for PianoHorizontal {
fn view (&self) -> impl Draw<Tui> {
south(
east(w_exact(5, format!("{}x{}", self.size.w(), self.size.h())), self.timeline()),
east(self.keys(), self.size.of(below(wh_full(self.notes()), wh_full(self.cursor())))),
east(
format!("{}x{}", self.size.w(), self.size.h()).exact_w(5),
self.timeline()
),
east(
self.keys(),
self.size.of(below(self.notes().full_wh(), self.cursor().full_wh()))
),
)
}
}
@ -203,7 +209,7 @@ impl PianoHorizontal {
let key_style = Some(Style::default().fg(Rgb(192, 192, 192)).bg(Rgb(0, 0, 0)));
let off_style = Some(Style::default().fg(g(255)));
let on_style = Some(Style::default().fg(Rgb(255,0,0)).bg(color.base.term).bold());
h_full(w_exact(self.keys_width, thunk(move|to: &mut Tui|{
thunk(move|to: &mut Tui|{
let xywh = to.area().into();
let XYWH(x, y0, _w, _h) = xywh;
for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
@ -218,11 +224,11 @@ impl PianoHorizontal {
};
}
Ok(Some(xywh))
})))
}).exact_w(self.keys_width).full_h()
}
fn timeline (&self) -> impl Draw<Tui> + '_ {
w_full(h_exact(1, thunk(move|to: &mut Tui|{
thunk(move|to: &mut Tui|{
let xywh = to.area().into();
let XYWH(x, y, w, _h) = xywh;
let style = Some(Style::default().dim());
@ -234,7 +240,7 @@ impl PianoHorizontal {
}
}
Ok(Some(xywh))
})))
}).exact_h(1).full_w()
}
}

View file

@ -40,9 +40,9 @@ impl_draw!(|self: Log10Meter, to: Tui| {
});
fn draw_meters (meters: &[f32]) -> impl Draw<Tui> + use<'_> {
bg(Black, w_exact(2, iter_east_fixed(1, ||meters.iter(), |value, _index|{
h_full(RmsMeter(*value))
})))
bg(Black, iter_east_fixed(1, ||meters.iter(), |value, _index|{
RmsMeter(*value).full_h()
}).exact_w(2))
}
pub fn to_log10 (samples: &[f32]) -> f32 {