-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] - Utility methods for Val #6134
Conversation
Co-authored-by: Mike <mike.hsu@gmail.com>
… api and added add/sub assigning with size
@Pietrek14 feel free to resolve comments as you address them; it makes it much easier for other reviewers to see what still needs to be done :) |
I think I covered it all. Sorry it took so long, I was busy with Ludum Dare. |
Should I adjust the migration guide in the PR description, since I deleted the addition and subtraction of |
Yes please :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is two methods without doc.
Other than that LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, I'm happy with how this turned out. Love the error enum. We can add more impls and methods later once we see how this batch plays out.
bors r+
# Objective Adds a better interface for performing mathematical operations with UI unit `Val`. Fixes #6080. ## Solution - Added `try_add` and `try_sub` methods to Val. - Removed the `Add` and `AddAssign` impls for `Val` that introduced unintuitive and bug-prone behaviour. - As a consequence of the prior, ~~changed the `Add` and `Sub` impls for the `Size` struct to take a `(Val, Val)` instead of `Vec2`~~ deleted the `Add` and `Sub` impls for the `Size` struct - Added a `From<(Val, Val)>` impl for the `Size` struct - Added `evaluate(size: f32)` method that converts from `Val::Percent` to `Val::Px`. - Added `try_add_with_size` and `try_sub_with_size` methods to `Val`, which evaluate `Val::Percent` values into `Val::Px` values before adding. --- ## Migration Guide Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. Co-authored-by: Dawid Piotrowski <41804418+Pietrek14@users.noreply.github.com>
Build failed (retrying...): |
# Objective Adds a better interface for performing mathematical operations with UI unit `Val`. Fixes #6080. ## Solution - Added `try_add` and `try_sub` methods to Val. - Removed the `Add` and `AddAssign` impls for `Val` that introduced unintuitive and bug-prone behaviour. - As a consequence of the prior, ~~changed the `Add` and `Sub` impls for the `Size` struct to take a `(Val, Val)` instead of `Vec2`~~ deleted the `Add` and `Sub` impls for the `Size` struct - Added a `From<(Val, Val)>` impl for the `Size` struct - Added `evaluate(size: f32)` method that converts from `Val::Percent` to `Val::Px`. - Added `try_add_with_size` and `try_sub_with_size` methods to `Val`, which evaluate `Val::Percent` values into `Val::Px` values before adding. --- ## Migration Guide Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. Co-authored-by: Dawid Piotrowski <41804418+Pietrek14@users.noreply.github.com>
It's really not that important, but do PRs merged by bors count for Hacktoberfest? |
# Objective Adds a better interface for performing mathematical operations with UI unit `Val`. Fixes bevyengine#6080. ## Solution - Added `try_add` and `try_sub` methods to Val. - Removed the `Add` and `AddAssign` impls for `Val` that introduced unintuitive and bug-prone behaviour. - As a consequence of the prior, ~~changed the `Add` and `Sub` impls for the `Size` struct to take a `(Val, Val)` instead of `Vec2`~~ deleted the `Add` and `Sub` impls for the `Size` struct - Added a `From<(Val, Val)>` impl for the `Size` struct - Added `evaluate(size: f32)` method that converts from `Val::Percent` to `Val::Px`. - Added `try_add_with_size` and `try_sub_with_size` methods to `Val`, which evaluate `Val::Percent` values into `Val::Px` values before adding. --- ## Migration Guide Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. Co-authored-by: Dawid Piotrowski <41804418+Pietrek14@users.noreply.github.com>
Adds a better interface for performing mathematical operations with UI unit `Val`. Fixes bevyengine#6080. - Added `try_add` and `try_sub` methods to Val. - Removed the `Add` and `AddAssign` impls for `Val` that introduced unintuitive and bug-prone behaviour. - As a consequence of the prior, ~~changed the `Add` and `Sub` impls for the `Size` struct to take a `(Val, Val)` instead of `Vec2`~~ deleted the `Add` and `Sub` impls for the `Size` struct - Added a `From<(Val, Val)>` impl for the `Size` struct - Added `evaluate(size: f32)` method that converts from `Val::Percent` to `Val::Px`. - Added `try_add_with_size` and `try_sub_with_size` methods to `Val`, which evaluate `Val::Percent` values into `Val::Px` values before adding. --- Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. Co-authored-by: Dawid Piotrowski <41804418+Pietrek14@users.noreply.github.com>
# Objective Adds a better interface for performing mathematical operations with UI unit `Val`. Fixes bevyengine#6080. ## Solution - Added `try_add` and `try_sub` methods to Val. - Removed the `Add` and `AddAssign` impls for `Val` that introduced unintuitive and bug-prone behaviour. - As a consequence of the prior, ~~changed the `Add` and `Sub` impls for the `Size` struct to take a `(Val, Val)` instead of `Vec2`~~ deleted the `Add` and `Sub` impls for the `Size` struct - Added a `From<(Val, Val)>` impl for the `Size` struct - Added `evaluate(size: f32)` method that converts from `Val::Percent` to `Val::Px`. - Added `try_add_with_size` and `try_sub_with_size` methods to `Val`, which evaluate `Val::Percent` values into `Val::Px` values before adding. --- ## Migration Guide Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. Co-authored-by: Dawid Piotrowski <41804418+Pietrek14@users.noreply.github.com>
Objective
Adds a better interface for performing mathematical operations with UI unit
Val
. Fixes #6080.Solution
try_add
andtry_sub
methods to Val.Add
andAddAssign
impls forVal
that introduced unintuitive and bug-prone behaviour.changed thedeleted theAdd
andSub
impls for theSize
struct to take a(Val, Val)
instead ofVec2
Add
andSub
impls for theSize
structFrom<(Val, Val)>
impl for theSize
structevaluate(size: f32)
method that converts fromVal::Percent
toVal::Px
.try_add_with_size
andtry_sub_with_size
methods toVal
, which evaluateVal::Percent
values intoVal::Px
values before adding.Migration Guide
Instead of using the + and - operators, perform calculations on
Val
s using the newtry_add
andtry_sub
methods. Multiplication and division remained unchanged. Also, when adding or subtracting fromSize
,use aperform the addition onVal
tuple instead ofVec2
width
andheight
separately.