Popup: allow forcing to heavy weight popup windows (issue #189)

This commit is contained in:
Karl Tauber
2020-11-23 18:09:44 +01:00
parent 539737d1c5
commit 6c8b8e8949
2 changed files with 28 additions and 25 deletions

View File

@@ -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 -------------------------------------------------------
/** /**

View File

@@ -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;
} }
/** /**