mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 15:00:54 +03:00
Window decorations:
- use window border color from UI defaults - support "active" and "inactive" window border colors - better window border colors for dark themes
This commit is contained in:
@@ -4,6 +4,8 @@ FlatLaf Change Log
|
|||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- Hide focus indicator when window is inactive.
|
- Hide focus indicator when window is inactive.
|
||||||
|
- Improved/fixed window border color in dark themes in custom window
|
||||||
|
decorations.
|
||||||
|
|
||||||
|
|
||||||
## 0.37
|
## 0.37
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.LayoutManager;
|
import java.awt.LayoutManager;
|
||||||
import java.awt.LayoutManager2;
|
import java.awt.LayoutManager2;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Window;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
@@ -51,6 +51,8 @@ import com.formdev.flatlaf.util.SystemInfo;
|
|||||||
* <!-- FlatRootPaneUI -->
|
* <!-- FlatRootPaneUI -->
|
||||||
*
|
*
|
||||||
* @uiDefault RootPane.border Border
|
* @uiDefault RootPane.border Border
|
||||||
|
* @uiDefault RootPane.activeBorderColor Color
|
||||||
|
* @uiDefault RootPane.inactiveBorderColor Color
|
||||||
*
|
*
|
||||||
* <!-- FlatWindowResizer -->
|
* <!-- FlatWindowResizer -->
|
||||||
*
|
*
|
||||||
@@ -323,19 +325,20 @@ public class FlatRootPaneUI
|
|||||||
public static class FlatWindowBorder
|
public static class FlatWindowBorder
|
||||||
extends BorderUIResource.EmptyBorderUIResource
|
extends BorderUIResource.EmptyBorderUIResource
|
||||||
{
|
{
|
||||||
|
protected final Color activeBorderColor = UIManager.getColor( "RootPane.activeBorderColor" );
|
||||||
|
protected final Color inactiveBorderColor = UIManager.getColor( "RootPane.inactiveBorderColor" );
|
||||||
|
protected final Color baseBorderColor = UIManager.getColor( "Panel.background" );
|
||||||
|
|
||||||
public FlatWindowBorder() {
|
public FlatWindowBorder() {
|
||||||
super( 1, 1, 1, 1 );
|
super( 1, 1, 1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
|
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
|
||||||
Object borderColorObj = Toolkit.getDefaultToolkit().getDesktopProperty(
|
Container parent = c.getParent();
|
||||||
"win.frame.activeBorderColor" );
|
boolean active = parent instanceof Window ? ((Window)parent).isActive() : false;
|
||||||
Color borderColor = (borderColorObj instanceof Color)
|
|
||||||
? (Color) borderColorObj
|
|
||||||
: UIManager.getColor( "windowBorder" );
|
|
||||||
|
|
||||||
g.setColor( borderColor );
|
g.setColor( FlatUIUtils.deriveColor( active ? activeBorderColor : inactiveBorderColor, baseBorderColor ) );
|
||||||
HiDPIUtils.paintAtScale1x( (Graphics2D) g, x, y, width, height, this::paintImpl );
|
HiDPIUtils.paintAtScale1x( (Graphics2D) g, x, y, width, height, this::paintImpl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -385,6 +385,16 @@ public class FlatTitlePane
|
|||||||
g.fillRect( 0, 0, getWidth(), getHeight() );
|
g.fillRect( 0, 0, getWidth(), getHeight() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void repaintWindowBorder() {
|
||||||
|
int width = rootPane.getWidth();
|
||||||
|
int height = rootPane.getHeight();
|
||||||
|
Insets insets = rootPane.getInsets();
|
||||||
|
rootPane.repaint( 0, 0, width, insets.top ); // top
|
||||||
|
rootPane.repaint( 0, 0, insets.left, height ); // left
|
||||||
|
rootPane.repaint( 0, height - insets.bottom, width, insets.bottom ); // bottom
|
||||||
|
rootPane.repaint( width - insets.right, 0, insets.right, height ); // right
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iconifies the window.
|
* Iconifies the window.
|
||||||
*/
|
*/
|
||||||
@@ -613,6 +623,8 @@ public class FlatTitlePane
|
|||||||
|
|
||||||
if( hasJBRCustomDecoration() )
|
if( hasJBRCustomDecoration() )
|
||||||
JBRWindowTopBorder.getInstance().repaintBorder( FlatTitlePane.this );
|
JBRWindowTopBorder.getInstance().repaintBorder( FlatTitlePane.this );
|
||||||
|
|
||||||
|
repaintWindowBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -622,6 +634,8 @@ public class FlatTitlePane
|
|||||||
|
|
||||||
if( hasJBRCustomDecoration() )
|
if( hasJBRCustomDecoration() )
|
||||||
JBRWindowTopBorder.getInstance().repaintBorder( FlatTitlePane.this );
|
JBRWindowTopBorder.getInstance().repaintBorder( FlatTitlePane.this );
|
||||||
|
|
||||||
|
repaintWindowBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -239,6 +239,12 @@ ProgressBar.selectionBackground=@foreground
|
|||||||
RadioButton.icon[filled].centerDiameter=5
|
RadioButton.icon[filled].centerDiameter=5
|
||||||
|
|
||||||
|
|
||||||
|
#---- RootPane ----
|
||||||
|
|
||||||
|
RootPane.activeBorderColor=darken(@background,7%,derived)
|
||||||
|
RootPane.inactiveBorderColor=darken(@background,5%,derived)
|
||||||
|
|
||||||
|
|
||||||
#---- ScrollBar ----
|
#---- ScrollBar ----
|
||||||
|
|
||||||
ScrollBar.track=lighten(@background,1%,derived noAutoInverse)
|
ScrollBar.track=lighten(@background,1%,derived noAutoInverse)
|
||||||
|
|||||||
@@ -251,6 +251,12 @@ ProgressBar.selectionBackground=@foreground
|
|||||||
RadioButton.icon[filled].centerDiameter=5
|
RadioButton.icon[filled].centerDiameter=5
|
||||||
|
|
||||||
|
|
||||||
|
#---- RootPane ----
|
||||||
|
|
||||||
|
RootPane.activeBorderColor=#707070
|
||||||
|
RootPane.inactiveBorderColor=lighten($RootPane.activeBorderColor,20%)
|
||||||
|
|
||||||
|
|
||||||
#---- ScrollBar ----
|
#---- ScrollBar ----
|
||||||
|
|
||||||
ScrollBar.track=lighten(@background,1%,derived noAutoInverse)
|
ScrollBar.track=lighten(@background,1%,derived noAutoInverse)
|
||||||
|
|||||||
@@ -752,6 +752,7 @@ Resizable.resizeBorder [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.F
|
|||||||
|
|
||||||
#---- RootPane ----
|
#---- RootPane ----
|
||||||
|
|
||||||
|
RootPane.activeBorderColor #4d5154 com.formdev.flatlaf.util.DerivedColor [UI] darken(7% autoInverse)
|
||||||
RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI]
|
RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI]
|
||||||
RootPane.borderDragThickness 5
|
RootPane.borderDragThickness 5
|
||||||
RootPane.cornerDragWidth 16
|
RootPane.cornerDragWidth 16
|
||||||
@@ -765,6 +766,7 @@ RootPane.defaultButtonWindowKeyBindings length=8 [Ljava.lang.Object;
|
|||||||
[6] ctrl released ENTER
|
[6] ctrl released ENTER
|
||||||
[7] release
|
[7] release
|
||||||
RootPane.honorMinimumSizeOnResize true
|
RootPane.honorMinimumSizeOnResize true
|
||||||
|
RootPane.inactiveBorderColor #484c4e com.formdev.flatlaf.util.DerivedColor [UI] darken(5% autoInverse)
|
||||||
RootPaneUI com.formdev.flatlaf.ui.FlatRootPaneUI
|
RootPaneUI com.formdev.flatlaf.ui.FlatRootPaneUI
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -757,6 +757,7 @@ Resizable.resizeBorder [lazy] 4,4,4,4 false com.formdev.flatlaf.ui.F
|
|||||||
|
|
||||||
#---- RootPane ----
|
#---- RootPane ----
|
||||||
|
|
||||||
|
RootPane.activeBorderColor #707070 javax.swing.plaf.ColorUIResource [UI]
|
||||||
RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI]
|
RootPane.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRootPaneUI$FlatWindowBorder [UI]
|
||||||
RootPane.borderDragThickness 5
|
RootPane.borderDragThickness 5
|
||||||
RootPane.cornerDragWidth 16
|
RootPane.cornerDragWidth 16
|
||||||
@@ -770,6 +771,7 @@ RootPane.defaultButtonWindowKeyBindings length=8 [Ljava.lang.Object;
|
|||||||
[6] ctrl released ENTER
|
[6] ctrl released ENTER
|
||||||
[7] release
|
[7] release
|
||||||
RootPane.honorMinimumSizeOnResize true
|
RootPane.honorMinimumSizeOnResize true
|
||||||
|
RootPane.inactiveBorderColor #a3a3a3 javax.swing.plaf.ColorUIResource [UI]
|
||||||
RootPaneUI com.formdev.flatlaf.ui.FlatRootPaneUI
|
RootPaneUI com.formdev.flatlaf.ui.FlatRootPaneUI
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user