mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 06:20:53 +03:00
Window decorations: small area at top of embedded menu bar to resize window
This commit is contained in:
@@ -3,6 +3,12 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
## 2.4-SNAPSHOT
|
## 2.4-SNAPSHOT
|
||||||
|
|
||||||
|
#### New features and improvements
|
||||||
|
|
||||||
|
- Native window decorations (Windows 10/11 only):
|
||||||
|
- There is now a small area at top of the embedded menu bar to resize the
|
||||||
|
window.
|
||||||
|
|
||||||
#### Fixed bugs
|
#### Fixed bugs
|
||||||
|
|
||||||
- ComboBox: Fixed vertical alignment of text in popup list with text in combo
|
- ComboBox: Fixed vertical alignment of text in popup list with text in combo
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
* @uiDefault TitlePane.centerTitle boolean
|
* @uiDefault TitlePane.centerTitle boolean
|
||||||
* @uiDefault TitlePane.centerTitleIfMenuBarEmbedded boolean
|
* @uiDefault TitlePane.centerTitleIfMenuBarEmbedded boolean
|
||||||
* @uiDefault TitlePane.menuBarTitleGap int
|
* @uiDefault TitlePane.menuBarTitleGap int
|
||||||
|
* @uiDefault TitlePane.menuBarResizeHeight int
|
||||||
* @uiDefault TitlePane.closeIcon Icon
|
* @uiDefault TitlePane.closeIcon Icon
|
||||||
* @uiDefault TitlePane.iconifyIcon Icon
|
* @uiDefault TitlePane.iconifyIcon Icon
|
||||||
* @uiDefault TitlePane.maximizeIcon Icon
|
* @uiDefault TitlePane.maximizeIcon Icon
|
||||||
@@ -111,6 +112,7 @@ public class FlatTitlePane
|
|||||||
protected final boolean centerTitle = UIManager.getBoolean( "TitlePane.centerTitle" );
|
protected final boolean centerTitle = UIManager.getBoolean( "TitlePane.centerTitle" );
|
||||||
protected final boolean centerTitleIfMenuBarEmbedded = FlatUIUtils.getUIBoolean( "TitlePane.centerTitleIfMenuBarEmbedded", true );
|
protected final boolean centerTitleIfMenuBarEmbedded = FlatUIUtils.getUIBoolean( "TitlePane.centerTitleIfMenuBarEmbedded", true );
|
||||||
protected final int menuBarTitleGap = FlatUIUtils.getUIInt( "TitlePane.menuBarTitleGap", 20 );
|
protected final int menuBarTitleGap = FlatUIUtils.getUIInt( "TitlePane.menuBarTitleGap", 20 );
|
||||||
|
/** @since 2.4 */ protected final int menuBarResizeHeight = FlatUIUtils.getUIInt( "TitlePane.menuBarResizeHeight", 4 );
|
||||||
|
|
||||||
protected final JRootPane rootPane;
|
protected final JRootPane rootPane;
|
||||||
|
|
||||||
@@ -233,10 +235,7 @@ public class FlatTitlePane
|
|||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize() {
|
public Dimension getPreferredSize() {
|
||||||
Dimension size = super.getPreferredSize();
|
Dimension size = super.getPreferredSize();
|
||||||
if( buttonMaximizedHeight > 0 &&
|
if( buttonMaximizedHeight > 0 && isWindowMaximized() ) {
|
||||||
window instanceof Frame &&
|
|
||||||
(((Frame)window).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0 )
|
|
||||||
{
|
|
||||||
// make title pane height smaller when frame is maximized
|
// make title pane height smaller when frame is maximized
|
||||||
size = new Dimension( size.width, Math.min( size.height, UIScale.scale( buttonMaximizedHeight ) ) );
|
size = new Dimension( size.width, Math.min( size.height, UIScale.scale( buttonMaximizedHeight ) ) );
|
||||||
}
|
}
|
||||||
@@ -567,6 +566,11 @@ debug*/
|
|||||||
frame.setExtendedState( frame.getExtendedState() | Frame.ICONIFIED );
|
frame.setExtendedState( frame.getExtendedState() | Frame.ICONIFIED );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @since 2.4 */
|
||||||
|
protected boolean isWindowMaximized() {
|
||||||
|
return window instanceof Frame && (((Frame)window).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximizes the window.
|
* Maximizes the window.
|
||||||
*/
|
*/
|
||||||
@@ -741,9 +745,7 @@ debug*/
|
|||||||
|
|
||||||
// if frame is maximized, increase icon bounds to upper-left corner
|
// if frame is maximized, increase icon bounds to upper-left corner
|
||||||
// of window to allow closing window via double-click in upper-left corner
|
// of window to allow closing window via double-click in upper-left corner
|
||||||
if( window instanceof Frame &&
|
if( isWindowMaximized() ) {
|
||||||
(((Frame)window).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0 )
|
|
||||||
{
|
|
||||||
iconBounds.height += iconBounds.y;
|
iconBounds.height += iconBounds.y;
|
||||||
iconBounds.y = 0;
|
iconBounds.y = 0;
|
||||||
|
|
||||||
@@ -768,6 +770,15 @@ debug*/
|
|||||||
if( hasVisibleEmbeddedMenuBar( menuBar ) ) {
|
if( hasVisibleEmbeddedMenuBar( menuBar ) ) {
|
||||||
r = getNativeHitTestSpot( menuBar );
|
r = getNativeHitTestSpot( menuBar );
|
||||||
if( r != null ) {
|
if( r != null ) {
|
||||||
|
// if frame is not maximized, make menu bar hit test spot smaller at top
|
||||||
|
// to have a small area above the menu bar to resize the window
|
||||||
|
if( !isWindowMaximized() ) {
|
||||||
|
// limit to 8, because Windows does not use a larger height
|
||||||
|
int resizeHeight = UIScale.scale( Math.min( menuBarResizeHeight, 8 ) );
|
||||||
|
r.y += resizeHeight;
|
||||||
|
r.height -= resizeHeight;
|
||||||
|
}
|
||||||
|
|
||||||
Component horizontalGlue = findHorizontalGlue( menuBar );
|
Component horizontalGlue = findHorizontalGlue( menuBar );
|
||||||
if( horizontalGlue != null ) {
|
if( horizontalGlue != null ) {
|
||||||
// If menu bar is embedded and contains a horizontal glue component,
|
// If menu bar is embedded and contains a horizontal glue component,
|
||||||
@@ -854,7 +865,7 @@ debug*/
|
|||||||
} else if( borderColor != null && (rootPane.getJMenuBar() == null || !rootPane.getJMenuBar().isVisible()) )
|
} else if( borderColor != null && (rootPane.getJMenuBar() == null || !rootPane.getJMenuBar().isVisible()) )
|
||||||
insets.bottom += UIScale.scale( 1 );
|
insets.bottom += UIScale.scale( 1 );
|
||||||
|
|
||||||
if( !SystemInfo.isWindows_11_orLater && hasNativeCustomDecoration() && !isWindowMaximized( c ) )
|
if( !SystemInfo.isWindows_11_orLater && hasNativeCustomDecoration() && !isWindowMaximized() )
|
||||||
insets = FlatUIUtils.addInsets( insets, WindowTopBorder.getInstance().getBorderInsets() );
|
insets = FlatUIUtils.addInsets( insets, WindowTopBorder.getInstance().getBorderInsets() );
|
||||||
|
|
||||||
return insets;
|
return insets;
|
||||||
@@ -873,7 +884,7 @@ debug*/
|
|||||||
FlatUIUtils.paintFilledRectangle( g, borderColor, x, y + height - lineHeight, width, lineHeight );
|
FlatUIUtils.paintFilledRectangle( g, borderColor, x, y + height - lineHeight, width, lineHeight );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !SystemInfo.isWindows_11_orLater && hasNativeCustomDecoration() && !isWindowMaximized( c ) )
|
if( !SystemInfo.isWindows_11_orLater && hasNativeCustomDecoration() && !isWindowMaximized() )
|
||||||
WindowTopBorder.getInstance().paintBorder( c, g, x, y, width, height );
|
WindowTopBorder.getInstance().paintBorder( c, g, x, y, width, height );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -881,10 +892,6 @@ debug*/
|
|||||||
JMenuBar menuBar = rootPane.getJMenuBar();
|
JMenuBar menuBar = rootPane.getJMenuBar();
|
||||||
return hasVisibleEmbeddedMenuBar( menuBar ) ? menuBar.getBorder() : null;
|
return hasVisibleEmbeddedMenuBar( menuBar ) ? menuBar.getBorder() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isWindowMaximized( Component c ) {
|
|
||||||
return window instanceof Frame && (((Frame) window).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- class FlatTitleLabelUI ---------------------------------------------
|
//---- class FlatTitleLabelUI ---------------------------------------------
|
||||||
|
|||||||
@@ -794,6 +794,7 @@ TitlePane.buttonMaximizedHeight = 22
|
|||||||
TitlePane.centerTitle = false
|
TitlePane.centerTitle = false
|
||||||
TitlePane.centerTitleIfMenuBarEmbedded = true
|
TitlePane.centerTitleIfMenuBarEmbedded = true
|
||||||
TitlePane.menuBarTitleGap = 20
|
TitlePane.menuBarTitleGap = 20
|
||||||
|
TitlePane.menuBarResizeHeight = 4
|
||||||
TitlePane.closeIcon = com.formdev.flatlaf.icons.FlatWindowCloseIcon
|
TitlePane.closeIcon = com.formdev.flatlaf.icons.FlatWindowCloseIcon
|
||||||
TitlePane.iconifyIcon = com.formdev.flatlaf.icons.FlatWindowIconifyIcon
|
TitlePane.iconifyIcon = com.formdev.flatlaf.icons.FlatWindowIconifyIcon
|
||||||
TitlePane.maximizeIcon = com.formdev.flatlaf.icons.FlatWindowMaximizeIcon
|
TitlePane.maximizeIcon = com.formdev.flatlaf.icons.FlatWindowMaximizeIcon
|
||||||
|
|||||||
@@ -1233,6 +1233,7 @@ TitlePane.inactiveBackground #303234 HSL 210 4 20 javax.swing.plaf.Colo
|
|||||||
TitlePane.inactiveForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.ColorUIResource [UI]
|
TitlePane.inactiveForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.ColorUIResource [UI]
|
||||||
TitlePane.maximizeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
|
TitlePane.maximizeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
|
||||||
TitlePane.menuBarEmbedded true
|
TitlePane.menuBarEmbedded true
|
||||||
|
TitlePane.menuBarResizeHeight 4
|
||||||
TitlePane.menuBarTitleGap 20
|
TitlePane.menuBarTitleGap 20
|
||||||
TitlePane.noIconLeftGap 8
|
TitlePane.noIconLeftGap 8
|
||||||
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
|
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
|
||||||
|
|||||||
@@ -1238,6 +1238,7 @@ TitlePane.inactiveBackground #ffffff HSL 0 0 100 javax.swing.plaf.Colo
|
|||||||
TitlePane.inactiveForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.ColorUIResource [UI]
|
TitlePane.inactiveForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.ColorUIResource [UI]
|
||||||
TitlePane.maximizeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
|
TitlePane.maximizeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
|
||||||
TitlePane.menuBarEmbedded true
|
TitlePane.menuBarEmbedded true
|
||||||
|
TitlePane.menuBarResizeHeight 4
|
||||||
TitlePane.menuBarTitleGap 20
|
TitlePane.menuBarTitleGap 20
|
||||||
TitlePane.noIconLeftGap 8
|
TitlePane.noIconLeftGap 8
|
||||||
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
|
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
|
||||||
|
|||||||
@@ -1266,6 +1266,7 @@ TitlePane.inactiveBackground #008800 HSL 120 100 27 javax.swing.plaf.Colo
|
|||||||
TitlePane.inactiveForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI]
|
TitlePane.inactiveForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI]
|
||||||
TitlePane.maximizeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
|
TitlePane.maximizeIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowMaximizeIcon [UI]
|
||||||
TitlePane.menuBarEmbedded true
|
TitlePane.menuBarEmbedded true
|
||||||
|
TitlePane.menuBarResizeHeight 4
|
||||||
TitlePane.menuBarTitleGap 20
|
TitlePane.menuBarTitleGap 20
|
||||||
TitlePane.noIconLeftGap 8
|
TitlePane.noIconLeftGap 8
|
||||||
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
|
TitlePane.restoreIcon [lazy] 44,30 com.formdev.flatlaf.icons.FlatWindowRestoreIcon [UI]
|
||||||
|
|||||||
@@ -999,6 +999,7 @@ TitlePane.inactiveBackground
|
|||||||
TitlePane.inactiveForeground
|
TitlePane.inactiveForeground
|
||||||
TitlePane.maximizeIcon
|
TitlePane.maximizeIcon
|
||||||
TitlePane.menuBarEmbedded
|
TitlePane.menuBarEmbedded
|
||||||
|
TitlePane.menuBarResizeHeight
|
||||||
TitlePane.menuBarTitleGap
|
TitlePane.menuBarTitleGap
|
||||||
TitlePane.noIconLeftGap
|
TitlePane.noIconLeftGap
|
||||||
TitlePane.restoreIcon
|
TitlePane.restoreIcon
|
||||||
|
|||||||
Reference in New Issue
Block a user