diff --git a/output/src/ops.rs b/output/src/ops.rs index bdbcff0..a1c3de3 100644 --- a/output/src/ops.rs +++ b/output/src/ops.rs @@ -776,7 +776,7 @@ pub struct Stack { direction: Direction, callback: F } -impl Stack { +impl)->())->()> Stack { pub fn new (direction: Direction, callback: F) -> Self { Self { direction, callback, __: Default::default(), } } @@ -792,6 +792,12 @@ impl Stack { pub fn west (callback: F) -> Self { Self::new(West, callback) } + pub fn above (callback: F) -> Self { + Self::new(Above, callback) + } + pub fn below (callback: F) -> Self { + Self::new(Below, callback) + } } impl)->())->()> Content for Stack { fn layout (&self, to: E::Area) -> E::Area { @@ -802,31 +808,23 @@ impl)->())->()> Content for St (self.callback)(&mut move |component: &dyn Render|{ let [_, _, w, h] = component.layout([x, y, w_remaining, h_remaining].into()).xywh(); match self.direction { - South => { - y = y.plus(h); - h_used = h_used.plus(h); - h_remaining = h_remaining.minus(h); - w_used = w_used.max(w); - }, - East => { - x = x.plus(w); - w_used = w_used.plus(w); - w_remaining = w_remaining.minus(w); - h_used = h_used.max(h); - }, - North | West => { - todo!() - }, + South => { y = y.plus(h); + h_used = h_used.plus(h); + h_remaining = h_remaining.minus(h); + w_used = w_used.max(w); }, + East => { x = x.plus(w); + w_used = w_used.plus(w); + w_remaining = w_remaining.minus(w); + h_used = h_used.max(h); }, + North | West => { todo!() }, + Above | Below => {}, _ => unreachable!(), } }); match self.direction { - North | West => { - todo!() - }, - South | East => { - [to.x(), to.y(), w_used.into(), h_used.into()].into() - }, + North | West => { todo!() }, + South | East => { [to.x(), to.y(), w_used.into(), h_used.into()].into() }, + Above | Below => { [to.x(), to.y(), to.w(), to.h()].into() }, _ => unreachable!(), } } @@ -850,6 +848,9 @@ impl)->())->()> Content for St w_used = w_used.plus(layout.h()); to.place(layout, component); }, + Above | Below => { + to.place(layout, component); + } North | West => { todo!() },