libui icon indicating copy to clipboard operation
libui copied to clipboard

Set window icon

Open emersion opened this issue 8 years ago • 10 comments

Maybe related to the images issue (#2). On GTK there is gtk_window_set_icon. If possible, setting a list of icons with different sizes would be nice to have (gtk_window_set_icon_list).

emersion avatar Jul 24 '16 16:07 emersion

+1 for this suggestion. On Windows, it should also be easily possible to change the default icon. This feature would help a lot making the libui-interface feel more "native".

jandoerntlein avatar Jul 27 '16 10:07 jandoerntlein

Window icons for Windows only accept the ico format. I don't know what the other systems use. https://msdn.microsoft.com/en-us/library/windows/desktop/ms632643(v=vs.85).aspx

For cross-platform, I'd think that having a few formats and converting/scaling them at run-time may be a good option. Personally, I'd like to see SVG, but that would require rasterizing, then converting format. A large PNG could be scaled down as well, but you'd probably want a small image that looks good scaled down as well. Keeping in mind that these icons can be displayed in the Alt+Tab, Taskbar, and other places on various systems.

duckbrain avatar Jul 27 '16 20:07 duckbrain

I was considering just doing what Windows Explorer does and taking the first icon out of the executable to use for all window icons.

andlabs avatar Jul 27 '16 22:07 andlabs

Don't support a specific format, just take a pixel buffer; for Windows, look how SDL does it: https://github.com/spurious/SDL-mirror/blob/e1e235cb9012f8edc705d2cb61df9e8a5b0a4047/src/video/windows/SDL_windowswindow.c#L402

Someguynamedpie avatar Aug 08 '16 15:08 Someguynamedpie

@Someguynamedpie what do you mean?

andlabs avatar Aug 18 '16 23:08 andlabs

Note that under OS X, an icon in the titlebar typically represents the document/directory displayed in the window, e.g. if you have an RTF document open you'll see a little RTF icon in the titlebar. As such I would recommend not displaying titlebar icons under OS X unless the window in question has its representedDocument set.

More info is at https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/WinPanel/Tasks/SettingWindowTitle.html

jwells89 avatar Sep 26 '16 02:09 jwells89

Yep; for now I'm going to have this special code on Windows only. Not sure how GTK+ would handle it, or if that's intrinsically tied to .desktop files.

andlabs avatar Sep 26 '16 03:09 andlabs

Whoops didn't see you replied. I meant an array of RGB[A] pixels. SDL has an implementation for X11 window icons as well if you want to use that as a reference: https://github.com/spurious/SDL-mirror/blob/e1e235cb9012f8edc705d2cb61df9e8a5b0a4047/src/video/x11/SDL_x11window.c#L739

Someguynamedpie avatar Sep 26 '16 12:09 Someguynamedpie

Why don't set an other name than IDI_APPLICATION like LIBUI_ICON and set a default icon in the libui.dll as res ?

dotnetcomgazio avatar May 23 '20 16:05 dotnetcomgazio

That could happen. After Alpha 5 is finished I plan on writing a tool for handling situations that cannot be done in source code, presumably called uires, which will handle things like this.

However, making the program icon the first icon in the Windows resource section would be compatible with other programs like Explorer that also do this.

andlabs avatar May 23 '20 16:05 andlabs