mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27:13 -06:00
Popup: allow forcing to heavy weight popup windows (issue #189)
This commit is contained in:
@@ -181,6 +181,15 @@ public interface FlatClientProperties
|
|||||||
*/
|
*/
|
||||||
String POPUP_DROP_SHADOW_PAINTED = "Popup.dropShadowPainted";
|
String POPUP_DROP_SHADOW_PAINTED = "Popup.dropShadowPainted";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies whether a heavy weight window should be used if the component is shown in a popup
|
||||||
|
* or if the component is the owner of another component that is shown in a popup.
|
||||||
|
* <p>
|
||||||
|
* <strong>Component</strong> {@link javax.swing.JComponent}<br>
|
||||||
|
* <strong>Value type</strong> {@link java.lang.Boolean}
|
||||||
|
*/
|
||||||
|
String POPUP_FORCE_HEAVY_WEIGHT = "Popup.forceHeavyWeight";
|
||||||
|
|
||||||
//---- JProgressBar -------------------------------------------------------
|
//---- JProgressBar -------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -68,19 +68,17 @@ public class FlatPopupFactory
|
|||||||
y = pt.y;
|
y = pt.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !isDropShadowPainted( owner, contents ) )
|
boolean forceHeavyWeight = isOptionEnabled( owner, contents, FlatClientProperties.POPUP_FORCE_HEAVY_WEIGHT, "Popup.forceHeavyWeight" );
|
||||||
return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, false ), contents );
|
|
||||||
|
if( !isOptionEnabled( owner, contents, FlatClientProperties.POPUP_DROP_SHADOW_PAINTED, "Popup.dropShadowPainted" ) )
|
||||||
|
return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, forceHeavyWeight ), contents );
|
||||||
|
|
||||||
// macOS and Linux adds drop shadow to heavy weight popups
|
// macOS and Linux adds drop shadow to heavy weight popups
|
||||||
if( SystemInfo.isMacOS || SystemInfo.isLinux ) {
|
if( SystemInfo.isMacOS || SystemInfo.isLinux )
|
||||||
Popup popup = getPopupForScreenOfOwner( owner, contents, x, y, true );
|
return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, true ), contents );
|
||||||
if( popup == null )
|
|
||||||
popup = getPopupForScreenOfOwner( owner, contents, x, y, false );
|
|
||||||
return new NonFlashingPopup( popup, contents );
|
|
||||||
}
|
|
||||||
|
|
||||||
// create drop shadow popup
|
// create drop shadow popup
|
||||||
return new DropShadowPopup( getPopupForScreenOfOwner( owner, contents, x, y, false ), owner, contents );
|
return new DropShadowPopup( getPopupForScreenOfOwner( owner, contents, x, y, forceHeavyWeight ), owner, contents );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,24 +153,20 @@ public class FlatPopupFactory
|
|||||||
popup.show();
|
popup.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDropShadowPainted( Component owner, Component contents ) {
|
private boolean isOptionEnabled( Component owner, Component contents, String clientKey, String uiKey ) {
|
||||||
Boolean b = isDropShadowPainted( owner );
|
if( owner instanceof JComponent ) {
|
||||||
if( b != null )
|
Boolean b = FlatClientProperties.clientPropertyBooleanStrict( (JComponent) owner, clientKey, null );
|
||||||
return b;
|
if( b != null )
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
b = isDropShadowPainted( contents );
|
if( contents instanceof JComponent ) {
|
||||||
if( b != null )
|
Boolean b = FlatClientProperties.clientPropertyBooleanStrict( (JComponent) contents, clientKey, null );
|
||||||
return b;
|
if( b != null )
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
return UIManager.getBoolean( "Popup.dropShadowPainted" );
|
return UIManager.getBoolean( uiKey );
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean isDropShadowPainted( Component c ) {
|
|
||||||
if( !(c instanceof JComponent) )
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Object value = ((JComponent)c).getClientProperty( FlatClientProperties.POPUP_DROP_SHADOW_PAINTED );
|
|
||||||
return (value instanceof Boolean ) ? (Boolean) value : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user