mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: Outset=Center+2*Grow, Inset=Center+2*Shrink
This commit is contained in:
parent
c9b79e76fc
commit
4b413cfb60
2 changed files with 203 additions and 120 deletions
|
|
@ -418,13 +418,11 @@ impl<N: Number, T> Min<N, T> {
|
||||||
impl<E: Engine, T: Widget<Engine = E>> Widget for Min<E::Unit, T> {
|
impl<E: Engine, T: Widget<Engine = E>> Widget for Min<E::Unit, T> {
|
||||||
type Engine = E;
|
type Engine = E;
|
||||||
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
||||||
Ok(match self {
|
Ok(self.inner().layout(to)?.map(|to|match *self {
|
||||||
Self::X(w, _) => (to.w() < *w).then(||[to.x() + *w, to.y(), to.w() - *w, to.h()]),
|
Self::X(w, _) => [to.x(), to.y(), to.w().max(w), to.h()],
|
||||||
Self::Y(h, _) => (to.h() < *h).then(||[to.x(), to.y() + *h, to.w(), to.h() - *h]),
|
Self::Y(h, _) => [to.x(), to.y(), to.w(), to.h().max(h)],
|
||||||
Self::XY(w, h, _) => (to.w() < *w || to.h() < *h).then(||[
|
Self::XY(w, h, _) => [to.x(), to.y(), to.w().max(w), to.h().max(h)],
|
||||||
to.x() + *w, to.y() + *h, to.w() - *w, to.h() - *h
|
}.into()))
|
||||||
])
|
|
||||||
}.map(|stretched|self.inner().layout(stretched.into())).transpose()?.flatten())
|
|
||||||
}
|
}
|
||||||
// TODO: 🡘 🡙 ←🡙→
|
// TODO: 🡘 🡙 ←🡙→
|
||||||
fn render (&self, to: &mut E) -> Perhaps<E::Area> {
|
fn render (&self, to: &mut E) -> Perhaps<E::Area> {
|
||||||
|
|
@ -451,13 +449,11 @@ impl<N: Number, T> Max<N, T> {
|
||||||
impl<E: Engine, T: Widget<Engine = E>> Widget for Max<E:: Unit, T> {
|
impl<E: Engine, T: Widget<Engine = E>> Widget for Max<E:: Unit, T> {
|
||||||
type Engine = E;
|
type Engine = E;
|
||||||
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
||||||
Ok(match self {
|
Ok(self.inner().layout(to)?.map(|to|match *self {
|
||||||
Self::X(w, _) => (*w <= to.w()).then(||[to.x(), to.y(), to.w().min(*w), to.h()]),
|
Self::X(w, _) => [to.x(), to.y(), to.w().min(w), to.h()],
|
||||||
Self::Y(h, _) => (*h <= to.h()).then(||[to.x(), to.y(), to.w(), to.h().min(*h)]),
|
Self::Y(h, _) => [to.x(), to.y(), to.w(), to.h().min(h)],
|
||||||
Self::XY(w, h, _) => (*w <= to.w() || *h <= to.h()).then(||[
|
Self::XY(w, h, _) => [to.x(), to.y(), to.w().min(w), to.h().min(h)],
|
||||||
to.x(), to.y(), to.w().min(*w), to.h().min(*h)
|
}.into()))
|
||||||
])
|
|
||||||
}.map(|clamped|self.inner().layout(clamped.into())).transpose()?.flatten())
|
|
||||||
}
|
}
|
||||||
fn render (&self, to: &mut E) -> Perhaps<E::Area> {
|
fn render (&self, to: &mut E) -> Perhaps<E::Area> {
|
||||||
Ok(self.layout(to.area())?.map(|a|to.render_in(a, self.inner())).transpose()?.flatten())
|
Ok(self.layout(to.area())?.map(|a|to.render_in(a, self.inner())).transpose()?.flatten())
|
||||||
|
|
@ -465,7 +461,7 @@ impl<E: Engine, T: Widget<Engine = E>> Widget for Max<E:: Unit, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Expand drawing area
|
/// Expand drawing area
|
||||||
pub enum Outset<N: Number, T> {
|
pub enum Grow<N: Number, T> {
|
||||||
/// Increase width
|
/// Increase width
|
||||||
X(N, T),
|
X(N, T),
|
||||||
/// Increase height
|
/// Increase height
|
||||||
|
|
@ -474,22 +470,20 @@ pub enum Outset<N: Number, T> {
|
||||||
XY(N, N, T)
|
XY(N, N, T)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Number, T> Outset<N, T> {
|
impl<N: Number, T> Grow<N, T> {
|
||||||
fn inner (&self) -> &T {
|
fn inner (&self) -> &T {
|
||||||
match self { Self::X(_, i) => i, Self::Y(_, i) => i, Self::XY(_, _, i) => i, }
|
match self { Self::X(_, i) => i, Self::Y(_, i) => i, Self::XY(_, _, i) => i, }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Engine, T: Widget<Engine = E>> Widget for Outset<E::Unit, T> {
|
impl<E: Engine, T: Widget<Engine = E>> Widget for Grow<E::Unit, T> {
|
||||||
type Engine = E;
|
type Engine = E;
|
||||||
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
||||||
Ok(match self {
|
Ok(self.inner().layout(to)?.map(|to|match *self {
|
||||||
Self::X(w, _) => (*w <= to.w()).then(||[to.x() - *w, to.y(), to.w() + *w + *w, to.h()]),
|
Self::X(w, _) => [to.x(), to.y(), to.w() + w, to.h()],
|
||||||
Self::Y(h, _) => (*h <= to.h()).then(||[to.x(), to.y() - *h, to.w(), to.h() + *h + *h]),
|
Self::Y(h, _) => [to.x(), to.y(), to.w(), to.h() + h],
|
||||||
Self::XY(w, h, _) => (*w <= to.w() || *h <= to.h()).then(||[
|
Self::XY(w, h, _) => [to.x(), to.y(), to.w() + w, to.h() + h],
|
||||||
to.x()- *w, to.y() - *h, to.w() + *w + *w, to.h() + *h + *h
|
}.into()))
|
||||||
])
|
|
||||||
}.map(|grown|self.inner().layout(grown.into())).transpose()?.flatten())
|
|
||||||
}
|
}
|
||||||
fn render (&self, to: &mut E) -> Perhaps<E::Area> {
|
fn render (&self, to: &mut E) -> Perhaps<E::Area> {
|
||||||
Ok(self.layout(to.area())?.map(|a|to.render_in(a, self.inner())).transpose()?.flatten())
|
Ok(self.layout(to.area())?.map(|a|to.render_in(a, self.inner())).transpose()?.flatten())
|
||||||
|
|
@ -497,6 +491,36 @@ impl<E: Engine, T: Widget<Engine = E>> Widget for Outset<E::Unit, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shrink drawing area
|
/// Shrink drawing area
|
||||||
|
pub enum Shrink<N: Number, T> {
|
||||||
|
/// Decrease width
|
||||||
|
X(N, T),
|
||||||
|
/// Decrease height
|
||||||
|
Y(N, T),
|
||||||
|
/// Decrease width and height
|
||||||
|
XY(N, N, T),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Number, T: Widget> Shrink<N, T> {
|
||||||
|
fn inner (&self) -> &T {
|
||||||
|
match self { Self::X(_, i) => i, Self::Y(_, i) => i, Self::XY(_, _, i) => i, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<E: Engine, T: Widget<Engine = E>> Widget for Shrink<E::Unit, T> {
|
||||||
|
type Engine = E;
|
||||||
|
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
||||||
|
Ok(self.inner().layout(to)?.map(|to|match *self {
|
||||||
|
Self::X(w, _) => [to.x(), to.y(), to.w() - w, to.h()],
|
||||||
|
Self::Y(h, _) => [to.x(), to.y(), to.w(), to.h() - h],
|
||||||
|
Self::XY(w, h, _) => [to.x(), to.y(), to.w() - w, to.h() - h]
|
||||||
|
}.into()))
|
||||||
|
}
|
||||||
|
fn render (&self, to: &mut E) -> Perhaps<E::Area> {
|
||||||
|
Ok(self.layout(to.area())?.map(|a|to.render_in(a, self.inner())).transpose()?.flatten())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Shrink from each side
|
||||||
pub enum Inset<N: Number, T> {
|
pub enum Inset<N: Number, T> {
|
||||||
/// Decrease width
|
/// Decrease width
|
||||||
X(N, T),
|
X(N, T),
|
||||||
|
|
@ -512,19 +536,41 @@ impl<N: Number, T: Widget> Inset<N, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Engine, T: Widget<Engine = E>> Widget for Inset<E::Unit, T> {
|
impl<E: Engine, T: Widget<Engine = E>> Content for Inset<E::Unit, T> {
|
||||||
type Engine = E;
|
type Engine = E;
|
||||||
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
fn content (&self) -> impl Widget<Engine = E> {
|
||||||
Ok(match self {
|
Align::Center(match *self {
|
||||||
Self::X(w, _) => (*w <= to.w()).then(||[to.x() + *w, to.y(), to.w() - *w, to.h()]),
|
Self::X(x, inner) => Shrink::X(x + x, inner),
|
||||||
Self::Y(h, _) => (*h <= to.h()).then(||[to.x(), to.y() + *h, to.w(), to.h() - *h]),
|
Self::Y(y, inner) => Shrink::X(y + y, inner),
|
||||||
Self::XY(w, h, _) => (*w <= to.w() || *h <= to.h()).then(||[
|
Self::XY(x, y, inner) => Shrink::XY(x, y, inner),
|
||||||
to.x() - *w, to.y() - *h, to.w() + *w, to.h() + *h
|
})
|
||||||
])
|
|
||||||
}.map(|shrunk|self.inner().layout(shrunk.into())).transpose()?.flatten())
|
|
||||||
}
|
}
|
||||||
fn render (&self, to: &mut E) -> Perhaps<E::Area> {
|
}
|
||||||
Ok(self.layout(to.area())?.map(|a|to.render_in(a, self.inner())).transpose()?.flatten())
|
|
||||||
|
/// Grow on each side
|
||||||
|
pub enum Outset<N: Number, T> {
|
||||||
|
/// Increase width
|
||||||
|
X(N, T),
|
||||||
|
/// Increase height
|
||||||
|
Y(N, T),
|
||||||
|
/// Increase width and height
|
||||||
|
XY(N, N, T),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Number, T: Widget> Outset<N, T> {
|
||||||
|
fn inner (&self) -> &T {
|
||||||
|
match self { Self::X(_, i) => i, Self::Y(_, i) => i, Self::XY(_, _, i) => i, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<E: Engine, T: Widget<Engine = E>> Content for Outset<E::Unit, T> {
|
||||||
|
type Engine = E;
|
||||||
|
fn content (&self) -> impl Widget<Engine = E> {
|
||||||
|
Align::Center(match self {
|
||||||
|
Self::X(x, inner) => Grow::X(*x + *x, inner),
|
||||||
|
Self::Y(y, inner) => Grow::X(*y + *y, inner),
|
||||||
|
Self::XY(x, y, inner) => Grow::XY(*x, *y, inner),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -553,13 +599,11 @@ impl<N: Number, T: Widget> Offset<N, T> {
|
||||||
impl<E: Engine, T: Widget<Engine = E>> Widget for Offset<E::Unit, T> {
|
impl<E: Engine, T: Widget<Engine = E>> Widget for Offset<E::Unit, T> {
|
||||||
type Engine = E;
|
type Engine = E;
|
||||||
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
||||||
Ok(match self {
|
Ok(self.inner().layout(to)?.map(|to|match *self {
|
||||||
Self::X(w, _) => (*w <= to.w()).then(||[to.x() + *w, to.y(), to.w() - *w, to.h()]),
|
Self::X(x, _) => [to.x() + x, to.y(), to.w(), to.h()],
|
||||||
Self::Y(h, _) => (*h <= to.h()).then(||[to.x(), to.y() + *h, to.w(), to.h() - *h]),
|
Self::Y(y, _) => [to.x(), to.y() + y, to.w(), to.h()],
|
||||||
Self::XY(w, h, _) => (*w <= to.w() || *h <= to.h()).then(||[
|
Self::XY(x, y, _) => [to.x() + x, to.y() + y, to.w(), to.h()]
|
||||||
to.x() + *w, to.y() + *h, to.w() - *w, to.h() - *h
|
}.into()))
|
||||||
])
|
|
||||||
}.map(|shifted|self.inner().layout(shifted.into())).transpose()?.flatten())
|
|
||||||
}
|
}
|
||||||
fn render (&self, to: &mut E) -> Perhaps<E::Area> {
|
fn render (&self, to: &mut E) -> Perhaps<E::Area> {
|
||||||
Ok(self.layout(to.area())?.map(|a|to.render_in(a, self.inner())).transpose()?.flatten())
|
Ok(self.layout(to.area())?.map(|a|to.render_in(a, self.inner())).transpose()?.flatten())
|
||||||
|
|
|
||||||
|
|
@ -14,87 +14,126 @@ impl Widget for TestArea {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_offset () -> Usually<()> {
|
fn test_misc () -> Usually<()> {
|
||||||
let area: [u16;4] = [50, 50, 100, 100];
|
let area: [u16;4] = [0, 0, 10, 10];
|
||||||
let test = TestArea(3, 3);
|
let test = TestArea(4, 4);
|
||||||
assert_eq!(Offset::X(1, test).layout(area)?, Some([51, 50, 3, 3]));
|
assert_eq!(test.layout(area)?,
|
||||||
assert_eq!(Offset::Y(1, test).layout(area)?, Some([50, 51, 3, 3]));
|
Some([0, 0, 4, 4]));
|
||||||
assert_eq!(Offset::XY(1, 1, test).layout(area)?, Some([51, 51, 3, 3]));
|
assert_eq!(Align::Center(test).layout(area)?,
|
||||||
Ok(())
|
Some([3, 3, 4, 4]));
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_outset () -> Usually<()> {
|
|
||||||
let area: [u16;4] = [50, 50, 100, 100];
|
|
||||||
let test = TestArea(3, 3);
|
|
||||||
assert_eq!(Outset::X(1, test).layout(area)?, Some([49, 50, 5, 1]));
|
|
||||||
assert_eq!(Outset::Y(1, test).layout(area)?, Some([50, 49, 1, 5]));
|
|
||||||
assert_eq!(Outset::XY(1, 1, test).layout(area)?, Some([49, 49, 5, 5]));
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_inset () -> Usually<()> {
|
|
||||||
let area: [u16;4] = [50, 50, 100, 100];
|
|
||||||
let test = TestArea(3, 3);
|
|
||||||
assert_eq!(Inset::X(1, test).layout(area)?, Some([51, 50, 1, 3]));
|
|
||||||
assert_eq!(Inset::Y(1, test).layout(area)?, Some([50, 51, 3, 1]));
|
|
||||||
assert_eq!(Inset::XY(1, 1, test).layout(area)?, Some([51, 51, 1, 1]));
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_stuff () -> Usually<()> {
|
|
||||||
let area: [u16;4] = [0, 0, 100, 100];
|
|
||||||
assert_eq!("1".layout(area)?,
|
|
||||||
Some([0, 0, 1, 1]));
|
|
||||||
assert_eq!("333".layout(area)?,
|
|
||||||
Some([0, 0, 3, 1]));
|
|
||||||
assert_eq!(Layers::new(|add|{add(&"1")?;add(&"333")}).layout(area)?,
|
|
||||||
Some([0, 0, 3, 1]));
|
|
||||||
assert_eq!(Split::down(|add|{add(&"1")?;add(&"333")}).layout(area)?,
|
|
||||||
Some([0, 0, 3, 2]));
|
|
||||||
assert_eq!(Split::right(|add|{add(&"1")?;add(&"333")}).layout(area)?,
|
|
||||||
Some([0, 0, 4, 1]));
|
|
||||||
assert_eq!(Split::down(|add|{
|
|
||||||
add(&Split::right(|add|{add(&"1")?;add(&"333")}))?;
|
|
||||||
add(&"55555")
|
|
||||||
}).layout(area)?,
|
|
||||||
Some([0, 0, 5, 2]));
|
|
||||||
let area: [u16;4] = [1, 1, 100, 100];
|
|
||||||
assert_eq!(Outset::X(1, Split::right(|add|{add(&"1")?;add(&"333")})).layout(area)?,
|
|
||||||
Some([0, 1, 6, 1]));
|
|
||||||
assert_eq!(Outset::Y(1, Split::right(|add|{add(&"1")?;add(&"333")})).layout(area)?,
|
|
||||||
Some([1, 0, 4, 3]));
|
|
||||||
assert_eq!(Outset::XY(1, 1, Split::right(|add|{add(&"1")?;add(&"333")})).layout(area)?,
|
|
||||||
Some([0, 0, 6, 3]));
|
|
||||||
assert_eq!(Split::down(|add|{
|
|
||||||
add(&Outset::XY(1, 1, "1"))?;
|
|
||||||
add(&Outset::XY(1, 1, "333"))
|
|
||||||
}).layout(area)?,
|
|
||||||
Some([1, 1, 5, 6]));
|
|
||||||
let area: [u16;4] = [1, 1, 95, 100];
|
|
||||||
assert_eq!(Align::Center(Split::down(|add|{
|
assert_eq!(Align::Center(Split::down(|add|{
|
||||||
add(&Outset::XY(1, 1, "1"))?;
|
add(&test)?;
|
||||||
add(&Outset::XY(1, 1, "333"))
|
add(&test)
|
||||||
})).layout(area)?,
|
})).layout(area)?,
|
||||||
Some([46, 48, 5, 6]));
|
Some([3, 1, 4, 8]));
|
||||||
assert_eq!(Align::Center(Split::down(|add|{
|
assert_eq!(Align::Center(Split::down(|add|{
|
||||||
add(&Layers::new(|add|{
|
add(&Outset::XY(2, 2, test))?;
|
||||||
//add(&Outset::XY(1, 1, FillBg(Color::Rgb(0,128,0))))?;
|
add(&test)
|
||||||
add(&Outset::XY(1, 1, "1"))?;
|
})).layout(area)?,
|
||||||
add(&Outset::XY(1, 1, "333"))?;
|
Some([2, 0, 6, 10]));
|
||||||
//add(&FillBg(Color::Rgb(0,128,0)))?;
|
assert_eq!(Align::Center(Split::down(|add|{
|
||||||
Ok(())
|
add(&Outset::XY(2, 2, test))?;
|
||||||
|
add(&Inset::XY(2, 2, test))
|
||||||
|
})).layout(area)?,
|
||||||
|
Some([2, 1, 6, 8]));
|
||||||
|
assert_eq!(Split::down(|add|{
|
||||||
|
add(&Outset::XY(2, 2, test))?;
|
||||||
|
add(&Inset::XY(2, 2, test))
|
||||||
|
}).layout(area)?,
|
||||||
|
Some([0, 0, 6, 8]));
|
||||||
|
assert_eq!(Split::right(|add|{
|
||||||
|
add(&Split::down(|add|{
|
||||||
|
add(&Outset::XY(2, 2, test))?;
|
||||||
|
add(&Inset::XY(2, 2, test))
|
||||||
}))?;
|
}))?;
|
||||||
add(&Layers::new(|add|{
|
add(&Align::Center(TestArea(2 ,2)))
|
||||||
//add(&Outset::XY(1, 1, FillBg(Color::Rgb(0,0,128))))?;
|
}).layout(area)?,
|
||||||
add(&Outset::XY(1, 1, "555"))?;
|
Some([0, 0, 8, 8]));
|
||||||
add(&Outset::XY(1, 1, "777777"))?;
|
|
||||||
//add(&FillBg(Color::Rgb(0,0,128)))?;
|
|
||||||
Ok(())
|
|
||||||
}))
|
|
||||||
})).layout(area)?,
|
|
||||||
Some([46, 48, 5, 6]));
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#[test]
|
||||||
|
//fn test_offset () -> Usually<()> {
|
||||||
|
//let area: [u16;4] = [50, 50, 100, 100];
|
||||||
|
//let test = TestArea(3, 3);
|
||||||
|
//assert_eq!(Offset::X(1, test).layout(area)?, Some([51, 50, 3, 3]));
|
||||||
|
//assert_eq!(Offset::Y(1, test).layout(area)?, Some([50, 51, 3, 3]));
|
||||||
|
//assert_eq!(Offset::XY(1, 1, test).layout(area)?, Some([51, 51, 3, 3]));
|
||||||
|
//Ok(())
|
||||||
|
//}
|
||||||
|
|
||||||
|
//#[test]
|
||||||
|
//fn test_outset () -> Usually<()> {
|
||||||
|
//let area: [u16;4] = [50, 50, 100, 100];
|
||||||
|
//let test = TestArea(3, 3);
|
||||||
|
//assert_eq!(Outset::X(1, test).layout(area)?, Some([49, 50, 5, 3]));
|
||||||
|
//assert_eq!(Outset::Y(1, test).layout(area)?, Some([50, 49, 3, 5]));
|
||||||
|
//assert_eq!(Outset::XY(1, 1, test).layout(area)?, Some([49, 49, 5, 5]));
|
||||||
|
//Ok(())
|
||||||
|
//}
|
||||||
|
|
||||||
|
//#[test]
|
||||||
|
//fn test_inset () -> Usually<()> {
|
||||||
|
//let area: [u16;4] = [50, 50, 100, 100];
|
||||||
|
//let test = TestArea(3, 3);
|
||||||
|
//assert_eq!(Inset::X(1, test).layout(area)?, Some([51, 50, 1, 3]));
|
||||||
|
//assert_eq!(Inset::Y(1, test).layout(area)?, Some([50, 51, 3, 1]));
|
||||||
|
//assert_eq!(Inset::XY(1, 1, test).layout(area)?, Some([51, 51, 1, 1]));
|
||||||
|
//Ok(())
|
||||||
|
//}
|
||||||
|
|
||||||
|
//#[test]
|
||||||
|
//fn test_stuff () -> Usually<()> {
|
||||||
|
//let area: [u16;4] = [0, 0, 100, 100];
|
||||||
|
//assert_eq!("1".layout(area)?,
|
||||||
|
//Some([0, 0, 1, 1]));
|
||||||
|
//assert_eq!("333".layout(area)?,
|
||||||
|
//Some([0, 0, 3, 1]));
|
||||||
|
//assert_eq!(Layers::new(|add|{add(&"1")?;add(&"333")}).layout(area)?,
|
||||||
|
//Some([0, 0, 3, 1]));
|
||||||
|
//assert_eq!(Split::down(|add|{add(&"1")?;add(&"333")}).layout(area)?,
|
||||||
|
//Some([0, 0, 3, 2]));
|
||||||
|
//assert_eq!(Split::right(|add|{add(&"1")?;add(&"333")}).layout(area)?,
|
||||||
|
//Some([0, 0, 4, 1]));
|
||||||
|
//assert_eq!(Split::down(|add|{
|
||||||
|
//add(&Split::right(|add|{add(&"1")?;add(&"333")}))?;
|
||||||
|
//add(&"55555")
|
||||||
|
//}).layout(area)?,
|
||||||
|
//Some([0, 0, 5, 2]));
|
||||||
|
//let area: [u16;4] = [1, 1, 100, 100];
|
||||||
|
//assert_eq!(Outset::X(1, Split::right(|add|{add(&"1")?;add(&"333")})).layout(area)?,
|
||||||
|
//Some([0, 1, 6, 1]));
|
||||||
|
//assert_eq!(Outset::Y(1, Split::right(|add|{add(&"1")?;add(&"333")})).layout(area)?,
|
||||||
|
//Some([1, 0, 4, 3]));
|
||||||
|
//assert_eq!(Outset::XY(1, 1, Split::right(|add|{add(&"1")?;add(&"333")})).layout(area)?,
|
||||||
|
//Some([0, 0, 6, 3]));
|
||||||
|
//assert_eq!(Split::down(|add|{
|
||||||
|
//add(&Outset::XY(1, 1, "1"))?;
|
||||||
|
//add(&Outset::XY(1, 1, "333"))
|
||||||
|
//}).layout(area)?,
|
||||||
|
//Some([1, 1, 5, 6]));
|
||||||
|
//let area: [u16;4] = [1, 1, 95, 100];
|
||||||
|
//assert_eq!(Align::Center(Split::down(|add|{
|
||||||
|
//add(&Outset::XY(1, 1, "1"))?;
|
||||||
|
//add(&Outset::XY(1, 1, "333"))
|
||||||
|
//})).layout(area)?,
|
||||||
|
//Some([46, 48, 5, 6]));
|
||||||
|
//assert_eq!(Align::Center(Split::down(|add|{
|
||||||
|
//add(&Layers::new(|add|{
|
||||||
|
////add(&Outset::XY(1, 1, FillBg(Color::Rgb(0,128,0))))?;
|
||||||
|
//add(&Outset::XY(1, 1, "1"))?;
|
||||||
|
//add(&Outset::XY(1, 1, "333"))?;
|
||||||
|
////add(&FillBg(Color::Rgb(0,128,0)))?;
|
||||||
|
//Ok(())
|
||||||
|
//}))?;
|
||||||
|
//add(&Layers::new(|add|{
|
||||||
|
////add(&Outset::XY(1, 1, FillBg(Color::Rgb(0,0,128))))?;
|
||||||
|
//add(&Outset::XY(1, 1, "555"))?;
|
||||||
|
//add(&Outset::XY(1, 1, "777777"))?;
|
||||||
|
////add(&FillBg(Color::Rgb(0,0,128)))?;
|
||||||
|
//Ok(())
|
||||||
|
//}))
|
||||||
|
//})).layout(area)?,
|
||||||
|
//Some([46, 48, 5, 6]));
|
||||||
|
//Ok(())
|
||||||
|
//}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue