darcula RadioButtonUI

This commit is contained in:
Konstantin Bulenkov
2012-09-13 15:04:38 +04:00
parent 5056f5e06f
commit e4bf8eafe1
5 changed files with 178 additions and 51 deletions
@@ -15,10 +15,10 @@
*/
package com.intellij.ide.ui.laf.borders;
import com.intellij.ide.ui.laf.DarculaUIUtil;
import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.ui.Gray;
import com.intellij.util.ui.JBInsets;
import com.intellij.util.ui.MacUIUtil;
import javax.swing.border.Border;
import javax.swing.plaf.UIResource;
@@ -37,7 +37,7 @@ public class DarculaButtonPainter implements Border, UIResource {
final int yOff = getBorderInsets(c).height() / 4;
int offset = getOffset();
if (c.hasFocus()) {
MacUIUtil.paintFocusRing(g2d, new Color(96, 175, 255), new Rectangle(offset, yOff, width-2*offset, height - 2*yOff));
DarculaUIUtil.paintFocusRing(g2d, offset, yOff, width - 2 * offset, height - 2 * yOff);
} else {
final GraphicsConfig config = new GraphicsConfig(g);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
@@ -45,7 +45,7 @@ public class DarculaButtonPainter implements Border, UIResource {
g2d.setPaint(new GradientPaint(width / 2, y + yOff + 1, Gray._120.withAlpha(90), width / 2, height - 2*yOff, Gray._105.withAlpha(90)));
g.drawRoundRect(x + offset + 1, y + yOff + 1, width - 2 * offset, height - 2*yOff, 5, 5);
((Graphics2D)g).setPaint(Gray._30);
((Graphics2D)g).setPaint(Gray._40.withAlpha(180));
g.drawRoundRect(x + offset, y + yOff, width - 2 * offset, height - 2*yOff, 5, 5);
config.restore();
@@ -15,10 +15,9 @@
*/
package com.intellij.ide.ui.laf.borders;
import com.intellij.ide.ui.laf.DarculaUIUtil;
import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.ui.ColorUtil;
import com.intellij.ui.Gray;
import com.intellij.util.ui.MacUIUtil;
import sun.swing.SwingUtilities2;
import javax.swing.*;
@@ -89,18 +88,18 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI {
final boolean armed = b.getModel().isArmed();
if (c.hasFocus()) {
g.setPaint(new GradientPaint(w/2, 1, armed ? Gray._40: Gray._60, w/2, h, armed ? Gray._25 : Gray._45));
g.setPaint(new GradientPaint(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);
MacUIUtil.paintFocusRing(g, new Color(96, 175, 255), new Rectangle(1, 1, w - 2, h - 2));
DarculaUIUtil.paintFocusRing(g, 1, 1, w - 2, h - 2);
} else {
g.setPaint(new GradientPaint(w / 2, 1, Gray._80, w / 2, h, Gray._65));
g.setPaint(new GradientPaint(w / 2, 1, Gray._110, w / 2, h, Gray._95));
g.fillRoundRect(0, 0, w , h , 4, 4);
g.setPaint(new GradientPaint(w / 2, 1, ColorUtil.toAlpha(Gray._120, 90), w / 2, h, ColorUtil.toAlpha(Gray._105, 90)));
g.setPaint(new GradientPaint(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._30);
g.setPaint(Gray._40.withAlpha(180));
g.drawRoundRect(0, 0, w, h - 1, 4, 4);
}
@@ -0,0 +1,126 @@
/*
* Copyright 2000-2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ide.ui.laf.borders;
import com.intellij.ide.ui.laf.DarculaUIUtil;
import com.intellij.openapi.ui.GraphicsConfig;
import com.intellij.ui.Gray;
import sun.swing.SwingUtilities2;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.plaf.metal.MetalRadioButtonUI;
import javax.swing.text.View;
import java.awt.*;
/**
* @author Konstantin Bulenkov
*/
public class DarculaRadioButtonUI extends MetalRadioButtonUI {
@SuppressWarnings("MethodOverridesStaticMethodOfSuperclass")
public static ComponentUI createUI(JComponent c) {
return new DarculaRadioButtonUI();
}
@Override
public synchronized void paint(Graphics g2d, JComponent c) {
Graphics2D g = (Graphics2D)g2d;
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
Dimension size = c.getSize();
Font f = c.getFont();
g.setFont(f);
FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f);
Rectangle viewRect = new Rectangle(size);
Rectangle iconRect = new Rectangle();
Rectangle textRect = new Rectangle();
Insets i = c.getInsets();
viewRect.x += i.left;
viewRect.y += i.top;
viewRect.width -= (i.right + viewRect.x);
viewRect.height -= (i.bottom + viewRect.y);
String text = SwingUtilities.layoutCompoundLabel(
c, fm, b.getText(), getDefaultIcon(),
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewRect, iconRect, textRect, b.getIconTextGap());
// fill background
if(c.isOpaque()) {
g.setColor(b.getBackground());
g.fillRect(0,0, size.width, size.height);
}
// Paint the radio button
final int x = iconRect.x + 2;
final int y = iconRect.y + 2;
final int w = iconRect.width - 4;
final int h = iconRect.height - 4;
final int u = w / 16;
g.translate(x, y);
//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_NORMALIZE);
if (b.hasFocus()) {
DarculaUIUtil.paintFocusOval(g, x-6, y-3, w-3, h-3);
} else {
g.setPaint(new GradientPaint(w / 2, 1, Gray._180.withAlpha(90), w / 2, h, Gray._125.withAlpha(90)));
g.drawOval(0, 2, w - 2, h - 2);
g.setPaint(Gray._40.withAlpha(200));
g.drawOval(0, 1, w - 2, h - 2);
}
if (b.isSelected()) {
g.setColor(Gray._0.withAlpha(50));
g.fillOval(w/2 - 3*u+1, h/2 - 3*u + 2, 5*u, 5*u);
g.setColor(Gray._255.withAlpha(180));
g.fillOval(w/2 - 3*u, h/2 - 3*u + 1, 5*u, 5*u);
}
config.restore();
g.translate(-x, -y);
// Draw the Text
if(text != null) {
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
v.paint(g, textRect);
} else {
int mnemIndex = b.getDisplayedMnemonicIndex();
if(model.isEnabled()) {
// *** paint the text normally
g.setColor(b.getForeground());
} else {
// *** paint the text disabled
g.setColor(getDisabledTextColor());
}
SwingUtilities2.drawStringUnderlineCharAt(c, g, text,
mnemIndex, textRect.x, textRect.y + fm.getAscent());
}
}
}
}
@@ -3,67 +3,69 @@ MenuItem.maxGutterIconWidth=18
MenuItem.acceleratorDelimiter=-
#Trees
Tree.background=333333
Tree.foreground=cccccc
Tree.textForeground=cccccc
Tree.textBackground=333333
Tree.background=535353
Tree.foreground=eeeeee
Tree.textForeground=eeeeee
Tree.textBackground=535353
#Tree.selectionBackground=BEBEBE
#Tree.selectionForeground=333333
#Tree.selectionForeground=535353
#Lists
List.background=333333
List.foreground=cccccc
List.background=535353
List.foreground=eeeeee
#Tables
Table.background=333333
Table.foreground=cccccc
control=333333
Panel.background=333333
Panel.foreground=cccccc
Table.background=535353
Table.foreground=eeeeee
control=535353
Panel.background=535353
Panel.foreground=eeeeee
Menu.selectionBackground=bebebe
MenuBar.background=333333
MenuBar.disabledBackground=333333
MenuBar.shadow=333333
Menu.background=333333
MenuItem.background=333333
Menu.foreground=cccccc
MenuItem.foreground=cccccc
MenuBar.background=535353
MenuBar.disabledBackground=535353
MenuBar.shadow=535353
Menu.background=535353
MenuItem.background=535353
Menu.foreground=eeeeee
MenuItem.foreground=eeeeee
TabbedPane.tabInsets=0,4,0,4
ToggleButton.foreground=cccccc
Separator.background=333333
ToggleButton.foreground=eeeeee
Separator.background=535353
Separator.foreground=888888
Label.background=333333
Label.foreground=cccccc
Label.background=535353
Label.foreground=eeeeee
Focus.color=ff0000
TextField.background=333333
TextField.foreground=cccccc
TextField.caretForeground=cccccc
TextField.background=535353
TextField.foreground=eeeeee
TextField.caretForeground=eeeeee
TextArea.background=333333
TextArea.foreground=cccccc
TextArea.caretForeground=cccccc
TextArea.background=535353
TextArea.foreground=eeeeee
TextArea.caretForeground=eeeeee
TextPane.background=333333
TextPane.foreground=cccccc
TextPane.caretForeground=cccccc
TextPane.background=535353
TextPane.foreground=eeeeee
TextPane.caretForeground=eeeeee
CheckBox.background=333333
CheckBox.foreground=cccccc
CheckBox.background=535353
CheckBox.foreground=eeeeee
CheckBoxUI=com.intellij.ide.ui.laf.borders.DarculaCheckBoxUI
RadioButton.foreground=cccccc
RadioButton.foreground=eeeeee
RadioButton.background=535353
RadioButtonUI=com.intellij.ide.ui.laf.borders.DarculaRadioButtonUI
StatusBar.topColor=2c2c2c
StatusBar.top2Color=2c2c2c
StatusBar.bottomColor=2c2c2c
Button.foreground=cccccc
Button.background=333333
Button.foreground=eeeeee
Button.background=535353
Button.border=com.intellij.ide.ui.laf.borders.DarculaButtonPainter
MenuItem.acceleratorForeground=cccccc
PopupMenu.background=333333
PopupMenu.translucentBackground=333333
MenuItem.acceleratorForeground=eeeeee
PopupMenu.background=535353
PopupMenu.translucentBackground=535353
@@ -2160,7 +2160,7 @@ public class UIUtil {
public TextPainter() {
myDrawShadow = isUnderAquaLookAndFeel();
myShadowColor = isUnderDarcula() ? Gray._0 : Gray._220;
myShadowColor = isUnderDarcula() ? Gray._0.withAlpha(180) : Gray._220;
myLineSpacing = 1.0f;
}