summaryrefslogtreecommitdiff
path: root/src/library/shape.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/shape.rs')
-rw-r--r--src/library/shape.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/library/shape.rs b/src/library/shape.rs
index dbd6eea7..5d9b4152 100644
--- a/src/library/shape.rs
+++ b/src/library/shape.rs
@@ -140,7 +140,7 @@ impl Layout for ShapeNode {
// When there's no child, fill the area if expansion is on,
// otherwise fall back to a default size.
let default = Length::pt(30.0);
- let size = Size::new(
+ let mut size = Size::new(
if regions.expand.x {
regions.current.w
} else {
@@ -154,6 +154,11 @@ impl Layout for ShapeNode {
if regions.expand.y { regions.current.h } else { default },
);
+ if matches!(self.kind, ShapeKind::Square | ShapeKind::Circle) {
+ size.w = size.w.min(size.h);
+ size.h = size.w;
+ }
+
Frame::new(size, size.h)
};
@@ -171,6 +176,13 @@ impl Layout for ShapeNode {
frame.prepend(pos, Element::Geometry(geometry, fill));
}
+ // Ensure frame size matches regions size if expansion is on.
+ let expand = regions.expand;
+ frame.size = Size::new(
+ if expand.x { regions.current.w } else { frame.size.w },
+ if expand.y { regions.current.h } else { frame.size.h },
+ );
+
// Return tight constraints for now.
let mut cts = Constraints::new(regions.expand);
cts.exact = regions.current.to_spec().map(Some);