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

Change the default for the measure_func field of ContentSize to None. #9346

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Aug 3, 2023

Objective

The default for ContentSize should have the measure_func field set to None, instead of a fixed size of zero. This means that until a measure func is set the size of the UI node will be determined by its Style constraints. This is preferable as it allows users to specify the space the Node should take up in the layout while waiting for content to load.

Solution

Derive Default for ContentSize.

The PR also adds a fixed_size helper function to make it a bit easier to access the old behaviour.

Changelog

  • Derived Default for ContentSize
  • Added a fixed_size helper function to ContentSize that creates a new ContentSize with a MeasureFunc that always returns the same value, regardless of layout constraints.

Migration Guide

The default for ContentSize now sets its measure_func to None, instead of a fixed size measure that returns Vec2::ZERO.
The helper function fixed_size can be called with ContentSize::fixed_size(Vec2::ZERO) to get the previous behaviour.

@ickshonpe ickshonpe changed the title Change the default for ContentSize's measure_func field to None. Change the default for the measure_func field of ContentSize to None. Aug 3, 2023
@alice-i-cecile alice-i-cecile added A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A simple quality-of-life change that makes Bevy easier to use C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide labels Aug 3, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2023

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Aug 6, 2023
@alice-i-cecile
Copy link
Member

@ickshonpe ping on the migration guide, but I'll merge this tomorrow regardless.

* Added a `fixed_size` helper function that  creates a new `ContentSize` with a `Measure` that always returns the same value, regardless of the UI layout's contraints.
@ickshonpe
Copy link
Contributor Author

Migration guide fixed and added a little helper function. Should be all ready.

@alice-i-cecile
Copy link
Member

The helper function is a great idea :)

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Aug 7, 2023
Merged via the queue into bevyengine:main with commit fe37ba5 Aug 7, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants