Window decorations: support toolbox-style "small" window title bar (issue #659)

This commit is contained in:
Karl Tauber
2023-07-30 15:26:44 +02:00
parent dfe4404a17
commit 8e3c8ba6c5
22 changed files with 627 additions and 57 deletions

View File

@@ -1238,6 +1238,7 @@ TitlePane.buttonMaximizedHeight 22
TitlePane.buttonMinimumWidth 30
TitlePane.buttonPressedBackground #484c4f HSL 206 5 30 com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse)
TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI]
TitlePane.buttonSymbolHeight 10
TitlePane.centerTitle false
TitlePane.centerTitleIfMenuBarEmbedded true
TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI]
@@ -1264,6 +1265,14 @@ TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWin
TitlePane.showIcon true
TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.small.buttonSize 30,20 javax.swing.plaf.DimensionUIResource [UI]
TitlePane.small.buttonSymbolHeight 8
TitlePane.small.closeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI]
TitlePane.small.font [active] Segoe UI plain 11 javax.swing.plaf.FontUIResource [UI]
TitlePane.small.iconifyIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI]
TitlePane.small.maximizeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
TitlePane.small.restoreIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.small.showIcon false
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true

View File

@@ -1243,6 +1243,7 @@ TitlePane.buttonMaximizedHeight 22
TitlePane.buttonMinimumWidth 30
TitlePane.buttonPressedBackground #ebebeb HSL 0 0 92 com.formdev.flatlaf.util.DerivedColor [UI] darken(8% autoInverse)
TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI]
TitlePane.buttonSymbolHeight 10
TitlePane.centerTitle false
TitlePane.centerTitleIfMenuBarEmbedded true
TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI]
@@ -1269,6 +1270,14 @@ TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWin
TitlePane.showIcon true
TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.small.buttonSize 30,20 javax.swing.plaf.DimensionUIResource [UI]
TitlePane.small.buttonSymbolHeight 8
TitlePane.small.closeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI]
TitlePane.small.font [active] Segoe UI plain 11 javax.swing.plaf.FontUIResource [UI]
TitlePane.small.iconifyIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI]
TitlePane.small.maximizeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
TitlePane.small.restoreIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.small.showIcon false
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true

View File

@@ -1248,6 +1248,7 @@ TitlePane.buttonMaximizedHeight 22
TitlePane.buttonMinimumWidth 30
TitlePane.buttonPressedBackground #4c4c4c HSL 0 0 30 com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse)
TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI]
TitlePane.buttonSymbolHeight 10
TitlePane.centerTitle false
TitlePane.centerTitleIfMenuBarEmbedded true
TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI]
@@ -1274,6 +1275,14 @@ TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWin
TitlePane.showIcon true
TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.small.buttonSize 30,20 javax.swing.plaf.DimensionUIResource [UI]
TitlePane.small.buttonSymbolHeight 8
TitlePane.small.closeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI]
TitlePane.small.font [active] Segoe UI plain 11 javax.swing.plaf.FontUIResource [UI]
TitlePane.small.iconifyIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI]
TitlePane.small.maximizeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
TitlePane.small.restoreIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.small.showIcon false
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true

View File

@@ -1252,6 +1252,7 @@ TitlePane.buttonMaximizedHeight 22
TitlePane.buttonMinimumWidth 30
TitlePane.buttonPressedBackground #d8d8d8 HSL 0 0 85 com.formdev.flatlaf.util.DerivedColor [UI] darken(8% autoInverse)
TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI]
TitlePane.buttonSymbolHeight 10
TitlePane.centerTitle false
TitlePane.centerTitleIfMenuBarEmbedded true
TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI]
@@ -1278,6 +1279,14 @@ TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWin
TitlePane.showIcon true
TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.small.buttonSize 30,20 javax.swing.plaf.DimensionUIResource [UI]
TitlePane.small.buttonSymbolHeight 8
TitlePane.small.closeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI]
TitlePane.small.font [active] Segoe UI plain 11 javax.swing.plaf.FontUIResource [UI]
TitlePane.small.iconifyIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI]
TitlePane.small.maximizeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
TitlePane.small.restoreIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.small.showIcon false
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true

