-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Make GridPlacement
's fields non-zero and add accessor functions.
#9486
Conversation
* Field types have been changed to `Option<NonZeroI16>` and `Option<NonZeroU16>`. This is because zero values are not valid for `GridPlacement`. Previously, Taffy interpreted these as auto variants. * Constructor functions for `GridPlacement` that accept numeric values now return `Result<Self, GridPlacementError>`. An error of type `GridPlacementError` is returned on arguments equal to zero. * Added accessor functions: `get_start`, `get_end`, and `get_span`. These return the inner primitive value (if present) of the respective fields.
Example |
…neering. Switched the functions back so they return `Self unless given a zero valued argument in which they will panic with a `GridPlacementError`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach, but it needs some more polish.
Example |
Once there's docs for |
Example |
@viridia can I get your review on this PR? If this looks good to you and meets your needs, I'll be able to merge it with your approval :) See the relevant section of CONTRIBUTING.md for more details on the community approval model we use. |
Example |
1 similar comment
Example |
Added a few trivial tests but there isn't much here to check; the logic is all in layout's convert function and Taffy. |
Example |
2 similar comments
Example |
Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
…evyengine#9486) # Objective * There is no way to read the fields of `GridPlacement` once set. * Values of `0` for `GridPlacement`'s fields are invalid but can be set. * A non-zero representation would be half the size. fixes bevyengine#9474 ## Solution * Add `get_start`, `get_end` and `get_span` accessor methods. * Change`GridPlacement`'s constructor functions to panic on arguments of zero. * Use non-zero types instead of primitives for `GridPlacement`'s fields. --- ## Changelog `bevy_ui::ui_node::GridPlacement`: * Field types have been changed to `Option<NonZeroI16>` and `Option<NonZeroU16>`. This is because zero values are not valid for `GridPlacement`. Previously, Taffy interpreted these as auto variants. * Constructor functions for `GridPlacement` panic on arguments of `0`. * Added accessor functions: `get_start`, `get_end`, and `get_span`. These return the inner primitive value (if present) of the respective fields. ## Migration Guide `GridPlacement`'s constructor functions no longer accept values of `0`. Given any argument of `0` they will panic with a `GridPlacementError`.
Objective
GridPlacement
once set.0
forGridPlacement
's fields are invalid but can be set.fixes #9474
Solution
get_start
,get_end
andget_span
accessor methods.GridPlacement
's constructor functions to panic on arguments of zero.GridPlacement
's fields.Changelog
bevy_ui::ui_node::GridPlacement
:Option<NonZeroI16>
andOption<NonZeroU16>
. This is because zero values are not valid forGridPlacement
. Previously, Taffy interpreted these as auto variants.GridPlacement
panic on arguments of0
.get_start
,get_end
, andget_span
. These return the inner primitive value (if present) of the respective fields.Migration Guide
GridPlacement
's constructor functions no longer accept values of0
. Given any argument of0
they will panic with aGridPlacementError
.