mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
fix scenes centering, too!
This commit is contained in:
parent
6b463f14f0
commit
a386ba1d86
2 changed files with 35 additions and 43 deletions
|
|
@ -79,7 +79,7 @@ macro_rules! per_track {
|
|||
let content = Fixed::y(1, $content);
|
||||
let styled = Tui::fg_bg($track.color.lightest.rgb, $track.color.base.rgb, content);
|
||||
Either(x2 >= $area, (),
|
||||
map_east(x1 as u16, width, Fixed::x(width, styled))) }))).into() }} }
|
||||
map_east(x1 as u16, width, Align::y(Fixed::x(width, styled)))) }))).into() }} }
|
||||
macro_rules! io_header {
|
||||
($self:ident, $key:expr, $label:expr, $count:expr, $content:expr) => {
|
||||
(move||{
|
||||
|
|
@ -173,17 +173,19 @@ impl Tek {
|
|||
Tui::fg(Rgb(255, 128, 0), Bsp::s(" ▗▄▖ ", " ▝▀▘ ",)))))))
|
||||
}
|
||||
fn view_editor (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
self.editor.as_ref().map(|e|Bsp::e(e.clip_status(), e.edit_status()))
|
||||
self.editor.as_ref()
|
||||
.map(|e|Bsp::e(e.clip_status(), e.edit_status()))
|
||||
}
|
||||
fn view_pool (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
self.pool.as_ref().map(|pool|PoolView(self.is_editing(), pool))
|
||||
self.pool.as_ref()
|
||||
.map(|pool|Fixed::x(self.w_sidebar(), PoolView(self.is_editing(), pool)))
|
||||
}
|
||||
fn view_row <'a> (
|
||||
&'a self, w: u16, h: u16, a: impl Content<TuiOut> + 'a, b: impl Content<TuiOut> + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
Fixed::y(h, Bsp::a(
|
||||
Fill::x(Align::w(Fixed::xy(self.w_sidebar() as u16, h, a))),
|
||||
Fill::x(Align::c(Fixed::xy(w, h, b)))
|
||||
Fill::xy(Align::w(Fixed::x(self.w_sidebar() as u16, a))),
|
||||
Fill::xy(Align::c(Fixed::x(w, b)))
|
||||
))
|
||||
}
|
||||
fn view_inputs (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
|
|
@ -311,14 +313,13 @@ impl Tek {
|
|||
Some(Reset)
|
||||
)
|
||||
};
|
||||
Map::new(scenes, move|(_, scene, y1, y2), s| {
|
||||
Align::y(Map::new(scenes, move|(_, scene, y1, y2), s| {
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
let cell = cell(s, &scene.color, scene.name.clone());
|
||||
*last_color.write().unwrap() = scene.color;
|
||||
Either(y2 > size_h, (), map_south(y1 as u16, height,
|
||||
Push::y(1, Fixed::y(height, Outer(false, bstyle)
|
||||
.enclose(cell)))))
|
||||
}).boxed()
|
||||
Fixed::y(height, Outer(false, bstyle)
|
||||
.enclose(cell(s, &scene.color, scene.name.clone())))))
|
||||
})).boxed()
|
||||
};
|
||||
let content: ThunkBox<_> = per_track!(self.size.w(); |self, track, t|{
|
||||
let tab = " Tab ";
|
||||
|
|
@ -346,49 +347,40 @@ impl Tek {
|
|||
} else {
|
||||
Some(last_color.read().unwrap().base.rgb)
|
||||
};
|
||||
let mid = if selected { bg.light } else { bg.base }.rgb;
|
||||
*last_color.write().unwrap() = bg;
|
||||
let name = if active {
|
||||
self.editor.as_ref()
|
||||
.map(|e|e.clip().as_ref().map(|c|c.clone()))
|
||||
.flatten()
|
||||
.map(|c|c.read().unwrap().name.clone())
|
||||
.unwrap_or_else(||"".into())
|
||||
} else {
|
||||
self.fmtd.read().unwrap().edit.clone()
|
||||
};
|
||||
let label = move||{
|
||||
let clip = scene.clips[t].clone();
|
||||
let icon = " ⏹ ";
|
||||
let name = clip.map(|c|c.read().unwrap().name.clone());
|
||||
Align::nw(Tui::fg(fg, Bsp::e(icon, Bsp::e(Tui::bold(true, name), " "))))};
|
||||
let editor = Thunk::new(move||Bsp::a(
|
||||
Fill::xy(Align::nw(button(tab, label()))),
|
||||
&self.editor));
|
||||
let cell = Thunk::new(move||Bsp::a(
|
||||
When::new(selected, Fill::y(Align::n(button(tab, "edit")))),
|
||||
phat_sel_3(
|
||||
selected,
|
||||
label(),
|
||||
label(),
|
||||
top,
|
||||
mid,
|
||||
Some(Reset)
|
||||
)));
|
||||
|
||||
Align::nw(Tui::fg(fg, Bsp::e(icon, Bsp::e(Tui::bold(true, name), " "))))
|
||||
};
|
||||
//map_south(y1 as u16, height, format!("{height}/{size_h}"))
|
||||
Either(y2 > size_h, (), map_south(y1 as u16, height,
|
||||
Push::y(1, Fixed::y(height, Outer(false, bstyle)
|
||||
.enclose(Either::new(active, editor, cell))))))
|
||||
Fixed::y(height, Outer(false, bstyle)
|
||||
.enclose(Either::new(active,
|
||||
Thunk::new(move||Bsp::a(
|
||||
Fill::xy(Align::nw(button(tab, label()))),
|
||||
&self.editor)),
|
||||
Thunk::new(move||Bsp::a(
|
||||
When::new(selected, Fill::y(Align::n(button(tab, "edit")))),
|
||||
phat_sel_3(
|
||||
selected,
|
||||
label(),
|
||||
label(),
|
||||
top,
|
||||
if selected { bg.light } else { bg.base }.rgb,
|
||||
Some(Reset)
|
||||
))))))))
|
||||
})
|
||||
})
|
||||
});
|
||||
let border = move|x|Outer(false, bstyle).enclose_bg(x);
|
||||
border(self.view_row(
|
||||
//let border = move|x|Outer(false, bstyle).enclose_bg(x);
|
||||
self.view_row(
|
||||
self.w(),
|
||||
size_h as u16,
|
||||
<_ as Into<ThunkBox<_>>>::into(header),
|
||||
<_ as Into<ThunkBox<_>>>::into(content),
|
||||
))
|
||||
)
|
||||
}
|
||||
fn w (&self) -> u16 {
|
||||
self.tracks_sizes(self.is_editing(), self.editor_w())
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
(bsp/a (fill/xy (align/n (max/y 1 :toolbar)))
|
||||
(fill/x (align/c (bsp/a (fill/xy (align/e (fixed/x :sidebar-w :pool)))
|
||||
(bsp/s (max/y 1 :toolbar)
|
||||
(fill/x (align/c (bsp/a (fill/xy (align/e :pool))
|
||||
(bsp/a (fill/xy (align/n (bsp/s :tracks :inputs)))
|
||||
(bsp/a (fill/x (fixed/y :outs-y (align/s :outputs)))
|
||||
(bsp/s (fill/xy :scenes) :scene-add)))))))
|
||||
(bsp/s :scenes :scene-add)))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue