mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
almost correctly working phrase list
This commit is contained in:
parent
3c14456566
commit
77091671a3
2 changed files with 41 additions and 26 deletions
|
|
@ -38,5 +38,16 @@ pub(crate) use std::marker::PhantomData;
|
|||
assert_eq!(Align::sw(four()).layout(area), [10, 26, 4, 4]);
|
||||
assert_eq!(Align::w(four()).layout(area), [10, 18, 4, 4]);
|
||||
|
||||
let two_by_four = ||Fixed::<Tui, _>::xy(4, 2, unit);
|
||||
|
||||
assert_eq!(Align::nw(two_by_four()).layout(area), [10, 10, 4, 2]);
|
||||
assert_eq!(Align::n(two_by_four()).layout(area), [18, 10, 4, 2]);
|
||||
assert_eq!(Align::ne(two_by_four()).layout(area), [26, 10, 4, 2]);
|
||||
assert_eq!(Align::e(two_by_four()).layout(area), [26, 19, 4, 2]);
|
||||
assert_eq!(Align::se(two_by_four()).layout(area), [26, 28, 4, 2]);
|
||||
assert_eq!(Align::s(two_by_four()).layout(area), [18, 28, 4, 2]);
|
||||
assert_eq!(Align::sw(two_by_four()).layout(area), [10, 28, 4, 2]);
|
||||
assert_eq!(Align::w(two_by_four()).layout(area), [10, 19, 4, 2]);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
56
src/pool.rs
56
src/pool.rs
|
|
@ -208,27 +208,24 @@ impl PoolModel {
|
|||
pub struct PoolView<'a>(pub(crate) &'a PoolModel);
|
||||
// TODO: Display phrases always in order of appearance
|
||||
render!(Tui: (self: PoolView<'a>) => {
|
||||
//let content = "...";
|
||||
//let content = Tui::map(||["abc", "def", "ghi"].iter(), |item, index|Push::y(index as u16, item));
|
||||
let PoolModel { phrases, mode, .. } = self.0;
|
||||
//let bg = TuiTheme::g(32);
|
||||
//let title_color = TuiTheme::ti1();
|
||||
//let upper_left = "Pool:";
|
||||
//let upper_right = format!("({})", phrases.len());
|
||||
//let color = self.0.phrase().read().unwrap().color;
|
||||
////let with_files = |x|Tui::either(self.0.file_picker().is_some(),
|
||||
////Thunk::new(||self.0.file_picker().unwrap()),
|
||||
////Thunk::new(x));
|
||||
let content = Tui::map(||phrases.iter(), |clip, i|{
|
||||
let color = self.0.phrase().read().unwrap().color;
|
||||
let content = Tui::bg(Color::Black, Tui::map(||self.0.phrases().iter(), |clip, i|{
|
||||
let MidiClip { ref name, color, length, .. } = *clip.read().unwrap();
|
||||
//let mut length = PhraseLength::new(length, None);
|
||||
//if let Some(PoolMode::Length(clip, new_length, focus)) = self.0.mode {
|
||||
//if i == clip {
|
||||
//length.pulses = new_length;
|
||||
//length.focus = Some(focus);
|
||||
//}
|
||||
//}
|
||||
Push::y(i as u16, format!(" {i} {name} {length} "))/*
|
||||
let item_height = 1;
|
||||
let item_offset = i as u16 * item_height;
|
||||
let selected = i == self.0.phrase_index();
|
||||
let offset = |a|Push::y(item_offset, Align::n(Fixed::y(item_height, Fill::x(a))));
|
||||
offset(Tui::bg(if selected { color.light.rgb } else { color.base.rgb }, lay!(
|
||||
Align::w(Tui::fg(color.lightest.rgb, format!(" {i:>3} {name}"))),
|
||||
Align::e(Tui::fg(color.lightest.rgb, format!("{length} "))),
|
||||
Align::w(Tui::when(selected, Tui::bold(true, Tui::fg(color.lightest.rgb, "[")))),
|
||||
Align::e(Tui::when(selected, Tui::bold(true, Tui::fg(color.lightest.rgb, "]")))),
|
||||
//Tui::when(, Fixed::y(1, Tui::fg(Color::Green, lay!(
|
||||
//Align::w(format!("[")),
|
||||
//Align::e(format!("]")),
|
||||
//))))
|
||||
)))/*
|
||||
//format!(" {i} {name} {length} ")[>
|
||||
//Push::y(i as u16 * 2, Fixed::y(2, Tui::bg(color.base.rgb, Fill::x(
|
||||
//format!(" {i} {name} {length} ")))))[>,
|
||||
|
|
@ -247,13 +244,20 @@ render!(Tui: (self: PoolView<'a>) => {
|
|||
row2
|
||||
}),
|
||||
))))//lay!(clip, Tui::when(i == self.0.clip_index(), CORNERS)))*/
|
||||
});
|
||||
Tui::bg(Color::Red, content)
|
||||
//let border = Outer(Style::default().fg(color.base.rgb).bg(color.dark.rgb));
|
||||
//let enclose = |x|lay!(
|
||||
//Fill::xy(border),
|
||||
//Padding::xy(0, 1, Tui::bg(bg, x))
|
||||
//);
|
||||
}));
|
||||
let border = Outer(Style::default().fg(color.base.rgb).bg(color.darker.rgb));
|
||||
let enclose = |x|lay!(Fill::xy(border), Tui::bg(color.darkest.rgb, x));
|
||||
////let with_files = |x|Tui::either(self.0.file_picker().is_some(),
|
||||
////Thunk::new(||self.0.file_picker().unwrap()),
|
||||
////Thunk::new(x));
|
||||
//let mut length = PhraseLength::new(length, None);
|
||||
//if let Some(PoolMode::Length(clip, new_length, focus)) = self.0.mode {
|
||||
//if i == clip {
|
||||
//length.pulses = new_length;
|
||||
//length.focus = Some(focus);
|
||||
//}
|
||||
//}
|
||||
enclose(content)
|
||||
//enclose(lay!(
|
||||
////add(&Lozenge(Style::default().bg(border_bg).fg(border_color)))?;
|
||||
//Fill::xy(content),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue