diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-11-17 17:09:19 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-11-17 17:09:19 +0100 |
| commit | 89f2e71852e96062ea9b756bf92fbf4e894871b1 (patch) | |
| tree | 836099ebd17adf30a24fc62464dfdd3d9c248480 /src/library/shape.rs | |
| parent | 9a800daa82833c57eee04e92c701ca9a05a67d3b (diff) | |
Align node
Diffstat (limited to 'src/library/shape.rs')
| -rw-r--r-- | src/library/shape.rs | 14 |
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); |
