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

The following examples show how to use com.intellij.util.ui.UIUtil#isUnderDarcula() . 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: DesktopStripePanelImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Insets getBorderInsets(Component c) {
  DesktopStripePanelImpl stripe = (DesktopStripePanelImpl)c;
  ToolWindowAnchor anchor = stripe.getAnchor();

  Insets result = new Insets(0, 0, 0, 0);
  final int off = UIUtil.isUnderDarcula() ? 1 : 0;
  if (anchor == ToolWindowAnchor.LEFT) {
    result.top = 1;
    result.right = 1 + off;
  }
  else if (anchor == ToolWindowAnchor.RIGHT) {
    result.left = 1 + off;
    result.top = 1;
  }
  else if (anchor == ToolWindowAnchor.TOP) {
    result.bottom = 0;
    //result.bottom = 1;
    result.top = 1;
  }
  else {
    result.top = 1 + off;
  }

  return result;
}
 
Example 2
Source File: EditorTextField.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void initOneLineMode(final EditorEx editor) {
  final boolean isOneLineMode = isOneLineMode();

  // set mode in editor
  editor.setOneLineMode(isOneLineMode);

  EditorColorsManager colorsManager = EditorColorsManager.getInstance();
  final EditorColorsScheme defaultScheme = UIUtil.isUnderDarcula() ? colorsManager.getGlobalScheme() : colorsManager.getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME);
  EditorColorsScheme customGlobalScheme = isOneLineMode ? defaultScheme : null;

  editor.setColorsScheme(editor.createBoundColorSchemeDelegate(customGlobalScheme));

  EditorColorsScheme colorsScheme = editor.getColorsScheme();
  editor.getSettings().setCaretRowShown(false);

  // color scheme settings:
  setupEditorFont(editor);
  updateBorder(editor);
  editor.setBackgroundColor(getBackgroundColor(isEnabled()));
}
 
Example 3
Source File: FlutterLogColors.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
public static Color forCategory(@NotNull String category) {
  if (category.equals(ERROR_CATEGORY)) {
    return JBColor.red;
  }
  if (category.startsWith("flutter.")) {
    return JBColor.gray;
  }
  if (category.startsWith("runtime.")) {
    return UIUtil.isUnderDarcula() ? JBColor.magenta : JBColor.pink;
  }
  if (category.equals("http")) {
    return JBColor.blue;
  }

  // TODO(pq): add more presets.

  // Default.
  return JBColor.darkGray;
}
 
Example 4
Source File: NavBarPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public NavBarPanel(@Nonnull Project project, boolean docked) {
  super(new FlowLayout(FlowLayout.LEFT, 0, 0));
  myProject = project;
  myModel = createModel();
  myIdeView = new NavBarIdeView(this);
  myPresentation = new NavBarPresentation(myProject);
  myUpdateQueue = new NavBarUpdateQueue(this);

  installPopupHandler(this, -1);
  setOpaque(false);
  if (!docked && UIUtil.isUnderDarcula()) {
    setBorder(new LineBorder(Gray._120, 1));
  }
  myUpdateQueue.queueModelUpdateFromFocus();
  myUpdateQueue.queueRebuildUi();
  if (!docked) {
    final ActionCallback typeAheadDone = new ActionCallback();
    IdeFocusManager.getInstance(project).typeAheadUntil(typeAheadDone, "NavBarPanel");
    myUpdateQueue.queueTypeAheadDone(typeAheadDone);
  }

  Disposer.register(project, this);
  AccessibleContextUtil.setName(this, "Navigation Bar");
}
 
Example 5
Source File: DesktopStripePanelImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void paintComponent(final Graphics g) {
  super.paintComponent(g);
  if (!myFinishingDrop && isDroppingButton() && myDragButton.getParent() != this) {
    g.setColor(getBackground().brighter());
    g.fillRect(0, 0, getWidth(), getHeight());
  }
  if (UIUtil.isUnderDarcula()) return;
  ToolWindowAnchor anchor = getAnchor();
  g.setColor(new Color(255, 255, 255, 40));
  Rectangle r = getBounds();
  if (anchor == ToolWindowAnchor.LEFT || anchor == ToolWindowAnchor.RIGHT) {
    g.drawLine(0, 0, 0, r.height);
    g.drawLine(r.width - 2, 0, r.width - 2, r.height);
  }
  else {
    g.drawLine(0, 1, r.width, 1);
    g.drawLine(0, r.height - 1, r.width, r.height - 1);
  }
}
 
Example 6
Source File: ContentRootPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void drawDottedLine(Graphics2D g, int x1, int y1, int x2, int y2) {
  /*
  // TODO!!!
  final Color color = g.getColor();
  g.setColor(getBackground());
  g.setColor(color);
  for (int i = x1 / 2 * 2; i < x2; i += 2) {
    g.drawRect(i, y1, 0, 0);
  }
  */
  final Stroke saved = g.getStroke();
  if (!SystemInfo.isMac && !UIUtil.isUnderDarcula()) {
    g.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, DASH, y1 % 2));
  }

  if (UIUtil.isUnderDarcula()) {
    UIUtil.drawDottedLine(g, x1, y1, x2, y2, null, g.getColor());
  }
  else {
    UIUtil.drawLine(g, x1, y1, x2, y2);
  }

  g.setStroke(saved);
}
 
Example 7
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 8
Source File: EditorColorsUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @return the appropriate color scheme for UI other than text editor (QuickDoc, UsagesView, etc.)
 * depending on the current LAF, current editor color scheme and background color.
 */
public static EditorColorsScheme getColorSchemeForBackground(@Nullable Color background) {
  EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
  boolean dark1 = background == null ? UIUtil.isUnderDarcula() : ColorUtil.isDark(background);
  boolean dark2 = ColorUtil.isDark(globalScheme.getDefaultBackground());
  if (dark1 != dark2) {
    EditorColorsScheme scheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
    if (scheme != null) {
      return scheme;
    }
  }
  return globalScheme;
}
 
Example 9
Source File: EditorComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Dimension getPreferredSize() {
  if (UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula()) {
    return super.getPreferredSize();
  }
  if (myEditorField != null) {
    final Dimension preferredSize = new Dimension(myEditorField.getComponent().getPreferredSize());
    JBInsets.addTo(preferredSize, getInsets());
    return preferredSize;
  }

  //final int cbHeight = new JComboBox().getPreferredSize().height; // should be used actually
  return new Dimension(100, UIUtil.fixComboBoxHeight(20));
}
 
Example 10
Source File: ReferencesPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static Color getLabelColor(@Nonnull Color color) {
  if (UIUtil.isUnderDarcula()) {
    color = ColorUtil.darker(color, 6);
  }
  else {
    color = ColorUtil.brighter(color, 6);
  }
  return ColorUtil.desaturate(color, 3);
}
 
Example 11
Source File: FileColorConfigurationEditDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createColorButtonsPanel(final FileColorConfiguration configuration) {
  final JPanel result = new JPanel(new BorderLayout());
  result.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

  final JPanel inner = new JPanel();
  inner.setLayout(new BoxLayout(inner, BoxLayout.X_AXIS));
  inner.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
  if (!UIUtil.isUnderDarcula()) {
    inner.setBackground(Color.WHITE);
  }
  result.add(inner, BorderLayout.CENTER);

  final ButtonGroup group = new ButtonGroup();

  myColorToButtonMap = new HashMap<String, AbstractButton>();

  final Collection<String> names = myManager.getColorNames();
  for (final String name : names) {
    final ColorButton colorButton = new ColorButton(name, myManager.getColor(name));
    group.add(colorButton);
    inner.add(colorButton);
    myColorToButtonMap.put(name, colorButton);
    inner.add(Box.createHorizontalStrut(5));
  }
  final CustomColorButton customButton = new CustomColorButton();
  group.add(customButton);
  inner.add(customButton);
  myColorToButtonMap.put(customButton.getText(), customButton);
  inner.add(Box.createHorizontalStrut(5));


  if (configuration != null) {
    final AbstractButton button = myColorToButtonMap.get(configuration.getColorName());
    if (button != null) {
      button.setSelected(true);
    }
  }

  return result;
}
 
Example 12
Source File: ContentTabLabel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected Color getActiveFg(boolean selected) {
  if (contentManager().getContentCount() > 1) {
    return selected ? JBColor.white : UIUtil.isUnderDarcula() ? UIUtil.getLabelForeground() : JBColor.black;
  }

  return super.getActiveFg(selected);
}
 
