vi-eclipse / Eclipse-Platform

Umbrella repository for managing a backlog of features/issues related to the Eclipse Platform
2 stars 0 forks source link

Icons of Text are not scaled #80

Open akoch-yatta opened 1 week ago

akoch-yatta commented 1 week ago

The icons (IDI_SEARCH, IDI_CANCEL, ...) are not scaled on dpi change, e.g. visible in the Error Log or the Preferences Dialog

Image

Image

amartya4256 commented 6 days ago

The issue is with how the icon is loaded and drawn. The method addIcons loads the icon using OS.LoadIconMetric (OS.GetLibraryHandle (), searchIconResource, 1, phicon). Here there is no reference provided to what size the image is going to be loaded for neither does the OS know for what monitor it is loaded. I tested this with my primary monitor set to 200 and 100 and for both I get the icon of different sizes, 28x28 and 20x20 respectively. So, one thing is for certain that this method loads the icon accordign to the primary monitor zoom level. Refer: https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-loadiconmetric

Now this icon is later on drawn in the method WM_DRAWITEM. The drawing call is like this: OS.DrawIconEx (struct.hDC, 0, y, hIcon, side, side, 0, 0, OS.DI_NORMAL); The documentation says, with this call, it will draw the image in the size in which it was loaded (default). So, that's why there is no scaling. Refer: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-drawiconex

However, I have implemented a fix for this and that has a little to do with how the icon is loaded since it is independent of what window it is going to be drawn on. Rather, when we are drawing it, we should calculate the bounds of the image and scale it up.

Here's how it looks when the image is scaled down from 200 to 100:

Image

Similarly, here's the snip for 100 to 200:

Image

amartya4256 commented 6 days ago

Although I see a little bit of sharpness on the edge in the image when it is drawn with a higher Zoom.