Search in sources :

Example 11 with GraphicsConfig

use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.

the class DarculaCheckBoxMenuItemUI method paintCheckIcon.

@Override
protected void paintCheckIcon(Graphics g2, MenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr, Color holdc, Color foreground) {
    Graphics2D g = (Graphics2D) g2;
    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);
    g.translate(lr.getCheckRect().x - 2, lr.getCheckRect().y);
    final int sz = 13;
    g.setPaint(new GradientPaint(sz / 2, 1, Gray._110, sz / 2, sz, Gray._95));
    g.fillRoundRect(0, 0, sz, sz - 1, 4, 4);
    g.setPaint(new GradientPaint(sz / 2, 1, Gray._120.withAlpha(0x5a), sz / 2, sz, Gray._105.withAlpha(90)));
    g.drawRoundRect(0, (UIUtil.isUnderDarcula() ? 1 : 0), sz, sz - 1, 4, 4);
    g.setPaint(Gray._40.withAlpha(180));
    g.drawRoundRect(0, 0, sz, sz - 1, 4, 4);
    if (lh.getMenuItem().isSelected()) {
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
        g.setStroke(new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
        g.setPaint(Gray._30);
        g.drawLine(4, 7, 7, 10);
        g.drawLine(7, 10, sz, 2);
        g.setPaint(Gray._170);
        g.drawLine(4, 5, 7, 8);
        g.drawLine(7, 8, sz, 0);
    }
    g.translate(-lr.getCheckRect().x + 2, -lr.getCheckRect().y);
    config.restore();
    g.setColor(foreground);
}
Also used : GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig)

Example 12 with GraphicsConfig

use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.

the class DarculaComboBoxUI method createArrowButton.

protected JButton createArrowButton() {
    final Color bg = myComboBox.getBackground();
    final Color fg = myComboBox.getForeground();
    JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) {

        @Override
        public void paint(Graphics g2) {
            final Graphics2D g = (Graphics2D) g2;
            final GraphicsConfig config = new GraphicsConfig(g);
            final int w = getWidth();
            final int h = getHeight();
            if (!isTableCellEditor(myComboBox)) {
                g.setColor(getArrowButtonFillColor(UIUtil.getControlColor()));
                g.fillRect(0, 0, w, h);
            }
            g.setColor(new JBColor(Gray._255, comboBox.isEnabled() ? getForeground() : getBorderColor()));
            config.setupRoundedBorderAntialiasing();
            final int tW = JBUI.scale(8);
            final int tH = JBUI.scale(6);
            final int xU = (w - tW) / 2;
            final int yU = (h - tH) / 2;
            g.translate(JBUI.scale(2), JBUI.scale(1));
            final Path2D.Double path = new Path2D.Double();
            path.moveTo(xU, yU);
            path.lineTo(xU + tW, yU);
            path.lineTo(xU + tW / 2, yU + tH);
            path.lineTo(xU, yU);
            //path.moveTo(xU + 1, yU + 2);
            //path.lineTo(3 * xU + 1, yU + 2);
            //path.lineTo(2 * xU + 1, 3 * yU);
            //path.lineTo(xU + 1, yU + 2);
            path.closePath();
            g.fill(path);
            g.translate(-JBUI.scale(2), -JBUI.scale(1));
            if (!isTableCellEditor(myComboBox)) {
                g.setColor(getArrowButtonFillColor(getBorderColor()));
                g.drawLine(0, -1, 0, h);
            }
            config.restore();
        }

        @Override
        public Dimension getPreferredSize() {
            int size = getFont().getSize() + 4;
            if (size % 2 == 1)
                size++;
            return new DimensionUIResource(size, size);
        }
    };
    button.setBorder(BorderFactory.createEmptyBorder());
    button.setOpaque(false);
    return button;
}
Also used : BasicArrowButton(javax.swing.plaf.basic.BasicArrowButton) JBColor(com.intellij.ui.JBColor) Path2D(java.awt.geom.Path2D) JBColor(com.intellij.ui.JBColor) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig) DimensionUIResource(javax.swing.plaf.DimensionUIResource)

Example 13 with GraphicsConfig

use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.

the class DarculaRadioButtonMenuItemUI method paintCheckIcon.

@Override
protected void paintCheckIcon(Graphics g2, MenuItemLayoutHelper lh, MenuItemLayoutHelper.LayoutResult lr, Color holdc, Color foreground) {
    Graphics2D g = (Graphics2D) g2;
    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);
    g.translate(lr.getCheckRect().x - 1, lr.getCheckRect().y - 1);
    int rad = 5;
    final int x = 0;
    final int y = 0;
    final int w = 13;
    final int h = 13;
    g.translate(x, y);
    //setup AA for lines
    Color bg = lh.getMenuItem().getBackground();
    g.setPaint(new GradientPaint(0, 0, ColorUtil.shift(bg, 1.5), 0, 16, ColorUtil.shift(bg, 1.2)));
    g.fillOval(0, 1, w - 1, h - 1);
    g.setPaint(new GradientPaint(w / 2, 1, Gray._160.withAlpha(90), w / 2, h, Gray._100.withAlpha(90)));
    g.drawOval(0, 2, w - 1, h - 1);
    g.setPaint(Gray._40.withAlpha(200));
    g.drawOval(0, 1, w - 1, h - 1);
    if (lh.getMenuItem().isSelected()) {
        final boolean enabled = lh.getMenuItem().isEnabled();
        g.setColor(UIManager.getColor(enabled ? "RadioButton.darcula.selectionEnabledShadowColor" : "RadioButton.darcula.selectionDisabledShadowColor"));
        g.fillOval((w - rad) / 2, h / 2, rad, rad);
        g.setColor(UIManager.getColor(enabled ? "RadioButton.darcula.selectionEnabledColor" : "RadioButton.darcula.selectionDisabledColor"));
        g.fillOval((w - rad) / 2, h / 2 - 1, rad, rad);
    }
    config.restore();
    g.translate(-x, -y);
    g.translate(-lr.getCheckRect().x + 1, -lr.getCheckRect().y + 1);
    config.restore();
}
Also used : GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig)

Example 14 with GraphicsConfig

use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.

the class DarculaSpinnerBorder method paintBorder.

@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    final JSpinner spinner = (JSpinner) c;
    final JFormattedTextField editor = UIUtil.findComponentOfType(spinner, JFormattedTextField.class);
    final int x1 = x + 1;
    final int y1 = y + 3;
    final int width1 = width - 2;
    final int height1 = height - 6;
    final boolean focused = c.isEnabled() && c.isVisible() && editor != null && editor.hasFocus();
    final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
    if (c.isOpaque()) {
        g.setColor(UIUtil.getPanelBackground());
        g.fillRect(x, y, width, height);
    }
    g.setColor(UIUtil.getTextFieldBackground());
    g.fillRoundRect(x1, y1, width1, height1, 5, 5);
    g.setColor(UIManager.getColor(spinner.isEnabled() ? "Spinner.darcula.enabledButtonColor" : "Spinner.darcula.disabledButtonColor"));
    if (editor != null) {
        final int off = editor.getBounds().x + editor.getWidth() + ((JSpinner) c).getInsets().left + 1;
        final Area rect = new Area(new RoundRectangle2D.Double(x1, y1, width1, height1, 5, 5));
        final Area blueRect = new Area(new Rectangle(off, y1, 22, height1));
        rect.intersect(blueRect);
        ((Graphics2D) g).fill(rect);
        if (UIUtil.isUnderDarcula()) {
            g.setColor(Gray._100);
            g.drawLine(off, y1, off, height1 + 2);
        }
    }
    if (!c.isEnabled()) {
        ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
    }
    if (focused) {
        DarculaUIUtil.paintFocusRing(g, new Rectangle(x1 + 2, y1, width1 - 3, height1));
    } else {
        g.setColor(new JBColor(Gray._149, Gray._100));
        g.drawRoundRect(x1, y1, width1, height1, 5, 5);
    }
    config.restore();
}
Also used : Area(java.awt.geom.Area) RoundRectangle2D(java.awt.geom.RoundRectangle2D) JBColor(com.intellij.ui.JBColor) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig)

Example 15 with GraphicsConfig

use of com.intellij.openapi.ui.GraphicsConfig in project intellij-community by JetBrains.

the class DarculaSpinnerUI method createArrow.

private JButton createArrow(@MagicConstant(intValues = { SwingConstants.NORTH, SwingConstants.SOUTH }) int direction) {
    final Color shadow = UIUtil.getPanelBackground();
    final Color enabledColor = new JBColor(Gray._255, UIUtil.getLabelForeground());
    final Color disabledColor = new JBColor(Gray._200, UIUtil.getLabelForeground().darker());
    BasicArrowButton b = new BasicArrowButton(direction, shadow, shadow, enabledColor, shadow) {

        @Override
        public void paint(Graphics g) {
            paintArrowButton(g, this, direction);
        }

        @Override
        public boolean isOpaque() {
            return false;
        }

        @Override
        public void paintTriangle(Graphics g, int x, int y, int size, int direction, boolean isEnabled) {
            final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
            int mid;
            final int w = 8;
            final int h = 6;
            mid = w / 2;
            g.setColor(isEnabled ? enabledColor : disabledColor);
            g.translate(x, y);
            switch(direction) {
                case SOUTH:
                    g.fillPolygon(new int[] { 0, w, mid }, new int[] { 1, 1, h }, 3);
                    break;
                case NORTH:
                    g.fillPolygon(new int[] { 0, w, mid }, new int[] { h - 1, h - 1, 0 }, 3);
                    break;
                case WEST:
                case EAST:
            }
            g.translate(-x, -y);
            config.restore();
        }
    };
    Border buttonBorder = UIManager.getBorder("Spinner.arrowButtonBorder");
    if (buttonBorder instanceof UIResource) {
        // Wrap the border to avoid having the UIResource be replaced by
        // the ButtonUI. This is the opposite of using BorderUIResource.
        b.setBorder(new CompoundBorder(buttonBorder, null));
    } else {
        b.setBorder(buttonBorder);
    }
    b.setInheritsPopupMenu(true);
    return b;
}
Also used : BasicArrowButton(javax.swing.plaf.basic.BasicArrowButton) JBColor(com.intellij.ui.JBColor) JBColor(com.intellij.ui.JBColor) CompoundBorder(javax.swing.border.CompoundBorder) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig) Border(javax.swing.border.Border) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) UIResource(javax.swing.plaf.UIResource)

Aggregations

GraphicsConfig (com.intellij.openapi.ui.GraphicsConfig)38 JBColor (com.intellij.ui.JBColor)10 Border (javax.swing.border.Border)5 RoundRectangle2D (java.awt.geom.RoundRectangle2D)4 JBGradientPaint (com.intellij.ui.JBGradientPaint)2 Path2D (java.awt.geom.Path2D)2 Rectangle2D (java.awt.geom.Rectangle2D)2 BasicArrowButton (javax.swing.plaf.basic.BasicArrowButton)2 JTextComponent (javax.swing.text.JTextComponent)2 SettingsDialog (com.intellij.openapi.options.newEditor.SettingsDialog)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 JBInsets (com.intellij.util.ui.JBInsets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Area (java.awt.geom.Area)1 CompoundBorder (javax.swing.border.CompoundBorder)1 EmptyBorder (javax.swing.border.EmptyBorder)1 DimensionUIResource (javax.swing.plaf.DimensionUIResource)1 UIResource (javax.swing.plaf.UIResource)1 BasicTreeUI (javax.swing.plaf.basic.BasicTreeUI)1