diff --git a/CHANGELOG.md b/CHANGELOG.md index fea72c9e..3501db20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,10 +23,13 @@ FlatLaf Change Log - Tree: Support wide cell renderer. (issue #922) - Extras: `FlatSVGIcon` color filters now can access painting component to implement component state based color mappings. (issue #906) -- Linux: Added `libflatlaf-linux-arm64.so` for Linux on ARM64. (issue #899) -- Linux: Use X11 window manager events to resize window, if FlatLaf window - decorations are enabled. This gives FlatLaf windows a more "native" feeling. - (issue #866) +- Linux: + - Rounded iconify/maximize/close buttons if using FlatLaf window decorations. + (PR #971) + - Added `libflatlaf-linux-arm64.so` for Linux on ARM64. (issue #899) + - Use X11 window manager events to resize window, if FlatLaf window + decorations are enabled. This gives FlatLaf windows a more "native" feeling. + (issue #866) - IntelliJ Themes: - Updated to latest versions and fixed various issues. - Support customizing through properties files. (issue #824) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowAbstractIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowAbstractIcon.java index 46ed00cb..46845340 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowAbstractIcon.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowAbstractIcon.java @@ -18,44 +18,95 @@ package com.formdev.flatlaf.icons; import java.awt.Color; import java.awt.Component; +import java.awt.Container; import java.awt.Dimension; import java.awt.Graphics2D; -import java.awt.RenderingHints; +import java.awt.Insets; +import java.awt.Window; +import javax.swing.SwingUtilities; import com.formdev.flatlaf.ui.FlatButtonUI; +import com.formdev.flatlaf.ui.FlatTitlePane; import com.formdev.flatlaf.ui.FlatUIUtils; +import com.formdev.flatlaf.util.DerivedColor; import com.formdev.flatlaf.util.HiDPIUtils; +import com.formdev.flatlaf.util.UIScale; /** * Base class for window icons. * * @uiDefault TitlePane.buttonSize Dimension + * @uiDefault TitlePane.buttonInsets Insets optional + * @uiDefault TitlePane.buttonArc int optional * @uiDefault TitlePane.buttonSymbolHeight int - * @uiDefault TitlePane.buttonHoverBackground Color - * @uiDefault TitlePane.buttonPressedBackground Color + * @uiDefault TitlePane.buttonBackground Color optional + * @uiDefault TitlePane.buttonForeground Color optional + * @uiDefault TitlePane.buttonInactiveBackground Color optional + * @uiDefault TitlePane.buttonInactiveForeground Color optional + * @uiDefault TitlePane.buttonHoverBackground Color optional + * @uiDefault TitlePane.buttonHoverForeground Color optional + * @uiDefault TitlePane.buttonPressedBackground Color optional + * @uiDefault TitlePane.buttonPressedForeground Color optional * * @author Karl Tauber */ public abstract class FlatWindowAbstractIcon extends FlatAbstractIcon { - private final int symbolHeight; - private final Color hoverBackground; - private final Color pressedBackground; + /** @since 3.6 */ protected final Insets insets; + /** @since 3.6 */ protected final int arc; + /** @since 3.6 */ protected final int symbolHeight; + + /** @since 3.6 */ protected final Color background; + /** @since 3.6 */ protected final Color foreground; + /** @since 3.6 */ protected final Color inactiveBackground; + /** @since 3.6 */ protected final Color inactiveForeground; + protected final Color hoverBackground; + /** @since 3.6 */ protected final Color hoverForeground; + protected final Color pressedBackground; + /** @since 3.6 */ protected final Color pressedForeground; /** @since 3.2 */ protected FlatWindowAbstractIcon( String windowStyle ) { - this( FlatUIUtils.getSubUIDimension( "TitlePane.buttonSize", windowStyle ), - FlatUIUtils.getSubUIInt( "TitlePane.buttonSymbolHeight", windowStyle, 10 ), - FlatUIUtils.getSubUIColor( "TitlePane.buttonHoverBackground", windowStyle ), - FlatUIUtils.getSubUIColor( "TitlePane.buttonPressedBackground", windowStyle ) ); + this( windowStyle, null, null, null, null, null, null, null, null ); } - /** @since 3.2 */ - protected FlatWindowAbstractIcon( Dimension size, int symbolHeight, Color hoverBackground, Color pressedBackground ) { + /** @since 3.6 */ + protected FlatWindowAbstractIcon( String windowStyle, + Color background, Color foreground, Color inactiveBackground, Color inactiveForeground, + Color hoverBackground, Color hoverForeground, Color pressedBackground, Color pressedForeground ) + { + this( FlatUIUtils.getSubUIDimension( "TitlePane.buttonSize", windowStyle ), + FlatUIUtils.getSubUIInsets( "TitlePane.buttonInsets", windowStyle ), + FlatUIUtils.getSubUIInt( "TitlePane.buttonArc", windowStyle, 0 ), + FlatUIUtils.getSubUIInt( "TitlePane.buttonSymbolHeight", windowStyle, 10 ), + (background != null) ? background : FlatUIUtils.getSubUIColor( "TitlePane.buttonBackground", windowStyle ), + (foreground != null) ? foreground : FlatUIUtils.getSubUIColor( "TitlePane.buttonForeground", windowStyle ), + (inactiveBackground != null) ? inactiveBackground : FlatUIUtils.getSubUIColor( "TitlePane.buttonInactiveBackground", windowStyle ), + (inactiveForeground != null) ? inactiveForeground : FlatUIUtils.getSubUIColor( "TitlePane.buttonInactiveForeground", windowStyle ), + (hoverBackground != null) ? hoverBackground : FlatUIUtils.getSubUIColor( "TitlePane.buttonHoverBackground", windowStyle ), + (hoverForeground != null) ? hoverForeground : FlatUIUtils.getSubUIColor( "TitlePane.buttonHoverForeground", windowStyle ), + (pressedBackground != null) ? pressedBackground : FlatUIUtils.getSubUIColor( "TitlePane.buttonPressedBackground", windowStyle ), + (pressedForeground != null) ? pressedForeground : FlatUIUtils.getSubUIColor( "TitlePane.buttonPressedForeground", windowStyle ) ); + } + + /** @since 3.6 */ + protected FlatWindowAbstractIcon( Dimension size, Insets insets, int arc, int symbolHeight, + Color background, Color foreground, Color inactiveBackground, Color inactiveForeground, + Color hoverBackground, Color hoverForeground, Color pressedBackground, Color pressedForeground ) + { super( size.width, size.height, null ); + this.insets = (insets != null) ? insets : new Insets( 0, 0, 0, 0 ); + this.arc = arc; this.symbolHeight = symbolHeight; + + this.background = background; + this.foreground = foreground; + this.inactiveBackground = inactiveBackground; + this.inactiveForeground = inactiveForeground; this.hoverBackground = hoverBackground; + this.hoverForeground = hoverForeground; this.pressedBackground = pressedBackground; + this.pressedForeground = pressedForeground; } @Override @@ -69,26 +120,39 @@ public abstract class FlatWindowAbstractIcon /** @since 3.5.2 */ @Override protected void paintBackground( Component c, Graphics2D g, int x, int y ) { - Color background = FlatButtonUI.buttonStateColor( c, null, null, null, hoverBackground, pressedBackground ); + Color bg = null; + if( background != null || inactiveBackground != null ) { + Window window = SwingUtilities.windowForComponent( c ); + bg = (window == null || window.isActive()) ? background : inactiveBackground; + } + + Color background = FlatButtonUI.buttonStateColor( c, bg, null, null, hoverBackground, pressedBackground ); if( background != null ) { - // disable antialiasing for background rectangle painting to avoid blurry edges when scaled (e.g. at 125% or 175%) - Object oldHint = g.getRenderingHint( RenderingHints.KEY_ANTIALIASING ); - g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF ); + Insets insets = UIScale.scale( this.insets ); + float arc = UIScale.scale( (float) this.arc ); - // fill background of whole component - g.setColor( FlatUIUtils.deriveColor( background, c.getBackground() ) ); - g.fillRect( 0, 0, c.getWidth(), c.getHeight() ); + // derive color from title pane background + if( background instanceof DerivedColor ) { + Container titlePane = SwingUtilities.getAncestorOfClass( FlatTitlePane.class, c ); + Component baseComp = (titlePane != null) ? titlePane : c; + background = FlatUIUtils.deriveColor( background, baseComp.getBackground() ); + } - g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, oldHint ); + g.setColor( background ); + FlatUIUtils.paintComponentBackground( g, insets.left, insets.top, + c.getWidth() - insets.left - insets.right, + c.getHeight() - insets.top - insets.bottom, + 0, arc ); } } protected Color getForeground( Component c ) { - return c.getForeground(); - } - - /** @since 3.2 */ - protected int getSymbolHeight() { - return symbolHeight; + Color fg = null; + if( foreground != null || inactiveForeground != null ) { + Window window = SwingUtilities.windowForComponent( c ); + fg = (window == null || window.isActive()) ? foreground : inactiveForeground; + } + return FlatButtonUI.buttonStateColor( c, (fg != null) ? fg : c.getForeground(), + null, null, hoverForeground, pressedForeground ); } } diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowCloseIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowCloseIcon.java index a4fd835d..f5187c95 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowCloseIcon.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowCloseIcon.java @@ -17,53 +17,54 @@ package com.formdev.flatlaf.icons; import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Component; import java.awt.Graphics2D; import java.awt.geom.Path2D; -import com.formdev.flatlaf.ui.FlatButtonUI; import com.formdev.flatlaf.ui.FlatUIUtils; import com.formdev.flatlaf.util.SystemInfo; /** * "close" icon for windows (frames and dialogs). * - * @uiDefault TitlePane.closeHoverBackground Color - * @uiDefault TitlePane.closePressedBackground Color - * @uiDefault TitlePane.closeHoverForeground Color - * @uiDefault TitlePane.closePressedForeground Color + * @uiDefault TitlePane.closeBackground Color optional + * @uiDefault TitlePane.closeForeground Color optional + * @uiDefault TitlePane.closeInactiveBackground Color optional + * @uiDefault TitlePane.closeInactiveForeground Color optional + * @uiDefault TitlePane.closeHoverBackground Color optional + * @uiDefault TitlePane.closeHoverForeground Color optional + * @uiDefault TitlePane.closePressedBackground Color optional + * @uiDefault TitlePane.closePressedForeground Color optional * * @author Karl Tauber */ public class FlatWindowCloseIcon extends FlatWindowAbstractIcon { - private final Color hoverForeground; - private final Color pressedForeground; - public FlatWindowCloseIcon() { this( null ); } /** @since 3.2 */ public FlatWindowCloseIcon( String windowStyle ) { - super( FlatUIUtils.getSubUIDimension( "TitlePane.buttonSize", windowStyle ), - FlatUIUtils.getSubUIInt( "TitlePane.buttonSymbolHeight", windowStyle, 10 ), + super( windowStyle, + FlatUIUtils.getSubUIColor( "TitlePane.closeBackground", windowStyle ), + FlatUIUtils.getSubUIColor( "TitlePane.closeForeground", windowStyle ), + FlatUIUtils.getSubUIColor( "TitlePane.closeInactiveBackground", windowStyle ), + FlatUIUtils.getSubUIColor( "TitlePane.closeInactiveForeground", windowStyle ), FlatUIUtils.getSubUIColor( "TitlePane.closeHoverBackground", windowStyle ), - FlatUIUtils.getSubUIColor( "TitlePane.closePressedBackground", windowStyle ) ); - - hoverForeground = FlatUIUtils.getSubUIColor( "TitlePane.closeHoverForeground", windowStyle ); - pressedForeground = FlatUIUtils.getSubUIColor( "TitlePane.closePressedForeground", windowStyle ); + FlatUIUtils.getSubUIColor( "TitlePane.closeHoverForeground", windowStyle ), + FlatUIUtils.getSubUIColor( "TitlePane.closePressedBackground", windowStyle ), + FlatUIUtils.getSubUIColor( "TitlePane.closePressedForeground", windowStyle ) ); } @Override protected void paintIconAt1x( Graphics2D g, int x, int y, int width, int height, double scaleFactor ) { - int iwh = (int) (getSymbolHeight() * scaleFactor); + int iwh = (int) (symbolHeight * scaleFactor); int ix = x + ((width - iwh) / 2); int iy = y + ((height - iwh) / 2); int ix2 = ix + iwh - 1; int iy2 = iy + iwh - 1; - float thickness = Math.max( SystemInfo.isWindows_11_orLater ? (float) scaleFactor : (int) scaleFactor, 1 ); + boolean isWindows10 = SystemInfo.isWindows_10_orLater && !SystemInfo.isWindows_11_orLater; + float thickness = Math.max( isWindows10 ? (int) scaleFactor : (float) scaleFactor, 1 ); Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD, 4 ); path.moveTo( ix, iy ); @@ -73,9 +74,4 @@ public class FlatWindowCloseIcon g.setStroke( new BasicStroke( thickness ) ); g.draw( path ); } - - @Override - protected Color getForeground( Component c ) { - return FlatButtonUI.buttonStateColor( c, c.getForeground(), null, null, hoverForeground, pressedForeground ); - } } diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowIconifyIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowIconifyIcon.java index e7d11cda..c0367e2c 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowIconifyIcon.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowIconifyIcon.java @@ -37,7 +37,7 @@ public class FlatWindowIconifyIcon @Override protected void paintIconAt1x( Graphics2D g, int x, int y, int width, int height, double scaleFactor ) { - int iw = (int) (getSymbolHeight() * scaleFactor); + int iw = (int) (symbolHeight * scaleFactor); int ih = Math.max( (int) scaleFactor, 1 ); int ix = x + ((width - iw) / 2); int iy = y + ((height - ih) / 2); diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowMaximizeIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowMaximizeIcon.java index a731c21b..abd3992b 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowMaximizeIcon.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowMaximizeIcon.java @@ -39,10 +39,11 @@ public class FlatWindowMaximizeIcon @Override protected void paintIconAt1x( Graphics2D g, int x, int y, int width, int height, double scaleFactor ) { - int iwh = (int) (getSymbolHeight() * scaleFactor); + int iwh = (int) (symbolHeight * scaleFactor); int ix = x + ((width - iwh) / 2); int iy = y + ((height - iwh) / 2); - float thickness = Math.max( SystemInfo.isWindows_11_orLater ? (float) scaleFactor : (int) scaleFactor, 1 ); + boolean isWindows10 = SystemInfo.isWindows_10_orLater && !SystemInfo.isWindows_11_orLater; + float thickness = Math.max( isWindows10 ? (int) scaleFactor : (float) scaleFactor, 1 ); int arc = Math.max( (int) (1.5 * scaleFactor), 2 ); g.fill( SystemInfo.isWindows_11_orLater diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowRestoreIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowRestoreIcon.java index 4e216495..bdfd8115 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowRestoreIcon.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/icons/FlatWindowRestoreIcon.java @@ -42,14 +42,15 @@ public class FlatWindowRestoreIcon @Override protected void paintIconAt1x( Graphics2D g, int x, int y, int width, int height, double scaleFactor ) { - int iwh = (int) (getSymbolHeight() * scaleFactor); + int iwh = (int) (symbolHeight * scaleFactor); int ix = x + ((width - iwh) / 2); int iy = y + ((height - iwh) / 2); - float thickness = Math.max( SystemInfo.isWindows_11_orLater ? (float) scaleFactor : (int) scaleFactor, 1 ); + boolean isWindows10 = SystemInfo.isWindows_10_orLater && !SystemInfo.isWindows_11_orLater; + float thickness = Math.max( isWindows10 ? (int) scaleFactor : (float) scaleFactor, 1 ); int arc = Math.max( (int) (1.5 * scaleFactor), 2 ); int arcOuter = (int) (arc + (1.5 * scaleFactor)); - int rwh = (int) ((getSymbolHeight() - 2) * scaleFactor); + int rwh = (int) ((symbolHeight - 2) * scaleFactor); int ro2 = iwh - rwh; // upper-right rectangle diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java index d5b77bfa..6ec58389 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRootPaneUI.java @@ -31,6 +31,7 @@ import java.awt.Window; import java.awt.event.ComponentListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.Objects; import java.util.function.Function; import javax.swing.JComponent; import javax.swing.JDialog; @@ -485,8 +486,12 @@ public class FlatRootPaneUI break; case "ancestor": - if( e.getNewValue() instanceof Window ) + if( e.getNewValue() instanceof Window ) { + if( titlePane != null && !Objects.equals( titlePane.windowStyle, FlatTitlePane.getWindowStyle( rootPane ) ) ) + setTitlePane( createTitlePane() ); + macClearBackgroundForTranslucentWindow( rootPane ); + } macUninstallWindowBackgroundListener( rootPane ); macInstallWindowBackgroundListener( rootPane ); diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java index de7217d7..369332e7 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTitlePane.java @@ -89,13 +89,16 @@ import com.formdev.flatlaf.util.UIScale; * @uiDefault TitlePane.iconSize Dimension * @uiDefault TitlePane.iconMargins Insets * @uiDefault TitlePane.titleMargins Insets - * @uiDefault TitlePane.menuBarEmbedded boolean * @uiDefault TitlePane.titleMinimumWidth int * @uiDefault TitlePane.buttonMinimumWidth int * @uiDefault TitlePane.buttonMaximizedHeight int + * @uiDefault TitlePane.buttonsGap int + * @uiDefault TitlePane.buttonsMargins Insets + * @uiDefault TitlePane.buttonsFillVertically boolean * @uiDefault TitlePane.centerTitle boolean * @uiDefault TitlePane.centerTitleIfMenuBarEmbedded boolean * @uiDefault TitlePane.showIconBesideTitle boolean + * @uiDefault TitlePane.menuBarEmbedded boolean * @uiDefault TitlePane.menuBarTitleGap int * @uiDefault TitlePane.menuBarTitleMinimumGap int * @uiDefault TitlePane.closeIcon Icon @@ -123,9 +126,14 @@ public class FlatTitlePane /** @since 2.5 */ protected final boolean showIconInDialogs; /** @since 2 */ protected final int noIconLeftGap; protected final Dimension iconSize; + /** @since 3.6 */ protected final Insets iconMargins; + /** @since 3.6 */ protected final Insets titleMargins; /** @since 2.4 */ protected final int titleMinimumWidth; /** @since 2.4 */ protected final int buttonMinimumWidth; protected final int buttonMaximizedHeight; + /** @since 3.6 */ protected final int buttonsGap; + /** @since 3.6 */ protected final Insets buttonsMargins; + /** @since 3.6 */ protected final boolean buttonsFillVertically; protected final boolean centerTitle; protected final boolean centerTitleIfMenuBarEmbedded; /** @since 2.4 */ protected final boolean showIconBesideTitle; @@ -145,6 +153,9 @@ public class FlatTitlePane protected JButton restoreButton; protected JButton closeButton; + private JComponent iconifyMaximizeGapComp; + private JComponent maximizeCloseGapComp; + protected Window window; private final Handler handler; @@ -179,9 +190,7 @@ public class FlatTitlePane public FlatTitlePane( JRootPane rootPane ) { this.rootPane = rootPane; - Window w = SwingUtilities.getWindowAncestor( rootPane ); - String defaultWindowStyle = (w != null && w.getType() == Window.Type.UTILITY) ? WINDOW_STYLE_SMALL : null; - windowStyle = clientProperty( rootPane, WINDOW_STYLE, defaultWindowStyle, String.class ); + windowStyle = getWindowStyle( rootPane ); titleFont = FlatUIUtils.getSubUIFont( "TitlePane.font", windowStyle ); activeBackground = FlatUIUtils.getSubUIColor( "TitlePane.background", windowStyle ); @@ -196,9 +205,14 @@ public class FlatTitlePane showIconInDialogs = FlatUIUtils.getSubUIBoolean( "TitlePane.showIconInDialogs", windowStyle, true ); noIconLeftGap = FlatUIUtils.getSubUIInt( "TitlePane.noIconLeftGap", windowStyle, 8 ); iconSize = FlatUIUtils.getSubUIDimension( "TitlePane.iconSize", windowStyle ); + iconMargins = FlatUIUtils.getSubUIInsets( "TitlePane.iconMargins", windowStyle ); + titleMargins = FlatUIUtils.getSubUIInsets( "TitlePane.titleMargins", windowStyle ); titleMinimumWidth = FlatUIUtils.getSubUIInt( "TitlePane.titleMinimumWidth", windowStyle, 60 ); buttonMinimumWidth = FlatUIUtils.getSubUIInt( "TitlePane.buttonMinimumWidth", windowStyle, 30 ); buttonMaximizedHeight = FlatUIUtils.getSubUIInt( "TitlePane.buttonMaximizedHeight", windowStyle, 0 ); + buttonsGap = FlatUIUtils.getSubUIInt( "TitlePane.buttonsGap", windowStyle, 0 ); + buttonsMargins = FlatUIUtils.getSubUIInsets( "TitlePane.buttonsMargins", windowStyle ); + buttonsFillVertically = FlatUIUtils.getSubUIBoolean( "TitlePane.buttonsFillVertically", windowStyle, true ); centerTitle = FlatUIUtils.getSubUIBoolean( "TitlePane.centerTitle", windowStyle, false ); centerTitleIfMenuBarEmbedded = FlatUIUtils.getSubUIBoolean( "TitlePane.centerTitleIfMenuBarEmbedded", windowStyle, true ); showIconBesideTitle = FlatUIUtils.getSubUIBoolean( "TitlePane.showIconBesideTitle", windowStyle, false ); @@ -228,6 +242,12 @@ public class FlatTitlePane applyComponentOrientation( rootPane.getComponentOrientation() ); } + static String getWindowStyle( JRootPane rootPane ) { + Window w = SwingUtilities.getWindowAncestor( rootPane ); + String defaultWindowStyle = (w != null && w.getType() == Window.Type.UTILITY) ? WINDOW_STYLE_SMALL : null; + return clientProperty( rootPane, WINDOW_STYLE, defaultWindowStyle, String.class ); + } + protected FlatTitlePaneBorder createTitlePaneBorder() { return new FlatTitlePaneBorder(); } @@ -245,8 +265,8 @@ public class FlatTitlePane setUI( new FlatTitleLabelUI() ); } }; - iconLabel.setBorder( new FlatEmptyBorder( FlatUIUtils.getSubUIInsets( "TitlePane.iconMargins", windowStyle ) ) ); - titleLabel.setBorder( new FlatEmptyBorder( FlatUIUtils.getSubUIInsets( "TitlePane.titleMargins", windowStyle ) ) ); + iconLabel.setBorder( new FlatEmptyBorder( iconMargins ) ); + titleLabel.setBorder( new FlatEmptyBorder( titleMargins ) ); leftPanel.setLayout( new BoxLayout( leftPanel, BoxLayout.LINE_AXIS ) ); leftPanel.setOpaque( false ); @@ -349,10 +369,15 @@ public class FlatTitlePane restoreButton = createButton( "TitlePane.restoreIcon", "Restore", e -> restore() ); closeButton = createButton( "TitlePane.closeIcon", "Close", e -> close() ); + iconifyMaximizeGapComp = createButtonsGapComp(); + maximizeCloseGapComp = createButtonsGapComp(); + // initially hide buttons that are only supported in frames iconifyButton.setVisible( false ); maximizeButton.setVisible( false ); restoreButton.setVisible( false ); + iconifyMaximizeGapComp.setVisible( false ); + maximizeCloseGapComp.setVisible( false ); buttonPanel = new JPanel() { @Override @@ -364,12 +389,13 @@ public class FlatTitlePane if( buttonMaximizedHeight > 0 && isWindowMaximized() && !hasVisibleEmbeddedMenuBar( rootPane.getJMenuBar() ) ) { // make title pane height smaller when frame is maximized - size = new Dimension( size.width, Math.min( size.height, UIScale.scale( buttonMaximizedHeight ) ) ); + size = new Dimension( size.width, Math.min( size.height, UIScale.scale( buttonMaximizedHeight + buttonsMargins.top + buttonsMargins.bottom ) ) ); } return size; } }; buttonPanel.setOpaque( false ); + buttonPanel.setBorder( FlatUIUtils.nonUIResource( new FlatEmptyBorder( buttonsMargins ) ) ); buttonPanel.setLayout( new BoxLayout( buttonPanel, BoxLayout.LINE_AXIS ) ); if( rootPane.getWindowDecorationStyle() == JRootPane.FRAME ) { // JRootPane.FRAME works only for frames (and not for dialogs) @@ -378,8 +404,10 @@ public class FlatTitlePane // later in frameStateChanged(), which is invoked from addNotify() buttonPanel.add( iconifyButton ); + buttonPanel.add( iconifyMaximizeGapComp ); buttonPanel.add( maximizeButton ); buttonPanel.add( restoreButton ); + buttonPanel.add( maximizeCloseGapComp ); } buttonPanel.add( closeButton ); @@ -396,13 +424,17 @@ public class FlatTitlePane @Override public Dimension getMinimumSize() { // allow the button to shrink if space is rare - return new Dimension( UIScale.scale( buttonMinimumWidth ), super.getMinimumSize().height ); + return new Dimension( + Math.min( UIScale.scale( buttonMinimumWidth ), super.getPreferredSize().width ), + super.getMinimumSize().height ); } @Override public Dimension getMaximumSize() { // allow the button to fill whole button area height // see also BasicMenuUI.getMaximumSize() - return new Dimension( super.getMaximumSize().width, Short.MAX_VALUE ); + return buttonsFillVertically + ? new Dimension( super.getMaximumSize().width, Short.MAX_VALUE ) + : super.getMaximumSize(); } }; button.setFocusable( false ); @@ -413,6 +445,14 @@ public class FlatTitlePane return button; } + private JComponent createButtonsGapComp() { + JComponent gapComp = new JPanel(); + gapComp.setOpaque( false ); + gapComp.setMinimumSize( new Dimension( 0, 0 ) ); + gapComp.setPreferredSize( new Dimension( UIScale.scale( buttonsGap ), 0 ) ); + return gapComp; + } + protected void activeChanged( boolean active ) { Color background = clientPropertyColor( rootPane, TITLE_BAR_BACKGROUND, null ); Color foreground = clientPropertyColor( rootPane, TITLE_BAR_FOREGROUND, null ); @@ -434,6 +474,9 @@ public class FlatTitlePane closeButton.setForeground( foreground ); // this is necessary because hover/pressed colors are derived from background color + // (since FlatWindowAbstractIcon now invokes FlatTitlePane.getBackground() + // to get base color, this is no longer necessary, but keep it for compatibility; + // e.g. for custom window icons) iconifyButton.setBackground( background ); maximizeButton.setBackground( background ); restoreButton.setBackground( background ); @@ -493,6 +536,13 @@ public class FlatTitlePane maximizeButton.setVisible( false ); restoreButton.setVisible( false ); } + + boolean iconifyVisible = iconifyButton.isVisible(); + boolean maximizeVisible = maximizeButton.isVisible(); + boolean restoreVisible = restoreButton.isVisible(); + boolean closeVisible = closeButton.isVisible(); + iconifyMaximizeGapComp.setVisible( iconifyVisible && (maximizeVisible || restoreVisible || closeVisible) ); + maximizeCloseGapComp.setVisible( closeVisible && (maximizeVisible || restoreVisible) ); } protected void updateIcon() { @@ -746,12 +796,17 @@ public class FlatTitlePane if( isFullWindowContent() ) return; + g.setColor( getBackground() ); + g.fillRect( 0, 0, getWidth(), getHeight() ); + } + + @Override + public Color getBackground() { // not storing value of "TitlePane.unifiedBackground" in class to allow changing at runtime - g.setColor( (UIManager.getBoolean( "TitlePane.unifiedBackground" ) && + return (UIManager.getBoolean( "TitlePane.unifiedBackground" ) && clientPropertyColor( rootPane, TITLE_BAR_BACKGROUND, null ) == null) ? FlatUIUtils.getParentBackground( this ) - : getBackground() ); - g.fillRect( 0, 0, getWidth(), getHeight() ); + : super.getBackground(); } /** @@ -1093,6 +1148,7 @@ public class FlatTitlePane if( !c.isDisplayable() || !c.isVisible() || !contains( c, x, y ) || c == mouseLayer ) return true; // continue checking with next component + // check enabled component that has mouse listeners if( c.isEnabled() && (c.getMouseListeners().length > 0 || c.getMouseMotionListeners().length > 0) ) diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties index 96a12438..1eda0de3 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties @@ -343,8 +343,13 @@ TableHeader.bottomSeparatorColor = $TableHeader.separatorColor #---- TitlePane ---- TitlePane.embeddedForeground = darken($TitlePane.foreground,15%) -TitlePane.buttonHoverBackground = lighten($TitlePane.background,15%,derived) -TitlePane.buttonPressedBackground = lighten($TitlePane.background,10%,derived) +TitlePane.buttonHoverBackground = lighten($TitlePane.background,10%,derived) +TitlePane.buttonPressedBackground = lighten($TitlePane.background,6%,derived) + +# Linux +[linux]TitlePane.buttonBackground = lighten($TitlePane.background,5%,derived) +[linux]TitlePane.buttonHoverBackground = lighten($TitlePane.background,10%,derived) +[linux]TitlePane.buttonPressedBackground = lighten($TitlePane.background,15%,derived) #---- ToggleButton ---- diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index 9a9f3c90..ec2dbdaa 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -823,9 +823,14 @@ TitlePane.iconMargins = 3,8,3,8 TitlePane.titleMargins = 3,0,3,0 TitlePane.titleMinimumWidth = 60 TitlePane.buttonSize = 44,30 +TitlePane.buttonInsets = 0,0,0,0 +TitlePane.buttonArc = 0 TitlePane.buttonMinimumWidth = 30 TitlePane.buttonMaximizedHeight = 22 TitlePane.buttonSymbolHeight = 10 +TitlePane.buttonsGap = 0 +TitlePane.buttonsMargins = 0,0,0,0 +TitlePane.buttonsFillVertically = true TitlePane.centerTitle = false TitlePane.centerTitleIfMenuBarEmbedded = true TitlePane.showIconBesideTitle = false @@ -856,6 +861,27 @@ TitlePane.small.iconifyIcon = com.formdev.flatlaf.icons.FlatWindowIconifyIcon, s TitlePane.small.maximizeIcon = com.formdev.flatlaf.icons.FlatWindowMaximizeIcon, small TitlePane.small.restoreIcon = com.formdev.flatlaf.icons.FlatWindowRestoreIcon, small +# Linux +[linux]TitlePane.buttonSize = 26,26 +[linux]TitlePane.buttonInsets = 2,2,2,2 +[linux]TitlePane.buttonArc = 999 +[linux]TitlePane.buttonMaximizedHeight = -1 +[linux]TitlePane.buttonSymbolHeight = 8 +[linux]TitlePane.buttonsGap = 8 +[linux]TitlePane.buttonsMargins = 4,4,4,4 +[linux]TitlePane.buttonsFillVertically = false +[linux]TitlePane.small.buttonSize = 20,20 +[linux]TitlePane.small.buttonInsets = 1,1,1,1 +[linux]TitlePane.small.buttonSymbolHeight = 6 +[linux]TitlePane.small.buttonsGap = 4 +[linux]TitlePane.small.buttonsMargins = 2,2,2,2 +[linux]TitlePane.closeBackground = $?TitlePane.buttonBackground +[linux]TitlePane.closeInactiveBackground = $?TitlePane.buttonInactiveBackground +[linux]TitlePane.closeHoverBackground = $?TitlePane.buttonHoverBackground +[linux]TitlePane.closePressedBackground = $?TitlePane.buttonPressedBackground +[linux]TitlePane.closeHoverForeground = $?TitlePane.foreground +[linux]TitlePane.closePressedForeground = $?TitlePane.foreground + #---- ToggleButton ---- diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties index a2dc31dc..a9165856 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties @@ -349,8 +349,13 @@ TableHeader.bottomSeparatorColor = $TableHeader.separatorColor #---- TitlePane ---- TitlePane.embeddedForeground = lighten($TitlePane.foreground,35%) -TitlePane.buttonHoverBackground = darken($TitlePane.background,10%,derived) -TitlePane.buttonPressedBackground = darken($TitlePane.background,8%,derived) +TitlePane.buttonHoverBackground = darken($TitlePane.background,5%,derived) +TitlePane.buttonPressedBackground = darken($TitlePane.background,3%,derived) + +# Linux +[linux]TitlePane.buttonBackground = darken($TitlePane.background,5%,derived) +[linux]TitlePane.buttonHoverBackground = darken($TitlePane.background,10%,derived) +[linux]TitlePane.buttonPressedBackground = darken($TitlePane.background,15%,derived) #---- ToggleButton ---- diff --git a/flatlaf-extras/src/main/resources/com/formdev/flatlaf/extras/resources/DerivedColorKeys.properties b/flatlaf-extras/src/main/resources/com/formdev/flatlaf/extras/resources/DerivedColorKeys.properties index c1231de4..0e8836da 100644 --- a/flatlaf-extras/src/main/resources/com/formdev/flatlaf/extras/resources/DerivedColorKeys.properties +++ b/flatlaf-extras/src/main/resources/com/formdev/flatlaf/extras/resources/DerivedColorKeys.properties @@ -215,8 +215,14 @@ TableHeader.pressedForeground = TableHeader.foreground #---- TitlePane ---- +TitlePane.buttonBackground = TitlePane.background +TitlePane.buttonInactiveBackground = TitlePane.background TitlePane.buttonHoverBackground = TitlePane.background TitlePane.buttonPressedBackground = TitlePane.background +TitlePane.closeBackground = TitlePane.background +TitlePane.closeInactiveBackground = TitlePane.background +TitlePane.closeHoverBackground = TitlePane.background +TitlePane.closePressedBackground = TitlePane.background #---- ToggleButton ---- diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0-linux.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0-linux.txt index 8bc449d5..f70ad825 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0-linux.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0-linux.txt @@ -45,8 +45,86 @@ #---- TitlePane ---- +- TitlePane.buttonArc 0 ++ TitlePane.buttonArc 999 + ++ TitlePane.buttonBackground #3c3f41 HSL 204 4 25 com.formdev.flatlaf.util.DerivedColor [UI] lighten(5% autoInverse) + +- TitlePane.buttonInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] ++ TitlePane.buttonInsets 2,2,2,2 javax.swing.plaf.InsetsUIResource [UI] + +- TitlePane.buttonMaximizedHeight 22 ++ TitlePane.buttonMaximizedHeight -1 + +- TitlePane.buttonPressedBackground #3f4144 HSL 216 4 26 com.formdev.flatlaf.util.DerivedColor [UI] lighten(6% autoInverse) ++ TitlePane.buttonPressedBackground #55585c HSL 214 4 35 com.formdev.flatlaf.util.DerivedColor [UI] lighten(15% autoInverse) + +- TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI] ++ TitlePane.buttonSize 26,26 javax.swing.plaf.DimensionUIResource [UI] + +- TitlePane.buttonSymbolHeight 10 ++ TitlePane.buttonSymbolHeight 8 + +- TitlePane.buttonsFillVertically true ++ TitlePane.buttonsFillVertically false + +- TitlePane.buttonsGap 0 ++ TitlePane.buttonsGap 8 + +- TitlePane.buttonsMargins 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] ++ TitlePane.buttonsMargins 4,4,4,4 javax.swing.plaf.InsetsUIResource [UI] + ++ TitlePane.closeBackground #3c3f41 HSL 204 4 25 com.formdev.flatlaf.util.DerivedColor [UI] lighten(5% autoInverse) + +- TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI] ++ TitlePane.closeHoverBackground #484c4f HSL 206 5 30 com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse) + +- TitlePane.closeHoverForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ++ TitlePane.closeHoverForeground #dddddd HSL 0 0 87 javax.swing.plaf.ColorUIResource [UI] + +- TitlePane.closeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI] ++ TitlePane.closeIcon [lazy] 26,26 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI] + +- TitlePane.closePressedBackground #c42b1ce6 90% HSLA 5 75 44 90 javax.swing.plaf.ColorUIResource [UI] ++ TitlePane.closePressedBackground #55585c HSL 214 4 35 com.formdev.flatlaf.util.DerivedColor [UI] lighten(15% autoInverse) + +- TitlePane.closePressedForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ++ TitlePane.closePressedForeground #dddddd HSL 0 0 87 javax.swing.plaf.ColorUIResource [UI] + +- TitlePane.iconifyIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI] ++ TitlePane.iconifyIcon [lazy] 26,26 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI] + +- TitlePane.maximizeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI] ++ TitlePane.maximizeIcon [lazy] 26,26 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI] + +- TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] ++ TitlePane.restoreIcon [lazy] 26,26 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] + ++ TitlePane.small.buttonInsets 1,1,1,1 javax.swing.plaf.InsetsUIResource [UI] + +- TitlePane.small.buttonSize 30,20 javax.swing.plaf.DimensionUIResource [UI] ++ TitlePane.small.buttonSize 20,20 javax.swing.plaf.DimensionUIResource [UI] + +- TitlePane.small.buttonSymbolHeight 8 ++ TitlePane.small.buttonSymbolHeight 6 + ++ TitlePane.small.buttonsGap 4 ++ TitlePane.small.buttonsMargins 2,2,2,2 javax.swing.plaf.InsetsUIResource [UI] + +- TitlePane.small.closeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI] ++ TitlePane.small.closeIcon [lazy] 20,20 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI] + - TitlePane.small.font [active] Segoe UI plain 11 javax.swing.plaf.FontUIResource [UI] + TitlePane.small.font [active] Liberation Sans plain 14 javax.swing.plaf.FontUIResource [UI] + +- TitlePane.small.iconifyIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI] ++ TitlePane.small.iconifyIcon [lazy] 20,20 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI] + +- TitlePane.small.maximizeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI] ++ TitlePane.small.maximizeIcon [lazy] 20,20 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI] + +- TitlePane.small.restoreIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] ++ TitlePane.small.restoreIcon [lazy] 20,20 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] - defaultFont Segoe UI plain 12 javax.swing.plaf.FontUIResource [UI] + defaultFont Liberation Sans plain 15 javax.swing.plaf.FontUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt index d5866f93..ce1fec24 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt @@ -1255,12 +1255,17 @@ TipOfTheDay.tipAreaInsets 4,16,4,16 javax.swing.plaf.InsetsUIResource [U #---- TitlePane ---- TitlePane.background #303234 HSL 210 4 20 javax.swing.plaf.ColorUIResource [UI] -TitlePane.buttonHoverBackground #55585c HSL 214 4 35 com.formdev.flatlaf.util.DerivedColor [UI] lighten(15% autoInverse) +TitlePane.buttonArc 0 +TitlePane.buttonHoverBackground #484c4f HSL 206 5 30 com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse) +TitlePane.buttonInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.buttonMaximizedHeight 22 TitlePane.buttonMinimumWidth 30 -TitlePane.buttonPressedBackground #484c4f HSL 206 5 30 com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse) +TitlePane.buttonPressedBackground #3f4144 HSL 216 4 26 com.formdev.flatlaf.util.DerivedColor [UI] lighten(6% autoInverse) TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI] TitlePane.buttonSymbolHeight 10 +TitlePane.buttonsFillVertically true +TitlePane.buttonsGap 0 +TitlePane.buttonsMargins 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.centerTitle false TitlePane.centerTitleIfMenuBarEmbedded true TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0-linux.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0-linux.txt index 8bc449d5..d8837b5a 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0-linux.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0-linux.txt @@ -45,8 +45,89 @@ #---- TitlePane ---- +- TitlePane.buttonArc 0 ++ TitlePane.buttonArc 999 + ++ TitlePane.buttonBackground #f2f2f2 HSL 0 0 95 com.formdev.flatlaf.util.DerivedColor [UI] darken(5% autoInverse) + +- TitlePane.buttonHoverBackground #f2f2f2 HSL 0 0 95 com.formdev.flatlaf.util.DerivedColor [UI] darken(5% autoInverse) ++ TitlePane.buttonHoverBackground #e6e6e6 HSL 0 0 90 com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse) + +- TitlePane.buttonInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] ++ TitlePane.buttonInsets 2,2,2,2 javax.swing.plaf.InsetsUIResource [UI] + +- TitlePane.buttonMaximizedHeight 22 ++ TitlePane.buttonMaximizedHeight -1 + +- TitlePane.buttonPressedBackground #f7f7f7 HSL 0 0 97 com.formdev.flatlaf.util.DerivedColor [UI] darken(3% autoInverse) ++ TitlePane.buttonPressedBackground #d9d9d9 HSL 0 0 85 com.formdev.flatlaf.util.DerivedColor [UI] darken(15% autoInverse) + +- TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI] ++ TitlePane.buttonSize 26,26 javax.swing.plaf.DimensionUIResource [UI] + +- TitlePane.buttonSymbolHeight 10 ++ TitlePane.buttonSymbolHeight 8 + +- TitlePane.buttonsFillVertically true ++ TitlePane.buttonsFillVertically false + +- TitlePane.buttonsGap 0 ++ TitlePane.buttonsGap 8 + +- TitlePane.buttonsMargins 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] ++ TitlePane.buttonsMargins 4,4,4,4 javax.swing.plaf.InsetsUIResource [UI] + ++ TitlePane.closeBackground #f2f2f2 HSL 0 0 95 com.formdev.flatlaf.util.DerivedColor [UI] darken(5% autoInverse) + +- TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI] ++ TitlePane.closeHoverBackground #e6e6e6 HSL 0 0 90 com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse) + +- TitlePane.closeHoverForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ++ TitlePane.closeHoverForeground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] + +- TitlePane.closeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI] ++ TitlePane.closeIcon [lazy] 26,26 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI] + +- TitlePane.closePressedBackground #c42b1ce6 90% HSLA 5 75 44 90 javax.swing.plaf.ColorUIResource [UI] ++ TitlePane.closePressedBackground #d9d9d9 HSL 0 0 85 com.formdev.flatlaf.util.DerivedColor [UI] darken(15% autoInverse) + +- TitlePane.closePressedForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ++ TitlePane.closePressedForeground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] + +- TitlePane.iconifyIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI] ++ TitlePane.iconifyIcon [lazy] 26,26 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI] + +- TitlePane.maximizeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI] ++ TitlePane.maximizeIcon [lazy] 26,26 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI] + +- TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] ++ TitlePane.restoreIcon [lazy] 26,26 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] + ++ TitlePane.small.buttonInsets 1,1,1,1 javax.swing.plaf.InsetsUIResource [UI] + +- TitlePane.small.buttonSize 30,20 javax.swing.plaf.DimensionUIResource [UI] ++ TitlePane.small.buttonSize 20,20 javax.swing.plaf.DimensionUIResource [UI] + +- TitlePane.small.buttonSymbolHeight 8 ++ TitlePane.small.buttonSymbolHeight 6 + ++ TitlePane.small.buttonsGap 4 ++ TitlePane.small.buttonsMargins 2,2,2,2 javax.swing.plaf.InsetsUIResource [UI] + +- TitlePane.small.closeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI] ++ TitlePane.small.closeIcon [lazy] 20,20 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI] + - TitlePane.small.font [active] Segoe UI plain 11 javax.swing.plaf.FontUIResource [UI] + TitlePane.small.font [active] Liberation Sans plain 14 javax.swing.plaf.FontUIResource [UI] + +- TitlePane.small.iconifyIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI] ++ TitlePane.small.iconifyIcon [lazy] 20,20 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI] + +- TitlePane.small.maximizeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI] ++ TitlePane.small.maximizeIcon [lazy] 20,20 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI] + +- TitlePane.small.restoreIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] ++ TitlePane.small.restoreIcon [lazy] 20,20 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI] - defaultFont Segoe UI plain 12 javax.swing.plaf.FontUIResource [UI] + defaultFont Liberation Sans plain 15 javax.swing.plaf.FontUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt index 8e36270a..47a09ec5 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt @@ -1260,12 +1260,17 @@ TipOfTheDay.tipAreaInsets 4,16,4,16 javax.swing.plaf.InsetsUIResource [U #---- TitlePane ---- TitlePane.background #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] -TitlePane.buttonHoverBackground #e6e6e6 HSL 0 0 90 com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse) +TitlePane.buttonArc 0 +TitlePane.buttonHoverBackground #f2f2f2 HSL 0 0 95 com.formdev.flatlaf.util.DerivedColor [UI] darken(5% autoInverse) +TitlePane.buttonInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.buttonMaximizedHeight 22 TitlePane.buttonMinimumWidth 30 -TitlePane.buttonPressedBackground #ebebeb HSL 0 0 92 com.formdev.flatlaf.util.DerivedColor [UI] darken(8% autoInverse) +TitlePane.buttonPressedBackground #f7f7f7 HSL 0 0 97 com.formdev.flatlaf.util.DerivedColor [UI] darken(3% autoInverse) TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI] TitlePane.buttonSymbolHeight 10 +TitlePane.buttonsFillVertically true +TitlePane.buttonsGap 0 +TitlePane.buttonsMargins 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.centerTitle false TitlePane.centerTitleIfMenuBarEmbedded true TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt index 6c876704..4cf7891a 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt @@ -1265,12 +1265,17 @@ TipOfTheDay.tipAreaInsets 4,16,4,16 javax.swing.plaf.InsetsUIResource [U #---- TitlePane ---- TitlePane.background #323232 HSL 0 0 20 javax.swing.plaf.ColorUIResource [UI] -TitlePane.buttonHoverBackground #585858 HSL 0 0 35 com.formdev.flatlaf.util.DerivedColor [UI] lighten(15% autoInverse) +TitlePane.buttonArc 0 +TitlePane.buttonHoverBackground #4c4c4c HSL 0 0 30 com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse) +TitlePane.buttonInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.buttonMaximizedHeight 22 TitlePane.buttonMinimumWidth 30 -TitlePane.buttonPressedBackground #4c4c4c HSL 0 0 30 com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse) +TitlePane.buttonPressedBackground #414141 HSL 0 0 25 com.formdev.flatlaf.util.DerivedColor [UI] lighten(6% autoInverse) TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI] TitlePane.buttonSymbolHeight 10 +TitlePane.buttonsFillVertically true +TitlePane.buttonsGap 0 +TitlePane.buttonsMargins 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.centerTitle false TitlePane.centerTitleIfMenuBarEmbedded true TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt index 89d3bce3..0cefb988 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt @@ -1269,12 +1269,17 @@ TipOfTheDay.tipAreaInsets 4,16,4,16 javax.swing.plaf.InsetsUIResource [U #---- TitlePane ---- TitlePane.background #ececec HSL 0 0 93 javax.swing.plaf.ColorUIResource [UI] -TitlePane.buttonHoverBackground #d3d3d3 HSL 0 0 83 com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse) +TitlePane.buttonArc 0 +TitlePane.buttonHoverBackground #dfdfdf HSL 0 0 87 com.formdev.flatlaf.util.DerivedColor [UI] darken(5% autoInverse) +TitlePane.buttonInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.buttonMaximizedHeight 22 TitlePane.buttonMinimumWidth 30 -TitlePane.buttonPressedBackground #d8d8d8 HSL 0 0 85 com.formdev.flatlaf.util.DerivedColor [UI] darken(8% autoInverse) +TitlePane.buttonPressedBackground #e4e4e4 HSL 0 0 89 com.formdev.flatlaf.util.DerivedColor [UI] darken(3% autoInverse) TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI] TitlePane.buttonSymbolHeight 10 +TitlePane.buttonsFillVertically true +TitlePane.buttonsGap 0 +TitlePane.buttonsMargins 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.centerTitle false TitlePane.centerTitleIfMenuBarEmbedded true TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt index d08a43b5..572dc92e 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt @@ -1302,17 +1302,34 @@ TipOfTheDay.tipAreaInsets 4,16,4,16 javax.swing.plaf.InsetsUIResource [U TitlePane.background #00ff00 HSL 120 100 50 javax.swing.plaf.ColorUIResource [UI] TitlePane.borderColor #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI] +TitlePane.buttonArc 0 +TitlePane.buttonBackground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] +TitlePane.buttonForeground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] +TitlePane.buttonHoverBackground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI] +TitlePane.buttonHoverForeground #00ff00 HSL 120 100 50 javax.swing.plaf.ColorUIResource [UI] +TitlePane.buttonInactiveBackground #dddddd HSL 0 0 87 javax.swing.plaf.ColorUIResource [UI] +TitlePane.buttonInactiveForeground #0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI] +TitlePane.buttonInsets 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.buttonMaximizedHeight 22 TitlePane.buttonMinimumWidth 30 +TitlePane.buttonPressedBackground #999999 HSL 0 0 60 javax.swing.plaf.ColorUIResource [UI] +TitlePane.buttonPressedForeground #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI] TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI] TitlePane.buttonSymbolHeight 10 +TitlePane.buttonsFillVertically true +TitlePane.buttonsGap 0 +TitlePane.buttonsMargins 0,0,0,0 javax.swing.plaf.InsetsUIResource [UI] TitlePane.centerTitle false TitlePane.centerTitleIfMenuBarEmbedded true -TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI] -TitlePane.closeHoverForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] +TitlePane.closeBackground #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI] +TitlePane.closeForeground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] +TitlePane.closeHoverBackground #bb0000 HSL 0 100 37 javax.swing.plaf.ColorUIResource [UI] +TitlePane.closeHoverForeground #ff00ff HSL 300 100 50 javax.swing.plaf.ColorUIResource [UI] TitlePane.closeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI] -TitlePane.closePressedBackground #c42b1ce6 90% HSLA 5 75 44 90 javax.swing.plaf.ColorUIResource [UI] -TitlePane.closePressedForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] +TitlePane.closeInactiveBackground #dd0000 HSL 0 100 43 javax.swing.plaf.ColorUIResource [UI] +TitlePane.closeInactiveForeground #00ffff HSL 180 100 50 javax.swing.plaf.ColorUIResource [UI] +TitlePane.closePressedBackground #990000 HSL 0 100 30 javax.swing.plaf.ColorUIResource [UI] +TitlePane.closePressedForeground #00ff00 HSL 120 100 50 javax.swing.plaf.ColorUIResource [UI] TitlePane.font [active] $defaultFont [UI] TitlePane.foreground #0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI] TitlePane.icon [lazy] 16,16 sun.swing.ImageIconUIResource [UI] (sun.awt.image.ToolkitImage) @@ -1714,6 +1731,24 @@ windowText #ff0000 HSL 0 100 50 javax.swing.plaf.Colo #-- activeTitleForeground -- InternalFrame.activeTitleForeground #ffaaaa #880000 5.7 !! +#-- buttonForeground -- +TitlePane.buttonForeground #000000 #ffffff 21.0 + +#-- buttonHoverForeground -- +TitlePane.buttonHoverForeground #00ff00 #bbbbbb 1.4 !!!!!! + +#-- buttonInactiveForeground -- +TitlePane.buttonInactiveForeground #0000ff #dddddd 6.3 ! + +#-- buttonPressedForeground -- +TitlePane.buttonPressedForeground #ff0000 #999999 1.4 !!!!!! + +#-- closeForeground -- +TitlePane.closeForeground #000000 #ff0000 5.3 !! + +#-- closeInactiveForeground -- +TitlePane.closeInactiveForeground #00ffff #dd0000 4.1 !!! + #-- disabledForeground -- ComboBox.disabledForeground #000088 #e0e0e0 11.7 Label.disabledForeground #000088 #ccffcc 13.8 diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java index 61fcba20..71bbd22d 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/uidefaults/UIDefaultsDump.java @@ -106,9 +106,9 @@ public class UIDefaultsDump dump( FlatMacLightLaf.class.getName(), dir, false ); dump( FlatMacDarkLaf.class.getName(), dir, false ); - } - dump( FlatTestLaf.class.getName(), dir, false ); + dump( FlatTestLaf.class.getName(), dir, false ); + } // dump( MyBasicLookAndFeel.class.getName(), dir, false ); // dump( MetalLookAndFeel.class.getName(), dir, false ); @@ -192,8 +192,11 @@ public class UIDefaultsDump dump( dir, "", lookAndFeel, defaults, key -> !key.contains( "InputMap" ), true ); if( lookAndFeel.getClass() == FlatLightLaf.class || !(lookAndFeel instanceof FlatLaf) ) { - dump( dir, "_InputMap", lookAndFeel, defaults, key -> key.contains( "InputMap" ), false ); - dumpActionMaps( dir, "_ActionMap", lookAndFeel, defaults ); + if( SystemInfo.isWindows || SystemInfo.isMacOS ) + dump( dir, "_InputMap", lookAndFeel, defaults, key -> key.contains( "InputMap" ), false ); + + if( SystemInfo.isWindows ) + dumpActionMaps( dir, "_ActionMap", lookAndFeel, defaults ); } if( lookAndFeel instanceof IntelliJTheme.ThemeLaf ) { diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties index fe2d401a..50a6b72a 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties @@ -463,6 +463,24 @@ TitlePane.foreground = #00f TitlePane.inactiveForeground = #fff TitlePane.borderColor = #f00 +TitlePane.buttonBackground = #fff +TitlePane.buttonForeground = #000 +TitlePane.buttonInactiveBackground = #ddd +TitlePane.buttonInactiveForeground = #00f +TitlePane.buttonHoverBackground = #bbb +TitlePane.buttonHoverForeground = #0f0 +TitlePane.buttonPressedBackground = #999 +TitlePane.buttonPressedForeground = #f00 + +TitlePane.closeBackground = #f00 +TitlePane.closeForeground = #000 +TitlePane.closeInactiveBackground = #d00 +TitlePane.closeInactiveForeground = #0ff +TitlePane.closeHoverBackground = #b00 +TitlePane.closeHoverForeground = #f0f +TitlePane.closePressedBackground = #900 +TitlePane.closePressedForeground = #0f0 + #---- ToggleButton ---- diff --git a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt index 9d4f9b76..3c93a6ae 100644 --- a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt +++ b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt @@ -1066,17 +1066,32 @@ TipOfTheDay.icon.socketColor TipOfTheDay.tipAreaInsets TitlePane.background TitlePane.borderColor +TitlePane.buttonArc +TitlePane.buttonBackground +TitlePane.buttonForeground TitlePane.buttonHoverBackground +TitlePane.buttonHoverForeground +TitlePane.buttonInactiveBackground +TitlePane.buttonInactiveForeground +TitlePane.buttonInsets TitlePane.buttonMaximizedHeight TitlePane.buttonMinimumWidth TitlePane.buttonPressedBackground +TitlePane.buttonPressedForeground TitlePane.buttonSize TitlePane.buttonSymbolHeight +TitlePane.buttonsFillVertically +TitlePane.buttonsGap +TitlePane.buttonsMargins TitlePane.centerTitle TitlePane.centerTitleIfMenuBarEmbedded +TitlePane.closeBackground +TitlePane.closeForeground TitlePane.closeHoverBackground TitlePane.closeHoverForeground TitlePane.closeIcon +TitlePane.closeInactiveBackground +TitlePane.closeInactiveForeground TitlePane.closePressedBackground TitlePane.closePressedForeground TitlePane.embeddedForeground @@ -1098,17 +1113,32 @@ TitlePane.showIcon TitlePane.showIconBesideTitle TitlePane.showIconInDialogs TitlePane.small.background +TitlePane.small.buttonArc +TitlePane.small.buttonBackground +TitlePane.small.buttonForeground TitlePane.small.buttonHoverBackground +TitlePane.small.buttonHoverForeground +TitlePane.small.buttonInactiveBackground +TitlePane.small.buttonInactiveForeground +TitlePane.small.buttonInsets TitlePane.small.buttonMaximizedHeight TitlePane.small.buttonMinimumWidth TitlePane.small.buttonPressedBackground +TitlePane.small.buttonPressedForeground TitlePane.small.buttonSize TitlePane.small.buttonSymbolHeight +TitlePane.small.buttonsFillVertically +TitlePane.small.buttonsGap +TitlePane.small.buttonsMargins TitlePane.small.centerTitle TitlePane.small.centerTitleIfMenuBarEmbedded +TitlePane.small.closeBackground +TitlePane.small.closeForeground TitlePane.small.closeHoverBackground TitlePane.small.closeHoverForeground TitlePane.small.closeIcon +TitlePane.small.closeInactiveBackground +TitlePane.small.closeInactiveForeground TitlePane.small.closePressedBackground TitlePane.small.closePressedForeground TitlePane.small.embeddedForeground