mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
split Outset into 2 phases
This commit is contained in:
parent
00da7de142
commit
a0fbbc6257
3 changed files with 76 additions and 22 deletions
|
|
@ -568,12 +568,8 @@ where
|
|||
Ok(Some([x, y, w, h]))
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
let layout = self.layout(to.area())?;
|
||||
self.layout(to.area())?
|
||||
.map(|area|(self.0)(&mut |layer| {
|
||||
to.render_in(area, &layer)?;
|
||||
Ok(())
|
||||
}).map(|_|area))
|
||||
.map(|area|(self.0)(&mut |layer|to.render_in(area, &layer).map(|_|())).map(|_|area))
|
||||
.transpose()
|
||||
}
|
||||
}
|
||||
|
|
@ -606,19 +602,36 @@ impl<T: Widget<Engine = Tui>> Content for Inset<u16, T> {
|
|||
//}
|
||||
//}
|
||||
|
||||
impl<T: Widget<Engine = Tui>> Content for Outset<u16, T> {
|
||||
impl<T: Widget<Engine = Tui>> Widget for Outset<u16, T> {
|
||||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
fn layout (&self, to: [u16;4]) -> Perhaps<[u16;4]> {
|
||||
match *self {
|
||||
Self::X(x, ref inner) =>
|
||||
Grow::X(x + x, inner as &dyn Widget<Engine = Tui>),
|
||||
Self::Y(y, ref inner) =>
|
||||
Grow::Y(y + y, inner as &dyn Widget<Engine = Tui>),
|
||||
Self::XY(x, y, ref inner) =>
|
||||
Grow::XY(x, y, inner as &dyn Widget<Engine = Tui>),
|
||||
}
|
||||
Self::X(x, ref inner) => Grow::X(x + x, inner as &dyn Widget<Engine = Tui>),
|
||||
Self::Y(y, ref inner) => Grow::Y(y + y, inner as &dyn Widget<Engine = Tui>),
|
||||
Self::XY(x, y, ref inner) => Grow::XY(x + x, y + y, inner as &dyn Widget<Engine = Tui>),
|
||||
}.layout(to)
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
match *self {
|
||||
Self::X(x, ref inner) => Plus::X(x, inner as &dyn Widget<Engine = Tui>),
|
||||
Self::Y(y, ref inner) => Plus::Y(y, inner as &dyn Widget<Engine = Tui>),
|
||||
Self::XY(x, y, ref inner) => Plus::XY(x, y, inner as &dyn Widget<Engine = Tui>),
|
||||
}.render(to)
|
||||
}
|
||||
}
|
||||
//impl<T: Widget<Engine = Tui>> Content for Outset<u16, T> {
|
||||
//type Engine = Tui;
|
||||
//fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
//match *self {
|
||||
//Self::X(x, ref inner) =>
|
||||
//Grow::X(x + x, inner as &dyn Widget<Engine = Tui>),
|
||||
//Self::Y(y, ref inner) =>
|
||||
//Grow::Y(y + y, inner as &dyn Widget<Engine = Tui>),
|
||||
//Self::XY(x, y, ref inner) =>
|
||||
//Grow::XY(x, y, inner as &dyn Widget<Engine = Tui>),
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
|
||||
pub trait BorderStyle {
|
||||
const NW: &'static str = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue