mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-14 15:57:12 -06:00
Window decorations: FlatMenuBarBorder: use same conditions for bottom separator painting as for menu bar background painting (fixes/improves previous commit)
This commit is contained in:
@@ -53,7 +53,7 @@ public class FlatMenuBarBorder
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
|
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
|
||||||
if( !showBottomSeparator() )
|
if( !showBottomSeparator( c ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float lineHeight = scale( (float) 1 );
|
float lineHeight = scale( (float) 1 );
|
||||||
@@ -73,7 +73,7 @@ public class FlatMenuBarBorder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @since 2 */
|
/** @since 2 */
|
||||||
protected boolean showBottomSeparator() {
|
protected boolean showBottomSeparator( Component c ) {
|
||||||
return !UIManager.getBoolean( "TitlePane.unifiedBackground" );
|
return !FlatMenuBarUI.useUnifiedBackground( c );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
@@ -189,10 +190,8 @@ public class FlatMenuBarUI
|
|||||||
return background;
|
return background;
|
||||||
|
|
||||||
// use parent background for unified title pane
|
// use parent background for unified title pane
|
||||||
// (not storing value of "TitlePane.unifiedBackground" in class to allow changing at runtime)
|
if( useUnifiedBackground( c ) )
|
||||||
if( UIManager.getBoolean( "TitlePane.unifiedBackground" ) &&
|
background = FlatUIUtils.getParentBackground( c );
|
||||||
FlatNativeWindowBorder.hasCustomDecoration( (Window) rootPane.getParent() ) )
|
|
||||||
background = FlatUIUtils.getParentBackground( c );
|
|
||||||
|
|
||||||
// paint background in full screen mode
|
// paint background in full screen mode
|
||||||
if( FlatUIUtils.isFullScreen( rootPane ) )
|
if( FlatUIUtils.isFullScreen( rootPane ) )
|
||||||
@@ -202,6 +201,22 @@ public class FlatMenuBarUI
|
|||||||
return FlatRootPaneUI.isMenuBarEmbedded( rootPane ) ? null : background;
|
return FlatRootPaneUI.isMenuBarEmbedded( rootPane ) ? null : background;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**@since 2 */
|
||||||
|
static boolean useUnifiedBackground( Component c ) {
|
||||||
|
// check whether:
|
||||||
|
// - TitlePane.unifiedBackground is true and
|
||||||
|
// - menu bar is the "main" menu bar and
|
||||||
|
// - window has custom decorations enabled
|
||||||
|
|
||||||
|
JRootPane rootPane;
|
||||||
|
// (not storing value of "TitlePane.unifiedBackground" in class to allow changing at runtime)
|
||||||
|
return UIManager.getBoolean( "TitlePane.unifiedBackground" ) &&
|
||||||
|
(rootPane = SwingUtilities.getRootPane( c )) != null &&
|
||||||
|
rootPane.getParent() instanceof Window &&
|
||||||
|
rootPane.getJMenuBar() == c &&
|
||||||
|
FlatNativeWindowBorder.hasCustomDecoration( (Window) rootPane.getParent() );
|
||||||
|
}
|
||||||
|
|
||||||
//---- class TakeFocus ----------------------------------------------------
|
//---- class TakeFocus ----------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -870,7 +870,7 @@ debug*/
|
|||||||
Border menuBarBorder = getMenuBarBorder();
|
Border menuBarBorder = getMenuBarBorder();
|
||||||
if( menuBarBorder != null ) {
|
if( menuBarBorder != null ) {
|
||||||
// if menu bar is embedded, paint menu bar border
|
// if menu bar is embedded, paint menu bar border
|
||||||
menuBarBorder.paintBorder( c, g, x, y, width, height );
|
menuBarBorder.paintBorder( rootPane.getJMenuBar(), g, x, y, width, height );
|
||||||
} else if( borderColor != null && (rootPane.getJMenuBar() == null || !rootPane.getJMenuBar().isVisible()) ) {
|
} else if( borderColor != null && (rootPane.getJMenuBar() == null || !rootPane.getJMenuBar().isVisible()) ) {
|
||||||
// paint border between title pane and content if border color is specified
|
// paint border between title pane and content if border color is specified
|
||||||
float lineHeight = UIScale.scale( (float) 1 );
|
float lineHeight = UIScale.scale( (float) 1 );
|
||||||
|
|||||||
Reference in New Issue
Block a user