Browse Source

REPORT-4554 tab导航按钮样式

master
plough 7 years ago
parent
commit
dda9731acb
  1. 5
      designer_base/src/com/fr/design/constants/UIConstants.java
  2. 18
      designer_base/src/com/fr/design/gui/ibutton/UIButtonUI.java
  3. 20
      designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java
  4. 19
      designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java

5
designer_base/src/com/fr/design/constants/UIConstants.java

@ -106,6 +106,11 @@ public interface UIConstants {
public static final Color TITLED_BORDER_COLOR = new Color(0xededee);
public static final Color POP_DIALOG_BORDER = new Color(218, 218, 221);
public static final Color PROPERTY_DIALOG_BORDER = new Color(0xc9c9cd);
public static final Color TAB_BUTTON_HOVER = new Color(231, 230, 235);
public static final Color TAB_BUTTON_HOVER_SELECTED = new Color(239, 238, 243);
public static final Color TAB_BUTTON_PRESS = new Color(228, 227, 232);
public static final Color TAB_BUTTON_PRESS_SELECTED = new Color(236, 236, 238);
public static final BufferedImage DRAG_BAR = BaseUtils.readImage("com/fr/design/images/control/bar.png");

18
designer_base/src/com/fr/design/gui/ibutton/UIButtonUI.java

@ -42,19 +42,23 @@ public class UIButtonUI extends BasicButtonUI {
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (b.isExtraPainted()) {
if (isPressed(b) && b.isPressedPainted()) {
GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles));
} else if (isRollOver(b)) {
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted());
} else if (b.isNormalPainted()) {
GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted());
}
doExtraPainting(b, g2d, w, h, selectedRoles);
}
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
paintContent(g, b, text);
}
protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) {
if (isPressed(b) && b.isPressedPainted()) {
GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles));
} else if (isRollOver(b)) {
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted());
} else if (b.isNormalPainted()) {
GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted());
}
}
protected boolean isRollOver(AbstractButton b) {
ButtonModel model = b.getModel();
return model.isRollover() && !b.isSelected();

20
designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java

@ -4,10 +4,12 @@ import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.icontainer.UIEastResizableContainer;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.Inter;
@ -638,6 +640,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
selectedItem = this;
}
private boolean isTabButtonSelected() {
return button.getBackground() == selectedBtnBackground;
}
private void initButton() {
button = new UIButton(BaseUtils.readIcon(getBtnIconUrl())) {
public Dimension getPreferredSize() {
@ -649,6 +655,20 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
}
};
button.set4LargeToolbarButton();
button.setUI(new UIButtonUI() {
@Override
protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) {
if (isPressed(b) && b.isPressedPainted()) {
Color pressColor = isTabButtonSelected() ? UIConstants.TAB_BUTTON_PRESS_SELECTED : UIConstants.TAB_BUTTON_PRESS;
GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), pressColor);
} else if (isRollOver(b)) {
Color hoverColor = isTabButtonSelected() ? UIConstants.TAB_BUTTON_HOVER_SELECTED : UIConstants.TAB_BUTTON_HOVER;
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), hoverColor);
} else if (b.isNormalPainted()) {
GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted());
}
}
});
originBtnBackground = button.getBackground();
button.addActionListener(new ActionListener() {
@Override

19
designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java

@ -85,13 +85,18 @@ public class GUIPaintUtils {
* @param isPressedPainted 是否按压画
*/
public static final void fillRollOver(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) {
fillRollOver(g2d, x, y, width, height, isRound, rectDirection, isAuthorityEdited, isPressedPainted, null);
}
public static final void fillRollOver(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted, Color hoverColor) {
GradientPaint gp;
if (BaseUtils.isAuthorityEditing() && isAuthorityEdited) {
if (hoverColor != null) {
gp = new GradientPaint(1, 1, hoverColor, 1, height - 1, hoverColor);
} else if (BaseUtils.isAuthorityEditing() && isAuthorityEdited) {
gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1, UIConstants.HOVER_BLUE);
} else if (isPressedPainted) {
gp = new GradientPaint(1, 1, UIConstants.ATTRIBUTE_HOVER, 1, height - 1, UIConstants.ATTRIBUTE_HOVER);
}else {
// gp = new GradientPaint(1, 1, UIConstants.NORMAL_BACKGROUND, 1, height - 1, UIConstants.HOVER_BLUE);
} else {
gp = new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, height - 1, UIConstants.HOVER_BLUE);
}
fillPaint(g2d, x, y, width, height, isRound, rectDirection, gp, UIConstants.ARC);
@ -110,8 +115,14 @@ public class GUIPaintUtils {
*
*/
public static final void fillPressed(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited) {
fillPressed(g2d, x, y, width, height, isRound, rectDirection, isAuthorityEdited, null);
}
public static final void fillPressed(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, Color pressedColor) {
Color oldColor = g2d.getColor();
if (BaseUtils.isAuthorityEditing() && isAuthorityEdited) {
if (pressedColor != null) {
g2d.setColor(pressedColor);
} else if (BaseUtils.isAuthorityEditing() && isAuthorityEdited) {
g2d.setColor(UIConstants.AUTHORITY_PRESS_BLUE);
} else {
g2d.setColor(UIConstants.ATTRIBUTE_PRESS);

Loading…
Cancel
Save