-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add icon to WindowDescriptor
and Window
#5488
Conversation
Awesome! Folks have been asking for this forever. |
|
||
fn main() { | ||
App::new() | ||
.insert_resource(WindowDescriptor { | ||
title: "I am a window!".to_string(), | ||
icon: Some(WindowIcon::new( |
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.
Yeah this is way too low level for me to feel comfortable exposing directly to the user.
Are there reasonable choices for things to implement From
for?
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.
Would bevy::render::texture::Image
be a good fit?
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.
Ping @superdump for an informed opinion. That would be my natural first choice though.
/// Mirror of `Icon` from `winit`. | ||
#[derive(Debug, Clone)] | ||
pub struct WindowIcon { | ||
/// 32-bit-per-pixel RGBA image data. |
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.
I am not keen on exposing something so raw, but I'm not sure it's worth the complexity to fix now.
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.
The main concern here is that a byte vec is a pretty gnarly API to expose. I'd like to see if we can make that nicer and more type-safe.
The obvious choice would be to reuse our various rendering types but a) I'm not sure we want to add that dependency and b) IIRC those rely on async asset loading to e.g. load an icon from a file.
A quick reading suggests that this is going to run into the same issue as the original (license locked so best not to look at the code I guess?): |
As far as I can tell it *needs* to be mutable for wasm to compile, but it gets block by CI due to being unused elsewhere, so this should actually fix it.
I'm working on this but I can't figure out how to use |
What will probably need to happen is a refactoring PR disentangling things. Let's wait to see what Rob and Cart think before attempting that (likely a couple of days), and then attempt that in a separate PR. My instinct is that we could probably have rendering primitives like |
Hi. I was running into the same dependency issues, when trying to incorporate bevy_asset into the mix, so sadly I can not be of any help there. @alice-i-cecile suggestion is probably the way to go, because I do not remember trying to inverse the dependencies for bevy_render, bevy_window and bevy_camera going particularly well :D |
That's incredibly valuable, thanks! |
Can we try to support the following code? App::new()
.insert_resource(WindowDescriptor {
width: 288.,
height: 512.,
icon: include_bytes!("your_game_icon_path.ico"),
..default()
}) |
Any updates on this? |
Looks like development of this feature was moved here #8130 but it still has some unresolved issues/discussions. |
Objective
WindowDescriptor
and a method onWindow
.window_settings
example to demonstrate this.Solution
WindowIcon
that is equivalent towinit::window::Icon
and convert it to anIcon
when changing the icon. It is exposed to modification as mentioned above.Notes
The icon's data is a
Vec<u8>
to match with winit. This feels sub-optimal to use without the image crate, but winit's icon uses specifically 8bit RGBA values, which would probably be very cumbersome to convert to.I think it would be nice to have the default icon be the bevy logo, but I can't think of a way to do it without having a huge literal of bytes somewhere.