bevy/crates/bevy_ui/src
Peter Hebden 5875ea7db0 Add additional constructors for UiRect to specify values for specific fields (#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
2022-09-27 18:11:39 +00:00
..
flex Query filter types must be ReadOnlyWorldQuery (#6008) 2022-09-18 23:52:01 +00:00
render Rename UiColor to BackgroundColor (#6087) 2022-09-25 00:39:17 +00:00
widget Limit FontAtlasSets (#5708) 2022-09-19 16:12:12 +00:00
entity.rs Don't use the UIBundle's Transform Fields (#6095) 2022-09-26 01:31:22 +00:00
focus.rs bevy_reflect: Update enum derives (#5473) 2022-08-02 22:40:29 +00:00
geometry.rs Add additional constructors for UiRect to specify values for specific fields (#5988) 2022-09-27 18:11:39 +00:00
lib.rs Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
ui_node.rs Rename UiColor to BackgroundColor (#6087) 2022-09-25 00:39:17 +00:00
update.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00