diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-11-25 20:51:16 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-11-25 20:51:16 +0100 |
| commit | 393d74f9bb0d4c71a69108d5be261103c39f47f3 (patch) | |
| tree | a1d4219de2d8fbec1a16ac3760a95e0b7c9529c5 /src/library/shape.rs | |
| parent | 304d9dd1107504f3925c2593dd279ea6616defab (diff) | |
Layout improvements
Diffstat (limited to 'src/library/shape.rs')
| -rw-r--r-- | src/library/shape.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/library/shape.rs b/src/library/shape.rs index 5d3504d0..36e25b3c 100644 --- a/src/library/shape.rs +++ b/src/library/shape.rs @@ -165,12 +165,16 @@ impl Layout for ShapeNode { if regions.expand.y { regions.current.h } else { default }, ); + // Don't overflow the region. + size.w = size.w.min(regions.current.w); + size.h = size.h.min(regions.current.h); + if matches!(self.kind, ShapeKind::Square | ShapeKind::Circle) { size.w = size.w.min(size.h); size.h = size.w; } - Frame::new(size, size.h) + Frame::new(size) }; // Add fill and/or stroke. @@ -197,9 +201,6 @@ impl Layout for ShapeNode { ); // Return tight constraints for now. - let mut cts = Constraints::new(regions.expand); - cts.exact = regions.current.to_spec().map(Some); - cts.base = regions.base.to_spec().map(Some); - vec![frame.constrain(cts)] + vec![frame.constrain(Constraints::tight(regions))] } } |
