From da907ef8c69492fb552ef44f7e72c5718b8aeaa4 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Tue, 18 Jun 2019 03:25:25 +0300 Subject: [PATCH] support colored buttons GitOrigin-RevId: 4078b5e320e01b703c7bd748d36bd9affbd42a18 --- .../actionSystem/ex/ActionButtonLook.java | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) 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 0723a469023e..f01bee6e1c56 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 @@ -87,14 +87,13 @@ public abstract class ActionButtonLook { } public void paintBackground(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state) { - if (state != ActionButtonComponent.NORMAL) { - Rectangle rect = new Rectangle(component.getSize()); - JBInsets.removeFrom(rect, component.getInsets()); - - Color color = state == ActionButtonComponent.PUSHED ? - JBUI.CurrentTheme.ActionButton.pressedBackground() : JBUI.CurrentTheme.ActionButton.hoverBackground(); - paintLookBackground(g, rect, color); - } + if (state == ActionButtonComponent.NORMAL && !component.isBackgroundSet()) return; + Rectangle rect = new Rectangle(component.getSize()); + JBInsets.removeFrom(rect, component.getInsets()); + Color color = state == ActionButtonComponent.NORMAL ? component.getBackground() : + state == ActionButtonComponent.PUSHED ? JBUI.CurrentTheme.ActionButton.pressedBackground() : + JBUI.CurrentTheme.ActionButton.hoverBackground(); + paintLookBackground(g, rect, color); } public void paintBackground(Graphics g, JComponent component, Color color) { @@ -104,14 +103,12 @@ public abstract class ActionButtonLook { } public void paintBorder(Graphics g, JComponent component, @ActionButtonComponent.ButtonState int state) { - if (state != ActionButtonComponent.NORMAL) { - Rectangle rect = new Rectangle(component.getSize()); - JBInsets.removeFrom(rect, component.getInsets()); - - Color color = state == ActionButtonComponent.PUSHED ? - JBUI.CurrentTheme.ActionButton.pressedBorder() : JBUI.CurrentTheme.ActionButton.hoverBorder(); - paintLookBorder(g, rect, color); - } + if (state == ActionButtonComponent.NORMAL && !component.isBackgroundSet()) return; + Rectangle rect = new Rectangle(component.getSize()); + JBInsets.removeFrom(rect, component.getInsets()); + Color color = state == ActionButtonComponent.PUSHED ? JBUI.CurrentTheme.ActionButton.pressedBorder() : + JBUI.CurrentTheme.ActionButton.hoverBorder(); + paintLookBorder(g, rect, color); } public void paintBorder(Graphics g, JComponent component, Color color) {