forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional constructors for
UiRect
to specify values for specif…
…ic fields (bevyengine#5988) # Objective Often one wants to create a `UiRect` with a value only specifying a single field. These ways are already available, but not the most ergonomic: ```rust UiRect::new(Val::Undefined, Val::Undefined, Val::Percent(25.0), Val::Undefined) ``` ```rust UiRect { top: Val::Percent(25.0), ..default() } ``` ## Solution Introduce 6 new constructors: - `horizontal` - `vertical` - `left` - `right` - `top` - `bottom` So the above code can be written instead as: ```rust UiRect::top(Val::Percent(25.0)) ``` This solution is similar to the style fields `margin-left`, `padding-top`, etc. that you would see in CSS, from which bevy's UI has other inspiration. Therefore, it should still feel intuitive to users coming from CSS. --- ## Changelog ### Added - Additional constructors for `UiRect` to specify values for specific fields
- Loading branch information
Showing
1 changed file
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters