-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
ImageMode::KeepAspect
interacts in a confusing way with AlignItems
#6637
Comments
Thank you @bzm3r for creating this issue, I am said user :) |
Thought about this some more, and I don't think it's a bug, just confusing. ImageMode::KeepAspect tells the UI to store the image size so it can draw the image with the correct aspect ratio. To get the image to display correctly, change the flex-direction to FlexDirection::Column. Then the cross-axis will be the x-axis, the image width will be stretched to 100 pixels, and the height will be scaled according to the image's aspect ratio, 100 / 64 * 32 = 50, as desired. |
@ickshonpe Any recommendations on what can be done in terms of documentation to make this less confusing? My guess:
Or do we have to go farther than documentation, and rework some of the API? How is this sort of interaction handled in other UI toolkits? |
ImageMode::KeepAspect
is not respectedImageMode::KeepAspect
interacts in a confusing way with AlignItems
I'm putting in a PR that deletes ImageMode. It's confusing and doesn't serve any purpose. |
I think making image aspect ratios independent of flex should work, and be ergonomic and foolproof. Might be a bit hacky though. Implementing it now. |
# Objective Delete `ImageMode`. It doesn't do anything except mislead people into thinking it controls the aspect ratio of images somehow. Fixes #3933 and #6637 ## Solution Delete `ImageMode` ## Changelog Removes the `ImageMode` enum. Removes the `image_mode` field from `ImageBundle` Removes the `With<ImageMode>` query filter from `image_node_system` Renames `image_node_system` to` update_image_calculated_size_system`
Closed by: #6674 |
# Objective Delete `ImageMode`. It doesn't do anything except mislead people into thinking it controls the aspect ratio of images somehow. Fixes bevyengine#3933 and bevyengine#6637 ## Solution Delete `ImageMode` ## Changelog Removes the `ImageMode` enum. Removes the `image_mode` field from `ImageBundle` Removes the `With<ImageMode>` query filter from `image_node_system` Renames `image_node_system` to` update_image_calculated_size_system`
# Objective Delete `ImageMode`. It doesn't do anything except mislead people into thinking it controls the aspect ratio of images somehow. Fixes bevyengine#3933 and bevyengine#6637 ## Solution Delete `ImageMode` ## Changelog Removes the `ImageMode` enum. Removes the `image_mode` field from `ImageBundle` Removes the `With<ImageMode>` query filter from `image_node_system` Renames `image_node_system` to` update_image_calculated_size_system`
# Objective Delete `ImageMode`. It doesn't do anything except mislead people into thinking it controls the aspect ratio of images somehow. Fixes bevyengine#3933 and bevyengine#6637 ## Solution Delete `ImageMode` ## Changelog Removes the `ImageMode` enum. Removes the `image_mode` field from `ImageBundle` Removes the `With<ImageMode>` query filter from `image_node_system` Renames `image_node_system` to` update_image_calculated_size_system`
Bevy version
0.9
What user did
Programmer is working with
bevy_ui
ImageBundle
and spawned aImageBundle
as a child of aNodeBundle
. TheNodeBundle
is a fixed size, 100px by 100px. The image that they want to show is a pixel art image that is 64px width by 32px tall. They set theImageMode
explicitly toKeepAspect
, which they assume to mean is the Aspect Ratio of the image, in this case 2x1 (and this is confirmed by the docs forImageMode
).What went wrong
The image stretches to fit the 100px by 100px parent, it does not keep the aspect ratio.
Additional information
From the following Bevy Discord question: https://discord.com/channels/691052431525675048/1042098354735300658
The text was updated successfully, but these errors were encountered: