Skip to content

Commit

Permalink
Fixes for aspect ratio and min/max sizes (#317)
Browse files Browse the repository at this point in the history
* Add aspect ratio support to gentest script + add aspect ratio support to text node content sizing

* Add maybe_apply_aspect_ratio helper to Size<Option<f32>>

* Apply aspect ratio to leaf node style resolution

* Apply aspect ratio when doing final placement of grid items

* Make cargo gentest compile generator in release mode

* Add tests for aspect ratio of leaf nodes in grid containers

* Apply aspect ratio to grid container styles

* Apply aspect ratio to automatic minimum size

* Add tests for aspect ratio of content-sized leaf nodes

* Use main size for flex-basis if flex-basis is not set

* Resolve size, min_size, max_size against aspect ratio when generating flex items

* Add gentests for aspect-ratio in flex-row (align-start)

* Move aspect ratio handling from text measure func to leaf.rs

* Tweak clamping of flex item minimum sizes

* Add aspect ratio tests for flex-columns with align-items: start

* FLexbox: don't apply aspect ratio to max_width when clamping stretched cross-sizes

* Add tests for aspect ratio with align-items:stretch (flexbox)

* Apply aspect ratio to absolute children of flex container

* Remove duplicate test

* Namespace grid aspect ratio tests under grid

* Absolute positioning: Apply aspect ratio to inset-generated width before generating height from inset

* Add tests for aspect ratio height/width for absolutely positioned nodes

* Exclude hidden items from absolute positioning

* Apply min/max sizes when finally positioning grid items

* Add tests for interaction between inset and aspect ratio for absolutely positioned grid children

* Always apply margins to absolutely positioned grid items

* Rewrite flex item absolute positioning

It now:
- Applies margins correctly
- Applies min/max correctly
- Applies aspect ratio correctly

* Take border into account when absolutely positioning grid items relative to the grid container

* Add absolute positioning margin test

* Apply suggestions from code review

Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>

* Update release notes

* Add test for absolutely positioned fallback to static position of grid item in container with border

* Implement Add for Rect where the inner type implements Add

* Apply aspect ratio and min/max size to flex container size

* Cleanup TODOs in the flexbox algorithm

* Remove one more TODO

* Add min/max size tests for absolutely positioned flex items

* Move absolute flex positioning aspect ratio tests under absolute namespace

* Clamp available_space by min/max size for final layout

* Add tests for applying aspect ratio to min/max size of flex items

Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>
  • Loading branch information
nicoburns and Weibye committed Jan 12, 2023
1 parent 06a168c commit 610c92f
Show file tree
Hide file tree
Showing 256 changed files with 7,001 additions and 327 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
@@ -1,2 +1,2 @@
[alias]
gentest = "run --package gentest --"
gentest = "run --release --package gentest --"
3 changes: 3 additions & 0 deletions RELEASES.md
Expand Up @@ -13,6 +13,9 @@
### Fixes

- Flexbox nodes sized under a min-content constraint now size correctly (#291)
- Aspect ratio is now applied correctly in many circumstances
- Absolutely positioned items now apply margins correctly
- Min/max size are now applied correctly

### Removed

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions benches/generated/absolute_aspect_ratio_fill_height.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions benches/generated/absolute_aspect_ratio_fill_height_from_inset.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions benches/generated/absolute_aspect_ratio_fill_max_height.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions benches/generated/absolute_aspect_ratio_fill_max_width.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions benches/generated/absolute_aspect_ratio_fill_min_height.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions benches/generated/absolute_aspect_ratio_fill_min_width.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions benches/generated/absolute_aspect_ratio_fill_width.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions benches/generated/absolute_aspect_ratio_fill_width_from_inset.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions benches/generated/absolute_aspect_ratio_height_overrides_inset.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions benches/generated/absolute_aspect_ratio_width_overrides_inset.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions benches/generated/absolute_margin_bottom_left.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 610c92f

Please sign in to comment.