mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 15:27:16 -06:00
Window decorations: fixed missing window top border on Windows 10 in "full window content" mode (issue #809)
This commit is contained in:
@@ -8,6 +8,8 @@ FlatLaf Change Log
|
|||||||
- TabbedPane: Fixed swapped back and forward scroll buttons when using
|
- TabbedPane: Fixed swapped back and forward scroll buttons when using
|
||||||
`TabbedPane.scrollButtonsPlacement = trailing` (regression in FlatLaf 3.3).
|
`TabbedPane.scrollButtonsPlacement = trailing` (regression in FlatLaf 3.3).
|
||||||
- Extras: `FlatSVGIcon` color filters now support linear gradients. (PR #817)
|
- Extras: `FlatSVGIcon` color filters now support linear gradients. (PR #817)
|
||||||
|
- Fixed missing window top border on Windows 10 in "full window content" mode.
|
||||||
|
(issue 809)
|
||||||
|
|
||||||
|
|
||||||
## 3.4
|
## 3.4
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ public class FlatRootPaneUI
|
|||||||
// layer title pane under frame content layer to allow placing menu bar over title pane
|
// layer title pane under frame content layer to allow placing menu bar over title pane
|
||||||
protected final static Integer TITLE_PANE_LAYER = JLayeredPane.FRAME_CONTENT_LAYER - 1;
|
protected final static Integer TITLE_PANE_LAYER = JLayeredPane.FRAME_CONTENT_LAYER - 1;
|
||||||
private final static Integer TITLE_PANE_MOUSE_LAYER = JLayeredPane.FRAME_CONTENT_LAYER - 2;
|
private final static Integer TITLE_PANE_MOUSE_LAYER = JLayeredPane.FRAME_CONTENT_LAYER - 2;
|
||||||
|
private final static Integer WINDOW_TOP_BORDER_LAYER = Integer.MAX_VALUE;
|
||||||
|
|
||||||
// for fullWindowContent mode, layer title pane over frame content layer to allow placing title bar buttons over content
|
// for fullWindowContent mode, layer title pane over frame content layer to allow placing title bar buttons over content
|
||||||
/** @since 3.4 */
|
/** @since 3.4 */
|
||||||
@@ -285,11 +286,15 @@ public class FlatRootPaneUI
|
|||||||
if( titlePane != null ) {
|
if( titlePane != null ) {
|
||||||
layeredPane.remove( titlePane );
|
layeredPane.remove( titlePane );
|
||||||
layeredPane.remove( titlePane.mouseLayer );
|
layeredPane.remove( titlePane.mouseLayer );
|
||||||
|
if( titlePane.windowTopBorderLayer != null )
|
||||||
|
layeredPane.remove( titlePane.windowTopBorderLayer );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( newTitlePane != null ) {
|
if( newTitlePane != null ) {
|
||||||
layeredPane.add( newTitlePane, getLayerForTitlePane() );
|
layeredPane.add( newTitlePane, getLayerForTitlePane() );
|
||||||
layeredPane.add( newTitlePane.mouseLayer, TITLE_PANE_MOUSE_LAYER );
|
layeredPane.add( newTitlePane.mouseLayer, TITLE_PANE_MOUSE_LAYER );
|
||||||
|
if( newTitlePane.windowTopBorderLayer != null && newTitlePane.isWindowTopBorderNeeded() && isFullWindowContent( rootPane ) )
|
||||||
|
layeredPane.add( newTitlePane.windowTopBorderLayer, WINDOW_TOP_BORDER_LAYER );
|
||||||
}
|
}
|
||||||
|
|
||||||
titlePane = newTitlePane;
|
titlePane = newTitlePane;
|
||||||
@@ -446,6 +451,13 @@ public class FlatRootPaneUI
|
|||||||
case FlatClientProperties.FULL_WINDOW_CONTENT:
|
case FlatClientProperties.FULL_WINDOW_CONTENT:
|
||||||
if( titlePane != null ) {
|
if( titlePane != null ) {
|
||||||
rootPane.getLayeredPane().setLayer( titlePane, getLayerForTitlePane() );
|
rootPane.getLayeredPane().setLayer( titlePane, getLayerForTitlePane() );
|
||||||
|
if( titlePane.windowTopBorderLayer != null ) {
|
||||||
|
JLayeredPane layeredPane = rootPane.getLayeredPane();
|
||||||
|
if( titlePane.isWindowTopBorderNeeded() && isFullWindowContent( rootPane ) )
|
||||||
|
layeredPane.add( titlePane.windowTopBorderLayer, WINDOW_TOP_BORDER_LAYER );
|
||||||
|
else
|
||||||
|
layeredPane.remove( titlePane.windowTopBorderLayer );
|
||||||
|
}
|
||||||
titlePane.updateIcon();
|
titlePane.updateIcon();
|
||||||
titlePane.updateVisibility();
|
titlePane.updateVisibility();
|
||||||
titlePane.updateFullWindowContentButtonsBoundsProperty();
|
titlePane.updateFullWindowContentButtonsBoundsProperty();
|
||||||
@@ -591,6 +603,12 @@ public class FlatRootPaneUI
|
|||||||
titlePane.setBounds( 0, 0, width, prefHeight );
|
titlePane.setBounds( 0, 0, width, prefHeight );
|
||||||
|
|
||||||
titlePane.mouseLayer.setBounds( 0, 0, width, prefHeight );
|
titlePane.mouseLayer.setBounds( 0, 0, width, prefHeight );
|
||||||
|
if( titlePane.windowTopBorderLayer != null ) {
|
||||||
|
boolean show = isFullWindowContent && !titlePane.isWindowMaximized() && !isFullScreen;
|
||||||
|
if( show )
|
||||||
|
titlePane.windowTopBorderLayer.setBounds( 0, 0, width, 1 );
|
||||||
|
titlePane.windowTopBorderLayer.setVisible( show );
|
||||||
|
}
|
||||||
|
|
||||||
if( !isFullWindowContent )
|
if( !isFullWindowContent )
|
||||||
nextY += prefHeight;
|
nextY += prefHeight;
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ public class FlatTitlePane
|
|||||||
extends JComponent
|
extends JComponent
|
||||||
{
|
{
|
||||||
static final String KEY_DEBUG_SHOW_RECTANGLES = "FlatLaf.debug.titlebar.showRectangles";
|
static final String KEY_DEBUG_SHOW_RECTANGLES = "FlatLaf.debug.titlebar.showRectangles";
|
||||||
|
private static final boolean isWindows_10 = SystemInfo.isWindows_10_orLater && !SystemInfo.isWindows_11_orLater;
|
||||||
|
|
||||||
/** @since 2.5 */ protected final Font titleFont;
|
/** @since 2.5 */ protected final Font titleFont;
|
||||||
protected final Color activeBackground;
|
protected final Color activeBackground;
|
||||||
@@ -166,6 +167,16 @@ public class FlatTitlePane
|
|||||||
*/
|
*/
|
||||||
final JPanel mouseLayer;
|
final JPanel mouseLayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This panel paint a border at the top of the window in fullWindowContent mode,
|
||||||
|
* if FlatLaf window decorations are enabled.
|
||||||
|
* Only used on Windows 10.
|
||||||
|
* <p>
|
||||||
|
* This panel is not a child of the title pane.
|
||||||
|
* Instead it is added by FlatRootPaneUI to the layered pane at a layer over all other layers.
|
||||||
|
*/
|
||||||
|
final JPanel windowTopBorderLayer;
|
||||||
|
|
||||||
public FlatTitlePane( JRootPane rootPane ) {
|
public FlatTitlePane( JRootPane rootPane ) {
|
||||||
this.rootPane = rootPane;
|
this.rootPane = rootPane;
|
||||||
|
|
||||||
@@ -207,6 +218,14 @@ public class FlatTitlePane
|
|||||||
mouseLayer.addMouseListener( handler );
|
mouseLayer.addMouseListener( handler );
|
||||||
mouseLayer.addMouseMotionListener( handler );
|
mouseLayer.addMouseMotionListener( handler );
|
||||||
|
|
||||||
|
if( isWindows_10 && FlatNativeWindowBorder.isSupported() ) {
|
||||||
|
windowTopBorderLayer = new JPanel();
|
||||||
|
windowTopBorderLayer.setVisible( false );
|
||||||
|
windowTopBorderLayer.setOpaque( false );
|
||||||
|
windowTopBorderLayer.setBorder( FlatUIUtils.nonUIResource( FlatNativeWindowBorder.WindowTopBorder.getInstance() ) );
|
||||||
|
} else
|
||||||
|
windowTopBorderLayer = null;
|
||||||
|
|
||||||
applyComponentOrientation( rootPane.getComponentOrientation() );
|
applyComponentOrientation( rootPane.getComponentOrientation() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -919,6 +938,10 @@ public class FlatTitlePane
|
|||||||
return window != null && FlatNativeWindowBorder.hasCustomDecoration( window );
|
return window != null && FlatNativeWindowBorder.hasCustomDecoration( window );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isWindowTopBorderNeeded() {
|
||||||
|
return isWindows_10 && hasNativeCustomDecoration();
|
||||||
|
}
|
||||||
|
|
||||||
// used to invoke updateNativeTitleBarHeightAndHitTestSpots() only once from latest invokeLater()
|
// used to invoke updateNativeTitleBarHeightAndHitTestSpots() only once from latest invokeLater()
|
||||||
private int laterCounter;
|
private int laterCounter;
|
||||||
|
|
||||||
@@ -1146,7 +1169,7 @@ public class FlatTitlePane
|
|||||||
} else if( borderColor != null && (rootPane.getJMenuBar() == null || !rootPane.getJMenuBar().isVisible()) )
|
} else if( borderColor != null && (rootPane.getJMenuBar() == null || !rootPane.getJMenuBar().isVisible()) )
|
||||||
insets.bottom += UIScale.scale( 1 );
|
insets.bottom += UIScale.scale( 1 );
|
||||||
|
|
||||||
if( !SystemInfo.isWindows_11_orLater && hasNativeCustomDecoration() && !isWindowMaximized() )
|
if( isWindowTopBorderNeeded() && !isWindowMaximized() )
|
||||||
insets = FlatUIUtils.addInsets( insets, WindowTopBorder.getInstance().getBorderInsets() );
|
insets = FlatUIUtils.addInsets( insets, WindowTopBorder.getInstance().getBorderInsets() );
|
||||||
|
|
||||||
return insets;
|
return insets;
|
||||||
@@ -1165,7 +1188,7 @@ public class FlatTitlePane
|
|||||||
FlatUIUtils.paintFilledRectangle( g, borderColor, x, y + height - lineHeight, width, lineHeight );
|
FlatUIUtils.paintFilledRectangle( g, borderColor, x, y + height - lineHeight, width, lineHeight );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !SystemInfo.isWindows_11_orLater && hasNativeCustomDecoration() && !isWindowMaximized() )
|
if( isWindowTopBorderNeeded() && !isWindowMaximized() && !isFullWindowContent() )
|
||||||
WindowTopBorder.getInstance().paintBorder( c, g, x, y, width, height );
|
WindowTopBorder.getInstance().paintBorder( c, g, x, y, width, height );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1329,7 +1352,7 @@ public class FlatTitlePane
|
|||||||
activeChanged( true );
|
activeChanged( true );
|
||||||
updateNativeTitleBarHeightAndHitTestSpots();
|
updateNativeTitleBarHeightAndHitTestSpots();
|
||||||
|
|
||||||
if( !SystemInfo.isWindows_11_orLater && hasNativeCustomDecoration() )
|
if( isWindowTopBorderNeeded() )
|
||||||
WindowTopBorder.getInstance().repaintBorder( FlatTitlePane.this );
|
WindowTopBorder.getInstance().repaintBorder( FlatTitlePane.this );
|
||||||
|
|
||||||
repaintWindowBorder();
|
repaintWindowBorder();
|
||||||
@@ -1340,7 +1363,7 @@ public class FlatTitlePane
|
|||||||
activeChanged( false );
|
activeChanged( false );
|
||||||
updateNativeTitleBarHeightAndHitTestSpots();
|
updateNativeTitleBarHeightAndHitTestSpots();
|
||||||
|
|
||||||
if( !SystemInfo.isWindows_11_orLater && hasNativeCustomDecoration() )
|
if( isWindowTopBorderNeeded() )
|
||||||
WindowTopBorder.getInstance().repaintBorder( FlatTitlePane.this );
|
WindowTopBorder.getInstance().repaintBorder( FlatTitlePane.this );
|
||||||
|
|
||||||
repaintWindowBorder();
|
repaintWindowBorder();
|
||||||
|
|||||||
Reference in New Issue
Block a user