Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Grid * expansion when size is larger than minimum, but less than sufficient to display full size #14902

Merged
merged 16 commits into from
May 16, 2023

Conversation

hartez
Copy link
Contributor

@hartez hartez commented May 3, 2023

Description of Change

(This is an expansion of the fix in #14114, which handled part of this problem on Windows, but didn't successfully fix it on Android and iOS. It also caused havoc in several other layout situations.)

When a Grid with * rows/columns is measured, the measurement should return the minimal values for those rows/columns to contain their content. When the Grid is arranged, those *s should (in some situations) be expanded to fill in the extra space if the arranged size is larger than the measured size. The size of those *s should be maxed out at what the Grid constraints allow for, and should not grow past that even if the contained controls return overly large sizes from measure (the situation described in #14818).

However - that expansion should not automatically be to the full potential size of the * rows/columns if the target size is not sufficient to contain it. Instead, the expansion should be distributed among the available space so that the smallest * rows/columns expand at the greatest rate until all rows/columns can be expanded to their full size.

This PR handles that expansion properly, and also avoids the rounding errors described in #14694. This includes smoothly expanding as the window size is changed in environments (e.g., Desktop) where that's an issue. This also adds tests for the problem behavior in #14818, and does not allow controls to force the sizes of their * rows/columns beyond the confines of the Grid.

In this PR:

  • New tests to cover the various permutations of the situations described above
  • Some cleanup and clarification of old tests
  • Removal of vestigial methods in GridStructure
  • A lot of method renaming in GridStructure to clarify what it's doing

Issues Fixed

Fixes #14694
Fixes #14818

@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2023

Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines.

@Eilon Eilon added the area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter label May 3, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2023

Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines.

@hartez hartez marked this pull request as ready for review May 3, 2023 22:44
@PureWeen PureWeen self-assigned this May 15, 2023
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's still an issue on iOS here

I've rebased on main and used the code you have here
#14694

image

@hartez
Copy link
Contributor Author

hartez commented May 16, 2023

I think there's still an issue on iOS here

I've rebased on main and used the code you have here #14694

image

Okay, should be fixed now. The changes were pointing up a long-standing problem with the ContentView/LayoutView backing controls, where they were measuring unnecessarily during LayoutSubviews.

@PureWeen PureWeen merged commit f54222a into main May 16, 2023
@PureWeen PureWeen deleted the fix-14694 branch May 16, 2023 16:47
rmarinho pushed a commit that referenced this pull request May 30, 2023
…an sufficient to display full size (#14902)

* Add tests for overlapping stuff, checkpoint before working out the multiple arrange stuff

* Working, just needs a lot of cleanup

* More cleanup

* Break down decompress method

* Add test for multiple Arrange calls

* More comprehensive test for multiple Arrange calls

* No longer need the Available* methods

* Pare down star decompression

* Fix empty star row/column error

* Make the grid structure methods clearer in their purpose

* Remove return from ResolveStars

* Auto-format source code

* Account for greedy control measurement behavior

* Auto-format source code

* Remove extraneous using

* Prevent unnecessary LayoutSubviews in xplat backing controls

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
@hartez hartez added the backport/suggested The PR author or issue review has suggested that the change should be backported. label May 31, 2023
@hartez hartez mentioned this pull request May 31, 2023
@hartez hartez added the backport/approved After some discussion or review, this PR or change was approved to be backported. label Jun 14, 2023
@hartez
Copy link
Contributor Author

hartez commented Jun 14, 2023

/backport to net7.0

@github-actions
Copy link
Contributor

Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/5270861797

@github-actions
Copy link
Contributor

@hartez backporting to net7.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Add tests for overlapping stuff, checkpoint before working out the multiple arrange stuff
Applying: Working, just needs a lot of cleanup
error: sha1 information is lacking or useless (src/Core/src/Layouts/GridLayoutManager.cs).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0002 Working, just needs a lot of cleanup
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

@hartez an error occurred while backporting to net7.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

hartez added a commit that referenced this pull request Jun 14, 2023
…an sufficient to display full size (#14902)

* Add tests for overlapping stuff, checkpoint before working out the multiple arrange stuff

* Working, just needs a lot of cleanup

* More cleanup

* Break down decompress method

* Add test for multiple Arrange calls

* More comprehensive test for multiple Arrange calls

* No longer need the Available* methods

* Pare down star decompression

* Fix empty star row/column error

* Make the grid structure methods clearer in their purpose

* Remove return from ResolveStars

* Auto-format source code

* Account for greedy control measurement behavior

* Auto-format source code

* Remove extraneous using

* Prevent unnecessary LayoutSubviews in xplat backing controls

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
rmarinho pushed a commit that referenced this pull request Jun 15, 2023
…an sufficient to display full size (#14902) (#15653)

* Add tests for overlapping stuff, checkpoint before working out the multiple arrange stuff

* Working, just needs a lot of cleanup

* More cleanup

* Break down decompress method

* Add test for multiple Arrange calls

* More comprehensive test for multiple Arrange calls

* No longer need the Available* methods

* Pare down star decompression

* Fix empty star row/column error

* Make the grid structure methods clearer in their purpose

* Remove return from ResolveStars

* Auto-format source code

* Account for greedy control measurement behavior

* Auto-format source code

* Remove extraneous using

* Prevent unnecessary LayoutSubviews in xplat backing controls

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
PureWeen added a commit that referenced this pull request Jun 28, 2023
… less than sufficient to display full size (#14902) (#15653)"

This reverts commit 8f0c2a8.
github-actions bot pushed a commit that referenced this pull request Jun 28, 2023
… less than sufficient to display full size (#14902) (#15653)"

This reverts commit 8f0c2a8.
rmarinho pushed a commit that referenced this pull request Jun 29, 2023
… less than sufficient to display full size (#14902) (#15653)" (#15915)

This reverts commit 8f0c2a8.
rmarinho pushed a commit that referenced this pull request Jun 29, 2023
… less than sufficient to display full size (#14902) (#15653)" (#15917)

This reverts commit 8f0c2a8.

Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
hartez added a commit that referenced this pull request Jun 30, 2023
…an sufficient to display full size (#14902)

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
github-actions bot pushed a commit that referenced this pull request Jun 30, 2023
…an sufficient to display full size (#14902)

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
rmarinho pushed a commit that referenced this pull request Jun 30, 2023
* Handle Grid * expansion when size is larger than minimum, but less than sufficient to display full size (#14902)

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>

* Fix incorrect calculation of expansion size when *s have different scalars (#15532)

Fixes #15494

---------

Co-authored-by: E.Z. Hart <hartez@gmail.com>
Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
rmarinho added a commit that referenced this pull request Jul 1, 2023
* Handle Grid * expansion when size is larger than minimum, but less than sufficient to display full size (#14902)

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>

* Fix incorrect calculation of expansion size when *s have different scalars (#15532)

Fixes #15494

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
Co-authored-by: Rui Marinho <me@ruimarinho.net>
@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter backport/approved After some discussion or review, this PR or change was approved to be backported. backport/suggested The PR author or issue review has suggested that the change should be backported. fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! layout-grid
Projects
None yet
5 participants