mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 23:07:15 -06:00
Window decorations: added debug option to paint title bar rectangles that are used by Windows 10/11 in WM_NCHITTEST to identify special areas
This commit is contained in:
@@ -107,6 +107,8 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
public class FlatTitlePane
|
public class FlatTitlePane
|
||||||
extends JComponent
|
extends JComponent
|
||||||
{
|
{
|
||||||
|
private static final String KEY_DEBUG_SHOW_RECTANGLES = "FlatLaf.debug.titlebar.showRectangles";
|
||||||
|
|
||||||
/** @since 2.5 */ protected final Font titleFont = UIManager.getFont( "TitlePane.font" );
|
/** @since 2.5 */ protected final Font titleFont = UIManager.getFont( "TitlePane.font" );
|
||||||
protected final Color activeBackground = UIManager.getColor( "TitlePane.background" );
|
protected final Color activeBackground = UIManager.getColor( "TitlePane.background" );
|
||||||
protected final Color inactiveBackground = UIManager.getColor( "TitlePane.inactiveBackground" );
|
protected final Color inactiveBackground = UIManager.getColor( "TitlePane.inactiveBackground" );
|
||||||
@@ -576,11 +578,13 @@ public class FlatTitlePane
|
|||||||
doLayout();
|
doLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*debug
|
|
||||||
@Override
|
@Override
|
||||||
public void paint( Graphics g ) {
|
public void paint( Graphics g ) {
|
||||||
super.paint( g );
|
super.paint( g );
|
||||||
|
|
||||||
|
if( !UIManager.getBoolean( KEY_DEBUG_SHOW_RECTANGLES ) )
|
||||||
|
return;
|
||||||
|
|
||||||
if( debugTitleBarHeight > 0 ) {
|
if( debugTitleBarHeight > 0 ) {
|
||||||
g.setColor( Color.green );
|
g.setColor( Color.green );
|
||||||
g.drawLine( 0, debugTitleBarHeight, getWidth(), debugTitleBarHeight );
|
g.drawLine( 0, debugTitleBarHeight, getWidth(), debugTitleBarHeight );
|
||||||
@@ -604,7 +608,6 @@ public class FlatTitlePane
|
|||||||
Point offset = SwingUtilities.convertPoint( this, 0, 0, window );
|
Point offset = SwingUtilities.convertPoint( this, 0, 0, window );
|
||||||
g.drawRect( r.x - offset.x, r.y - offset.y, r.width - 1, r.height - 1 );
|
g.drawRect( r.x - offset.x, r.y - offset.y, r.width - 1, r.height - 1 );
|
||||||
}
|
}
|
||||||
debug*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent( Graphics g ) {
|
protected void paintComponent( Graphics g ) {
|
||||||
@@ -933,15 +936,14 @@ debug*/
|
|||||||
FlatNativeWindowBorder.setTitleBarHeightAndHitTestSpots( window, titleBarHeight,
|
FlatNativeWindowBorder.setTitleBarHeightAndHitTestSpots( window, titleBarHeight,
|
||||||
hitTestSpots, appIconBounds, minimizeButtonBounds, maximizeButtonBounds, closeButtonBounds );
|
hitTestSpots, appIconBounds, minimizeButtonBounds, maximizeButtonBounds, closeButtonBounds );
|
||||||
|
|
||||||
/*debug
|
|
||||||
debugTitleBarHeight = titleBarHeight;
|
debugTitleBarHeight = titleBarHeight;
|
||||||
debugHitTestSpots = hitTestSpots;
|
debugHitTestSpots = hitTestSpots;
|
||||||
debugAppIconBounds = appIconBounds;
|
debugAppIconBounds = appIconBounds;
|
||||||
debugMinimizeButtonBounds = minimizeButtonBounds;
|
debugMinimizeButtonBounds = minimizeButtonBounds;
|
||||||
debugMaximizeButtonBounds = maximizeButtonBounds;
|
debugMaximizeButtonBounds = maximizeButtonBounds;
|
||||||
debugCloseButtonBounds = closeButtonBounds;
|
debugCloseButtonBounds = closeButtonBounds;
|
||||||
repaint();
|
if( UIManager.getBoolean( KEY_DEBUG_SHOW_RECTANGLES ) )
|
||||||
debug*/
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rectangle boundsInWindow( JComponent c ) {
|
private Rectangle boundsInWindow( JComponent c ) {
|
||||||
@@ -960,14 +962,12 @@ debug*/
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*debug
|
|
||||||
private int debugTitleBarHeight;
|
private int debugTitleBarHeight;
|
||||||
private List<Rectangle> debugHitTestSpots;
|
private List<Rectangle> debugHitTestSpots;
|
||||||
private Rectangle debugAppIconBounds;
|
private Rectangle debugAppIconBounds;
|
||||||
private Rectangle debugMinimizeButtonBounds;
|
private Rectangle debugMinimizeButtonBounds;
|
||||||
private Rectangle debugMaximizeButtonBounds;
|
private Rectangle debugMaximizeButtonBounds;
|
||||||
private Rectangle debugCloseButtonBounds;
|
private Rectangle debugCloseButtonBounds;
|
||||||
debug*/
|
|
||||||
|
|
||||||
//---- class FlatTitlePaneBorder ------------------------------------------
|
//---- class FlatTitlePaneBorder ------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class FlatNativeWindowBorderTest
|
|||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
FlatLightLaf.setup();
|
FlatLightLaf.setup();
|
||||||
FlatInspector.install( "ctrl shift alt X" );
|
FlatInspector.install( "ctrl shift alt X" );
|
||||||
|
UIManager.put( "FlatLaf.debug.titlebar.showRectangles", true );
|
||||||
|
|
||||||
mainFrame = showFrame();
|
mainFrame = showFrame();
|
||||||
} );
|
} );
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class FlatWindowDecorationsTest
|
|||||||
|
|
||||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatWindowDecorationsTest" );
|
FlatTestFrame frame = FlatTestFrame.create( args, "FlatWindowDecorationsTest" );
|
||||||
frame.applyComponentOrientationToFrame = true;
|
frame.applyComponentOrientationToFrame = true;
|
||||||
|
UIManager.put( "FlatLaf.debug.titlebar.showRectangles", true );
|
||||||
|
|
||||||
Class<?> cls = FlatWindowDecorationsTest.class;
|
Class<?> cls = FlatWindowDecorationsTest.class;
|
||||||
List<Image> images = Arrays.asList(
|
List<Image> images = Arrays.asList(
|
||||||
|
|||||||
Reference in New Issue
Block a user