View File

@@ -1278,6 +1278,7 @@ TitlePane.borderColor #ff0000 HSL 0 100 50 javax.swing.plaf.Colo
TitlePane.buttonMaximizedHeight 22
TitlePane.buttonMinimumWidth 30
TitlePane.buttonSize 44,30 javax.swing.plaf.DimensionUIResource [UI]
TitlePane.buttonSymbolHeight 10
TitlePane.centerTitle false
TitlePane.centerTitleIfMenuBarEmbedded true
TitlePane.closeHoverBackground #c42b1c HSL 5 75 44 javax.swing.plaf.ColorUIResource [UI]
@@ -1303,6 +1304,14 @@ TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWin
TitlePane.showIcon true
TitlePane.showIconBesideTitle false
TitlePane.showIconInDialogs true
TitlePane.small.buttonSize 30,20 javax.swing.plaf.DimensionUIResource [UI]
TitlePane.small.buttonSymbolHeight 8
TitlePane.small.closeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowCloseIcon [UI]
TitlePane.small.font [active] Segoe UI plain 11 javax.swing.plaf.FontUIResource [UI]
TitlePane.small.iconifyIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowIconifyIcon [UI]
TitlePane.small.maximizeIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
TitlePane.small.restoreIcon [lazy] 30,20 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
TitlePane.small.showIcon false
TitlePane.titleMargins 3,0,3,0 javax.swing.plaf.InsetsUIResource [UI]
TitlePane.titleMinimumWidth 60
TitlePane.unifiedBackground true

View File

