Skip to content
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

[Merged by Bors] - Add additional constructors for UiRect to specify values for specific fields #5988

Closed
wants to merge 4 commits into from

Conversation

Piturnah
Copy link
Contributor

@Piturnah Piturnah commented Sep 14, 2022

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:

  • horizontal
  • vertical
  • left
  • right
  • top
  • bottom

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 UiRect to specify values for specific fields

@Piturnah Piturnah changed the title Feat/uirect Add additional constructors for UiRect to specify values for specific fields Sep 14, 2022
@mockersf mockersf added A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A simple quality-of-life change that makes Bevy easier to use labels Sep 14, 2022
@rparrett rparrett added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Sep 23, 2022
@cart
Copy link
Member

cart commented Sep 27, 2022

bors r+

bors bot pushed a commit that referenced this pull request Sep 27, 2022
…ic 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
@bors
Copy link
Contributor

bors bot commented Sep 27, 2022

@bors bors bot changed the title Add additional constructors for UiRect to specify values for specific fields [Merged by Bors] - Add additional constructors for UiRect to specify values for specific fields Sep 27, 2022
@bors bors bot closed this Sep 27, 2022
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 19, 2022
…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
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
…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
Piturnah added a commit to fishfolk/bomby that referenced this pull request Nov 22, 2022
@Piturnah Piturnah deleted the feat/uirect branch November 22, 2022 01:30
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants