diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/darcula.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/darcula.properties index a59456153788..596e371918a1 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/darcula.properties +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/darcula.properties @@ -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=- diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf.properties index 9a05a5fef94a..8d97af02af97 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf.properties +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf.properties @@ -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 diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_mac.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_mac.properties index fd6d267dbeb5..087ac1fd93d1 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_mac.properties +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_mac.properties @@ -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 diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_native.properties b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_native.properties index 80aea3b294a4..7517d3d5e221 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_native.properties +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellijlaf_native.properties @@ -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 diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/ActionButtonLook.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/ActionButtonLook.java index 09221c0b03cf..b4c282ae08c2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/ActionButtonLook.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ex/ActionButtonLook.java @@ -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") diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java index 54530a0f214b..c118a4d2bc1b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/IdeaActionButtonLook.java @@ -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); diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/PoppedIcon.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/PoppedIcon.java index 3a6c40a3d0e9..2700b68a28a6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/PoppedIcon.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/PoppedIcon.java @@ -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); } diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Win10ActionButtonLook.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Win10ActionButtonLook.java index 0abdbadecf2a..7972d15422c3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Win10ActionButtonLook.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/Win10ActionButtonLook.java @@ -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"); - } - } } diff --git a/platform/util/src/com/intellij/util/ui/JBUI.java b/platform/util/src/com/intellij/util/ui/JBUI.java index 30fd6aa675f7..9d0a90895bd3 100644 --- a/platform/util/src/com/intellij/util/ui/JBUI.java +++ b/platform/util/src/com/intellij/util/ui/JBUI.java @@ -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() {