From 8627feca667406e19774107d7f701b82572c8bfb Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 30 Apr 2013 16:32:25 +0200 Subject: [PATCH] support icons in darcula comboboxUI (initial) --- .../ui/laf/darcula/ui/DarculaCheckBoxUI.java | 90 ++++++++++--------- 1 file changed, 48 insertions(+), 42 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 efd85749e2a3..94899dbe40c4 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 @@ -74,53 +74,59 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI { g.fillRect(0, 0, size.width, size.height); } - final int x = iconRect.x + 3; - final int y = iconRect.y + 3; - final int w = iconRect.width - 6; - final int h = iconRect.height - 6; - - g.translate(x, y); - final Paint paint = UIUtil.getGradientPaint(w / 2, 0, b.getBackground().brighter(), - w / 2, h, b.getBackground()); - g.setPaint(paint); - g.fillRect(1, 1, w - 2, h - 2); - - //setup AA for lines - final GraphicsConfig config = new GraphicsConfig(g); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); - - final boolean armed = b.getModel().isArmed(); - - if (c.hasFocus()) { - g.setPaint(UIUtil.getGradientPaint(w/2, 1, armed ? Gray._100: Gray._120, w/2, h, armed ? Gray._55 : Gray._75)); - g.fillRoundRect(0, 0, w - 2, h - 2, 4, 4); - - DarculaUIUtil.paintFocusRing(g, 1, 1, w - 2, h - 2); + if (b.isSelected() && b.getSelectedIcon() != null) { + b.getSelectedIcon().paintIcon(b, g, iconRect.x + 4, iconRect.y + 2); + } else if (!b.isSelected() && b.getIcon() != null) { + b.getIcon().paintIcon(b, g, iconRect.x + 4, iconRect.y + 2); } else { - g.setPaint(UIUtil.getGradientPaint(w / 2, 1, Gray._110, w / 2, h, Gray._95)); - g.fillRoundRect(0, 0, w , h , 4, 4); + final int x = iconRect.x + 3; + final int y = iconRect.y + 3; + final int w = iconRect.width - 6; + final int h = iconRect.height - 6; - g.setPaint(UIUtil.getGradientPaint(w / 2, 1, Gray._120.withAlpha(90), w / 2, h, Gray._105.withAlpha(90))); - g.drawRoundRect(0, 1, w, h - 1, 4, 4); + g.translate(x, y); + final Paint paint = UIUtil.getGradientPaint(w / 2, 0, b.getBackground().brighter(), + w / 2, h, b.getBackground()); + g.setPaint(paint); + g.fillRect(1, 1, w - 2, h - 2); - g.setPaint(Gray._40.withAlpha(180)); - g.drawRoundRect(0, 0, w, h - 1, 4, 4); + //setup AA for lines + final GraphicsConfig config = new GraphicsConfig(g); + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); + + final boolean armed = b.getModel().isArmed(); + + if (c.hasFocus()) { + g.setPaint(UIUtil.getGradientPaint(w/2, 1, armed ? Gray._100: Gray._120, w/2, h, armed ? Gray._55 : Gray._75)); + g.fillRoundRect(0, 0, w - 2, h - 2, 4, 4); + + DarculaUIUtil.paintFocusRing(g, 1, 1, w - 2, h - 2); + } else { + g.setPaint(UIUtil.getGradientPaint(w / 2, 1, Gray._110, w / 2, h, Gray._95)); + g.fillRoundRect(0, 0, w , h , 4, 4); + + g.setPaint(UIUtil.getGradientPaint(w / 2, 1, Gray._120.withAlpha(90), w / 2, h, Gray._105.withAlpha(90))); + g.drawRoundRect(0, 1, w, h - 1, 4, 4); + + g.setPaint(Gray._40.withAlpha(180)); + g.drawRoundRect(0, 0, w, h - 1, 4, 4); + } + + 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(b.isEnabled() ? Gray._30 : Gray._60); + g.drawLine(4, 7, 7, 11); + g.drawLine(7, 11, w, 2); + g.setPaint(b.isEnabled() ? Gray._170 : Gray._120); + g.drawLine(4, 5, 7, 9); + g.drawLine(7, 9, w, 0); + } + g.translate(-x, -y); + config.restore(); } - 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(b.isEnabled() ? Gray._30 : Gray._60); - g.drawLine(4, 7, 7, 11); - g.drawLine(7, 11, w, 2); - g.setPaint(b.isEnabled() ? Gray._170 : Gray._120); - g.drawLine(4, 5, 7, 9); - g.drawLine(7, 9, w, 0); - } - g.translate(-x, -y); - config.restore(); - //text if(text != null) { View view = (View) c.getClientProperty(BasicHTML.propertyKey);