-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Apply scale factor to ImageMeasure
sizes
#8545
Apply scale factor to ImageMeasure
sizes
#8545
Conversation
ImageMeasure
's sizeImageMeasure
sizes
Could you add a comment on |
Done, |
* Added comment to `ImageMeasure` noting that its size value needs to be in physical pixels.
Multiply `ImageMeasure::size` by the combined scale factor for UI texture atlas images too.
Checking for changed scale factor is required, unless the `image_size.size` is set to the scaled image size, which doesn't seem desirable.
This fix needs to be included with 0.11 I think, otherwise updating any UI projects using images from 0.10 is going to be really painful. |
// target size of the image | ||
size: Vec2, | ||
/// The size of the image's texture | ||
pub size: Vec2, |
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.
Do we want this to be editable by the user? Or should this be pub(crate)
?
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.
Yes it's intended to be pub
. That way someone can use ImageMeasure
for their own custom widget if they want.
Otherwise, it doesn't matter that it's pub
as measure funcs can't be accessed by users once they've been added to the layout tree.
Objective
In Bevy main, the unconstrained size of an
ImageBundle
orAtlasImageBundle
UI node is based solely on the size of its texture and doesn't change with window scale factor orUiScale
.Solution
ImageMeasure
should be multiplied by the current combined scale factor.ImageMeasure
should be updated when the combined scale factor is changed.Example:
The red node is given a size with the same dimensions as the texture. So we would expect the texture to fill the node exactly.
Result with Bevy main branch bb59509:

Result with this PR (and Bevy 0.10.1):

Changelog
bevy_ui::widget::image
ImageMeasure
s on changes to the window scale factor orUiScale
.ImageMeasure::size
by the window scale factor andUiScale
.Migration Guide