bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Add icon to `WindowDescriptor` and `Window`

Open alt0173 opened this issue 3 years ago • 7 comments

Objective

  • Allows setting the window icon via WindowDescriptor and a method on Window.
  • Methods to create square and rectangular window icons.
  • Expands window_settings example to demonstrate this.
  • Fixes #1031

Solution

  • A proxy struct WindowIcon that is equivalent to winit::window::Icon and convert it to an Icon 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.

alt0173 avatar Jul 29 '22 22:07 alt0173

Awesome! Folks have been asking for this forever.

alice-i-cecile avatar Jul 29 '22 22:07 alice-i-cecile

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

DJMcNab avatar Jul 29 '22 22:07 DJMcNab

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!

alice-i-cecile avatar Jul 29 '22 23:07 alice-i-cecile

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?

alt0173 avatar Jul 30 '22 00:07 alt0173

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.

alice-i-cecile avatar Jul 30 '22 01:07 alice-i-cecile

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

KirmesBude avatar Jul 30 '22 14:07 KirmesBude

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!

alice-i-cecile avatar Jul 30 '22 18:07 alice-i-cecile

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()
    })

cavivie avatar Nov 06 '22 14:11 cavivie

Any updates on this?

amfaber avatar Sep 18 '23 20:09 amfaber

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.

mnmaita avatar Oct 17 '23 14:10 mnmaita