-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Make default behavior for BackgroundColor and BorderColor more intuitive
#14017
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
Merged
alice-i-cecile
merged 13 commits into
bevyengine:main
from
alice-i-cecile:solid-white-rectangle
Jun 25, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
21e90c8
Use `NONE` as the default UI image color
alice-i-cecile 09c1b1e
Default to transparent white instead
alice-i-cecile 6f0c3dd
Refine API
alice-i-cecile a18c5e3
Make BackgroundColor transparent by default
alice-i-cecile 5811cbe
Make BorderColor transparent by default
alice-i-cecile 305f057
Don't override default BorderColor and BackgroundColor
alice-i-cecile c887fe9
Add BackgroundColor to ImageBundle
alice-i-cecile df678bf
Strengthen warning
alice-i-cecile 9fd21e3
Add BackgroundColor to ButtonBundle
alice-i-cecile 63d2654
Don't use UiImage to set background colors in examples
alice-i-cecile d62529e
Balance in all things, especially backticks
alice-i-cecile d308fb7
Use a default transparent image
alice-i-cecile d2b1266
Apply suggestions from code review
alice-i-cecile File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,14 @@ use bevy_app::{App, Plugin}; | |
| use bevy_asset::{AssetApp, Assets, Handle}; | ||
| use bevy_ecs::prelude::*; | ||
|
|
||
| /// A handle to a 1 x 1 transparent white image. | ||
| /// | ||
| /// Like [`Handle<Image>::default`], this is a handle to a fallback image asset. | ||
| /// While that handle points to an opaque white 1 x 1 image, this handle points to a transparent 1 x 1 white image. | ||
| // Number randomly selected by fair WolframAlpha query. Totally arbitrary. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better than a fair dice roll (xkcd)! |
||
| pub const TRANSPARENT_IMAGE_HANDLE: Handle<Image> = | ||
| Handle::weak_from_u128(154728948001857810431816125397303024160); | ||
|
|
||
| // TODO: replace Texture names with Image names? | ||
| /// Adds the [`Image`] as an asset and makes sure that they are extracted and prepared for the GPU. | ||
| pub struct ImagePlugin { | ||
|
|
@@ -89,9 +97,11 @@ impl Plugin for ImagePlugin { | |
| .init_asset::<Image>() | ||
| .register_asset_reflect::<Image>(); | ||
|
|
||
| app.world_mut() | ||
| .resource_mut::<Assets<Image>>() | ||
| .insert(&Handle::default(), Image::default()); | ||
| let mut image_assets = app.world_mut().resource_mut::<Assets<Image>>(); | ||
|
|
||
| image_assets.insert(&Handle::default(), Image::default()); | ||
| image_assets.insert(&TRANSPARENT_IMAGE_HANDLE, Image::transparent()); | ||
|
|
||
| #[cfg(feature = "basis-universal")] | ||
| if let Some(processor) = app | ||
| .world() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How will we find out? Will it fail to compile?
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.
This will panic when the examples are run :)