macOS large title bar: added client property FlatClientProperties.MACOS_LARGE_WINDOW_TITLE_BAR (or "FlatLaf.macOS.largeWindowTitleBar")

This commit is contained in:
Karl Tauber
2023-12-12 18:03:38 +01:00
parent 241fe855cc
commit f3be3f2d1c
4 changed files with 38 additions and 12 deletions

View File

@@ -527,6 +527,21 @@ public interface FlatClientProperties
*/
String WINDOW_STYLE_SMALL = "small";
/**
* Specifies whether the window should have a large title bar.
* This adds extra space around the close/minimize/zoom buttons.
* Useful if <a href="https://www.formdev.com/flatlaf/macos/#full_window_content">full window content</a>
* is enabled.
* <p>
* (requires macOS 10.14+, Java 17+ and client property {@code apple.awt.fullWindowContent} set to {@code true})
* <p>
* <strong>Component</strong> {@link javax.swing.JRootPane}<br>
* <strong>Value type</strong> {@link java.lang.Boolean}
*
* @since 3.3
*/
String MACOS_LARGE_WINDOW_TITLE_BAR = "FlatLaf.macOS.largeWindowTitleBar";
//---- JScrollBar / JScrollPane -------------------------------------------

View File

@@ -367,6 +367,21 @@ public class FlatRootPaneUI
if( rootPane.isDisplayable() )
throw new IllegalComponentStateException( "The client property 'Window.style' must be set before the window becomes displayable." );
break;
case FlatClientProperties.MACOS_LARGE_WINDOW_TITLE_BAR:
case "ancestor":
if( SystemInfo.isMacFullWindowContentSupported &&
SystemInfo.isJava_17_orLater &&
rootPane.isDisplayable() &&
FlatClientProperties.clientPropertyBoolean( rootPane, "apple.awt.fullWindowContent", false ) &&
FlatNativeMacLibrary.isLoaded() )
{
Window window = SwingUtilities.windowForComponent( rootPane );
boolean enabled = FlatClientProperties.clientPropertyBoolean( rootPane,
FlatClientProperties.MACOS_LARGE_WINDOW_TITLE_BAR, false );
FlatNativeMacLibrary.setWindowToolbar( window, enabled );
}
break;
}
}