@@ -361,6 +361,7 @@ debug*/
private void openDialog() {
Window owner = SwingUtilities.windowForComponent( this );
JDialog dialog = new JDialog( owner, "Dialog", ModalityType.DOCUMENT_MODAL );
initWindowType( dialog );
dialog.setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );
dialog.add( new FlatWindowDecorationsTest() );
dialog.pack();
@@ -371,6 +372,7 @@ debug*/
private void openFrame() {
FlatWindowDecorationsTest comp = new FlatWindowDecorationsTest();
JFrame frame = new JFrame( "Frame" );
initWindowType( frame );
frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
frame.add( comp );
frame.setJMenuBar( comp.menuBar );
@@ -379,6 +381,13 @@ debug*/
frame.setVisible( true );
}
private void initWindowType( Window window ) {
if( typeUtilityRadioButton.isSelected() )
window.setType( Window.Type.UTILITY );
else if( typeSmallRadioButton.isSelected() )
((RootPaneContainer)window).getRootPane().putClientProperty( "Window.style", "small" );
}
private void decorationStyleChanged() {
int style;
if( styleFrameRadioButton.isSelected() )
@@ -536,6 +545,9 @@ debug*/
colorizeMenusCheckBox = new JCheckBox();
JButton openDialogButton = new JButton();
JButton openFrameButton = new JButton();
typeNormalRadioButton = new JRadioButton();
typeUtilityRadioButton = new JRadioButton();
typeSmallRadioButton = new JRadioButton();
menuBar = new JMenuBar();
JMenu fileMenu = new JMenu();
JMenuItem newMenuItem = new JMenuItem();
@@ -567,7 +579,7 @@ debug*/
setLayout(new MigLayout(
"ltr,insets dialog,hidemode 3",
// columns
"[fill]" +
"[left]" +
"[fill]" +
"[fill]" +
"[fill]",
@@ -617,7 +629,7 @@ debug*/
maximizedBoundsCheckBox.addActionListener(e -> maximizedBoundsChanged());
panel7.add(maximizedBoundsCheckBox, "cell 0 4");
}
add(panel7, "cell 0 0");
add(panel7, "cell 0 0,growx");
//======== panel4 ========
{
@@ -818,7 +830,7 @@ debug*/
styleFileChooserRadioButton.addActionListener(e -> decorationStyleChanged());
panel1.add(styleFileChooserRadioButton, "cell 0 8");
}
add(panel1, "cell 0 1");
add(panel1, "cell 0 1,growx");
//======== panel2 ========
{
@@ -900,13 +912,26 @@ debug*/
//---- openDialogButton ----
openDialogButton.setText("Open Dialog");
openDialogButton.addActionListener(e -> openDialog());
add(openDialogButton, "cell 0 2");
add(openDialogButton, "cell 0 2 3 1");
//---- openFrameButton ----
openFrameButton.setText("Open Frame");
openFrameButton.setMnemonic('A');
openFrameButton.addActionListener(e -> openFrame());
add(openFrameButton, "cell 0 2");
add(openFrameButton, "cell 0 2 3 1");
//---- typeNormalRadioButton ----
typeNormalRadioButton.setText("Normal");
typeNormalRadioButton.setSelected(true);
add(typeNormalRadioButton, "cell 0 2 3 1");
//---- typeUtilityRadioButton ----
typeUtilityRadioButton.setText("Utility");
add(typeUtilityRadioButton, "cell 0 2 3 1");
//---- typeSmallRadioButton ----
typeSmallRadioButton.setText("Small");
add(typeSmallRadioButton, "cell 0 2 3 1");
//======== menuBar ========
{
@@ -1095,6 +1120,12 @@ debug*/
iconButtonGroup.add(iconTestRandomRadioButton);
iconButtonGroup.add(iconTestMRIRadioButton);
iconButtonGroup.add(iconTestDynMRIRadioButton);
//---- typeButtonGroup ----
ButtonGroup typeButtonGroup = new ButtonGroup();
typeButtonGroup.add(typeNormalRadioButton);
typeButtonGroup.add(typeUtilityRadioButton);
typeButtonGroup.add(typeSmallRadioButton);
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
@@ -1138,6 +1169,9 @@ debug*/
private JCheckBox colorizeTitleBarCheckBox;
private JCheckBox colorizeMenuBarCheckBox;
private JCheckBox colorizeMenusCheckBox;
private JRadioButton typeNormalRadioButton;
private JRadioButton typeUtilityRadioButton;
private JRadioButton typeSmallRadioButton;
private JMenuBar menuBar;
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "8.0.0.0.194" Java: "17.0.2" encoding: "UTF-8"
JFDML JFormDesigner: "8.1.0.0.283" Java: "19.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -8,7 +8,7 @@ new FormModel {
}
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
"$columnConstraints": "[fill][fill][fill][fill]"
"$columnConstraints": "[left][fill][fill][fill]"
"$rowConstraints": "[fill][fill][]"
} ) {
name: "this"
@@ -72,7 +72,7 @@ new FormModel {
"value": "cell 0 4"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
"value": "cell 0 0,growx"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,hidemode 3,gap 0 0"
@@ -378,7 +378,7 @@ new FormModel {
"value": "cell 0 8"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
"value": "cell 0 1,growx"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[left]"
@@ -501,7 +501,7 @@ new FormModel {
"text": "Open Dialog"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "openDialog", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
"value": "cell 0 2 3 1"
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "openFrameButton"
@@ -509,7 +509,38 @@ new FormModel {
"mnemonic": 65
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "openFrame", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
"value": "cell 0 2 3 1"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "typeNormalRadioButton"
"text": "Normal"
"selected": true
"$buttonGroup": new FormReference( "typeButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2 3 1"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "typeUtilityRadioButton"
"text": "Utility"
"$buttonGroup": new FormReference( "typeButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2 3 1"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "typeSmallRadioButton"
"text": "Small"
"$buttonGroup": new FormReference( "typeButtonGroup" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2 3 1"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
@@ -692,5 +723,10 @@ new FormModel {
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 615 )
} )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "typeButtonGroup"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 669 )
} )
}
}