Hi Sergey,
On 9/25/2017 1:44 PM, Sergey Bylokhov wrote:
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.
We will support all sizes natively not only 1-128. Windows does the scaling.
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.
Small and large don't have any special meanings for HiDPI. They are some
conditional sizes established by the native platform for the current
screen resolution.
Why is it half of the correct size? It is the same size as for non-HiDPI
and that is the correct size because otherwise java UI component that is
HiDPI unaware would paint icons 2 times bigger in size than it is
required. But the resolution of small/large icons may differs in case of
HiDPI because it is determined by the size of the images returned by the
native platform by the small/large icon queries.
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);
Why it should be changed? The code is requesting the proper icon.