mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-02-22 10:59:02 +01:00
output: refactor Content and Render traits
This commit is contained in:
parent
74b3af2212
commit
1c21a85f27
24 changed files with 346 additions and 613 deletions
|
|
@ -6,7 +6,7 @@ impl<A> When<A> {
|
|||
/// Create a binary condition.
|
||||
pub const fn new (c: bool, a: A) -> Self { Self(c, a) }
|
||||
}
|
||||
impl<E: Output, A: Render<E>> Content<E> for When<A> {
|
||||
impl<E: Output, A: Render<E>> Render<E> for When<A> {
|
||||
fn layout (&self, to: E::Area) -> E::Area {
|
||||
let Self(cond, item) = self;
|
||||
let mut area = E::Area::zero();
|
||||
|
|
@ -31,7 +31,7 @@ impl<A, B> Either<A, B> {
|
|||
/// Create a ternary view condition.
|
||||
pub const fn new (c: bool, a: A, b: B) -> Self { Self(c, a, b) }
|
||||
}
|
||||
impl<E: Output, A: Render<E>, B: Render<E>> Content<E> for Either<A, B> {
|
||||
impl<E: Output, A: Render<E>, B: Render<E>> Render<E> for Either<A, B> {
|
||||
fn layout (&self, to: E::Area) -> E::Area {
|
||||
let Self(cond, a, b) = self;
|
||||
if *cond { a.layout(to) } else { b.layout(to) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue