mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +03:00
Popop: fixed drop shadow if popup overlaps a heavyweight component (Windows 10 only; issue #626)
This commit is contained in:
@@ -9,6 +9,8 @@ FlatLaf Change Log
|
|||||||
#718)
|
#718)
|
||||||
- TextField: Fixed placeholder text painting, which did not respect horizontal
|
- TextField: Fixed placeholder text painting, which did not respect horizontal
|
||||||
alignment property of `JTextField`. (issue #721)
|
alignment property of `JTextField`. (issue #721)
|
||||||
|
- Popop: Fixed drop shadow if popup overlaps a heavyweight component. (Windows
|
||||||
|
10 only; issue #626)
|
||||||
|
|
||||||
|
|
||||||
## 3.2
|
## 3.2
|
||||||
|
|||||||
@@ -103,6 +103,10 @@ public class FlatPopupFactory
|
|||||||
return popup;
|
return popup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check whether popup overlaps a heavy weight component
|
||||||
|
if( !forceHeavyWeight && overlapsHeavyWeightComponent( owner, contents, x, y ) )
|
||||||
|
forceHeavyWeight = true;
|
||||||
|
|
||||||
// create drop shadow popup
|
// create drop shadow popup
|
||||||
return new DropShadowPopup( getPopupForScreenOfOwner( owner, contents, x, y, forceHeavyWeight ), owner, contents );
|
return new DropShadowPopup( getPopupForScreenOfOwner( owner, contents, x, y, forceHeavyWeight ), owner, contents );
|
||||||
}
|
}
|
||||||
@@ -389,6 +393,33 @@ public class FlatPopupFactory
|
|||||||
FlatNativeWindowsLibrary.setWindowCornerPreference( hwnd, FlatNativeWindowsLibrary.DWMWCP_DONOTROUND );
|
FlatNativeWindowsLibrary.setWindowCornerPreference( hwnd, FlatNativeWindowsLibrary.DWMWCP_DONOTROUND );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean overlapsHeavyWeightComponent( Component owner, Component contents, int x, int y ) {
|
||||||
|
Window window = SwingUtilities.getWindowAncestor( owner );
|
||||||
|
if( window == null )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Rectangle r = new Rectangle( new Point( x, y ), contents.getPreferredSize() );
|
||||||
|
return overlapsHeavyWeightComponent( window, r );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean overlapsHeavyWeightComponent( Component parent, Rectangle r ) {
|
||||||
|
if( !parent.isVisible() || !r.intersects( parent.getBounds() ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( !parent.isLightweight() && !(parent instanceof Window) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if( parent instanceof Container ) {
|
||||||
|
Rectangle r2 = new Rectangle( r.x - parent.getX(), r.y - parent.getY(), r.width, r.height );
|
||||||
|
for( Component c : ((Container)parent).getComponents() ) {
|
||||||
|
if( overlapsHeavyWeightComponent( c, r2 ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//---- class NonFlashingPopup ---------------------------------------------
|
//---- class NonFlashingPopup ---------------------------------------------
|
||||||
|
|
||||||
private static class NonFlashingPopup
|
private static class NonFlashingPopup
|
||||||
|
|||||||
Reference in New Issue
Block a user