Skip to content

Commit

Permalink
Window decorations: glass pane no longer overlaps the FlatLaf window …
Browse files Browse the repository at this point in the history
…title bar (issue #630)
  • Loading branch information
DevCharly committed Jan 3, 2023
1 parent 4b84435 commit 9101324
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
* <p>
* <strong>Component</strong> {@link javax.swing.JRootPane}<br>
* <strong>Value type</strong> {@link java.lang.Boolean}
*
* @since 3.1
*/
String GLASS_PANE_FULL_HEIGHT = "JRootPane.glassPaneFullHeight";

//---- JScrollBar / JScrollPane -------------------------------------------

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ public void propertyChange( PropertyChangeEvent e ) {
if( titlePane != null )
titlePane.titleBarColorsChanged();
break;

case FlatClientProperties.GLASS_PANE_FULL_HEIGHT:
rootPane.revalidate();
break;
}
}

Expand Down Expand Up @@ -442,18 +446,27 @@ public void layoutContainer( Container parent ) {
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;
titlePane.setBounds( 0, 0, width, prefHeight );
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();
Expand All @@ -467,10 +480,12 @@ public void layoutContainer( Container parent ) {
}
}

// 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -258,6 +259,14 @@ public void setEnabled( boolean enabled ) {

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 );

Expand Down

0 comments on commit 9101324

Please sign in to comment.