mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Menus: use disabled and pressed icons (issue #3)
This commit is contained in:
@@ -214,7 +214,7 @@ debug*/
|
||||
|
||||
paintBackground( g, selectionBackground );
|
||||
if( !isTopLevelMenu )
|
||||
paintIcon( g, iconRect, getIcon() );
|
||||
paintIcon( g, iconRect, getIconForPainting() );
|
||||
paintText( g, textRect, menuItem.getText(), selectionForeground, disabledForeground );
|
||||
paintAccelerator( g, accelRect, getAcceleratorText(), acceleratorForeground, acceleratorSelectionForeground, disabledForeground );
|
||||
if( !isTopLevelMenu )
|
||||
@@ -304,6 +304,26 @@ debug*/
|
||||
return (checkIcon != null) ? checkIcon : menuItem.getIcon();
|
||||
}
|
||||
|
||||
private Icon getIconForPainting() {
|
||||
if( checkIcon != null )
|
||||
return checkIcon;
|
||||
|
||||
Icon icon = menuItem.getIcon();
|
||||
if( icon == null )
|
||||
return null;
|
||||
|
||||
if( !menuItem.isEnabled() )
|
||||
return menuItem.getDisabledIcon();
|
||||
|
||||
if( menuItem.getModel().isPressed() && menuItem.isArmed() ) {
|
||||
Icon pressedIcon = menuItem.getPressedIcon();
|
||||
if( pressedIcon != null )
|
||||
return pressedIcon;
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
private Dimension getIconSize() {
|
||||
Icon icon = getIcon();
|
||||
int iconWidth = (icon != null) ? icon.getIconWidth() : 0;
|
||||
|
||||
Reference in New Issue
Block a user