Theme Editor: on macOS, use larger window title bar (PR #779)

This commit is contained in:
Karl Tauber
2024-05-31 13:57:01 +02:00
parent 0eb77c7f72
commit 0decbec595
3 changed files with 27 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ FlatLaf Change Log
- Label: Support painting background with rounded corners. (issue #842) - Label: Support painting background with rounded corners. (issue #842)
- Popup: Fixed flicker of popups (e.g. tooltips) while they are moving (e.g. - Popup: Fixed flicker of popups (e.g. tooltips) while they are moving (e.g.
following mouse pointer). (issues #832 and #672) following mouse pointer). (issues #832 and #672)
- Theme Editor: On macOS, use larger window title bar. (PR #779)
#### Fixed bugs #### Fixed bugs

View File

@@ -25,6 +25,7 @@ import java.awt.Cursor;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.GraphicsConfiguration; import java.awt.GraphicsConfiguration;
import java.awt.Insets; import java.awt.Insets;
@@ -191,22 +192,20 @@ class FlatThemeFileEditor
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_WINDOW_BUTTONS_SPACING, FlatClientProperties.MACOS_WINDOW_BUTTONS_SPACING_LARGE );
// 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 );
// add gap to left side of toolbar
controlPanel.add( Box.createHorizontalStrut( 70 ), 0 );
} }
// 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
@@ -1021,6 +1020,7 @@ class FlatThemeFileEditor
helpMenu = new JMenu(); helpMenu = new JMenu();
aboutMenuItem = new JMenuItem(); aboutMenuItem = new JMenuItem();
controlPanel = new JPanel(); controlPanel = new JPanel();
JPanel macFullWindowContentButtonsPlaceholder = new JPanel();
directoryLabel = new JLabel(); directoryLabel = new JLabel();
directoryField = new FlatThemeFileEditor.DirectoryComboBox(); directoryField = new FlatThemeFileEditor.DirectoryComboBox();
openDirectoryButton = new JButton(); openDirectoryButton = new JButton();
@@ -1224,7 +1224,7 @@ class FlatThemeFileEditor
//======== controlPanel ======== //======== controlPanel ========
{ {
controlPanel.setLayout(new MigLayout( controlPanel.setLayout(new MigLayout(
"hidemode 3", "insets panel,hidemode 3",
// columns // columns
"[fill]" + "[fill]" +
"[grow,fill]" + "[grow,fill]" +
@@ -1232,6 +1232,12 @@ class FlatThemeFileEditor
// rows // rows
"[]")); "[]"));
//======== macFullWindowContentButtonsPlaceholder ========
{
macFullWindowContentButtonsPlaceholder.setLayout(new FlowLayout());
}
controlPanel.add(macFullWindowContentButtonsPlaceholder, "west");
//---- directoryLabel ---- //---- directoryLabel ----
directoryLabel.setText("Directory:"); directoryLabel.setText("Directory:");
controlPanel.add(directoryLabel, "cell 0 0"); controlPanel.add(directoryLabel, "cell 0 0");
@@ -1264,6 +1270,9 @@ class FlatThemeFileEditor
lafButtonGroup.add(lightLafMenuItem); lafButtonGroup.add(lightLafMenuItem);
lafButtonGroup.add(darkLafMenuItem); lafButtonGroup.add(darkLafMenuItem);
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
// on macOS, panel on left side of control bar is a placeholder for title bar buttons in fullWindowContent mode
macFullWindowContentButtonsPlaceholder.putClientProperty( FlatClientProperties.FULL_WINDOW_CONTENT_BUTTONS_PLACEHOLDER, "mac" );
} }
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables

View File

@@ -13,11 +13,19 @@ new FormModel {
addEvent( new FormEvent( "java.awt.event.WindowListener", "windowDeactivated", "windowDeactivated", false ) ) addEvent( new FormEvent( "java.awt.event.WindowListener", "windowDeactivated", "windowDeactivated", false ) )
addEvent( new FormEvent( "java.awt.event.WindowListener", "windowActivated", "windowActivated", false ) ) addEvent( new FormEvent( "java.awt.event.WindowListener", "windowActivated", "windowActivated", false ) )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3" "$layoutConstraints": "insets panel,hidemode 3"
"$columnConstraints": "[fill][grow,fill][fill]" "$columnConstraints": "[fill][grow,fill][fill]"
"$rowConstraints": "[]" "$rowConstraints": "[]"
} ) { } ) {
name: "controlPanel" name: "controlPanel"
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
name: "macFullWindowContentButtonsPlaceholder"
auxiliary() {
"JavaCodeGenerator.variableLocal": true
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "west"
} )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "directoryLabel" name: "directoryLabel"
"text": "Directory:" "text": "Directory:"