mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 20:26:42 +01:00
wip: migrating to Widget trait
This commit is contained in:
parent
b944dd5f9e
commit
c4a5ee7b6e
4 changed files with 130 additions and 161 deletions
|
|
@ -24,7 +24,11 @@ impl Demo<Tui> {
|
|||
}));
|
||||
Self { index: 0, items }
|
||||
}
|
||||
fn content <'a> (&'a self) -> impl Layout<Tui> + 'a {
|
||||
}
|
||||
|
||||
impl<E: Engine> Content for Demo<E> {
|
||||
type Engine = E;
|
||||
fn content (&self) -> impl Widget<Engine = E> {
|
||||
Align::Center(Layers(&[
|
||||
&Outset::WH(2, 1, FillBg(Color::Rgb(0,128,128))),
|
||||
&Layers(&[
|
||||
|
|
@ -35,18 +39,6 @@ impl Demo<Tui> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Layout<Tui> for Demo<Tui> {
|
||||
fn layout (&self, area: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
self.content().layout(area)
|
||||
}
|
||||
}
|
||||
|
||||
impl Render<Tui> for Demo<Tui> {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
self.content().render(to)
|
||||
}
|
||||
}
|
||||
|
||||
impl Handle<Tui> for Demo<Tui> {
|
||||
fn handle (&mut self, from: &Tui) -> Perhaps<bool> {
|
||||
match from.event() {
|
||||
|
|
@ -62,7 +54,7 @@ impl Handle<Tui> for Demo<Tui> {
|
|||
};
|
||||
Ok(Some(true))
|
||||
},
|
||||
_ => Ok(None)
|
||||
_ => Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue