-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
add AsVal trait that helps with constructing Val #15825
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
Conversation
0c2b2e5
to
6cee2e4
Compare
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.
I like the syntax, and the implementation is clean. The use a macro is justified here IMO: there's a ton of boilerplate and the code is super simple.
Bumping to the 0.16 milestone since this is implementable externally and it's a new feature :) |
Co-authored-by: Joona Aalto <[email protected]>
Co-authored-by: Joona Aalto <[email protected]>
Co-authored-by: Joona Aalto <[email protected]>
Co-authored-by: Joona Aalto <[email protected]>
If we're going to be doing this, we should export the trait in the prelude TBH. |
It's there in the prelude already. From bevy_ui::prelude
…On Thu, Oct 10, 2024, 18:56 Alice Cecile ***@***.***> wrote:
If we're going to be doing this, we should export the trait in the prelude
TBH.
—
Reply to this email directly, view it on GitHub
<#15825 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYY7BWDQLPBAZ2BG3VZGQTZ22WSXAVCNFSM6AAAAABPXC7IGWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBVGYYTKOBQGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
As a heads up, within the context of BSN I was planning on doing: |
I'm fine with either solution. This plays a bit nicer with autocomplete. We should merge one or the other for 0.16 though :) |
The downside here (if this is in the prelude) is that it adds |
It got shot down the last time I suggested it, but I still think the lowest friction option for users is to change all the |
I'm closing this in favor of |
Objective
To reduce friction when writing Ui code by letting the code follow the left-to-right mindset.
Mental model: "The width should be 20 pixels" , as in "affect this, with value,of unit"
instead of:
ui_rect.width = Val::Px(20.0);
let us go:
ui_rect.width = 20.px();
Solution
Implement a trait in geometry and implement for the common types
Testing
Tested this by modifying the text_debug example to use this instead and it worked.