fix grid alignments

This commit is contained in:
🪞👃🪞 2025-01-14 23:30:44 +01:00
parent fadaaa1620
commit 385297c59f
2 changed files with 26 additions and 20 deletions

View file

@ -5,4 +5,4 @@
(@e editor show :pool-clip)
(@ctrl-a scene add)
(@ctrl-t track add)
(@tab pool toggle)
(@tab compact)

View file

@ -103,8 +103,12 @@ edn_view!(TuiOut: |self: App| self.size.of(EdnView::from_source(self, self.edn.a
":tracks" => self.row(self.w(), 3, self.track_header(), self.track_cells()).boxed(),
":inputs" => self.row(self.w(), 3, self.input_header(), self.input_cells()).boxed(),
":outputs" => self.row(self.w(), 3, self.output_header(), self.output_cells()).boxed(),
":scenes" => Rugged(Style::default()).enclose(self.row(self.w(), self.size.h().saturating_sub(12) as u16,
Rugged(Style::default()).enclose(self.scene_header()), self.scene_cells(self.is_editing()))).boxed() }});
":scenes" => Outer(Style::default().fg(TuiTheme::g(0))).enclose_bg(self.row(
self.w(),
self.size.h().saturating_sub(12) as u16,
self.scene_header(),
self.scene_cells(self.is_editing())
)).boxed() }});
impl App {
pub fn clock (
jack: &Arc<RwLock<JackConnection>>,
@ -202,7 +206,7 @@ impl App {
arranger.tracks_add(tracks, track_width, &[], &[]);
Ok(arranger)
}
fn compact (&self) -> bool { false }
fn compact (&self) -> bool { self.compact }
fn is_editing (&self) -> bool { self.editing.load(Relaxed) }
fn editor (&self) -> impl Content<TuiOut> + '_ { &self.editor }
fn w (&self) -> u16 { self.tracks_sizes(self.is_editing(), self.editor_w()).last().map(|x|x.3 as u16).unwrap_or(0) }
@ -217,7 +221,7 @@ impl App {
&'a self, w: u16, h: u16, a: impl Content<TuiOut> + 'a, b: impl Content<TuiOut> + 'a
) -> impl Content<TuiOut> + 'a {
Fixed::y(h, Bsp::e(
Fixed::xy(self.sidebar_w() as u16, h, a),
Fixed::x(self.sidebar_w() as u16, a),
Fill::x(Align::c(Fixed::xy(w, h, b)))
))
}
@ -316,12 +320,12 @@ impl App {
let scenes = ||self.scenes_sizes(self.is_editing(), 2, 15);
let selected_track = self.selected().track();
let selected_scene = self.selected().scene();
(move||Fill::y(Align::c(Map::new(tracks, move|(_, track, x1, x2), t| {
(move||Align::c(Map::new(tracks, move|(_, track, x1, x2), t| {
let w = (x2 - x1) as u16;
let color: ItemPalette = track.color.dark.into();
let last_color = Arc::new(RwLock::new(ItemPalette::from(Color::Rgb(0, 0, 0))));
let cells = Map::new(scenes, move|(_, scene, y1, y2), s| {
let h = (y2 - y1) as u16;
let h = (1 + y2 - y1) as u16;
let color = scene.color;
let (name, fg, bg) = if let Some(c) = &scene.clips[t] {
let c = c.read().unwrap();
@ -346,15 +350,11 @@ impl App {
));
let cell = Either::new(active, editor, cell);
*last_color.write().unwrap() = bg.into();
map_south(
y1 as u16,
h + 1,
Fill::x(Fixed::y(h + 1, cell))
)
map_south(y1 as u16, h, Push::y(1, Fixed::y(h, cell)))
});
let column = Fixed::x(w, Align::y(Rugged(Style::default()).enclose(cells))).boxed();
Fixed::x(w, map_east(x1 as u16, w, column))
}))).boxed()).into()
map_east(x1 as u16, w,
Outer(Style::default().fg(TuiTheme::g(0))).enclose(cells)).boxed()
})).boxed()).into()
}
fn activate (&mut self) -> Usually<()> {
let selected = self.selected().clone();
@ -426,12 +426,17 @@ handle!(TuiIn: |self: App, input|Ok({
Zoom(Option<usize>),
}
edn_command!(AppCommand: |state: App| {
("stop-all" [] Self::StopAll)
("compact" [] Self::Compact(None))
("compact" [c: bool] Self::Compact(c))
("color" [c: Color] Self::Color(c.map(ItemPalette::from).unwrap_or_default()))
("undo" [d: usize] Self::History(-(d.unwrap_or(0)as isize)))
("redo" [d: usize] Self::History(d.unwrap_or(0) as isize))
("zoom" [z: usize] Self::Zoom(z))
("stop-all" [] Self::StopAll)
("enqueue" [c: Arc<RwLock<MidiClip>>] Self::Enqueue(c))
("select" [t: usize, s: usize] match (t.expect("no track"), s.expect("no scene")) {
(0, 0) => Self::Select(Selection::Mix),
@ -844,8 +849,8 @@ pub trait HasScenes: HasSelection + HasEditor + Send + Sync {
let last_color = Arc::new(RwLock::new(ItemPalette::from(Color::Rgb(0, 0, 0))));
let selected = self.selected().scene();
let iter = ||self.scenes_sizes(self.is_editing(), 2, 15);
Fill::y(Align::c(Map::new(iter, move|(_, scene, y1, y2), i| {
let h = (y2 - y1) as u16;
Map::new(iter, move|(_, scene, y1, y2), i| {
let h = (1 + y2 - y1) as u16;
let name = format!("🭬{}", &scene.name);
let color = scene.color;
let active = selected == Some(i);
@ -860,8 +865,9 @@ pub trait HasScenes: HasSelection + HasEditor + Send + Sync {
Color::Rgb(0, 0, 0)
);
*last_color.write().unwrap() = color;
map_south(y1 as u16, h + 1, Fixed::y(h + 1, cell))
}))).boxed()
map_south(y1 as u16, h, Push::y(1, Fixed::y(h,
Outer(Style::default().fg(TuiTheme::g(0))).enclose(cell))))
}).boxed()
}).into()
}
}