Add icon to `WindowDescriptor` and `Window`
Objective
- Allows setting the window icon via
WindowDescriptorand a method onWindow. - Methods to create square and rectangular window icons.
- Expands
window_settingsexample to demonstrate this. - Fixes #1031
Solution
- A proxy struct
WindowIconthat is equivalent towinit::window::Iconand convert it to anIconwhen 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.
Awesome! Folks have been asking for this forever.
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?):
https://github.com/bevyengine/bevy/pull/1163
Based on @cart's comments in #1163 I think we should a) re-add runtime icon modification b) use the image type c) support loading images via bevy_asset :) Sorry for not checking that before giving advice!
Based on @cart's comments in #1163 I think we should a) re-add runtime icon modification b) use the image type c) support loading images via
bevy_asset:) Sorry for not checking that before giving advice!
I'm working on this but I can't figure out how to use image (from bevy_render) in bevy_window due to a cyclical dependency issue, do you have any idea how I could work around that?
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 Image and Color in their own crate, and then rely on that for both bevy_render and bevy_window, which would solve the cycle. But I'm not a domain expert here.
Hi. I still follow bevy development, but clearly I did not set up my github notifications correctly, so sorry for the radio silence on #2268. In case it is still beneficial, I have relicensed my past contributions. (Is this comment enough? https://github.com/bevyengine/bevy/issues/2373#issuecomment-1200175202).
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
In case it is still beneficial, I have relicensed my past contributions. (Is this comment enough? https://github.com/bevyengine/bevy/issues/2373#issuecomment-1200175202).
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?
Any updates on this?
Looks like development of this feature was moved here https://github.com/bevyengine/bevy/pull/8130 but it still has some unresolved issues/discussions.