mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-13 07:06:41 +01:00
125 lines
4.5 KiB
Rust
125 lines
4.5 KiB
Rust
use crate::*;
|
|
mod view_clock; pub use self::view_clock::*;
|
|
mod view_color; pub use self::view_color::*;
|
|
mod view_iter; pub use self::view_iter::*;
|
|
mod view_memo; pub use self::view_memo::*;
|
|
mod view_meter; pub use self::view_meter::*;
|
|
mod view_sizes; pub use self::view_sizes::*;
|
|
mod view_track; pub use self::view_track::*;
|
|
mod view_ports; pub use self::view_ports::*;
|
|
mod view_layout; pub use self::view_layout::*;
|
|
pub(crate) use std::fmt::Write;
|
|
pub(crate) use ::tengri::tui::ratatui::prelude::Position;
|
|
pub(crate) trait ScenesColors<'a> = Iterator<Item=SceneWithColor<'a>>;
|
|
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> {
|
|
app: &'a Tek,
|
|
|
|
is_editing: bool,
|
|
|
|
width: u16,
|
|
width_mid: u16,
|
|
width_side: u16,
|
|
|
|
inputs_count: usize,
|
|
inputs_height: u16,
|
|
|
|
outputs_count: usize,
|
|
outputs_height: u16,
|
|
|
|
scene_last: usize,
|
|
scene_count: usize,
|
|
scene_scroll: Fill<Fixed<ScrollbarV>>,
|
|
scene_selected: Option<usize>,
|
|
scenes_height: u16,
|
|
|
|
track_scroll: Fill<Fixed<ScrollbarH>>,
|
|
track_count: usize,
|
|
track_selected: Option<usize>,
|
|
tracks_height: u16,
|
|
}
|
|
|
|
impl<'a> Content<TuiOut> for ArrangerView<'a> {
|
|
fn content (&self) -> impl Render<TuiOut> {
|
|
Bsp::s(self.inputs(),
|
|
Bsp::s(self.tracks(),
|
|
Bsp::n(self.outputs(), Tui::bg(Reset, Bsp::s(self.track_scroll,
|
|
Bsp::e(self.scene_scroll,
|
|
Fixed::y(self.scenes_height,self.scenes())))))))
|
|
}
|
|
}
|
|
|
|
impl<'a> ArrangerView<'a> {
|
|
fn new (app: &'a Tek) -> Self {
|
|
Self {
|
|
app,
|
|
is_editing: app.is_editing(),
|
|
|
|
width: app.w(),
|
|
width_mid: app.w_tracks_area(),
|
|
width_side: app.w_sidebar(),
|
|
|
|
inputs_height: app.h_inputs().saturating_sub(1),
|
|
inputs_count: app.midi_ins.len(),
|
|
|
|
outputs_height: app.h_outputs().saturating_sub(1),
|
|
outputs_count: app.midi_outs.len(),
|
|
|
|
scenes_height: app.h_scenes(),
|
|
scene_selected: app.selected().scene(),
|
|
scene_count: app.scenes.len(),
|
|
scene_last: app.scenes.len().saturating_sub(1),
|
|
scene_scroll: Fill::y(Fixed::x(1, ScrollbarV {
|
|
offset: app.scene_scroll,
|
|
length: app.h_tracks_area() as usize,
|
|
total: app.h_scenes() as usize,
|
|
})),
|
|
|
|
tracks_height: app.h_tracks_area(),
|
|
track_count: app.tracks.len(),
|
|
track_selected: app.selected().track(),
|
|
track_scroll: Fill::y(Fixed::x(1, ScrollbarH {
|
|
offset: app.scene_scroll,
|
|
length: app.h_tracks_area() as usize,
|
|
total: app.h_scenes() as usize,
|
|
})),
|
|
|
|
}
|
|
}
|
|
pub(crate) fn inputs_with_sizes (&'a self) -> impl PortsSizes<'a> {
|
|
self.app.inputs_sizes()
|
|
}
|
|
pub(crate) fn outputs_with_sizes (&'a self) -> impl PortsSizes<'a> {
|
|
self.app.outputs_sizes()
|
|
}
|
|
pub(crate) fn tracks_with_sizes (&'a self) -> impl TracksSizes<'a> {
|
|
self.app.tracks_sizes_scrolled()
|
|
}
|
|
}
|