IDEA-196199: Change colors for toolbar icon buttons

This commit is contained in:
Kirill Kirichenko
2018-08-20 17:27:03 +03:00
parent 808fde86e5
commit 07d04cfa0f
9 changed files with 40 additions and 98 deletions
@@ -32,6 +32,9 @@ textText=bbbbbb
infoText=bbbbbb
OptionPane.messageForeground=bbbbbb
ActionButton.hoverBackground=4c5052
ActionButton.pressedBackground=5c6164
Menu.maxGutterIconWidth=18
MenuItem.maxGutterIconWidth=18
MenuItem.acceleratorDelimiter=-
@@ -20,6 +20,9 @@ Outline.color=c4c4c4
Outline.focusedColor=87AFDA
Outline.disabledColor=cfcfcf
ActionButton.hoverBackground=dfdfdf
ActionButton.pressedBackground=cfcfcf
grayFilter=33,-35,100
text=000000
text.grayFilter=20,0,100
@@ -11,6 +11,9 @@ window=ececec
Border.width=4
CellEditor.border.width=2
ActionButton.hoverBackground=dadada
ActionButton.pressedBackground=c9c9c9
CheckBoxUI=com.intellij.ide.ui.laf.intellij.MacIntelliJCheckBoxUI
CheckBox.border=com.intellij.ide.ui.laf.darcula.ui.DarculaCheckBoxBorder
CheckBox.borderInsets=4,4,4,0
@@ -19,6 +19,9 @@ window=f2f2f2
Border.width=1
CellEditor.border.width=2
ActionButton.hoverBackground=dfdfdf
ActionButton.pressedBackground=cfcfcf
grayFilter=33,-35,100
text=000000
text.grayFilter=20,0,100
@@ -18,6 +18,7 @@ package com.intellij.openapi.actionSystem.ex;
import com.intellij.openapi.actionSystem.ActionButtonComponent;
import com.intellij.openapi.actionSystem.impl.IdeaActionButtonLook;
import com.intellij.openapi.actionSystem.impl.Win10ActionButtonLook;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
@@ -61,14 +62,18 @@ public abstract class ActionButtonLook {
paintBorder(g, button, getState(button));
}
public abstract void paintBackground(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state);
public abstract void paintBorder(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state);
public void paintBackground(@NotNull Graphics g, @NotNull JComponent component, @NotNull Color color) {
public void paintBackground(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state) {
if (state != ActionButtonComponent.NORMAL) {
paintBackground(g, component, state == ActionButtonComponent.PUSHED ?
JBUI.CurrentTheme.ActionButton.pressedBackground() :
JBUI.CurrentTheme.ActionButton.hoverBackground());
}
}
public void paintBorder(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state) {}
public void paintBackground(@NotNull Graphics g, @NotNull JComponent component, @NotNull Color color) {}
public void updateUI() {}
@SuppressWarnings("MethodMayBeStatic")
@@ -7,6 +7,7 @@ import com.intellij.openapi.actionSystem.ex.ActionButtonLook;
import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import com.intellij.util.ui.JBInsets;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
@@ -21,19 +22,9 @@ import java.awt.geom.RoundRectangle2D;
*/
@SuppressWarnings("UseJBColor")
public class IdeaActionButtonLook extends ActionButtonLook {
private static final Color POPPED_BG = new JBColor(Gray.xE8, new Color(0x464a4d));
private static final Color PRESSED_BG = new JBColor(Gray.xDB, new Color(0x55595c));
private static final Color POPPED_BORDER = new JBColor(Gray.xCC, new Color(0x757b80));
private static final Color PRESSED_BORDER = new JBColor(Gray.xC4, new Color(0x7a8084));
@Override
public void paintBackground(Graphics g, JComponent component, int state) {
if (state != ActionButtonComponent.NORMAL) {
paintBackground(g, component, getColorForState(state));
}
}
@Override
public void paintBackground(@NotNull Graphics g, @NotNull JComponent component, @NotNull Color color) {
Rectangle rect = new Rectangle(component.getSize());
@@ -42,17 +33,9 @@ public class IdeaActionButtonLook extends ActionButtonLook {
}
protected static void paintBackground(@NotNull Graphics g, @NotNull Rectangle rect, int state) {
paintBackgroundWithColor(g, rect, getColorForState(state));
}
private static Color getColorForState(int state) {
Color color;
if (UIUtil.isUnderAquaLookAndFeel() || UIUtil.isUnderDefaultMacTheme()) {
color = state == ActionButtonComponent.PUSHED ? Gray.xD7 : Gray.xE0;
} else {
color = state == ActionButtonComponent.PUSHED ? PRESSED_BG : POPPED_BG;
}
return color;
paintBackgroundWithColor(g, rect, state == ActionButtonComponent.PUSHED ?
JBUI.CurrentTheme.ActionButton.pressedBackground() :
JBUI.CurrentTheme.ActionButton.hoverBackground());
}
protected static void paintBackgroundWithColor(@NotNull Graphics g, @NotNull Rectangle rect, @NotNull Color color) {
@@ -71,15 +54,6 @@ public class IdeaActionButtonLook extends ActionButtonLook {
}
}
@Override
public void paintBorder(Graphics g, JComponent component, int state) {
if (state != ActionButtonComponent.NORMAL) {
Rectangle rect = new Rectangle(component.getSize());
JBInsets.removeFrom(rect, component.getInsets());
paintBorder(g, rect, state);
}
}
protected static void paintBorder(Graphics g, Rectangle rect, int state) {
Graphics2D g2 = (Graphics2D)g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
@@ -40,7 +40,6 @@ public class PoppedIcon implements Icon {
public void paintIcon(Component c, Graphics g, int x, int y) {
Rectangle rect = new Rectangle(getIconWidth() + 2*x, getIconHeight() + 2*x);
IdeaActionButtonLook.paintBackground(g, rect, ActionButtonComponent.POPPED);
IdeaActionButtonLook.paintBorder(g, rect, ActionButtonComponent.POPPED);
myIcon.paintIcon(c, g, x + (getIconWidth() - myIcon.getIconWidth())/2, y + (getIconHeight() - myIcon.getIconHeight())/2);
}
@@ -16,24 +16,13 @@
package com.intellij.openapi.actionSystem.impl;
import com.intellij.openapi.actionSystem.ex.ActionButtonLook;
import com.intellij.ui.Gray;
import com.intellij.util.ui.JBInsets;
import com.intellij.util.ui.JBUI;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Path2D;
import static com.intellij.openapi.actionSystem.ActionButtonComponent.*;
public class Win10ActionButtonLook extends ActionButtonLook {
@Override public void paintBackground(Graphics g, JComponent component, int state) {
if (state != NORMAL) {
paintBackground(g, component, getBackgroundColorForState(state));
}
}
@Override
public void paintBackground(@NotNull Graphics g, @NotNull JComponent component, @NotNull Color color) {
Rectangle rect = new Rectangle(component.getSize());
@@ -41,53 +30,4 @@ public class Win10ActionButtonLook extends ActionButtonLook {
g.setColor(color);
g.fillRect(rect.x, rect.y, rect.width, rect.height);
}
private static Color getBackgroundColorForState(int state) {
switch (state) {
case POPPED:
return Gray.xE8;
case PUSHED:
case SELECTED:
return Gray.xDB;
default:
return UIManager.getColor("Button.background");
}
}
@Override public void paintBorder(Graphics g, JComponent component, int state) {
if (state != NORMAL) {
Graphics2D g2 = (Graphics2D)g.create();
try {
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
g2.setColor(getBorderColorForState(state));
Rectangle rect = new Rectangle(component.getSize());
JBInsets.removeFrom(rect, component.getInsets());
Rectangle innerRect = new Rectangle(rect);
JBInsets.removeFrom(innerRect, JBUI.insets(1));
Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
border.append(rect, false);
border.append(innerRect, false);
g2.fill(border);
} finally {
g2.dispose();
}
}
}
private static Color getBorderColorForState(int state) {
switch (state) {
case POPPED:
return Gray.xCC;
case PUSHED:
case SELECTED:
return Gray.xC4;
default:
return UIManager.getColor("Button.intellij.native.borderColor");
}
}
}
@@ -1510,6 +1510,18 @@ public class JBUI {
}
public static class CurrentTheme {
public static class ActionButton {
@NotNull
public static Color pressedBackground() {
return JBColor.namedColor("ActionButton.pressedBackground", Gray.xCF);
}
@NotNull
public static Color hoverBackground() {
return JBColor.namedColor("ActionButton.hoverBackground", Gray.xDF);
}
}
public static class CustomFrameDecorations {
@NotNull
public static Color separatorForeground() {
@@ -1732,7 +1744,7 @@ public class JBUI {
}
public static int maxListHeight() {
return JBUI.scale(600);
return scale(600);
}
public static Color listSeparatorColor() {