Browse Source

调整下菜单的UI实现

persist/11.0-arabic
obo 4 months ago
parent
commit
97c9f8ba02
  1. 9
      designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java
  2. 6
      designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuUI.java

9
designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java

@ -35,17 +35,16 @@ public class UIMenuItemUI extends BasicMenuItemUI {
g.setColor(UIConstants.NORMAL_BACKGROUND); g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillRect(0, 0, menuWidth, menuHeight); g.fillRect(0, 0, menuWidth, menuHeight);
int bidiX = BidiUtils.rtl() ? 10 : 30; int bidiX = BidiUtils.rtl() ? 5 : 30;
int bidiWidth = BidiUtils.rtl() ? menuWidth - 35 : menuWidth - 30;
if (menuItem.isOpaque()) { if (menuItem.isOpaque()) {
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, bidiWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
} else { } else {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, bidiWidth, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7);
} }
g.setColor(oldColor); g.setColor(oldColor);
} else if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { } else if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, bidiWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
g.setColor(oldColor); g.setColor(oldColor);
} }
} }

6
designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuUI.java

@ -1,5 +1,6 @@
package com.fr.design.gui.imenu; package com.fr.design.gui.imenu;
import com.fr.base.i18n.BidiUtils;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.design.utils.gui.GUIPaintUtils;
@ -17,11 +18,12 @@ public class UIMenuUI extends BasicMenuUI {
Color oldColor = g.getColor(); Color oldColor = g.getColor();
int menuWidth = menuItem.getWidth(); int menuWidth = menuItem.getWidth();
int menuHeight = menuItem.getHeight(); int menuHeight = menuItem.getHeight();
int bidiX = BidiUtils.rtl() ? 5 : 30;
if (menuItem.isOpaque()) { if (menuItem.isOpaque()) {
if (menuItem.getParent() instanceof JPopupMenu && model.isSelected()) { if (menuItem.getParent() instanceof JPopupMenu && model.isSelected()) {
g.setColor(UIConstants.UI_MENU_BACKGOURND); g.setColor(UIConstants.UI_MENU_BACKGOURND);
g.fillRect(0, 0, menuWidth, menuHeight); g.fillRect(0, 0, menuWidth, menuHeight);
GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
} else if (model.isSelected()) { } else if (model.isSelected()) {
paintPressed(g, menuWidth, menuHeight); paintPressed(g, menuWidth, menuHeight);
} else { } else {
@ -54,7 +56,7 @@ public class UIMenuUI extends BasicMenuUI {
ButtonModel model = menuItem.getModel(); ButtonModel model = menuItem.getModel();
FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g); FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
int mnemIndex = -1; int mnemIndex = -1;
BidiUtils.applyOrientationByLocale(menuItem);
if (!model.isEnabled()) { if (!model.isEnabled()) {
// *** paint the text disabled // *** paint the text disabled
if (UIManager.get("MenuItem.disabledForeground") instanceof Color) { if (UIManager.get("MenuItem.disabledForeground") instanceof Color) {

Loading…
Cancel
Save