bevy_ui: Ability to display an image without scaling.
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
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.
Contributor guide
Research direction
Locate the bevy_ui implementation of the ImageMode component and the existing KeepAspect behavior. Review related UI layout tests or examples, then determine how exact-size and stretch behavior should be specified and tested. Done means the agreed ImageMode variants work for fixed-size and freely resized images without requiring manual style dimensions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100