bevy
bevy copied to clipboard
Add additional constructors for `UiRect` to specify values for specific fields
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:
UiRect::new(Val::Undefined, Val::Undefined, Val::Percent(25.0), Val::Undefined)
UiRect {
top: Val::Percent(25.0),
..default()
}
Solution
Introduce 6 new constructors:
horizontalverticalleftrighttopbottom
So the above code can be written instead as:
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
UiRectto specify values for specific fields