mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
Window decorations: enabling/disabling menu bar embedding via system and client properties now works the same way as for window decorations
(previously it was only possible to disable menu bar embedding)
This commit is contained in:
@@ -252,8 +252,15 @@ public interface FlatClientProperties
|
||||
String USE_WINDOW_DECORATIONS = "JRootPane.useWindowDecorations";
|
||||
|
||||
/**
|
||||
* Specifies whether the menu bar is embedded into the title pane if custom
|
||||
* window decorations are enabled. Default is {@code true}.
|
||||
* Specifies whether the menu bar is embedded into the window title pane
|
||||
* if window decorations are enabled.
|
||||
* <p>
|
||||
* Setting this enables/disables embedding
|
||||
* for the window that contains the root pane.
|
||||
* <p>
|
||||
* This client property has lower priority than system property
|
||||
* {@link FlatSystemProperties#MENUBAR_EMBEDDED}, but higher priority
|
||||
* than UI default {@code TitlePane.menuBarEmbedded}.
|
||||
* <p>
|
||||
* (requires Window 10)
|
||||
* <p>
|
||||
|
||||
@@ -59,8 +59,7 @@ public interface FlatSystemProperties
|
||||
* when creating {@code JFrame} or {@code JDialog}.
|
||||
* <p>
|
||||
* Setting this to {@code true} forces using native window decorations
|
||||
* even if they are not enabled by the application.
|
||||
* <p>
|
||||
* even if they are not enabled by the application.<br>
|
||||
* Setting this to {@code false} disables using native window decorations.
|
||||
* <p>
|
||||
* This system property has higher priority than client property
|
||||
@@ -92,12 +91,20 @@ public interface FlatSystemProperties
|
||||
String USE_JETBRAINS_CUSTOM_DECORATIONS = "flatlaf.useJetBrainsCustomDecorations";
|
||||
|
||||
/**
|
||||
* Specifies whether menubar is embedded into custom window decorations.
|
||||
* Specifies whether the menu bar is embedded into the window title pane
|
||||
* if window decorations are enabled.
|
||||
* <p>
|
||||
* Setting this to {@code true} forces embedding.<br>
|
||||
* Setting this to {@code false} disables embedding.
|
||||
* <p>
|
||||
* This system property has higher priority than client property
|
||||
* {@link FlatClientProperties#MENU_BAR_EMBEDDED} and
|
||||
* UI default {@code TitlePane.menuBarEmbedded}.
|
||||
* <p>
|
||||
* (requires Window 10)
|
||||
* <p>
|
||||
* <strong>Allowed Values</strong> {@code false} and {@code true}<br>
|
||||
* <strong>Default</strong> {@code true}
|
||||
* <strong>Default</strong> none
|
||||
*/
|
||||
String MENUBAR_EMBEDDED = "flatlaf.menuBarEmbedded";
|
||||
|
||||
|
||||
@@ -193,17 +193,11 @@ public class FlatNativeWindowBorder
|
||||
}
|
||||
|
||||
private static boolean useWindowDecorations( JRootPane rootPane ) {
|
||||
// check whether forced to enabled/disabled via system property
|
||||
Boolean enabled = FlatSystemProperties.getBooleanStrict( FlatSystemProperties.USE_WINDOW_DECORATIONS, null );
|
||||
if( enabled != null )
|
||||
return enabled;
|
||||
|
||||
// check whether forced to enabled/disabled via client property
|
||||
enabled = FlatClientProperties.clientPropertyBooleanStrict( rootPane, FlatClientProperties.USE_WINDOW_DECORATIONS, null );
|
||||
if( enabled != null )
|
||||
return enabled;
|
||||
|
||||
return UIManager.getBoolean( "TitlePane.useWindowDecorations" );
|
||||
return FlatUIUtils.getBoolean( rootPane,
|
||||
FlatSystemProperties.USE_WINDOW_DECORATIONS,
|
||||
FlatClientProperties.USE_WINDOW_DECORATIONS,
|
||||
"TitlePane.useWindowDecorations",
|
||||
false );
|
||||
}
|
||||
|
||||
public static boolean hasCustomDecoration( Window window ) {
|
||||
|
||||
@@ -429,9 +429,11 @@ public class FlatTitlePane
|
||||
*/
|
||||
protected boolean isMenuBarEmbedded() {
|
||||
// not storing value of "TitlePane.menuBarEmbedded" in class to allow changing at runtime
|
||||
return UIManager.getBoolean( "TitlePane.menuBarEmbedded" ) &&
|
||||
FlatClientProperties.clientPropertyBoolean( rootPane, FlatClientProperties.MENU_BAR_EMBEDDED, true ) &&
|
||||
FlatSystemProperties.getBoolean( FlatSystemProperties.MENUBAR_EMBEDDED, true );
|
||||
return FlatUIUtils.getBoolean( rootPane,
|
||||
FlatSystemProperties.MENUBAR_EMBEDDED,
|
||||
FlatClientProperties.MENU_BAR_EMBEDDED,
|
||||
"TitlePane.menuBarEmbedded",
|
||||
false );
|
||||
}
|
||||
|
||||
protected Rectangle getMenuBarBounds() {
|
||||
|
||||
@@ -54,6 +54,7 @@ import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import com.formdev.flatlaf.FlatSystemProperties;
|
||||
import com.formdev.flatlaf.util.DerivedColor;
|
||||
import com.formdev.flatlaf.util.Graphics2DProxy;
|
||||
import com.formdev.flatlaf.util.HiDPIUtils;
|
||||
@@ -140,6 +141,25 @@ public class FlatUIUtils
|
||||
return (value instanceof Number) ? ((Number)value).floatValue() : defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.1.2
|
||||
*/
|
||||
public static boolean getBoolean( JComponent c, String systemPropertyKey,
|
||||
String clientPropertyKey, String uiKey, boolean defaultValue )
|
||||
{
|
||||
// check whether forced to true/false via system property
|
||||
Boolean value = FlatSystemProperties.getBooleanStrict( systemPropertyKey, null );
|
||||
if( value != null )
|
||||
return value;
|
||||
|
||||
// check whether forced to true/false via client property
|
||||
value = FlatClientProperties.clientPropertyBooleanStrict( c, clientPropertyKey, null );
|
||||
if( value != null )
|
||||
return value;
|
||||
|
||||
return getUIBoolean( uiKey, defaultValue );
|
||||
}
|
||||
|
||||
public static boolean isChevron( String arrowType ) {
|
||||
return !"triangle".equals( arrowType );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user