Browse Source

Menu: Use disabled arrow icon if menu is disabled

Fixes #259
macos/dialog_size
weisj 3 years ago
parent
commit
e68f78eea0
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 4
      core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java
  2. 1
      core/src/main/resources/com/github/weisj/darklaf/ui/menuItem.properties

4
core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuUI.java

@ -38,6 +38,7 @@ public class DarkMenuUI extends BasicMenuUI implements MenuItemUI {
protected int acceleratorTextOffset; protected int acceleratorTextOffset;
protected boolean useEvenHeight; protected boolean useEvenHeight;
protected Icon arrowIconHover; protected Icon arrowIconHover;
protected Icon arrowIconDisabled;
protected JMenu menu; protected JMenu menu;
protected MouseListener mouseListener; protected MouseListener mouseListener;
@ -107,6 +108,7 @@ public class DarkMenuUI extends BasicMenuUI implements MenuItemUI {
acceleratorForeground = UIManager.getColor("Menu.foreground"); acceleratorForeground = UIManager.getColor("Menu.foreground");
acceleratorSelectionForeground = UIManager.getColor("Menu.selectionForeground"); acceleratorSelectionForeground = UIManager.getColor("Menu.selectionForeground");
arrowIconHover = UIManager.getIcon("Menu.arrowHover.icon"); arrowIconHover = UIManager.getIcon("Menu.arrowHover.icon");
arrowIconDisabled = UIManager.getIcon("Menu.arrowDisabled.icon");
useEvenHeight = !Boolean.TRUE.equals(UIManager.get(getPropertyPrefix() + ".evenHeight")); useEvenHeight = !Boolean.TRUE.equals(UIManager.get(getPropertyPrefix() + ".evenHeight"));
acceleratorTextOffset = UIManager.getInt(getPropertyPrefix() + ".acceleratorTextOffset"); acceleratorTextOffset = UIManager.getInt(getPropertyPrefix() + ".acceleratorTextOffset");
} }
@ -123,6 +125,8 @@ public class DarkMenuUI extends BasicMenuUI implements MenuItemUI {
} }
protected Icon getArrowIcon() { protected Icon getArrowIcon() {
if (!menuItem.isEnabled())
return arrowIconDisabled;
boolean hover = boolean hover =
menuItem.getModel().isArmed() || (menuItem instanceof JMenu && menuItem.getModel().isSelected()); menuItem.getModel().isArmed() || (menuItem instanceof JMenu && menuItem.getModel().isSelected());
return hover ? arrowIconHover : arrowIcon; return hover ? arrowIconHover : arrowIcon;

1
core/src/main/resources/com/github/weisj/darklaf/ui/menuItem.properties

@ -77,6 +77,7 @@ RadioButtonMenuItem.acceleratorTextOffset = 10
#Icons #Icons
Menu.arrowIcon = navigation/arrow/thick/arrowRight.svg[themed] Menu.arrowIcon = navigation/arrow/thick/arrowRight.svg[themed]
Menu.arrowDisabled.icon = navigation/arrow/thick/arrowRightDisabled.svg[themed]
Menu.arrowHover.icon = navigation/arrow/thick/arrowRightHover.svg[themed] Menu.arrowHover.icon = navigation/arrow/thick/arrowRightHover.svg[themed]
Menu.checkIcon = empty(0,0) Menu.checkIcon = empty(0,0)
MenuItem.checkIcon = empty(0,0) MenuItem.checkIcon = empty(0,0)

Loading…
Cancel
Save