mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 22:18:33 +00:00
# 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 |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |