diff --git a/CHANGELOG.md b/CHANGELOG.md index 61284ce1..1ba9b72a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,11 @@ FlatLaf Change Log #### Fixed bugs -- FlatLaf window decorations on Linux: Fixed broken window resizing on - multi-screen setups. (issue #632) +- FlatLaf window decorations: + - Fixed inconsistent size of glass pane depending on whether FlatLaf window + decorations are used (e.g. Windows 10/11) or not (e.g. macOS). Now the glass + pane no longer overlaps the FlatLaf window title bar. (issue #630) + - Linux: Fixed broken window resizing on multi-screen setups. (issue #632) - IntelliJ Themes: - Fixed default button hover background in "Solarized Light" theme. (issue #628) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java index 3e591a44..6bbd3afe 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -442,6 +442,17 @@ public interface FlatClientProperties */ String TITLE_BAR_FOREGROUND = "JRootPane.titleBarForeground"; + /** + * Specifies whether the glass pane should have full height and overlap the title bar, + * if FlatLaf window decorations are enabled. Default is {@code false}. + *

+ * Component {@link javax.swing.JRootPane}
+ * Value type {@link java.lang.Boolean} + * + * @since 3.1 + */ + String GLASS_PANE_FULL_HEIGHT = "JRootPane.glassPaneFullHeight"; + //---- JScrollBar / JScrollPane ------------------------------------------- /** 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 8177c4fe..6e333a6b 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 @@ -362,6 +362,10 @@ public class FlatRootPaneUI if( titlePane != null ) titlePane.titleBarColorsChanged(); break; + + case FlatClientProperties.GLASS_PANE_FULL_HEIGHT: + rootPane.revalidate(); + break; } } @@ -442,11 +446,11 @@ public class FlatRootPaneUI int width = rootPane.getWidth() - insets.left - insets.right; int height = rootPane.getHeight() - insets.top - insets.bottom; + // layered pane if( rootPane.getLayeredPane() != null ) rootPane.getLayeredPane().setBounds( x, y, width, height ); - if( rootPane.getGlassPane() != null ) - rootPane.getGlassPane().setBounds( x, y, width, height ); + // title pane int nextY = 0; if( titlePane != null ) { int prefHeight = !isFullScreen ? titlePane.getPreferredSize().height : 0; @@ -454,6 +458,15 @@ public class FlatRootPaneUI nextY += prefHeight; } + // glass pane + if( rootPane.getGlassPane() != null ) { + boolean fullHeight = FlatClientProperties.clientPropertyBoolean( + rootPane, FlatClientProperties.GLASS_PANE_FULL_HEIGHT, false ); + int offset = fullHeight ? 0 : nextY; + rootPane.getGlassPane().setBounds( x, y + offset, width, height - offset ); + } + + // menu bar JMenuBar menuBar = rootPane.getJMenuBar(); if( menuBar != null && menuBar.isVisible() ) { boolean embedded = !isFullScreen && titlePane != null && titlePane.isMenuBarEmbedded(); @@ -467,10 +480,12 @@ public class FlatRootPaneUI } } + // content pane Container contentPane = rootPane.getContentPane(); if( contentPane != null ) contentPane.setBounds( 0, nextY, width, Math.max( height - nextY, 0 ) ); + // title pane if( titlePane != null ) titlePane.menuBarLayouted(); } diff --git a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatInspector.java b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatInspector.java index 3b2142ed..327cb228 100644 --- a/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatInspector.java +++ b/flatlaf-extras/src/main/java/com/formdev/flatlaf/extras/FlatInspector.java @@ -108,6 +108,7 @@ public class FlatInspector private Window window; private boolean enabled; + private Object oldGlassPaneFullHeight; private Component lastComponent; private int lastX; private int lastY; @@ -258,6 +259,14 @@ public class FlatInspector this.enabled = enabled; + // make sure that glass pane has full height if enabled + if( enabled ) { + oldGlassPaneFullHeight = rootPane.getClientProperty( FlatClientProperties.GLASS_PANE_FULL_HEIGHT ); + rootPane.putClientProperty( FlatClientProperties.GLASS_PANE_FULL_HEIGHT, true ); + rootPane.validate(); + } else + rootPane.putClientProperty( FlatClientProperties.GLASS_PANE_FULL_HEIGHT, oldGlassPaneFullHeight ); + // make sure that glass pane is not opaque, which is not the case in WebLaF ((JComponent)rootPane.getGlassPane()).setOpaque( false );