mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Linux with FlatLaf window decorations:
Some checks are pending
CI / build (11) (push) Waiting to run
CI / build-on (17, ) (push) Blocked by required conditions
CI / build-on (21, ) (push) Blocked by required conditions
CI / build-on (23, ) (push) Blocked by required conditions
CI / build-on (8, ) (push) Blocked by required conditions
CI / snapshot (push) Blocked by required conditions
CI / release (push) Blocked by required conditions
Some checks are pending
CI / build (11) (push) Waiting to run
CI / build-on (17, ) (push) Blocked by required conditions
CI / build-on (21, ) (push) Blocked by required conditions
CI / build-on (23, ) (push) Blocked by required conditions
CI / build-on (8, ) (push) Blocked by required conditions
CI / snapshot (push) Blocked by required conditions
CI / release (push) Blocked by required conditions
- moved window resizer components from layered pane to rootpane so that border is included in area where user can resize window - scale border thickness
This commit is contained in:
@@ -684,7 +684,7 @@ public class FlatRootPaneUI
|
|||||||
* Window border used for non-native window decorations.
|
* Window border used for non-native window decorations.
|
||||||
*/
|
*/
|
||||||
public static class FlatWindowBorder
|
public static class FlatWindowBorder
|
||||||
extends BorderUIResource.EmptyBorderUIResource
|
extends FlatEmptyBorder
|
||||||
{
|
{
|
||||||
protected final Color activeBorderColor = UIManager.getColor( "RootPane.activeBorderColor" );
|
protected final Color activeBorderColor = UIManager.getColor( "RootPane.activeBorderColor" );
|
||||||
protected final Color inactiveBorderColor = UIManager.getColor( "RootPane.inactiveBorderColor" );
|
protected final Color inactiveBorderColor = UIManager.getColor( "RootPane.inactiveBorderColor" );
|
||||||
@@ -717,7 +717,10 @@ public class FlatRootPaneUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void paintImpl( Graphics2D g, int x, int y, int width, int height, double scaleFactor ) {
|
private void paintImpl( Graphics2D g, int x, int y, int width, int height, double scaleFactor ) {
|
||||||
g.drawRect( x, y, width - 1, height - 1 );
|
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
|
||||||
|
float lineWidth = (float) (UIScale.scale( 1f ) * scaleFactor);
|
||||||
|
g.fill( FlatUIUtils.createRectangle( x, y, width, height, lineWidth ) );
|
||||||
|
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isWindowMaximized( Component c ) {
|
protected boolean isWindowMaximized( Component c ) {
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import java.util.function.Supplier;
|
|||||||
import javax.swing.DesktopManager;
|
import javax.swing.DesktopManager;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JInternalFrame;
|
import javax.swing.JInternalFrame;
|
||||||
import javax.swing.JLayeredPane;
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JRootPane;
|
import javax.swing.JRootPane;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
@@ -60,8 +59,6 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
public abstract class FlatWindowResizer
|
public abstract class FlatWindowResizer
|
||||||
implements PropertyChangeListener, ComponentListener
|
implements PropertyChangeListener, ComponentListener
|
||||||
{
|
{
|
||||||
protected final static Integer WINDOW_RESIZER_LAYER = JLayeredPane.DRAG_LAYER + 1;
|
|
||||||
|
|
||||||
protected final JComponent resizeComp;
|
protected final JComponent resizeComp;
|
||||||
|
|
||||||
protected final int borderDragThickness = FlatUIUtils.getUIInt( "RootPane.borderDragThickness", 5 );
|
protected final int borderDragThickness = FlatUIUtils.getUIInt( "RootPane.borderDragThickness", 5 );
|
||||||
@@ -82,12 +79,12 @@ public abstract class FlatWindowResizer
|
|||||||
leftDragComp = createDragBorderComponent( NW_RESIZE_CURSOR, W_RESIZE_CURSOR, SW_RESIZE_CURSOR );
|
leftDragComp = createDragBorderComponent( NW_RESIZE_CURSOR, W_RESIZE_CURSOR, SW_RESIZE_CURSOR );
|
||||||
rightDragComp = createDragBorderComponent( NE_RESIZE_CURSOR, E_RESIZE_CURSOR, SE_RESIZE_CURSOR );
|
rightDragComp = createDragBorderComponent( NE_RESIZE_CURSOR, E_RESIZE_CURSOR, SE_RESIZE_CURSOR );
|
||||||
|
|
||||||
Container cont = (resizeComp instanceof JRootPane) ? ((JRootPane)resizeComp).getLayeredPane() : resizeComp;
|
// for rootpanes, add after glasspane
|
||||||
Object cons = (cont instanceof JLayeredPane) ? WINDOW_RESIZER_LAYER : null;
|
int insertIndex = (resizeComp instanceof JRootPane) ? 1 : 0;
|
||||||
cont.add( topDragComp, cons, 0 );
|
resizeComp.add( topDragComp, insertIndex++ );
|
||||||
cont.add( bottomDragComp, cons, 1 );
|
resizeComp.add( bottomDragComp, insertIndex++ );
|
||||||
cont.add( leftDragComp, cons, 2 );
|
resizeComp.add( leftDragComp, insertIndex++ );
|
||||||
cont.add( rightDragComp, cons, 3 );
|
resizeComp.add( rightDragComp, insertIndex++ );
|
||||||
|
|
||||||
resizeComp.addComponentListener( this );
|
resizeComp.addComponentListener( this );
|
||||||
resizeComp.addPropertyChangeListener( "ancestor", this );
|
resizeComp.addPropertyChangeListener( "ancestor", this );
|
||||||
@@ -106,11 +103,10 @@ public abstract class FlatWindowResizer
|
|||||||
resizeComp.removeComponentListener( this );
|
resizeComp.removeComponentListener( this );
|
||||||
resizeComp.removePropertyChangeListener( "ancestor", this );
|
resizeComp.removePropertyChangeListener( "ancestor", this );
|
||||||
|
|
||||||
Container cont = topDragComp.getParent();
|
resizeComp.remove( topDragComp );
|
||||||
cont.remove( topDragComp );
|
resizeComp.remove( bottomDragComp );
|
||||||
cont.remove( bottomDragComp );
|
resizeComp.remove( leftDragComp );
|
||||||
cont.remove( leftDragComp );
|
resizeComp.remove( rightDragComp );
|
||||||
cont.remove( rightDragComp );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doLayout() {
|
public void doLayout() {
|
||||||
@@ -119,9 +115,8 @@ public abstract class FlatWindowResizer
|
|||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
Container cont = topDragComp.getParent();
|
int width = resizeComp.getWidth();
|
||||||
int width = cont.getWidth();
|
int height = resizeComp.getHeight();
|
||||||
int height = cont.getHeight();
|
|
||||||
if( width <= 0 || height <= 0 )
|
if( width <= 0 || height <= 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -252,8 +247,7 @@ public abstract class FlatWindowResizer
|
|||||||
centerComp = new JPanel();
|
centerComp = new JPanel();
|
||||||
centerComp.setOpaque( false );
|
centerComp.setOpaque( false );
|
||||||
centerComp.setVisible( false );
|
centerComp.setVisible( false );
|
||||||
Container cont = rootPane.getLayeredPane();
|
rootPane.add( centerComp, 5 );
|
||||||
cont.add( centerComp, WINDOW_RESIZER_LAYER, 4 );
|
|
||||||
|
|
||||||
// On Linux, limit window resizing to screen bounds because otherwise
|
// On Linux, limit window resizing to screen bounds because otherwise
|
||||||
// there would be a strange effect when the mouse is moved over a sidebar
|
// there would be a strange effect when the mouse is moved over a sidebar
|
||||||
@@ -263,8 +257,7 @@ public abstract class FlatWindowResizer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uninstall() {
|
public void uninstall() {
|
||||||
Container cont = topDragComp.getParent();
|
resizeComp.remove( centerComp );
|
||||||
cont.remove( centerComp );
|
|
||||||
|
|
||||||
super.uninstall();
|
super.uninstall();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user