mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
DesktopPane: on HiDPI screens, use high-resolution images for preview of iconified internal frames in dock
This commit is contained in:
10
CHANGELOG.md
10
CHANGELOG.md
@@ -8,7 +8,7 @@ FlatLaf Change Log
|
||||
- Button and ToggleButton: Support borderless button style (set client property
|
||||
`JButton.buttonType` to `borderless`). (PR #276)
|
||||
- DesktopPane: Improved layout of iconified internal frames in dock:
|
||||
- Always placed in bottom left of desktop pane.
|
||||
- Always placed at bottom-left in desktop pane.
|
||||
- Newly iconified frames are added to the right side of the dock.
|
||||
- If frame is deiconified, dock is compacted (icons move to the left).
|
||||
- If dock is wider than desktop width, additional rows are used.
|
||||
@@ -17,8 +17,12 @@ FlatLaf Change Log
|
||||
#### Fixed bugs
|
||||
|
||||
- DesktopPane:
|
||||
- Fixed empty minimized icon when using a custom desktop manager. (PR #294)
|
||||
- Fixed incomplete minimized icon when switching LaF.
|
||||
- Fixed missing preview of iconified internal frames in dock when using a
|
||||
custom desktop manager. (PR #294)
|
||||
- Fixed incomplete preview of iconified internal frames in dock when switching
|
||||
LaF.
|
||||
- On HiDPI screens, use high-resolution images for preview of iconified
|
||||
internal frames in dock.
|
||||
|
||||
|
||||
## 1.1.2
|
||||
|
||||
@@ -45,6 +45,7 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicDesktopIconUI;
|
||||
import com.formdev.flatlaf.util.MultiResolutionImageSupport;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
/**
|
||||
@@ -279,6 +280,27 @@ public class FlatDesktopIconUI
|
||||
|
||||
// scale preview
|
||||
Image previewImage = frameImage.getScaledInstance( previewWidth, previewHeight, Image.SCALE_SMOOTH );
|
||||
if( MultiResolutionImageSupport.isAvailable() ) {
|
||||
// On HiDPI screens, create preview images for 1x, 2x and current scale factor.
|
||||
// The icon then chooses the best resolution for painting, which is usually
|
||||
// the one for the current scale factor. But if changing scale factor or
|
||||
// moving window to another screen with different scale factor, then another
|
||||
// resolution may be used because the preview icon is not updated.
|
||||
Image previewImage2x = frameImage.getScaledInstance( previewWidth * 2, previewHeight * 2, Image.SCALE_SMOOTH );
|
||||
double scaleFactor = UIScale.getSystemScaleFactor( desktopIcon.getGraphicsConfiguration() );
|
||||
if( scaleFactor != 1 && scaleFactor != 2 ) {
|
||||
Image previewImageCurrent = frameImage.getScaledInstance(
|
||||
(int) Math.round( previewWidth * scaleFactor ),
|
||||
(int) Math.round( previewHeight * scaleFactor ),
|
||||
Image.SCALE_SMOOTH );
|
||||
|
||||
// the images must be ordered by resolution
|
||||
previewImage = (scaleFactor < 2)
|
||||
? MultiResolutionImageSupport.create( 0, previewImage, previewImageCurrent, previewImage2x )
|
||||
: MultiResolutionImageSupport.create( 0, previewImage, previewImage2x, previewImageCurrent );
|
||||
} else
|
||||
previewImage = MultiResolutionImageSupport.create( 0, previewImage, previewImage2x );
|
||||
}
|
||||
dockIcon.setIcon( new ImageIcon( previewImage ) );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user