Java Code Examples for com.intellij.util.ui.UIUtil#isUnderAquaLookAndFeel()

The following examples show how to use com.intellij.util.ui.UIUtil#isUnderAquaLookAndFeel() . 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: PoppedIcon.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void paintBorder(Graphics g, Dimension size, int state) {
  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 2
Source File: PoppedIcon.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void paintBackground(Graphics g, Dimension size, int state) {
  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 3
Source File: GlassPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private Area getComponentArea(final JComponent surfaceComponent, final JComponent lightComponent) {
  if (!lightComponent.isShowing()) return null;

  final Point panelPoint = SwingUtilities.convertPoint(lightComponent, new Point(0, 0), surfaceComponent);
  final int x = panelPoint.x;
  final int y = panelPoint.y;

  Insets insetsToIgnore = lightComponent.getInsets();
  final boolean isWithBorder = Boolean.TRUE.equals(lightComponent.getClientProperty(SearchUtil.HIGHLIGHT_WITH_BORDER));
  final boolean isLabelFromTabbedPane = Boolean.TRUE.equals(lightComponent.getClientProperty(JBTabbedPane.LABEL_FROM_TABBED_PANE));

  if ((insetsToIgnore == null || (UIUtil.isUnderAquaLookAndFeel() && lightComponent instanceof JButton)) || isWithBorder) {
    insetsToIgnore = EMPTY_INSETS;
  }

  int hInset = isWithBorder ? 7 : isLabelFromTabbedPane ? 20 : 7;
  int vInset = isWithBorder ? 1 : isLabelFromTabbedPane ? 10 : 5;
  final Area area = new Area(new RoundRectangle2D.Double(x - hInset + insetsToIgnore.left,
                                                         y - vInset + insetsToIgnore.top,
                                                         lightComponent.getWidth() + hInset * 2 - insetsToIgnore.right - insetsToIgnore.left,
                                                         lightComponent.getHeight() + vInset * 2 - insetsToIgnore.top - insetsToIgnore.bottom,
                                                         6, 6));
  return area;
}
 
Example 4
Source File: IJSwingUtilities.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void adjustComponentsOnMac(@Nullable JLabel label, @Nullable JComponent component) {
  if (component == null) return;
  if (!UIUtil.isUnderAquaLookAndFeel()) return;

  if (component instanceof JComboBox) {
    UIUtil.addInsets(component, new Insets(0,-2,0,0));
    if (label != null) {
      UIUtil.addInsets(label, new Insets(0,2,0,0));
    }
  }
  if (component instanceof JCheckBox) {
    UIUtil.addInsets(component, new Insets(0,-5,0,0));
  }
  if (component instanceof JTextField || component instanceof EditorTextField) {
    if (label != null) {
      UIUtil.addInsets(label, new Insets(0,3,0,0));
    }
  }
}
 
Example 5
Source File: FixedSizeButton.java    From consulo with Apache License 2.0 6 votes vote down vote up
private FixedSizeButton(int size, JComponent component) {
  Icon icon = AllIcons.General.Ellipsis;
  if (icon != null) {
    // loading may fail at design time
    setIcon(icon);
  }
  else {
    setText(".");
  }
  mySize = size;
  myComponent = component;
  setMargin(new Insets(0, 0, 0, 0));
  setDefaultCapable(false);
  setFocusable(false);
  if (((UIUtil.isUnderAquaLookAndFeel())&& size == -1) || UIUtil.isUnderBuildInLaF()) {
    putClientProperty("JButton.buttonType", "square");
  }
}
 
Example 6
Source File: TreeComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
private TreeListCellRenderer(@Nonnull final JComboBox comboBox, final boolean showRootNode, @Nullable final String defaultText) {
  myComboBox = comboBox;
  myShowRootNode = showRootNode;
  myDefaultText = defaultText;
  myUnderAquaLookAndFeel = UIUtil.isUnderAquaLookAndFeel();
  setOpaque(!myUnderAquaLookAndFeel);
}
 
Example 7
Source File: PopupComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public AwtPopupWrapper(Popup popup, JBPopup jbPopup) {
  myPopup = popup;
  myJBPopup = jbPopup;

  if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) {
    final Component c = (Component)ReflectionUtil.getField(Popup.class, myPopup, Component.class, "component");
    c.setBackground(UIUtil.getPanelBackground());
  }
}
 
Example 8
Source File: SearchTextField.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Dimension getPreferredSize() {
  Dimension size = super.getPreferredSize();
  Border border = super.getBorder();
  if (border != null && UIUtil.isUnderAquaLookAndFeel()) {
    JBInsets.addTo(size, border.getBorderInsets(this));
  }
  return size;
}
 
Example 9
Source File: ComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean hasFocus() {
  if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel() && myPaintingNow) {
    return false;
  }
  return super.hasFocus();
}
 
Example 10
Source File: ComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
public final void setEditor(final ComboBoxEditor editor) {
  ComboBoxEditor _editor = editor;
  if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) {
    if ("AquaComboBoxEditor".equals(editor.getClass().getSimpleName())) {
      _editor = new FixedComboBoxEditor();
    }
  }

  super.setEditor(new MyEditor(this, _editor));
}
 
Example 11
Source File: NavBarUIManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static NavBarUI getUI() {
  if (UIUtil.isUnderAquaLookAndFeel()) return AQUA;
  if (UIUtil.isUnderGTKLookAndFeel())  return GTK;
  if (UIUtil.isUnderDarcula())         return DARCULA;
  return COMMON;
}
 
Example 12
Source File: CommonActionsPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
CommonActionsPanel(ListenerFactory factory, @Nullable JComponent contextComponent, ActionToolbarPosition position,
                   @Nullable AnAction[] additionalActions, @Nullable Comparator<AnAction> buttonComparator,
                   String addName, String removeName, String moveUpName, String moveDownName, String editName,
                   Icon addIcon, Buttons... buttons) {
  super(new BorderLayout());
  final Listener listener = factory.createListener(this);
  AnAction[] actions = new AnAction[buttons.length];
  for (int i = 0; i < buttons.length; i++) {
    Buttons button = buttons[i];
    String name = null;
    switch (button) {
      case ADD:    name = addName;      break;        
      case EDIT:   name = editName;     break;
      case REMOVE: name = removeName;   break;
      case UP:     name = moveUpName;   break;
      case DOWN:   name = moveDownName; break;
    }
    final MyActionButton b = button.createButton(listener, name, button == Buttons.ADD && addIcon != null ? addIcon : button.getIcon());
    actions[i] = b;
    myButtons.put(button, b);
  }
  if (additionalActions != null && additionalActions.length > 0) {
    final ArrayList<AnAction> allActions = new ArrayList<>(Arrays.asList(actions));
    allActions.addAll(Arrays.asList(additionalActions));
    actions = allActions.toArray(new AnAction[allActions.size()]);
  }
  myActions = actions;
  for (AnAction action : actions) {
    if(action instanceof AnActionButton) {
      ((AnActionButton)action).setContextComponent(contextComponent);
    }
  }
  if (buttonComparator != null) {
    Arrays.sort(myActions, buttonComparator);
  }
  ArrayList<AnAction> toolbarActions = new ArrayList<>(Arrays.asList(myActions));
  for (int i = 0; i < toolbarActions.size(); i++) {
      if (toolbarActions.get(i) instanceof AnActionButton.CheckedAnActionButton) {
        toolbarActions.set(i, ((AnActionButton.CheckedAnActionButton)toolbarActions.get(i)).getDelegate());
      }
  }
  myDecorateButtons = UIUtil.isUnderAquaLookAndFeel() && position == ActionToolbarPosition.BOTTOM;

  final ActionManagerEx mgr = (ActionManagerEx)ActionManager.getInstance();
  final ActionToolbar toolbar = mgr.createActionToolbar(ActionPlaces.UNKNOWN,
                                                        new DefaultActionGroup(toolbarActions.toArray(new AnAction[toolbarActions.size()])),
                                                        position == ActionToolbarPosition.BOTTOM || position == ActionToolbarPosition.TOP,
                                                        myDecorateButtons);
  toolbar.getComponent().setOpaque(false);
  toolbar.getComponent().setBorder(null);
  add(toolbar.getComponent(), BorderLayout.CENTER);
}
 
Example 13
Source File: LafManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static void fixSeparatorColor(UIDefaults uiDefaults) {
  if (UIUtil.isUnderAquaLookAndFeel()) {
    uiDefaults.put("Separator.background", UIUtil.AQUA_SEPARATOR_BACKGROUND_COLOR);
    uiDefaults.put("Separator.foreground", UIUtil.AQUA_SEPARATOR_FOREGROUND_COLOR);
  }
}
 
Example 14
Source File: SearchTextField.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected boolean isSearchControlUISupported() {
  return (SystemInfo.isMacOSLeopard && UIUtil.isUnderAquaLookAndFeel()) || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF();
}
 
Example 15
Source File: ComboBoxWithWidePopup.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ComboBoxWithWidePopup(final Vector<E> items) {
  super(items);

  if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) setMaximumRowCount(25);
}
 
Example 16
Source File: ComboBoxWithWidePopup.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ComboBoxWithWidePopup(final E[] items) {
  super(items);

  if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) setMaximumRowCount(25);
}
 
Example 17
Source File: ComboBoxWithWidePopup.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ComboBoxWithWidePopup(final ComboBoxModel<E> aModel) {
  super(aModel);

  if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) setMaximumRowCount(25);
}
 
Example 18
Source File: DarculaUIUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void paintSearchFocusRing(Graphics2D g, Rectangle bounds, Component component, int maxArcSize) {
  int correction = UIUtil.isUnderAquaLookAndFeel() ? 30 : UIUtil.isUnderDarcula() ? 50 : 0;
  final Color[] colors = new Color[]{
          ColorUtil.toAlpha(GLOW_COLOR, 180 - correction),
          ColorUtil.toAlpha(GLOW_COLOR, 120 - correction),
          ColorUtil.toAlpha(GLOW_COLOR, 70  - correction),
          ColorUtil.toAlpha(GLOW_COLOR, 100 - correction),
          ColorUtil.toAlpha(GLOW_COLOR, 50  - correction)
  };

  final Object oldAntialiasingValue = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
  final Object oldStrokeControlValue = g.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);

  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);


  final Rectangle r = new Rectangle(bounds.x - 3, bounds.y - 3, bounds.width + 6, bounds.height + 6);
  int arcSize = r.height - 1;
  if (maxArcSize>0) arcSize = Math.min(maxArcSize, arcSize);
  if (arcSize %2 == 1) arcSize--;


  g.setColor(component.getBackground());
  g.fillRoundRect(r.x + 2, r.y + 2, r.width - 5, r.height - 5, arcSize - 4, arcSize - 4);

  g.setColor(colors[0]);
  g.drawRoundRect(r.x + 2, r.y + 2, r.width - 5, r.height - 5, arcSize-4, arcSize-4);

  g.setColor(colors[1]);
  g.drawRoundRect(r.x + 1, r.y + 1, r.width - 3, r.height - 3, arcSize-2, arcSize-2);

  g.setColor(colors[2]);
  g.drawRoundRect(r.x, r.y, r.width - 1, r.height - 1, arcSize, arcSize);


  g.setColor(colors[3]);
  g.drawRoundRect(r.x+3, r.y+3, r.width - 7, r.height - 7, arcSize-6, arcSize-6);

  g.setColor(colors[4]);
  g.drawRoundRect(r.x+4, r.y+4, r.width - 9, r.height - 9, arcSize-8, arcSize-8);

  // restore rendering hints
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue);
}
 
Example 19
Source File: DockManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private DockWindow(String id, Project project, DockContainer container, boolean dialog) {
  super(project, null, dialog);
  myId = id;
  myContainer = container;
  setProject(project);

  if (!(container instanceof DockContainer.Dialog)) {
    setStatusBar(WindowManager.getInstance().getStatusBar(project).createChild());
  }

  myUiContainer = new NonOpaquePanel(new BorderLayout());

  NonOpaquePanel center = new NonOpaquePanel(new BorderLayout(0, 2));
  if (UIUtil.isUnderAquaLookAndFeel()) {
    center.setOpaque(true);
    center.setBackground(JBTabsImpl.MAC_AQUA_BG_COLOR);
  }

  center.add(myNorthPanel, BorderLayout.NORTH);

  myDockContentUiContainer = new NonOpaquePanel(new BorderLayout());
  myDockContentUiContainer.add(myContainer.getContainerComponent(), BorderLayout.CENTER);
  center.add(myDockContentUiContainer, BorderLayout.CENTER);

  myUiContainer.add(center, BorderLayout.CENTER);
  if (myStatusBar != null) {
    myUiContainer.add(myStatusBar.getComponent(), BorderLayout.SOUTH);
  }

  setComponent(myUiContainer);
  addDisposable(container);

  IdeEventQueue.getInstance().addPostprocessor(this, this);

  myContainer.addListener(new DockContainer.Listener.Adapter() {
    @Override
    public void contentRemoved(Object key) {
      getReady().doWhenDone(() -> {
        if (myContainer.isEmpty()) {
          close();
        }
      });
    }
  }, this);

  UISettings.getInstance().addUISettingsListener(new UISettingsListener() {
    @Override
    public void uiSettingsChanged(UISettings source) {
      updateNorthPanel();
    }
  }, this);

  updateNorthPanel();
}
 
Example 20
Source File: DesktopColorPicker.java    From consulo with Apache License 2.0 4 votes vote down vote up
private JComponent buildTopPanel(boolean enablePipette) throws ParseException {
  final JPanel result = new JPanel(new BorderLayout());

  final JPanel previewPanel = new JPanel(new BorderLayout());
  if (enablePipette && ColorPipette.isAvailable()) {
    final JButton pipette = new JButton();
    pipette.setUI(new BasicButtonUI());
    pipette.setRolloverEnabled(true);
    pipette.setIcon(AllIcons.Ide.Pipette);
    pipette.setBorder(JBUI.Borders.empty());
    pipette.setRolloverIcon(AllIcons.Ide.Pipette_rollover);
    pipette.setFocusable(false);
    pipette.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        myPicker.myOldColor = getColor();
        myPicker.pick();
        //JBPopupFactory.getInstance().createBalloonBuilder(new JLabel("Press ESC button to close pipette"))
        //  .setAnimationCycle(2000)
        //  .setSmallVariant(true)
        //  .createBalloon().show(new RelativePoint(pipette, new Point(pipette.getWidth() / 2, 0)), Balloon.Position.above);
      }
    });
    previewPanel.add(pipette, BorderLayout.WEST);
  }

  myPreviewComponent = new ColorPreviewComponent();
  previewPanel.add(myPreviewComponent, BorderLayout.CENTER);

  result.add(previewPanel, BorderLayout.NORTH);

  final JPanel rgbPanel = new JPanel();
  rgbPanel.setLayout(new BoxLayout(rgbPanel, BoxLayout.X_AXIS));
  if (!UIUtil.isUnderAquaLookAndFeel()) {
    myR_after.setPreferredSize(new Dimension(14, -1));
    myG_after.setPreferredSize(new Dimension(14, -1));
    myB_after.setPreferredSize(new Dimension(14, -1));
  }
  rgbPanel.setBorder(JBUI.Borders.empty(10, 0, 0, 0));
  rgbPanel.add(myR);
  rgbPanel.add(myRed);
  if (!UIUtil.isUnderAquaLookAndFeel()) rgbPanel.add(myR_after);
  rgbPanel.add(Box.createHorizontalStrut(JBUI.scale(2)));
  rgbPanel.add(myG);
  rgbPanel.add(myGreen);
  if (!UIUtil.isUnderAquaLookAndFeel()) rgbPanel.add(myG_after);
  rgbPanel.add(Box.createHorizontalStrut(JBUI.scale(2)));
  rgbPanel.add(myB);
  rgbPanel.add(myBlue);
  if (!UIUtil.isUnderAquaLookAndFeel()) rgbPanel.add(myB_after);
  rgbPanel.add(Box.createHorizontalStrut(JBUI.scale(2)));
  rgbPanel.add(myFormat);

  result.add(rgbPanel, BorderLayout.WEST);

  final JPanel hexPanel = new JPanel();
  hexPanel.setLayout(new BoxLayout(hexPanel, BoxLayout.X_AXIS));
  hexPanel.setBorder(JBUI.Borders.empty(10, 0, 0, 0));
  hexPanel.add(new JLabel("#"));
  hexPanel.add(myHex);

  result.add(hexPanel, BorderLayout.EAST);

  return result;
}