mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 15:00:54 +03:00
macOS large title bar: added client property FlatClientProperties.MACOS_LARGE_WINDOW_TITLE_BAR (or "FlatLaf.macOS.largeWindowTitleBar")
This commit is contained in:
@@ -527,6 +527,21 @@ public interface FlatClientProperties
|
|||||||
*/
|
*/
|
||||||
String WINDOW_STYLE_SMALL = "small";
|
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 -------------------------------------------
|
//---- JScrollBar / JScrollPane -------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -367,6 +367,21 @@ public class FlatRootPaneUI
|
|||||||
if( rootPane.isDisplayable() )
|
if( rootPane.isDisplayable() )
|
||||||
throw new IllegalComponentStateException( "The client property 'Window.style' must be set before the window becomes displayable." );
|
throw new IllegalComponentStateException( "The client property 'Window.style' must be set before the window becomes displayable." );
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ import com.formdev.flatlaf.icons.FlatAbstractIcon;
|
|||||||
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
|
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
|
||||||
import com.formdev.flatlaf.themes.FlatMacLightLaf;
|
import com.formdev.flatlaf.themes.FlatMacLightLaf;
|
||||||
import com.formdev.flatlaf.extras.FlatSVGUtils;
|
import com.formdev.flatlaf.extras.FlatSVGUtils;
|
||||||
import com.formdev.flatlaf.ui.FlatNativeMacLibrary;
|
|
||||||
import com.formdev.flatlaf.util.ColorFunctions;
|
import com.formdev.flatlaf.util.ColorFunctions;
|
||||||
import com.formdev.flatlaf.util.FontUtils;
|
import com.formdev.flatlaf.util.FontUtils;
|
||||||
import com.formdev.flatlaf.util.LoggingFacade;
|
import com.formdev.flatlaf.util.LoggingFacade;
|
||||||
@@ -90,21 +89,23 @@ class DemoFrame
|
|||||||
// do not use HTML text in menu items because this is not supported in macOS screen menu
|
// do not use HTML text in menu items because this is not supported in macOS screen menu
|
||||||
htmlMenuItem.setText( "some text" );
|
htmlMenuItem.setText( "some text" );
|
||||||
|
|
||||||
|
JRootPane rootPane = getRootPane();
|
||||||
if( SystemInfo.isMacFullWindowContentSupported ) {
|
if( SystemInfo.isMacFullWindowContentSupported ) {
|
||||||
// expand window content into window title bar and make title bar transparent
|
// expand window content into window title bar and make title bar transparent
|
||||||
getRootPane().putClientProperty( "apple.awt.fullWindowContent", true );
|
rootPane.putClientProperty( "apple.awt.fullWindowContent", true );
|
||||||
getRootPane().putClientProperty( "apple.awt.transparentTitleBar", true );
|
rootPane.putClientProperty( "apple.awt.transparentTitleBar", true );
|
||||||
|
rootPane.putClientProperty( FlatClientProperties.MACOS_LARGE_WINDOW_TITLE_BAR, true );
|
||||||
|
|
||||||
// hide window title
|
// hide window title
|
||||||
if( SystemInfo.isJava_17_orLater )
|
if( SystemInfo.isJava_17_orLater )
|
||||||
getRootPane().putClientProperty( "apple.awt.windowTitleVisible", false );
|
rootPane.putClientProperty( "apple.awt.windowTitleVisible", false );
|
||||||
else
|
else
|
||||||
setTitle( null );
|
setTitle( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable full screen mode for this window (for Java 8 - 10; not necessary for Java 11+)
|
// enable full screen mode for this window (for Java 8 - 10; not necessary for Java 11+)
|
||||||
if( !SystemInfo.isJava_11_orLater )
|
if( !SystemInfo.isJava_11_orLater )
|
||||||
getRootPane().putClientProperty( "apple.awt.fullscreenable", true );
|
rootPane.putClientProperty( "apple.awt.fullscreenable", true );
|
||||||
}
|
}
|
||||||
|
|
||||||
// integrate into macOS screen menu
|
// integrate into macOS screen menu
|
||||||
@@ -902,10 +903,10 @@ class DemoFrame
|
|||||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||||
|
|
||||||
backButton.addActionListener( e -> {
|
backButton.addActionListener( e -> {
|
||||||
FlatNativeMacLibrary.setWindowToolbar( this, true );
|
rootPane.putClientProperty( FlatClientProperties.MACOS_LARGE_WINDOW_TITLE_BAR, true );
|
||||||
});
|
});
|
||||||
forwardButton.addActionListener( e -> {
|
forwardButton.addActionListener( e -> {
|
||||||
FlatNativeMacLibrary.setWindowToolbar( this, false );
|
rootPane.putClientProperty( FlatClientProperties.MACOS_LARGE_WINDOW_TITLE_BAR, null );
|
||||||
});
|
});
|
||||||
|
|
||||||
cutButton.addActionListener( e -> System.out.println( e ) );
|
cutButton.addActionListener( e -> System.out.println( e ) );
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import com.formdev.flatlaf.fonts.inter.FlatInterFont;
|
|||||||
import com.formdev.flatlaf.fonts.jetbrains_mono.FlatJetBrainsMonoFont;
|
import com.formdev.flatlaf.fonts.jetbrains_mono.FlatJetBrainsMonoFont;
|
||||||
import com.formdev.flatlaf.fonts.roboto.FlatRobotoFont;
|
import com.formdev.flatlaf.fonts.roboto.FlatRobotoFont;
|
||||||
import com.formdev.flatlaf.fonts.roboto_mono.FlatRobotoMonoFont;
|
import com.formdev.flatlaf.fonts.roboto_mono.FlatRobotoMonoFont;
|
||||||
import com.formdev.flatlaf.ui.FlatNativeMacLibrary;
|
|
||||||
import com.formdev.flatlaf.util.SystemInfo;
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,10 +117,6 @@ public class FlatLafDemo
|
|||||||
// show frame
|
// show frame
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setLocationRelativeTo( null );
|
frame.setLocationRelativeTo( null );
|
||||||
if( SystemInfo.isMacOS && FlatNativeMacLibrary.isLoaded() ) {
|
|
||||||
// TODO use client property
|
|
||||||
FlatNativeMacLibrary.setWindowToolbar( frame, true );
|
|
||||||
}
|
|
||||||
frame.setVisible( true );
|
frame.setVisible( true );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user