Skip to content

bevy_ui: Ability to display an image without scaling. #7349

Open
@inodentry

Description

What problem does this solve or what need does it fill?

Having images in UI that you want to be displayed exactly without any scaling. No resizing allowed.

For example, I want to create a toolbar button with an icon in it. The image assets for the button's background and the icons are intended to be fixed size and displayed as is, exactly that size.

What solution would you like?

Currently we have an ImageMode enum component, which seems to have been created for this exact purpose (controlling the behavior of image scaling). It only has one variant: KeepAspect. It seems like the sensible/appropriate place for this new addition. We could add a new variant: Exact, that preserves image dimensions exactly / allows no resizing.

While we are at it, we could also add a ImageMode::Stretch that allows arbitrary resizing without regard for aspect ratio. Then, the ImageMode feature set would feel "complete" and cover the most common use cases.

What alternative(s) have you considered?

I could use the Style properties to force the node to have exactly the size of the image, but this is boilerplatey and error-prone. It would be nice if the layout system could take care of it automatically.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-FeatureA new feature, making something new possibleD-TrivialNice and easy! A great choice to get started with Bevy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions