mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-08-07 22:17:07 +02:00
draw: try to fix splits
This commit is contained in:
parent
e398541b7e
commit
7a0459756e
1 changed files with 31 additions and 14 deletions
|
|
@ -50,19 +50,36 @@ impl Split {
|
|||
thunk(move|to: &mut S|{
|
||||
let (area_a, area_b) = to.xywh().split_half(self);
|
||||
let (origin_a, origin_b) = self.origins();
|
||||
let a = a.align(origin_a);
|
||||
let b = b.align(origin_b);
|
||||
let (a, b) = match self {
|
||||
Self::Below => (
|
||||
to.show(area(area_b, b.align(origin_b)))?,
|
||||
to.show(area(area_b, a.align(origin_a)))?,
|
||||
),
|
||||
_ => (
|
||||
to.show(area(area_a, a.align(origin_a)))?,
|
||||
to.show(area(area_b, b.align(origin_b)))?,
|
||||
)
|
||||
};
|
||||
Ok(if let (Some(XYWH(xa, ya, wa, ha)), Some(XYWH(xb, yb, wb, hb))) = (a, b) {
|
||||
match self {
|
||||
Self::Below => {
|
||||
to.show(area(area_b, b))?;
|
||||
to.show(area(area_b, a))?;
|
||||
},
|
||||
_ => {
|
||||
to.show(area(area_a, a))?;
|
||||
to.show(area(area_b, b))?;
|
||||
Self::South =>
|
||||
Some(XYWH(xa.min(xb), ya, wa.max(wb), ha + hb)),
|
||||
Self::East =>
|
||||
Some(XYWH(xa, ya.min(yb), wa + wb, ha.max(hb))),
|
||||
Self::North =>
|
||||
Some(XYWH(xa.min(xb), yb, wa.max(wb), ha + hb)),
|
||||
Self::West =>
|
||||
Some(XYWH(xb, ya.min(yb), wa + wb, ha.max(hb))),
|
||||
Self::Above | Self::Below =>
|
||||
Some(XYWH(xa.min(xb), ya.min(yb), wa.max(wb), ha.max(hb))),
|
||||
}
|
||||
}
|
||||
Ok(Some(to.xywh())) // FIXME: compute and return actually used area
|
||||
} else if let Some(a) = a {
|
||||
Some(a)
|
||||
} else if let Some(b) = b {
|
||||
Some(b)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue