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

Change UiScale to a tuple struct #9444

Merged
merged 9 commits into from
Aug 16, 2023

Conversation

st0rmbtw
Copy link
Contributor

@st0rmbtw st0rmbtw commented Aug 14, 2023

Objective

Inconvenient initialization of UiScale

Solution

Change UiScale to a tuple struct

Migration Guide

Replace initialization of UiScale like UiScale { scale: 1.0 } with UiScale(1.0)

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@alice-i-cecile alice-i-cecile 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 Aug 14, 2023
@alice-i-cecile
Copy link
Member

Nice and simple, but I'm not fully sold. Can you say a bit more about why you prefer this syntax?

@st0rmbtw
Copy link
Contributor Author

It feels more consistent and looks nicer for me :)

@mockersf
Copy link
Member

Would it be simpler to change the struct to a tuple struct? struct UiScale(f32);

@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

1 similar comment
@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@st0rmbtw
Copy link
Contributor Author

I think so, but wouldn't it be a breaking change?

@alice-i-cecile
Copy link
Member

Yep, but breaking changes are totally fine in Bevy at this stage. Especially for a very niche part of the API like this.

I'd prefer a tuple struct over the current change as well, although I'm neutral on tuple vs named struct.

@st0rmbtw
Copy link
Contributor Author

Done

@st0rmbtw st0rmbtw changed the title Add the 'new' method for UiScale Change UiScale to a tuple struct Aug 14, 2023
@mockersf
Copy link
Member

I prefer named struct when the name brings new information. I don't think a single field scale on a UiScale struct brings much...

You can probably derive Deref and DerefMut for that struct, and you'll need to fix all the places it's used...

@st0rmbtw
Copy link
Contributor Author

@mockersf Should I add a method like get to return a value of UiScale or just use .0 syntax?

Copy link
Contributor

@ickshonpe ickshonpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the tuple struct too.

@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

Copy link
Contributor

@ickshonpe ickshonpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UiScale doc comment isn't very informative atm. Maybe it could be changed to say something about how logical coordinates are multiplied by window scale factor and UiScale to get physical coordinates.

Copy link
Contributor

@tguichaoua tguichaoua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO tuple structs are better for wrapping a single meaningless value.
Also here it avoids the repetition of the word "scale".

@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@st0rmbtw
Copy link
Contributor Author

@alice-i-cecile I think this PR is ready to merge

@alice-i-cecile alice-i-cecile 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 Aug 16, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Aug 16, 2023
Merged via the queue into bevyengine:main with commit b6a9d8e Aug 16, 2023
20 of 21 checks passed
@st0rmbtw st0rmbtw deleted the new_method_uiscale branch August 16, 2023 18:51
@alice-i-cecile alice-i-cecile added the C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide label Aug 16, 2023
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-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide 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.

5 participants