mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
remove uses of Split, implement Bsp::area
This commit is contained in:
parent
9f7b23a252
commit
aa910540c0
5 changed files with 79 additions and 57 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
//! Groupings of elements.
|
//! Groupings of elements.
|
||||||
|
|
||||||
mod split; pub use self::split::*;
|
//mod split; pub use self::split::*;
|
||||||
//mod stack; pub use self::stack::*;
|
//mod stack; pub use self::stack::*;
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
@ -82,7 +82,7 @@ impl<E: Engine, A: Content<E>, B: Content<E>> Content<E> for Either<E, A, B> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Render<E: Engine> {
|
trait Render<E: Engine> {
|
||||||
fn area (&self, to: E::Area) -> E::Area;
|
fn area (&self, to: E::Area) -> E::Area;
|
||||||
fn render (&self, to: &mut E::Output);
|
fn render (&self, to: &mut E::Output);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,39 +120,58 @@ impl<E: Engine, X: Content<E>, Y: Content<E>> Default for Bsp<E, X, Y> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Engine, X: Content<E>, Y: Content<E>> Content<E> for Bsp<E, X, Y> {
|
impl<E: Engine, X: Content<E>, Y: Content<E>> Content<E> for Bsp<E, X, Y> {
|
||||||
fn render (&self, to: &mut E::Output) {
|
fn area (&self, outer: E::Area) -> E::Area {
|
||||||
let _n = E::Size::zero();
|
|
||||||
let _s = to.wh();
|
|
||||||
match self {
|
match self {
|
||||||
Self::Null(_) => {},
|
Self::Null(_) => [0.into(), 0.into(), 0.into(), 0.into()].into(),
|
||||||
//Self::S(p, a, b) => {
|
Self::N(_, a, b) | Self::S(_, a, b) => {
|
||||||
//let s_a = a.min_size(s)?.unwrap_or(n);
|
let a = a.area(outer);
|
||||||
//let _ = b.min_size(s)?.unwrap_or(n);
|
let b = b.area(outer);
|
||||||
//let h = s_a.h().into();
|
[a.x().min(b.x()), a.y().min(b.y()), a.w().max(b.w()), a.h() + b.h()].into()
|
||||||
//to.render_in(to.area().clip_h(h).into(), a);
|
},
|
||||||
//to.render_in(to.area().shrink_y(h).push_y(h).into(), b);
|
Self::E(_, a, b) | Self::W(_, a, b) => {
|
||||||
//},
|
let a = a.area(outer);
|
||||||
//Self::E(p, a, b) => {
|
let b = b.area(outer);
|
||||||
//let s_a = a.min_size(s)?.unwrap_or(n);
|
[a.x().min(b.x()), a.y().min(b.y()), a.w() + b.w(), a.h().max(b.h())].into()
|
||||||
//let _ = b.min_size(s)?.unwrap_or(n);
|
},
|
||||||
//let w = s_a.w().into();
|
Self::A(a, b) | Self::B(a, b) => {
|
||||||
//to.render_in(to.area().clip_w(w).into(), a);
|
let a = a.area(outer);
|
||||||
//to.render_in(to.area().push_x(w).shrink_x(w).into(), b);
|
let b = b.area(outer);
|
||||||
//},
|
[a.x().min(b.x()), a.y().min(b.y()), a.w().max(b.w()), a.h().max(b.h())].into()
|
||||||
//Self::W(p, a, b) => {
|
}
|
||||||
//let s_a = a.min_size(s)?.unwrap_or(n);
|
}
|
||||||
//let _ = b.min_size(s)?.unwrap_or(n);
|
}
|
||||||
//let w = (to.area().w() - s_a.w()).into();
|
fn render (&self, to: &mut E::Output) {
|
||||||
//to.render_in(to.area().push_x(w).into(), a);
|
let n = E::Area::zero();
|
||||||
//to.render_in(to.area().shrink_x(w).into(), b);
|
let area = to.area();
|
||||||
//},
|
match self {
|
||||||
//Self::N(p, a, b) => {
|
Self::S(p, a, b) => {
|
||||||
//let s_a = a.min_size(s)?.unwrap_or(n);
|
let s_a = a.area(area);
|
||||||
//let _ = b.min_size(s)?.unwrap_or(n);
|
let _ = b.area(area);
|
||||||
//let h = to.area().h() - s_a.h();
|
let h = s_a.h().into();
|
||||||
//to.render_in(to.area().push_y(h).into(), a);
|
to.place(to.area().clip_h(h).into(), a);
|
||||||
//to.render_in(to.area().shrink_y(h).into(), b);
|
to.place(to.area().shrink_y(h).push_y(h).into(), b);
|
||||||
//},
|
},
|
||||||
|
Self::E(p, a, b) => {
|
||||||
|
let s_a = a.area(area);
|
||||||
|
let _ = b.area(area);
|
||||||
|
let w = s_a.w().into();
|
||||||
|
to.place(to.area().clip_w(w).into(), a);
|
||||||
|
to.place(to.area().push_x(w).shrink_x(w).into(), b);
|
||||||
|
},
|
||||||
|
Self::W(p, a, b) => {
|
||||||
|
let s_a = a.area(area);
|
||||||
|
let _ = b.area(area);
|
||||||
|
let w = (to.area().w() - s_a.w()).into();
|
||||||
|
to.place(to.area().push_x(w).into(), a);
|
||||||
|
to.place(to.area().shrink_x(w).into(), b);
|
||||||
|
},
|
||||||
|
Self::N(p, a, b) => {
|
||||||
|
let s_a = a.area(area);
|
||||||
|
let _ = b.area(area);
|
||||||
|
let h = to.area().h() - s_a.h();
|
||||||
|
to.place(to.area().push_y(h).into(), a);
|
||||||
|
to.place(to.area().shrink_y(h).into(), b);
|
||||||
|
},
|
||||||
_ => todo!()
|
_ => todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,10 +103,10 @@ render!(Tui: (self: ArrangerTui) => {
|
||||||
let play = PlayPause(self.clock.is_rolling());
|
let play = PlayPause(self.clock.is_rolling());
|
||||||
let transport = TransportView::new(self, Some(ItemPalette::from(TuiTheme::g(96))), true);
|
let transport = TransportView::new(self, Some(ItemPalette::from(TuiTheme::g(96))), true);
|
||||||
let pool_size = if self.phrases.visible { self.splits[1] } else { 0 };
|
let pool_size = if self.phrases.visible { self.splits[1] } else { 0 };
|
||||||
let with_pool = |x|Split::w(false, pool_size, PoolView(&self.phrases), x);
|
let with_pool = |x|Bsp::w(Fixed::x(pool_size, PoolView(&self.phrases)), x);
|
||||||
let status = ArrangerStatus::from(self);
|
let status = ArrangerStatus::from(self);
|
||||||
let with_editbar = |x|Split::n(false, 1, MidiEditStatus(&self.editor), x);
|
let with_editbar = |x|Bsp::n(Fixed::y(1, MidiEditStatus(&self.editor)), x);
|
||||||
let with_status = |x|Split::n(false, 2, status, x);
|
let with_status = |x|Bsp::n(Fixed::y(2, status), x);
|
||||||
let with_size = |x|lay!(&self.size, x);
|
let with_size = |x|lay!(&self.size, x);
|
||||||
let arranger = ||{
|
let arranger = ||{
|
||||||
let color = self.color;
|
let color = self.color;
|
||||||
|
|
|
||||||
|
|
@ -128,29 +128,32 @@ render!(Tui: (self: Groovebox) => {
|
||||||
PhraseSelector::play_phrase(&self.player),
|
PhraseSelector::play_phrase(&self.player),
|
||||||
PhraseSelector::next_phrase(&self.player),
|
PhraseSelector::next_phrase(&self.player),
|
||||||
)));
|
)));
|
||||||
let pool = move|x|Split::w(false, pool_w,
|
let pool = move|x|Bsp::w(
|
||||||
Pull::y(1, Fill::y(Align::e(PoolView(&self.pool)))),
|
Fixed::x(pool_w, Pull::y(1, Fill::y(Align::e(PoolView(&self.pool))))),
|
||||||
x);
|
x);
|
||||||
let sampler = move|x|Split::e(false, sampler_w, Fill::xy(col!(
|
let sampler = move|x|Bsp::e(
|
||||||
|
Fixed::x(sampler_w, Fill::xy(col!(
|
||||||
Meters(self.sampler.input_meter.as_ref()),
|
Meters(self.sampler.input_meter.as_ref()),
|
||||||
GrooveboxSamples(self)
|
GrooveboxSamples(self)))),
|
||||||
)), x);
|
x);
|
||||||
let status = EditStatus(&self.sampler, &self.editor, note_pt, pool(sampler(&self.editor)));
|
let status = EditStatus(&self.sampler, &self.editor, note_pt, pool(sampler(&self.editor)));
|
||||||
Fill::xy(lay!(
|
lay!("kyp", "nymka")
|
||||||
&self.size,
|
//status
|
||||||
Fill::xy(Align::s(Fixed::y(2, GrooveboxStatus::from(self)))),
|
//Fill::xy(lay!(
|
||||||
Shrink::y(2, col!(
|
//&self.size,
|
||||||
transport,
|
//Fill::xy(Align::s(Fixed::y(2, GrooveboxStatus::from(self)))),
|
||||||
selector,
|
//Shrink::y(2, col!(
|
||||||
status
|
//transport,
|
||||||
))
|
//selector,
|
||||||
))
|
//status
|
||||||
|
//))
|
||||||
|
//))
|
||||||
});
|
});
|
||||||
|
|
||||||
struct EditStatus<'a, T: Content<Tui>>(&'a Sampler, &'a MidiEditor, usize, T);
|
struct EditStatus<'a, T: Content<Tui>>(&'a Sampler, &'a MidiEditor, usize, T);
|
||||||
impl<'a, T: Content<Tui>> Content<Tui> for EditStatus<'a, T> {
|
impl<'a, T: Content<Tui>> Content<Tui> for EditStatus<'a, T> {
|
||||||
fn content (&self) -> impl Content<Tui> {
|
fn content (&self) -> impl Content<Tui> {
|
||||||
Split::n(false, 9, col!(
|
Bsp::n(Fixed::y(9, col!(
|
||||||
row!(
|
row!(
|
||||||
self.0.mapped[self.2].as_ref().map(|sample|format!(
|
self.0.mapped[self.2].as_ref().map(|sample|format!(
|
||||||
"Sample {}-{}",
|
"Sample {}-{}",
|
||||||
|
|
@ -169,7 +172,7 @@ impl<'a, T: Content<Tui>> Content<Tui> for EditStatus<'a, T> {
|
||||||
SampleViewer(None)
|
SampleViewer(None)
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
), &self.3)
|
)), &self.3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,10 @@ render!(Tui: (self: SequencerTui) => {
|
||||||
let phrase_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 };
|
let phrase_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 };
|
||||||
let pool_w = if self.phrases.visible { phrase_w } else { 0 };
|
let pool_w = if self.phrases.visible { phrase_w } else { 0 };
|
||||||
let pool = Pull::y(1, Fill::y(Align::e(PoolView(&self.phrases))));
|
let pool = Pull::y(1, Fill::y(Align::e(PoolView(&self.phrases))));
|
||||||
let with_pool = move|x|Split::w(false, pool_w, pool, x);
|
let with_pool = move|x|Bsp::w(Fixed::x(pool_w, pool), x);
|
||||||
let status = SequencerStatus::from(self);
|
let status = SequencerStatus::from(self);
|
||||||
let with_status = |x|Split::n(false, if self.status { 2 } else { 0 }, status, x);
|
let with_status = |x|Bsp::n(Fixed::x(if self.status { 2 } else { 0 }, status), x);
|
||||||
let with_editbar = |x|Split::n(false, 1, MidiEditStatus(&self.editor), x);
|
let with_editbar = |x|Bsp::n(Fixed::x(1, MidiEditStatus(&self.editor)), x);
|
||||||
let with_size = |x|lay!(self.size.clone(), x);
|
let with_size = |x|lay!(self.size.clone(), x);
|
||||||
let editor = with_editbar(with_pool(Fill::xy(&self.editor)));
|
let editor = with_editbar(with_pool(Fill::xy(&self.editor)));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue