mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
'and then not have to worry about layout, ever'
This commit is contained in:
parent
21741ebc52
commit
f7e6449324
8 changed files with 74 additions and 74 deletions
|
|
@ -45,11 +45,11 @@ pub struct Opt<E: Engine, A, F: Fn(A)->R, R: Content<E>>(Option<A>, F, PhantomDa
|
|||
pub struct When<E: Engine, A>(bool, A, PhantomData<E>);
|
||||
|
||||
impl<E: Engine, A: Content<E>> Content<E> for When<E, A> {
|
||||
fn area (&self, to: E::Area) -> E::Area {
|
||||
fn layout (&self, to: E::Area) -> E::Area {
|
||||
let Self(cond, item, ..) = self;
|
||||
let mut area = E::Area::zero();
|
||||
if *cond {
|
||||
let item_area = item.area(to);
|
||||
let item_area = item.layout(to);
|
||||
area[0] = item_area.x();
|
||||
area[1] = item_area.y();
|
||||
area[2] = item_area.w();
|
||||
|
|
@ -67,9 +67,9 @@ impl<E: Engine, A: Content<E>> Content<E> for When<E, A> {
|
|||
pub struct Either<E: Engine, A, B>(bool, A, B, PhantomData<E>);
|
||||
|
||||
impl<E: Engine, A: Content<E>, B: Content<E>> Content<E> for Either<E, A, B> {
|
||||
fn area (&self, to: E::Area) -> E::Area {
|
||||
fn layout (&self, to: E::Area) -> E::Area {
|
||||
let Self(cond, a, b, ..) = self;
|
||||
if *cond { a.area(to) } else { b.area(to) }
|
||||
if *cond { a.layout(to) } else { b.layout(to) }
|
||||
}
|
||||
fn render (&self, to: &mut E::Output) {
|
||||
let Self(cond, a, b, ..) = self;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue