mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
support icons in darcula comboboxUI (initial)
This commit is contained in:
+48
-42
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user