Skip to content

Commit

Permalink
Window decorations: added option to show window icon only in frames, …
Browse files Browse the repository at this point in the history
…but not in dialogs (issue #589)
  • Loading branch information
DevCharly committed Sep 22, 2022
1 parent 86a4f30 commit 78e7839
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 4 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Expand Up @@ -14,9 +14,11 @@ FlatLaf Change Log
is disabled. (issue #501)
- TabbedPane: New option to disable tab run rotation in wrap layout. Set UI
value `TabbedPane.rotateTabRuns` to `false`. (issue #574)
- Native window decorations (Windows 10/11 only): Added client property to mark
components in embedded menu bar as "caption" (allow moving window). (issue
#569)
- Window decorations:
- Added client property to mark components in embedded menu bar as "caption"
(allow moving window). (issue #569)
- Option to show window icon only in frames, but not in dialogs. Set UI value
`TitlePane.showIconInDialogs` to `false`. (issue #589)
- Added system property `flatlaf.updateUIOnSystemFontChange` to allow disabling
automatic UI update when system font changes. (issue #580)

Expand Down
Expand Up @@ -55,6 +55,7 @@
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
Expand All @@ -80,6 +81,7 @@
* @uiDefault TitlePane.borderColor Color optional
* @uiDefault TitlePane.unifiedBackground boolean
* @uiDefault TitlePane.showIcon boolean
* @uiDefault TitlePane.showIconInDialogs boolean
* @uiDefault TitlePane.noIconLeftGap int
* @uiDefault TitlePane.iconSize Dimension
* @uiDefault TitlePane.iconMargins Insets
Expand Down Expand Up @@ -111,6 +113,7 @@ public class FlatTitlePane
protected final Color borderColor = UIManager.getColor( "TitlePane.borderColor" );

/** @since 2 */ protected final boolean showIcon = FlatUIUtils.getUIBoolean( "TitlePane.showIcon", true );
/** @since 2.5 */ protected final boolean showIconInDialogs = FlatUIUtils.getUIBoolean( "TitlePane.showIconInDialogs", true );
/** @since 2 */ protected final int noIconLeftGap = FlatUIUtils.getUIInt( "TitlePane.noIconLeftGap", 8 );
protected final Dimension iconSize = UIManager.getDimension( "TitlePane.iconSize" );
/** @since 2.4 */ protected final int titleMinimumWidth = FlatUIUtils.getUIInt( "TitlePane.titleMinimumWidth", 60 );
Expand Down Expand Up @@ -389,9 +392,13 @@ protected void frameStateChanged() {
}

protected void updateIcon() {
boolean defaultShowIcon = showIcon;
if( !showIconInDialogs && rootPane.getParent() instanceof JDialog )
defaultShowIcon = false;

// get window images
List<Image> images = null;
if( clientPropertyBoolean( rootPane, TITLE_BAR_SHOW_ICON, showIcon ) ) {
if( clientPropertyBoolean( rootPane, TITLE_BAR_SHOW_ICON, defaultShowIcon ) ) {
images = window.getIconImages();
if( images.isEmpty() ) {
// search in owners
Expand Down
Expand Up @@ -785,6 +785,7 @@ TitlePane.useWindowDecorations = true
TitlePane.menuBarEmbedded = true
TitlePane.unifiedBackground = true
TitlePane.showIcon = true
TitlePane.showIconInDialogs = true
TitlePane.noIconLeftGap = 8
TitlePane.iconSize = 16,16
TitlePane.iconMargins = 3,8,3,8
Expand Down
1 change: 1 addition & 0 deletions flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt
Expand Up @@ -1242,6 +1242,7 @@ TitlePane.noIconLeftGap 8
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.showIcon true
TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true
Expand Down
1 change: 1 addition & 0 deletions flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt
Expand Up @@ -1247,6 +1247,7 @@ TitlePane.noIconLeftGap 8
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.showIcon true
TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true
Expand Down
1 change: 1 addition & 0 deletions flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt
Expand Up @@ -1275,6 +1275,7 @@ TitlePane.noIconLeftGap 8
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.showIcon true
TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true
Expand Down
Expand Up @@ -1012,6 +1012,7 @@ TitlePane.noIconLeftGap
TitlePane.restoreIcon
TitlePane.showIcon
TitlePane.showIconBesideTitle
TitlePane.showIconInDialogs
TitlePane.titleMargins
TitlePane.titleMinimumWidth
TitlePane.unifiedBackground
Expand Down

0 comments on commit 78e7839

Please sign in to comment.