Example 13
Source File: SheetController.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static float getShadowAlpha() {
  return ((UIUtil.isUnderDarcula())) ? .85f : .35f;
}
 
Example 14
Source File: BreadcrumbsConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public JComponent createComponent() {
  if (component == null) {
    for (final BreadcrumbsProviderConfigurable configurable : getConfigurables()) {
      final String id = configurable.getId();
      if (!map.containsKey(id)) {
        map.put(id, configurable.createComponent());
      }
    }
    JPanel boxes = new JPanel(new GridLayout(0, 3, UIUtil.isUnderDarcula() ? JBUIScale.scale(10) : 0, 0));
    map.values().stream().sorted((box1, box2) -> naturalCompare(box1.getText(), box2.getText())).forEach(box -> boxes.add(box));

    show = new JCheckBox(message("checkbox.show.breadcrumbs"));
    show.addItemListener(event -> updateEnabled());

    above = new JRadioButton(message("radio.show.breadcrumbs.above"));
    below = new JRadioButton(message("radio.show.breadcrumbs.below"));

    ButtonGroup group = new ButtonGroup();
    group.add(above);
    group.add(below);

    placement = new JLabel(message("label.breadcrumbs.placement"));

    JPanel placementPanel = new JPanel(new HorizontalLayout(JBUIScale.scale(UIUtil.DEFAULT_HGAP)));
    placementPanel.setBorder(JBUI.Borders.emptyLeft(24));
    placementPanel.add(placement);
    placementPanel.add(above);
    placementPanel.add(below);

    languages = new JLabel(message("label.breadcrumbs.languages"));

    JPanel languagesPanel = new JPanel(new VerticalLayout(JBUIScale.scale(6)));
    languagesPanel.setBorder(JBUI.Borders.empty(0, 24, 12, 0));
    languagesPanel.add(languages);
    languagesPanel.add(boxes);

    component = new JPanel(new VerticalLayout(JBUIScale.scale(12), LEFT));
    component.add(show);
    component.add(placementPanel);
    component.add(languagesPanel);
    component.add(LinkLabel.create(message("configure.breadcrumbs.colors"), () -> {
      DataContext context = DataManager.getInstance().getDataContext(component);
      selectOrEditColor(context, "Breadcrumbs//Current", GeneralColorsPage.class);
    }));
  }
  return component;
}
 
Example 15
Source File: WideSelectionTreeUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean shouldPaintLines() {
  if (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
    return false;
  }
  return myForceDontPaintLines || !"None".equals(tree.getClientProperty("JTree.lineStyle"));
}
 
Example 16
Source File: AbstractNavBarUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static BufferedImage drawToBuffer(NavBarItem item, JBUI.ScaleContext ctx, boolean floating, boolean toolbarVisible, boolean selected, NavBarPanel navbar) {
  int w = item.getWidth();
  int h = item.getHeight();
  int offset = (w - getDecorationOffset());
  int h2 = h / 2;

  BufferedImage result = UIUtil.createImage(ctx, w, h, BufferedImage.TYPE_INT_ARGB, PaintUtil.RoundingMode.FLOOR);

  Color defaultBg = UIUtil.isUnderDarcula() ? Gray._100 : JBColor.WHITE;
  final Paint bg = floating ? defaultBg : null;
  final Color selection = UIUtil.getListSelectionBackground(true);

  Graphics2D g2 = result.createGraphics();
  g2.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);


  Path2D.Double shape = new Path2D.Double();
  shape.moveTo(0, 0);

  shape.lineTo(offset, 0);
  shape.lineTo(w, h2);
  shape.lineTo(offset, h);
  shape.lineTo(0, h);
  shape.closePath();

  Path2D.Double endShape = new Path2D.Double();
  endShape.moveTo(offset, 0);
  endShape.lineTo(w, 0);
  endShape.lineTo(w, h);
  endShape.lineTo(offset, h);
  endShape.lineTo(w, h2);
  endShape.closePath();

  if (bg != null && toolbarVisible) {
    g2.setPaint(bg);
    g2.fill(shape);
    g2.fill(endShape);
  }

  if (selected) {
    Path2D.Double focusShape = new Path2D.Double();
    if (toolbarVisible || floating) {
      focusShape.moveTo(offset, 0);
    }
    else {
      focusShape.moveTo(0, 0);
      focusShape.lineTo(offset, 0);
    }
    focusShape.lineTo(w - 1, h2);
    focusShape.lineTo(offset, h - 1);
    if (!toolbarVisible && !floating) {
      focusShape.lineTo(0, h - 1);

    }

    g2.setColor(selection);
    if (floating && item.isLastElement()) {
      g2.fillRect(0, 0, w, h);
    }
    else {
      g2.fill(shape);
    }
  }

  if (item.isNextSelected() && navbar.isFocused()) {
    g2.setColor(selection);
    g2.fill(endShape);
  }

  if (!item.isLastElement()) {
    if (!selected && (!navbar.isFocused() | !item.isNextSelected())) {
      Icon icon = AllIcons.Ide.NavBarSeparator;
      icon.paintIcon(item, g2, w - icon.getIconWidth() - JBUIScale.scale(1), h2 - icon.getIconHeight() / 2);
    }
  }

  g2.dispose();
  return result;
}
 
Example 17
Source File: FileColorManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
static String getAlias(String text) {
  if (UIUtil.isUnderDarcula()) {
    if (text.equals("Yellow")) return "Brown";
  }
  return text;
}
 
Example 18
Source File: InspectorTreeUI.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void paintRow(final Graphics g,
                        final Rectangle clipBounds,
                        final Insets insets,
                        final Rectangle bounds,
                        final TreePath path,
                        final int row,
                        final boolean isExpanded,
                        final boolean hasBeenExpanded,
                        final boolean isLeaf) {
  final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth();
  final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport)tree.getParent()).getViewPosition().x : 0;

  if (path != null && myWideSelection) {
    boolean selected = tree.isPathSelected(path);
    Graphics2D rowGraphics = (Graphics2D)g.create();
    rowGraphics.setClip(clipBounds);

    final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY);
    Color background = tree.getBackground();

    if ((row % 2) == 0 && Boolean.TRUE.equals(tree.getClientProperty(STRIPED_CLIENT_PROPERTY))) {
      background = UIUtil.getDecoratedRowColor();
    }

    if (sourceList != null && (Boolean)sourceList) {
      if (selected) {
        if (tree.hasFocus()) {
          LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
        else {
          LIST_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
      else if (myWideSelectionCondition.value(row)) {
        rowGraphics.setColor(background);
        rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
      }
    }
    else {
      if (selected && (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF())) {
        Color bg = getSelectionBackground(tree, true);

        if (myWideSelectionCondition.value(row)) {
          rowGraphics.setColor(bg);
          rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
    }

    if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) {
      paintExpandControl(rowGraphics, bounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    }

    super.paintRow(rowGraphics, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    rowGraphics.dispose();
  }
  else {
    super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
  }
}
 
Example 19
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 20
Source File: InspectorTreeUI.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void paintRow(final Graphics g,
                        final Rectangle clipBounds,
                        final Insets insets,
                        final Rectangle bounds,
                        final TreePath path,
                        final int row,
                        final boolean isExpanded,
                        final boolean hasBeenExpanded,
                        final boolean isLeaf) {
  final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth();
  final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport)tree.getParent()).getViewPosition().x : 0;

  if (path != null && myWideSelection) {
    boolean selected = tree.isPathSelected(path);
    Graphics2D rowGraphics = (Graphics2D)g.create();
    rowGraphics.setClip(clipBounds);

    final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY);
    Color background = tree.getBackground();

    if ((row % 2) == 0 && Boolean.TRUE.equals(tree.getClientProperty(STRIPED_CLIENT_PROPERTY))) {
      background = UIUtil.getDecoratedRowColor();
    }

    if (sourceList != null && (Boolean)sourceList) {
      if (selected) {
        if (tree.hasFocus()) {
          LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
        else {
          LIST_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
      else if (myWideSelectionCondition.value(row)) {
        rowGraphics.setColor(background);
        rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
      }
    }
    else {
      if (selected && (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF())) {
        Color bg = getSelectionBackground(tree, true);

        if (myWideSelectionCondition.value(row)) {
          rowGraphics.setColor(bg);
          rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
    }

    if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) {
      paintExpandControl(rowGraphics, bounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    }

    super.paintRow(rowGraphics, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    rowGraphics.dispose();
  }
  else {
    super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
  }
}