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.
|
||||
*/
|
||||
public static class FlatWindowBorder
|
||||
extends BorderUIResource.EmptyBorderUIResource
|
||||
extends FlatEmptyBorder
|
||||
{
|
||||
protected final Color activeBorderColor = UIManager.getColor( "RootPane.activeBorderColor" );
|
||||
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 ) {
|
||||
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 ) {
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.util.function.Supplier;
|
||||
import javax.swing.DesktopManager;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRootPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
@@ -60,8 +59,6 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
public abstract class FlatWindowResizer
|
||||
implements PropertyChangeListener, ComponentListener
|
||||
{
|
||||
protected final static Integer WINDOW_RESIZER_LAYER = JLayeredPane.DRAG_LAYER + 1;
|
||||
|
||||
protected final JComponent resizeComp;
|
||||
|
||||
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 );
|
||||
rightDragComp = createDragBorderComponent( NE_RESIZE_CURSOR, E_RESIZE_CURSOR, SE_RESIZE_CURSOR );
|
||||
|
||||
Container cont = (resizeComp instanceof JRootPane) ? ((JRootPane)resizeComp).getLayeredPane() : resizeComp;
|
||||
Object cons = (cont instanceof JLayeredPane) ? WINDOW_RESIZER_LAYER : null;
|
||||
cont.add( topDragComp, cons, 0 );
|
||||
cont.add( bottomDragComp, cons, 1 );
|
||||
cont.add( leftDragComp, cons, 2 );
|
||||
cont.add( rightDragComp, cons, 3 );
|
||||
// for rootpanes, add after glasspane
|
||||
int insertIndex = (resizeComp instanceof JRootPane) ? 1 : 0;
|
||||
resizeComp.add( topDragComp, insertIndex++ );
|
||||
resizeComp.add( bottomDragComp, insertIndex++ );
|
||||
resizeComp.add( leftDragComp, insertIndex++ );
|
||||
resizeComp.add( rightDragComp, insertIndex++ );
|
||||
|
||||
resizeComp.addComponentListener( this );
|
||||
resizeComp.addPropertyChangeListener( "ancestor", this );
|
||||
@@ -106,11 +103,10 @@ public abstract class FlatWindowResizer
|
||||
resizeComp.removeComponentListener( this );
|
||||
resizeComp.removePropertyChangeListener( "ancestor", this );
|
||||
|
||||
Container cont = topDragComp.getParent();
|
||||
cont.remove( topDragComp );
|
||||
cont.remove( bottomDragComp );
|
||||
cont.remove( leftDragComp );
|
||||
cont.remove( rightDragComp );
|
||||
resizeComp.remove( topDragComp );
|
||||
resizeComp.remove( bottomDragComp );
|
||||
resizeComp.remove( leftDragComp );
|
||||
resizeComp.remove( rightDragComp );
|
||||
}
|
||||
|
||||
public void doLayout() {
|
||||
@@ -119,9 +115,8 @@ public abstract class FlatWindowResizer
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
Container cont = topDragComp.getParent();
|
||||
int width = cont.getWidth();
|
||||
int height = cont.getHeight();
|
||||
int width = resizeComp.getWidth();
|
||||
int height = resizeComp.getHeight();
|
||||
if( width <= 0 || height <= 0 )
|
||||
return;
|
||||
|
||||
@@ -252,8 +247,7 @@ public abstract class FlatWindowResizer
|
||||
centerComp = new JPanel();
|
||||
centerComp.setOpaque( false );
|
||||
centerComp.setVisible( false );
|
||||
Container cont = rootPane.getLayeredPane();
|
||||
cont.add( centerComp, WINDOW_RESIZER_LAYER, 4 );
|
||||
rootPane.add( centerComp, 5 );
|
||||
|
||||
// On Linux, limit window resizing to screen bounds because otherwise
|
||||
// there would be a strange effect when the mouse is moved over a sidebar
|
||||
@@ -263,8 +257,7 @@ public abstract class FlatWindowResizer
|
||||
|
||||
@Override
|
||||
public void uninstall() {
|
||||
Container cont = topDragComp.getParent();
|
||||
cont.remove( centerComp );
|
||||
resizeComp.remove( centerComp );
|
||||
|
||||
super.uninstall();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user