mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
wip: fixing Map, centering
This commit is contained in:
parent
059ff2ca79
commit
d17d20e7db
10 changed files with 104 additions and 78 deletions
85
src/pool.rs
85
src/pool.rs
|
|
@ -209,49 +209,54 @@ pub struct PoolView<'a>(pub(crate) &'a PoolModel);
|
|||
// TODO: Display phrases always in order of appearance
|
||||
render!(Tui: (self: PoolView<'a>) => {
|
||||
let PoolModel { phrases, mode, .. } = self.0;
|
||||
let bg = TuiTheme::g(32);
|
||||
let bg = TuiTheme::g(32);
|
||||
let title_color = TuiTheme::ti1();
|
||||
let upper_left = "Pool:";
|
||||
let upper_left = "Pool:";
|
||||
let upper_right = format!("({})", phrases.len());
|
||||
let color = self.0.phrase().read().unwrap().color;
|
||||
let border = Fill::xy(Outer(Style::default().fg(color.base.rgb).bg(bg)));
|
||||
let enclose = |x|lay!(border, Padding::xy(0, 1, Tui::bg(bg, x)));
|
||||
let content = Tui::either(
|
||||
self.0.file_picker().is_some(),
|
||||
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(||Tui::map(phrases.iter(), |phrase, i|{
|
||||
let MidiClip { ref name, color, length, .. } = *phrase.read().unwrap();
|
||||
let mut length = PhraseLength::new(length, None);
|
||||
if let Some(PoolMode::Length(phrase, new_length, focus)) = self.0.mode {
|
||||
if i == phrase {
|
||||
length.pulses = new_length;
|
||||
length.focus = Some(focus);
|
||||
}
|
||||
}
|
||||
let clip = Tui::bg(color.base.rgb, Fill::x(col!(
|
||||
Fill::x(lay!(
|
||||
Fill::x(Align::w(format!(" {i}"))),
|
||||
Fill::x(Align::e(Pull::x(1, length.clone()))),
|
||||
)),
|
||||
Tui::bold(true, {
|
||||
let mut row2 = format!(" {name}");
|
||||
if let Some(PoolMode::Rename(phrase, _)) = self.0.mode {
|
||||
if i == phrase {
|
||||
row2 = format!("{row2}▄");
|
||||
}
|
||||
};
|
||||
row2
|
||||
}),
|
||||
)));
|
||||
Push::y(i as u16 * 2, lay!(clip, Tui::when(i == self.0.phrase_index(), CORNERS)))
|
||||
})));
|
||||
enclose(lay!(
|
||||
//add(&Lozenge(Style::default().bg(border_bg).fg(border_color)))?;
|
||||
content,
|
||||
Fill::x(Align::nw(Push::x(1, Tui::fg(title_color, upper_left.to_string())))),
|
||||
Fill::x(Align::ne(Pull::x(1, Tui::fg(title_color, upper_right.to_string())))),
|
||||
self.0.size.clone()
|
||||
))
|
||||
Thunk::new(x));
|
||||
let content = with_files(||Tui::map(||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(1 + i as u16 * 2, Fill::x(Fixed::y(2, Tui::bg(color.base.rgb,
|
||||
format!(" {i} {name} {length} ")))))/*,
|
||||
name.clone()))))Bsp::s(
|
||||
Fill::x(Bsp::a(
|
||||
Align::w(format!(" {i}")),
|
||||
Align::e(Pull::x(1, length)),
|
||||
)),
|
||||
Tui::bold(true, {
|
||||
let mut row2 = format!(" {name}");
|
||||
if let Some(PoolMode::Rename(clip, _)) = self.0.mode {
|
||||
if i == clip {
|
||||
row2 = format!("{row2}▄");
|
||||
}
|
||||
};
|
||||
row2
|
||||
}),
|
||||
))))//lay!(clip, Tui::when(i == self.0.clip_index(), CORNERS)))*/
|
||||
}));
|
||||
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))
|
||||
//);
|
||||
//enclose(lay!(
|
||||
////add(&Lozenge(Style::default().bg(border_bg).fg(border_color)))?;
|
||||
//Fill::xy(content),
|
||||
//Fill::x(Align::nw(Push::x(1, Tui::fg(title_color, upper_left.to_string())))),
|
||||
//Fill::x(Align::ne(Pull::x(1, Tui::fg(title_color, upper_right.to_string())))),
|
||||
//self.0.size.clone()
|
||||
//))
|
||||
});
|
||||
command!(|self: FileBrowserCommand, state: PoolModel|{
|
||||
use PoolMode::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue