Java Code Examples for com.intellij.openapi.actionSystem.impl.ActionButton#isBackgroundSet()

The following examples show how to use com.intellij.openapi.actionSystem.impl.ActionButton#isBackgroundSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DarculaActionButtonUI.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void paintBackground(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  Rectangle rect = new Rectangle(button.getSize());
  JBInsets.removeFrom(rect, button.getInsets());

  Color color = state == ActionButtonComponent.PUSHED ? JBUI.CurrentTheme.ActionButton.pressedBackground() : JBUI.CurrentTheme.ActionButton.hoverBackground();
  Graphics2D g2 = (Graphics2D)g.create();

  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    g2.setColor(color);

    float arc = DarculaUIUtil.BUTTON_ARC.getFloat();
    g2.fill(new RoundRectangle2D.Float(rect.x, rect.y, rect.width, rect.height, arc, arc));
  }
  finally {
    g2.dispose();
  }
}
 
Example 2
Source File: ActionButtonUI.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void paintBorder(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.POPPED) {
      g.setColor(ALPHA_30);
      g.drawRoundRect(0, 0, size.width - 2, size.height - 2, 4, 4);
    }
  }
  else {
    final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49;
    g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift));
    ((Graphics2D)g).setStroke(BASIC_STROKE);
    final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
    g.drawRoundRect(0, 0, size.width - JBUI.scale(2), size.height - JBUI.scale(2), JBUI.scale(4), JBUI.scale(4));
    config.restore();
  }
}
 
Example 3
Source File: DarculaActionButtonUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void paintBorder(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  Rectangle rect = new Rectangle(button.getSize());
  JBInsets.removeFrom(rect, button.getInsets());

  Graphics2D g2 = (Graphics2D)g.create();
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

  try {
    Color color = state == ActionButtonComponent.PUSHED ? JBUI.CurrentTheme.ActionButton.pressedBorder() : JBUI.CurrentTheme.ActionButton.hoverBorder();

    g2.setColor(color);

    float arc = DarculaUIUtil.BUTTON_ARC.getFloat();
    float lw = DarculaUIUtil.LW.getFloat();
    Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
    border.append(new RoundRectangle2D.Float(rect.x, rect.y, rect.width, rect.height, arc, arc), false);
    border.append(new RoundRectangle2D.Float(rect.x + lw, rect.y + lw, rect.width - lw * 2, rect.height - lw * 2, arc - lw, arc - lw), false);

    g2.fill(border);
  }
  finally {
    g2.dispose();
  }
}
 
Example 4
Source File: ActionButtonUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void paintBackground(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  if (UIUtil.isUnderAquaLookAndFeel()) {
    if (state == ActionButtonComponent.PUSHED) {
      ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, ALPHA_40, size.width, size.height, ALPHA_20));
      g.fillRect(0, 0, size.width - 1, size.height - 1);

      g.setColor(ALPHA_120);
      g.drawLine(0, 0, 0, size.height - 2);
      g.drawLine(1, 0, size.width - 2, 0);

      g.setColor(ALPHA_30);
      g.drawRect(1, 1, size.width - 3, size.height - 3);
    }
    else if (state == ActionButtonComponent.POPPED) {
      ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, Gray._235, 0, size.height, Gray._200));
      g.fillRect(1, 1, size.width - 3, size.height - 3);
    }
  }
  else {
    final Color bg = UIUtil.getPanelBackground();
    final boolean dark = UIUtil.isUnderDarcula();
    g.setColor(state == ActionButtonComponent.PUSHED ? ColorUtil.shift(bg, dark ? 1d / 0.7d : 0.7d) : dark ? Gray._255.withAlpha(40) : ALPHA_40);
    g.fillRect(JBUI.scale(1), JBUI.scale(1), size.width - JBUI.scale(2), size.height - JBUI.scale(2));
  }
}
 
Example 5
Source File: ModernActionButtonUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void paintBorder(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
  g.setColor(state == ActionButtonComponent.POPPED || state == ActionButtonComponent.PUSHED
             ? ModernUIUtil.getSelectionBackground()
             : ModernUIUtil.getBorderColor(button));
  RectanglePainter2D.DRAW.paint((Graphics2D)g, 0, 0, size.getWidth(), size.getHeight());
  config.restore();
}