mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
yay! partially fixed the layout
This commit is contained in:
parent
85749a3437
commit
fe9c1e38a4
2 changed files with 42 additions and 38 deletions
|
|
@ -11,33 +11,6 @@ pub(crate) use std::fmt::Write;
|
||||||
pub(crate) use ::tengri::tui::ratatui::prelude::Position;
|
pub(crate) use ::tengri::tui::ratatui::prelude::Position;
|
||||||
pub(crate) trait ScenesColors<'a> = Iterator<Item=SceneWithColor<'a>>;
|
pub(crate) trait ScenesColors<'a> = Iterator<Item=SceneWithColor<'a>>;
|
||||||
pub(crate) type SceneWithColor<'a> = (usize, &'a Scene, usize, usize, Option<ItemPalette>);
|
pub(crate) type SceneWithColor<'a> = (usize, &'a Scene, usize, usize, Option<ItemPalette>);
|
||||||
view!(TuiOut: |self: Tek| self.size.of(View(self, self.view)); {
|
|
||||||
//":inputs" => self.view_inputs().boxed(),
|
|
||||||
//":outputs" => self.view_outputs().boxed(),
|
|
||||||
//":scene-add" => self.view_scene_add().boxed(),
|
|
||||||
//":scenes" => self.view_scenes().boxed(),
|
|
||||||
//":tracks" => self.view_tracks().boxed(),
|
|
||||||
":arranger" => ArrangerView::new(self).boxed(),
|
|
||||||
":editor" => self.editor.as_ref().map(|e|Bsp::e(e.clip_status(), e.edit_status())).boxed(),
|
|
||||||
":sample" => ().boxed(),//self.view_sample(self.is_editing()).boxed(),
|
|
||||||
":sampler" => ().boxed(),//self.view_sampler(self.is_editing(), &self.editor).boxed(),
|
|
||||||
":status" => self.view_status().boxed(),
|
|
||||||
":transport" => self.view_transport().boxed(),
|
|
||||||
":pool" => self.pool.as_ref()
|
|
||||||
.map(|pool|Fixed::x(self.w_sidebar(), PoolView(self.is_editing(), pool)))
|
|
||||||
.boxed(),
|
|
||||||
});
|
|
||||||
provide_num!(u16: |self: Tek| {
|
|
||||||
":h-ins" => self.h_inputs(),
|
|
||||||
":h-outs" => self.h_outputs(),
|
|
||||||
":h-sample" => if self.is_editing() { 0 } else { 5 },
|
|
||||||
":w-samples" => if self.is_editing() { 4 } else { 11 },
|
|
||||||
":w-sidebar" => self.w_sidebar(),
|
|
||||||
":y-ins" => (self.size.h() as u16).saturating_sub(self.h_inputs() + 1),
|
|
||||||
":y-outs" => (self.size.h() as u16).saturating_sub(self.h_outputs() + 1),
|
|
||||||
":y-samples" => if self.is_editing() { 1 } else { 0 },
|
|
||||||
});
|
|
||||||
|
|
||||||
pub(crate) struct ArrangerView<'a> {
|
pub(crate) struct ArrangerView<'a> {
|
||||||
app: &'a Tek,
|
app: &'a Tek,
|
||||||
|
|
||||||
|
|
@ -69,14 +42,13 @@ pub(crate) struct ArrangerView<'a> {
|
||||||
|
|
||||||
impl<'a> Content<TuiOut> for ArrangerView<'a> {
|
impl<'a> Content<TuiOut> for ArrangerView<'a> {
|
||||||
fn content (&self) -> impl Render<TuiOut> {
|
fn content (&self) -> impl Render<TuiOut> {
|
||||||
let with_inputs = |x|Bsp::s(self.inputs(), x);
|
let ins = |x|Bsp::s(self.inputs(), x);
|
||||||
let with_tracks = |x|Bsp::s(self.tracks(), x);
|
let tracks = |x|Bsp::s(self.tracks(), x);
|
||||||
let with_outputs = |x|Bsp::n(self.outputs(), x);
|
let outs = |x|Bsp::n(self.outputs(), x);
|
||||||
let with_track_scroll = |x|Bsp::s(&self.track_scroll, x);
|
let bg = |x|Tui::bg(Reset, x);
|
||||||
let with_scene_scroll = |x|Bsp::e(&self.scene_scroll, x);
|
let track_scroll = |x|Bsp::s(&self.track_scroll, x);
|
||||||
let with_background = |x|Tui::bg(Reset, x);
|
let scene_scroll = |x|Bsp::e(&self.scene_scroll, x);
|
||||||
with_inputs(with_tracks(with_outputs(with_background(with_track_scroll(with_scene_scroll(
|
ins(tracks(outs(bg(track_scroll(scene_scroll(self.scenes()))))))
|
||||||
self.scenes()))))))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,7 +68,7 @@ impl<'a> ArrangerView<'a> {
|
||||||
outputs_height: app.h_outputs().saturating_sub(1),
|
outputs_height: app.h_outputs().saturating_sub(1),
|
||||||
outputs_count: app.midi_outs.len(),
|
outputs_count: app.midi_outs.len(),
|
||||||
|
|
||||||
scenes_height: app.h_scenes(),
|
scenes_height: app.h_tracks_area(),
|
||||||
scene_selected: app.selected().scene(),
|
scene_selected: app.selected().scene(),
|
||||||
scene_count: app.scenes.len(),
|
scene_count: app.scenes.len(),
|
||||||
scene_last: app.scenes.len().saturating_sub(1),
|
scene_last: app.scenes.len().saturating_sub(1),
|
||||||
|
|
@ -109,8 +81,8 @@ impl<'a> ArrangerView<'a> {
|
||||||
tracks_height: app.h_tracks_area(),
|
tracks_height: app.h_tracks_area(),
|
||||||
track_count: app.tracks.len(),
|
track_count: app.tracks.len(),
|
||||||
track_selected: app.selected().track(),
|
track_selected: app.selected().track(),
|
||||||
track_scroll: Fill::y(Fixed::x(1, ScrollbarH {
|
track_scroll: Fill::x(Fixed::y(1, ScrollbarH {
|
||||||
offset: app.scene_scroll,
|
offset: app.track_scroll,
|
||||||
length: app.h_tracks_area() as usize,
|
length: app.h_tracks_area() as usize,
|
||||||
total: app.h_scenes() as usize,
|
total: app.h_scenes() as usize,
|
||||||
})),
|
})),
|
||||||
|
|
@ -224,8 +196,36 @@ impl Tek {
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view!(TuiOut: |self: Tek| self.size.of(View(self, self.view)); {
|
||||||
|
//":inputs" => self.view_inputs().boxed(),
|
||||||
|
//":outputs" => self.view_outputs().boxed(),
|
||||||
|
//":scene-add" => self.view_scene_add().boxed(),
|
||||||
|
//":scenes" => self.view_scenes().boxed(),
|
||||||
|
//":tracks" => self.view_tracks().boxed(),
|
||||||
|
":transport" => self.view_transport().boxed(),
|
||||||
|
":arranger" => ArrangerView::new(self).boxed(),
|
||||||
|
":editor" => self.editor.as_ref().map(|e|Bsp::e(e.clip_status(), e.edit_status())).boxed(),
|
||||||
|
":sample" => ().boxed(),//self.view_sample(self.is_editing()).boxed(),
|
||||||
|
":sampler" => ().boxed(),//self.view_sampler(self.is_editing(), &self.editor).boxed(),
|
||||||
|
":status" => self.view_status().boxed(),
|
||||||
|
":pool" => self.pool.as_ref()
|
||||||
|
.map(|pool|Fixed::x(self.w_sidebar(), PoolView(self.is_editing(), pool)))
|
||||||
|
.boxed(),
|
||||||
|
});
|
||||||
|
provide_num!(u16: |self: Tek| {
|
||||||
|
":h-ins" => self.h_inputs(),
|
||||||
|
":h-outs" => self.h_outputs(),
|
||||||
|
":h-sample" => if self.is_editing() { 0 } else { 5 },
|
||||||
|
":w-samples" => if self.is_editing() { 4 } else { 11 },
|
||||||
|
":w-sidebar" => self.w_sidebar(),
|
||||||
|
":y-ins" => (self.size.h() as u16).saturating_sub(self.h_inputs() + 1),
|
||||||
|
":y-outs" => (self.size.h() as u16).saturating_sub(self.h_outputs() + 1),
|
||||||
|
":y-samples" => if self.is_editing() { 1 } else { 0 },
|
||||||
|
});
|
||||||
|
|
||||||
#[cfg(test)] #[test] fn test_view_iter () {
|
#[cfg(test)] #[test] fn test_view_iter () {
|
||||||
let mut tek = Tek::default();
|
let mut tek = Tek::default();
|
||||||
tek.editor = Some(Default::default());
|
tek.editor = Some(Default::default());
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,10 @@ impl Tek {
|
||||||
pub(crate) fn h_tracks_area (&self) -> u16 {
|
pub(crate) fn h_tracks_area (&self) -> u16 {
|
||||||
self.h().saturating_sub(self.h_inputs() + self.h_outputs() + 10)
|
self.h().saturating_sub(self.h_inputs() + self.h_outputs() + 10)
|
||||||
}
|
}
|
||||||
|
/// Height available to display tracks.
|
||||||
|
pub(crate) fn h_scenes_area (&self) -> u16 {
|
||||||
|
self.h().saturating_sub(self.h_tracks_area())
|
||||||
|
}
|
||||||
/// Height taken by all inputs.
|
/// Height taken by all inputs.
|
||||||
pub(crate) fn h_inputs (&self) -> u16 {
|
pub(crate) fn h_inputs (&self) -> u16 {
|
||||||
1 + self.inputs_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
|
1 + self.inputs_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue