<AWT Dev> <Swing Dev> [10] Review request for 8182043: Access to Windows Large Icons
Sergey Bylokhov
Sergey.Bylokhov at oracle.com
Mon Sep 25 20:44:49 UTC 2017
On 9/22/17 04:22, Alexey Ivanov wrote:
> There's no way of knowing in advance.
> Explorer does not restrict the size of icons (now), it's up to
> developers of a particular file handler to provide icons. Usually,
> there's only one icon with size larger than 255.
>
> If there's the icon of the requested size, Explorer will give it to you,
> otherwise it will scale the closest available to the requested size.
>
> Windows documentation suggests the following sizes:
> https://msdn.microsoft.com/en-us/library/windows/desktop/dn742485(v=vs.85).aspx#size_requirements
Ok, so it means that we will support 1-128 pixels
natively(MAX_ICON_SIZE) and others via MRI.
>
> As for FILE_ICON_SMALL and FILE_ICON_LARGE, I'd suggest using Windows
> API to retrieve the recommended size for small and large icon size
> rather than defaulting to 16×16 and 32×32. If HiDPI is in effect, the
> icons must be larger.
But this depends from the the DPI of the screen, we cannot just request
default FILE_ICON_SMALL/FILE_ICON_LARGE. If these constants will be
added then we should use something like this to get correct icons:
Icon icon = getSystemIcon(file, FILE_ICON_SMALL);
Icon hicon = getSystemIcon(file, icon.getIconWidth()*screenScale);
or
Icon icon = getSystemIcon(file);
Icon hicon = getSystemIcon(file, icon.getIconWidth()*screenScale);
Or we can do:
Icon hicon = getSystemIcon(file, FILE_ICON_LARGE);
This means that on HiDPI screen the FILE_ICON_LARGE works in similar way
as FILE_ICON_SMALL on non-HiDPI screen, and the meaning of the
FILE_ICON_SMALL on HiDPI is unclear, because it is half of the correct size.
For example one of the consumer of this new API is WindowsFileView.
How the code below should be changed to work on a different screens, and
request the proper icon?
WindowsFileChooserUI.java
1316 icon = getFileChooser().getFileSystemView().getSystemIcon(f);
--
Best regards, Sergey.
More information about the awt-dev
mailing list