mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: refactor pt.29: 12 errors
This commit is contained in:
parent
ceead4131c
commit
ab85a86b6b
27 changed files with 1890 additions and 1865 deletions
|
|
@ -122,6 +122,21 @@ impl<E: Engine, W: Widget<Engine = E>> Widget for Option<W> {
|
|||
self.as_ref().map(|widget|widget.render(to)).unwrap_or(Ok(()))
|
||||
}
|
||||
}
|
||||
/// Render either of two widgets depending on predicate
|
||||
pub struct Either<E: Engine, A: Widget<Engine = E>, B: Widget<Engine = E>>(
|
||||
pub bool,
|
||||
pub A,
|
||||
pub B,
|
||||
);
|
||||
impl<E: Engine, A: Widget<Engine = E>, B: Widget<Engine = E>> Widget for Either<E, A, B> {
|
||||
type Engine = E;
|
||||
fn layout (&self, to: E::Size) -> Perhaps<E::Size> {
|
||||
if self.0 { self.1.layout(to) } else { self.2.layout(to) }
|
||||
}
|
||||
fn render (&self, to: &mut E::Output) -> Usually<()> {
|
||||
if self.0 { self.1.render(to) } else { self.2.render(to) }
|
||||
}
|
||||
}
|
||||
/// A custom [Widget] defined by passing layout and render closures in place.
|
||||
pub struct CustomWidget<
|
||||
E: Engine,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue