mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
fixed Bsp?
This commit is contained in:
parent
8c28ef2bd7
commit
863d57447a
2 changed files with 57 additions and 29 deletions
|
|
@ -20,6 +20,21 @@ impl Direction {
|
||||||
|
|
||||||
pub struct Bsp<E: Engine, X: Content<E>, Y: Content<E>>(Direction, X, Y, PhantomData<E>);
|
pub struct Bsp<E: Engine, X: Content<E>, Y: Content<E>>(Direction, X, Y, PhantomData<E>);
|
||||||
|
|
||||||
|
impl<E: Engine, A: Content<E>, B: Content<E>> Content<E> for Bsp<E, A, B> {
|
||||||
|
fn layout (&self, outer: E::Area) -> E::Area {
|
||||||
|
let [_, _, c] = self.areas(outer);
|
||||||
|
c
|
||||||
|
}
|
||||||
|
fn render (&self, to: &mut E::Output) {
|
||||||
|
let [area_a, area_b, _] = self.areas(to.area());
|
||||||
|
let (a, b) = self.contents();
|
||||||
|
match self.0 {
|
||||||
|
Below => { to.place(area_a, a); to.place(area_b, b); },
|
||||||
|
_ => { to.place(area_b, b); to.place(area_a, a); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<E: Engine, A: Content<E>, B: Content<E>> Bsp<E, A, B> {
|
impl<E: Engine, A: Content<E>, B: Content<E>> Bsp<E, A, B> {
|
||||||
pub fn n (a: A, b: B) -> Self { Self(North, a, b, Default::default()) }
|
pub fn n (a: A, b: B) -> Self { Self(North, a, b, Default::default()) }
|
||||||
pub fn s (a: A, b: B) -> Self { Self(South, a, b, Default::default()) }
|
pub fn s (a: A, b: B) -> Self { Self(South, a, b, Default::default()) }
|
||||||
|
|
@ -28,37 +43,50 @@ impl<E: Engine, A: Content<E>, B: Content<E>> Bsp<E, A, B> {
|
||||||
pub fn a (a: A, b: B) -> Self { Self(Above, a, b, Default::default()) }
|
pub fn a (a: A, b: B) -> Self { Self(Above, a, b, Default::default()) }
|
||||||
pub fn b (a: A, b: B) -> Self { Self(Below, a, b, Default::default()) }
|
pub fn b (a: A, b: B) -> Self { Self(Below, a, b, Default::default()) }
|
||||||
pub fn contents (&self) -> (&A, &B) { (&self.1, &self.2) }
|
pub fn contents (&self) -> (&A, &B) { (&self.1, &self.2) }
|
||||||
pub fn areas (&self, outer: E::Area) -> [E::Area;2] {
|
pub fn areas (&self, outer: E::Area) -> [E::Area;3] {
|
||||||
let [x, y, w, h] = outer.xywh();
|
let [x, y, w, h] = outer.xywh();
|
||||||
let (a, b) = self.contents();
|
let (a, b) = self.contents();
|
||||||
let a = a.layout(outer);
|
let [ax, ay, aw, ah] = a.layout(outer).xywh();
|
||||||
let b = match self.0 {
|
let [bx, by, bw, bh] = b.layout(match self.0 {
|
||||||
North => b.layout([x, y, w, h.minus(a.h())].into()),
|
Above | Below => outer,
|
||||||
South => b.layout([x, y + a.h(), w, h.minus(a.h())].into()),
|
South => [x, y + ah, w, h.minus(ah)].into(),
|
||||||
East => b.layout([x + a.w(), y, w.minus(a.w()), h].into()),
|
North => [x, y, w, h.minus(ah)].into(),
|
||||||
West => b.layout([x, y, w.minus(a.w()), h].into()),
|
East => [x + aw, y, w.minus(aw), h].into(),
|
||||||
Above | Below => b.layout(outer),
|
West => [x, y, w.minus(aw), h].into(),
|
||||||
};
|
}).xywh();
|
||||||
[a, b]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<E: Engine, A: Content<E>, B: Content<E>> Content<E> for Bsp<E, A, B> {
|
|
||||||
fn layout (&self, outer: E::Area) -> E::Area {
|
|
||||||
let [a, b] = self.areas(outer);
|
|
||||||
let [ax, ay, aw, ah] = a.xywh();
|
|
||||||
let [bx, by, bw, bh] = b.xywh();
|
|
||||||
match self.0 {
|
match self.0 {
|
||||||
North | South => [ax.min(bx), ay.min(by), aw.max(bw), ah + bh ],
|
Above | Below => {
|
||||||
East | West => [ax.min(bx), ay.min(by), aw + bw, ah.max(bh)],
|
let x = ax.min(bx);
|
||||||
Above | Below => [ax.min(bx), ay.min(by), aw.max(bw), ah.max(bh)],
|
let w = (ax+aw).max(bx+bw).minus(x);
|
||||||
}.into()
|
let y = ay.min(by);
|
||||||
}
|
let h = (ay+ah).max(by+bh).minus(y);
|
||||||
fn render (&self, to: &mut E::Output) {
|
[[ax, ay, aw, ah].into(), [bx, by, bw, bh].into(), [x, y, w, h].into()]
|
||||||
let [area_a, area_b] = self.areas(to.area());
|
},
|
||||||
let (a, b) = self.contents();
|
South => {
|
||||||
to.place(area_a, a);
|
let [x, y, w, h] = outer.center_xy([aw.max(bw), ah + bh]);
|
||||||
to.place(area_b, b);
|
let a = [x, y, aw, ah];
|
||||||
|
let b = [x, y + ah, bw, bh];
|
||||||
|
[a.into(), b.into(), [x, y, w, h].into()]
|
||||||
|
},
|
||||||
|
North => {
|
||||||
|
let [x, y, w, h] = outer.center_xy([aw.max(bw), ah + bh]);
|
||||||
|
let a = [x, y + bh, aw, ah];
|
||||||
|
let b = [x, y, bw, bh];
|
||||||
|
[a.into(), b.into(), [x, y, w, h].into()]
|
||||||
|
},
|
||||||
|
East => {
|
||||||
|
let [x, y, w, h] = outer.center_xy([aw.max(bw), ah + bh]);
|
||||||
|
let a = [x, y, aw, ah];
|
||||||
|
let b = [x + aw, y, bw, bh];
|
||||||
|
[a.into(), b.into(), [x, y, w, h].into()]
|
||||||
|
},
|
||||||
|
West => {
|
||||||
|
let [x, y, w, h] = outer.center_xy([aw.max(bw), ah + bh]);
|
||||||
|
let a = [x + bw, y, aw, ah];
|
||||||
|
let b = [x, y, bw, bh];
|
||||||
|
[a.into(), b.into(), [x, y, w, h].into()]
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ from_jack!(|jack|TransportTui Self {
|
||||||
has_clock!(|self: TransportTui|&self.clock);
|
has_clock!(|self: TransportTui|&self.clock);
|
||||||
audio!(|self: TransportTui, client, scope|ClockAudio(self).process(client, scope));
|
audio!(|self: TransportTui, client, scope|ClockAudio(self).process(client, scope));
|
||||||
handle!(<Tui>|self: TransportTui, from|TransportCommand::execute_with_state(self, from));
|
handle!(<Tui>|self: TransportTui, from|TransportCommand::execute_with_state(self, from));
|
||||||
render!(Tui: (self: TransportTui) => PlayPause(false));
|
render!(Tui: (self: TransportTui) => Bsp::s("play", "pause"));//play/pause");//PlayPause(false));
|
||||||
/*Align::x(Fixed::y(3, row!(
|
/*Align::x(Fixed::y(3, row!(
|
||||||
Fixed::x(5, Fixed::y(3, PlayPause(false))),
|
Fixed::x(5, Fixed::y(3, PlayPause(false))),
|
||||||
TransportView::new(self, Some(self.color), true),
|
TransportView::new(self, Some(self.color), true),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue