mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
refactor groovebox into modules + accidental code golf
This commit is contained in:
parent
c2e3f73044
commit
005bb5fde8
4 changed files with 217 additions and 175 deletions
86
src/groovebox/groovebox_tui.rs
Normal file
86
src/groovebox/groovebox_tui.rs
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
use crate::*;
|
||||
use super::*;
|
||||
|
||||
/*
|
||||
render!(Tui: (self: Groovebox) => self.size.of(
|
||||
self.toolbar_view()
|
||||
.south(self.selector_view())
|
||||
.south(self.sample_view())
|
||||
.north(self.status_view())
|
||||
.north(self.pool_view())
|
||||
.west(Fill::xy(self.sampler_view().east(self.editor)))));
|
||||
*/
|
||||
|
||||
/*
|
||||
render!(Tui: (self: Groovebox) => self.size.of(
|
||||
self.editor
|
||||
.east_of(self.sample_view())
|
||||
.wrap(Fill::xy)
|
||||
.west_of(self.pool_view())
|
||||
.north_of(self.status_view())
|
||||
.north_of(self.sample_view())
|
||||
.south_of(self.selector_view())
|
||||
.south_of(self.toolbar_view())
|
||||
*/
|
||||
|
||||
/*
|
||||
render!(Tui: (self: Groovebox) => self.size.of(
|
||||
self.toolbar_view().north_of(
|
||||
self.selector_view().north_of(
|
||||
self.sample_view().south_of(
|
||||
self.status_view().south_of(
|
||||
self.pool_view().east_of(
|
||||
Fill::xy(self.sampler_view().west_of(
|
||||
self.editor)))))))));
|
||||
*/
|
||||
|
||||
render!(Tui: (self: Groovebox) => self.size.of(
|
||||
Bsp::s(self.toolbar_view(),
|
||||
Bsp::s(self.selector_view(),
|
||||
Bsp::n(self.sample_view(),
|
||||
Bsp::n(self.status_view(),
|
||||
Bsp::w(self.pool_view(), Fill::xy(Bsp::e(self.sampler_view(), &self.editor)))))))));
|
||||
|
||||
impl Groovebox {
|
||||
fn toolbar_view (&self) -> impl Content<Tui> + use<'_> {
|
||||
Fill::x(Fixed::y(2, lay!(
|
||||
Align::w(Meter("L/", self.sampler.input_meter[0])),
|
||||
Align::e(Meter("R/", self.sampler.input_meter[1])),
|
||||
Align::x(Tui::bg(TuiTheme::g(32), TransportView::new(true, &self.player.clock))),
|
||||
)))
|
||||
}
|
||||
fn status_view (&self) -> impl Content<Tui> + use<'_> {
|
||||
let note_pt = self.editor.note_point();
|
||||
lay!(
|
||||
Align::w(Fixed::y(1, SamplerStatus(&self.sampler, note_pt))),
|
||||
Align::x(Fixed::y(1, MidiEditStatus(&self.editor))),
|
||||
)
|
||||
}
|
||||
fn sampler_view (&self) -> impl Content<Tui> + use<'_> {
|
||||
let sampler_w = if !self.compact { 11 } else { 4 };
|
||||
let sampler_y = if self.compact { 1 } else { 0 };
|
||||
Fixed::x(sampler_w, Push::y(sampler_y, Fill::y(
|
||||
SampleList::new(self.compact, &self.sampler, &self.editor))))
|
||||
}
|
||||
fn sample_view (&self) -> impl Content<Tui> + use<'_> {
|
||||
let note_pt = self.editor.note_point();
|
||||
let sample_h = if self.compact { 0 } else { 5 };
|
||||
Max::y(sample_h, Fill::xy(
|
||||
SampleViewer::from_sampler(&self.sampler, note_pt)))
|
||||
}
|
||||
fn pool_view (&self) -> impl Content<Tui> + use<'_> {
|
||||
let w = self.size.w();
|
||||
let pool_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 };
|
||||
Fixed::x(if self.compact { 5 } else { pool_w },
|
||||
PoolView(self.compact, &self.pool))
|
||||
}
|
||||
fn selector_view (&self) -> impl Content<Tui> + use<'_> {
|
||||
lay!(
|
||||
Align::w(MidiEditClip(&self.editor)),
|
||||
Align::e(Bsp::e(
|
||||
ClipSelected::play_phrase(&self.player),
|
||||
ClipSelected::next_phrase(&self.player)
|
||||
))
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue