summaryrefslogtreecommitdiff
path: root/library/src/visualize/shape.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-04-06 12:25:55 +0200
committerLaurenz <laurmaedje@gmail.com>2023-04-06 12:26:39 +0200
commitf9b9be16f96d01ffb0587f65c8c32da9e9e4b3f5 (patch)
tree08395e4627bc669d2c6780f8e4885185d390d86b /library/src/visualize/shape.rs
parent23a884a67f4afde7541e4c39f22ff275f939a8f5 (diff)
Fix box and block sizing
Diffstat (limited to 'library/src/visualize/shape.rs')
-rw-r--r--library/src/visualize/shape.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/library/src/visualize/shape.rs b/library/src/visualize/shape.rs
index ba7f052f..c899ad6d 100644
--- a/library/src/visualize/shape.rs
+++ b/library/src/visualize/shape.rs
@@ -483,7 +483,7 @@ fn layout(
let mut frame;
if let Some(child) = body {
- let region = resolved.unwrap_or(regions.base());
+ let mut region = resolved.unwrap_or(regions.base());
if kind.is_round() {
inset = inset.map(|side| side + Ratio::new(0.5 - SQRT_2 / 4.0));
}
@@ -498,10 +498,13 @@ fn layout(
// the result is really a square or circle.
if kind.is_quadratic() {
let length = frame.size().max_by_side().min(region.min_by_side());
- let size = Size::splat(length);
- let pod = Regions::one(size, Axes::splat(true));
+ region = Size::splat(length);
+ let pod = Regions::one(region, Axes::splat(true));
frame = child.layout(vt, styles, pod)?.into_frame();
}
+
+ // Enforce correct size.
+ *frame.size_mut() = expand.select(region, frame.size());
} else {
// The default size that a shape takes on if it has no child and
// enough space.