diff options
author | Tor Norbye <tnorbye@google.com> | 2014-07-16 18:07:37 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-07-16 18:09:03 -0700 |
commit | 65f60eb9011bb2c549a6d83ae31257480368ddc5 (patch) | |
tree | de0dca03bec460e8797332e5f460400f5cf6485f /platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java | |
parent | 9ea67227e8fdcf8ed37e65bb96e32767291d0f4f (diff) | |
download | idea-65f60eb9011bb2c549a6d83ae31257480368ddc5.tar.gz |
Snapshot idea/138.1029 from git://git.jetbrains.org/idea/community.git
Update from idea/138.538 to idea/138.1029
Change-Id: I828f829a968439a99ec67640990c18ff7c9b58ce
Diffstat (limited to 'platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java')
-rw-r--r-- | platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java | 95 |
1 files changed, 57 insertions, 38 deletions
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java index b1b1d582df4c..58c6a8bae0d2 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaCheckBoxUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,9 +74,11 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { g.fillRect(0, 0, size.width, size.height); } - if (b.isSelected() && b.getSelectedIcon() != null) { + final boolean selected = b.isSelected(); + final boolean enabled = b.isEnabled(); + if (selected && b.getSelectedIcon() != null) { b.getSelectedIcon().paintIcon(b, g, iconRect.x + 4, iconRect.y + 2); - } else if (!b.isSelected() && b.getIcon() != null) { + } else if (!selected && b.getIcon() != null) { b.getIcon().paintIcon(b, g, iconRect.x + 4, iconRect.y + 2); } else { final int x = iconRect.x + 3; @@ -98,15 +100,18 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { final boolean armed = b.getModel().isArmed(); if (c.hasFocus()) { - g.setPaint(UIUtil.getGradientPaint(w/2, 1, getFocusedBackgroundColor1(armed), w/2, h, getFocusedBackgroundColor2(armed))); - g.fillRoundRect(0, 0, w - 2, h - 2, 4, 4); + g.setPaint(UIUtil.getGradientPaint(w/2, 1, getFocusedBackgroundColor1(armed, selected), w/2, h, getFocusedBackgroundColor2(armed, selected))); + g.fillRoundRect(0, 0, w, h, 4, 4); DarculaUIUtil.paintFocusRing(g, 1, 1, w - 2, h - 2); } else { - g.setPaint(UIUtil.getGradientPaint(w / 2, 1, getBackgroundColor1(), w / 2, h, getBackgroundColor2())); - g.fillRoundRect(0, 0, w, h - 1 , 4, 4); + g.setPaint(UIUtil.getGradientPaint(w / 2, 1, getBackgroundColor1(enabled, selected), w / 2, h, getBackgroundColor2(enabled, + selected))); + g.fillRoundRect(0, 0, w, h , 4, 4); - g.setPaint(UIUtil.getGradientPaint(w / 2, 1, getBorderColor1(b.isEnabled()), w / 2, h, getBorderColor2(b.isEnabled()))); + final Color borderColor1 = getBorderColor1(enabled, selected); + final Color borderColor2 = getBorderColor2(enabled, selected); + g.setPaint(UIUtil.getGradientPaint(w / 2, 1, borderColor1, w / 2, h, borderColor2)); g.drawRoundRect(0, (UIUtil.isUnderDarcula() ? 1 : 0), w, h - 1, 4, 4); g.setPaint(getInactiveFillColor()); @@ -114,14 +119,7 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { } if (b.getModel().isSelected()) { - g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); - g.setStroke(new BasicStroke(1 *2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); - g.setPaint(getShadowColor(b.isEnabled())); - g.drawLine(4, 7, 7, 11); - g.drawLine(7, 11, w, 2); - g.setPaint(getCheckSignColor(b.isEnabled())); - g.drawLine(4, 5, 7, 9); - g.drawLine(7, 9, w, 0); + paintCheckSign(g, enabled, w, h); } g.translate(-x, -y); config.restore(); @@ -142,46 +140,57 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { } } + protected void paintCheckSign(Graphics2D g, boolean enabled, int w, int h) { + g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); + g.setStroke(new BasicStroke(1 *2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); + g.setPaint(getShadowColor(enabled, true)); + g.drawLine(4, 7, 7, 11); + g.drawLine(7, 11, w, 2); + g.setPaint(getCheckSignColor(enabled, true)); + g.drawLine(4, 5, 7, 9); + g.drawLine(7, 9, w, 0); + } + protected Color getInactiveFillColor() { return getColor("inactiveFillColor", Gray._40.withAlpha(180)); } - protected Color getBorderColor1(boolean enabled) { - return enabled ? getColor("borderColor1", Gray._120.withAlpha(0x5a)) - : getColor("disabledBorderColor1", Gray._120.withAlpha(90)); + protected Color getBorderColor1(boolean enabled, boolean selected) { + return enabled ? getColor("borderColor1", Gray._120.withAlpha(0x5a), selected) + : getColor("disabledBorderColor1", Gray._120.withAlpha(90), selected); } - protected Color getBorderColor2(boolean enabled) { - return enabled ? getColor("borderColor2", Gray._105.withAlpha(90)) - : getColor("disabledBorderColor2", Gray._105.withAlpha(90)); + protected Color getBorderColor2(boolean enabled, boolean selected) { + return enabled ? getColor("borderColor2", Gray._105.withAlpha(90), selected) + : getColor("disabledBorderColor2", Gray._105.withAlpha(90), selected); } - protected Color getBackgroundColor1() { - return getColor("backgroundColor1", Gray._110); + protected Color getBackgroundColor1(boolean enabled, boolean selected) { + return getColor("backgroundColor1", Gray._110, selected); } - protected Color getBackgroundColor2() { - return getColor("backgroundColor2", Gray._95); + protected Color getBackgroundColor2(boolean enabled, boolean selected) { + return getColor("backgroundColor2", Gray._95, selected); } - protected Color getCheckSignColor(boolean enabled) { - return enabled ? getColor("checkSignColor", Gray._170) - : getColor("checkSignColorDisabled", Gray._120); + protected Color getCheckSignColor(boolean enabled, boolean selected) { + return enabled ? getColor("checkSignColor", Gray._170, selected) + : getColor("checkSignColorDisabled", Gray._120, selected); } - protected Color getShadowColor(boolean enabled) { - return enabled ? getColor("shadowColor", Gray._30) - : getColor("shadowColorDisabled", Gray._60); + protected Color getShadowColor(boolean enabled, boolean selected) { + return enabled ? getColor("shadowColor", Gray._30, selected) + : getColor("shadowColorDisabled", Gray._60, selected); } - protected Color getFocusedBackgroundColor1(boolean armed) { - return armed ? getColor("focusedArmed.backgroundColor1", Gray._100) - : getColor("focused.backgroundColor1", Gray._120); + protected Color getFocusedBackgroundColor1(boolean armed, boolean selected) { + return armed ? getColor("focusedArmed.backgroundColor1", Gray._100, selected) + : getColor("focused.backgroundColor1", Gray._120, selected); } - protected Color getFocusedBackgroundColor2(boolean armed) { - return armed ? getColor("focusedArmed.backgroundColor2", Gray._55) - : getColor("focused.backgroundColor2", Gray._75); + protected Color getFocusedBackgroundColor2(boolean armed, boolean selected) { + return armed ? getColor("focusedArmed.backgroundColor2", Gray._55, selected) + : getColor("focused.backgroundColor2", Gray._75, selected); } protected static Color getColor(String shortPropertyName, Color defaultValue) { @@ -189,6 +198,16 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { return color == null ? defaultValue : color; } + protected static Color getColor(String shortPropertyName, Color defaultValue, boolean selected) { + if (selected) { + final Color color = getColor(shortPropertyName + ".selected", null); + if (color != null) { + return color; + } + } + return getColor(shortPropertyName, defaultValue); + } + @Override public Icon getDefaultIcon() { return new IconUIResource(EmptyIcon.create(20)); |