mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-201019 Consider changing the color picker icon because it looks too much like the Microsoft logo
This commit is contained in:
@@ -201,6 +201,7 @@ public class JavaColorProvider implements ElementColorProvider {
|
||||
argumentList.add(factory.createExpressionFromText("true", null));
|
||||
replaceInt(expr[0], color.getRGB() | color.getAlpha() << 24, true, true);
|
||||
}
|
||||
return;
|
||||
case INT_BOOL:
|
||||
if ("true".equals(expr[1].getText())) {
|
||||
replaceInt(expr[0], color.getRGB() | color.getAlpha() << 24, true, true);
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.intellij.util.Function;
|
||||
import com.intellij.util.FunctionUtil;
|
||||
import com.intellij.util.ui.ColorIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.TwoColorsIcon;
|
||||
import com.intellij.util.ui.ColorsIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -87,10 +87,7 @@ public final class ColorLineMarkerProvider extends LineMarkerProviderDescriptor
|
||||
|
||||
@Override
|
||||
public Icon getCommonIcon(@NotNull List<MergeableLineMarkerInfo> infos) {
|
||||
if (infos.size() == 2 && infos.get(0) instanceof MyInfo && infos.get(1) instanceof MyInfo) {
|
||||
return JBUI.scale(new TwoColorsIcon(12, ((MyInfo)infos.get(0)).myColor, ((MyInfo)infos.get(1)).myColor));
|
||||
}
|
||||
return AllIcons.Gutter.Colors;
|
||||
return JBUI.scale(new ColorsIcon(12, infos.stream().map(_info -> ((MyInfo)_info).myColor).toArray(Color[]::new)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -285,7 +285,7 @@ public class UiDropperAction extends ToggleAction implements DumbAware {
|
||||
append(", double-buffered", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
componentNode.setText(toString());
|
||||
setIcon(JBUI.scale(new TwoColorsIcon(11, component.getForeground(), component.getBackground())));
|
||||
setIcon(JBUI.scale(new ColorsIcon(11, component.getBackground(), component.getForeground())));
|
||||
}
|
||||
|
||||
setForeground(foreground);
|
||||
|
||||
@@ -405,7 +405,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
append("data-provider", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
}
|
||||
componentNode.setText(toString());
|
||||
setIcon(createColorIcon(component.getForeground(), component.getBackground()));
|
||||
setIcon(createColorIcon(component.getBackground(), component.getForeground()));
|
||||
}
|
||||
if (value instanceof HierarchyTree.ClickInfoNode) {
|
||||
append(value.toString());
|
||||
@@ -1006,7 +1006,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
Color insideColor = getBorderColor(((CompoundBorder)value).getInsideBorder());
|
||||
Color outsideColor = getBorderColor(((CompoundBorder)value).getOutsideBorder());
|
||||
if (insideColor != null && outsideColor != null) {
|
||||
setIcon(createColorIcon(outsideColor, insideColor));
|
||||
setIcon(createColorIcon(insideColor, outsideColor));
|
||||
}
|
||||
else if (insideColor != null) {
|
||||
setIcon(createColorIcon(insideColor));
|
||||
@@ -1108,7 +1108,7 @@ public class UiInspectorAction extends ToggleAction implements DumbAware {
|
||||
}
|
||||
|
||||
private static Icon createColorIcon(Color color1, Color color2) {
|
||||
return JBUI.scale(new TwoColorsIcon(11, color1, color2));
|
||||
return JBUI.scale(new ColorsIcon(11, color1, color2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.ui;
|
||||
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.paint.RectanglePainter;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Vassiliy Kudryashov
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ColorsIcon extends ColorIcon {
|
||||
private static final int SQUARE_SIZE = JBUI.scale(6);
|
||||
private static final BufferedImage CHESS_IMAGE = UIUtil.createImage(SQUARE_SIZE, SQUARE_SIZE, BufferedImage.TYPE_INT_RGB);
|
||||
private static final TexturePaint CHESS;
|
||||
|
||||
static {
|
||||
Graphics2D graphics = CHESS_IMAGE.createGraphics();
|
||||
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
graphics.setColor(JBColor.LIGHT_GRAY);
|
||||
graphics.fillRect(0, 0, SQUARE_SIZE + 1, SQUARE_SIZE + 1);
|
||||
graphics.setColor(JBColor.GRAY);
|
||||
graphics.fillRect(0, 0, SQUARE_SIZE / 2, SQUARE_SIZE / 2);
|
||||
graphics.fillRect(SQUARE_SIZE / 2, SQUARE_SIZE / 2, SQUARE_SIZE / 2, SQUARE_SIZE / 2);
|
||||
graphics.dispose();
|
||||
CHESS = new TexturePaint(CHESS_IMAGE, new Rectangle(0, 0, SQUARE_SIZE, SQUARE_SIZE));
|
||||
}
|
||||
|
||||
private final Color[] myColors;
|
||||
|
||||
public ColorsIcon(int size, @NotNull Color... colors) {
|
||||
super(size, size, Gray.TRANSPARENT, false);
|
||||
myColors = ArrayUtil.reverseArray(colors);
|
||||
}
|
||||
|
||||
protected ColorsIcon(ColorsIcon icon) {
|
||||
super(icon);
|
||||
myColors = icon.myColors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ColorsIcon copy() {
|
||||
return new ColorsIcon(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(final Component component, Graphics g, int x, int y) {
|
||||
Graphics2D g2d = (Graphics2D)g.create();
|
||||
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g2d);
|
||||
try {
|
||||
final int w = getIconWidth();
|
||||
final int h = getIconHeight();
|
||||
if (myColors.length == 2) {
|
||||
g2d.setPaint(getPaint(myColors[0]));
|
||||
g2d.fillPolygon(new int[]{x, x + w, x}, new int[]{y, y, y + h}, 3);
|
||||
g2d.setPaint(getPaint(myColors[1]));
|
||||
g2d.fillPolygon(new int[]{x + w, x + w, x}, new int[]{y, y + h, y + h}, 3);
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < myColors.length; i++) {
|
||||
g2d.setPaint(getPaint(myColors[i]));
|
||||
RectanglePainter.FILL.paint(g2d,
|
||||
i % 2 == 0 ? x : x + w / 2 + 1,
|
||||
i < 2 ? y : y + h / 2 + 1,
|
||||
w / 2 - 1,
|
||||
h / 2 - 1, null);
|
||||
if (i ==3) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
g2d.dispose();
|
||||
}
|
||||
finally {
|
||||
config.restore();
|
||||
}
|
||||
}
|
||||
|
||||
protected Paint getPaint(Color color) {
|
||||
return color == null || color.getAlpha() == 0 ? CHESS : color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
ColorsIcon icon = (ColorsIcon)o;
|
||||
|
||||
if (getIconWidth() != icon.getIconWidth()) return false;
|
||||
if (getIconHeight() != icon.getIconHeight()) return false;
|
||||
if (!Comparing.equal(myColors, icon.myColors)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + Arrays.hashCode(myColors);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -27,33 +27,17 @@ import java.awt.image.BufferedImage;
|
||||
/**
|
||||
* @author Vassiliy Kudryashov
|
||||
* @author Konstantin Bulenkov
|
||||
*
|
||||
* @deprecated use {@link com.intellij.util.ui.ColorsIcon} instead
|
||||
*/
|
||||
public class TwoColorsIcon extends ColorIcon {
|
||||
@NotNull private final Color mySecondColor;
|
||||
private static final int SQUARE_SIZE = JBUI.scale(6);
|
||||
private static final BufferedImage CHESS_IMAGE = UIUtil.createImage(SQUARE_SIZE, SQUARE_SIZE, BufferedImage.TYPE_INT_RGB);
|
||||
private static final TexturePaint CHESS;
|
||||
|
||||
static {
|
||||
Graphics2D graphics = CHESS_IMAGE.createGraphics();
|
||||
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
graphics.setColor(JBColor.LIGHT_GRAY);
|
||||
graphics.fillRect(0, 0, SQUARE_SIZE + 1, SQUARE_SIZE + 1);
|
||||
graphics.setColor(JBColor.GRAY);
|
||||
graphics.fillRect(0, 0, SQUARE_SIZE / 2, SQUARE_SIZE / 2);
|
||||
graphics.fillRect(SQUARE_SIZE / 2, SQUARE_SIZE / 2, SQUARE_SIZE / 2, SQUARE_SIZE / 2);
|
||||
graphics.dispose();
|
||||
CHESS = new TexturePaint(CHESS_IMAGE, new Rectangle(0, 0, SQUARE_SIZE, SQUARE_SIZE));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public class TwoColorsIcon extends ColorsIcon {
|
||||
public TwoColorsIcon(int size, @Nullable Color color1, @Nullable Color secondColor) {
|
||||
super(size, size, color1 != null ? color1 : Gray.TRANSPARENT, false);
|
||||
mySecondColor = secondColor != null ? secondColor : Gray.TRANSPARENT;
|
||||
super(size, color1, secondColor);
|
||||
}
|
||||
|
||||
protected TwoColorsIcon(TwoColorsIcon icon) {
|
||||
super(icon);
|
||||
mySecondColor = icon.mySecondColor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -61,49 +45,4 @@ public class TwoColorsIcon extends ColorIcon {
|
||||
public TwoColorsIcon copy() {
|
||||
return new TwoColorsIcon(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(final Component component, Graphics g, int x, int y) {
|
||||
Graphics2D g2d = (Graphics2D)g.create();
|
||||
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g2d);
|
||||
try {
|
||||
final int w = getIconWidth();
|
||||
final int h = getIconHeight();
|
||||
g2d.setPaint(getPaint(getIconColor()));
|
||||
g2d.fillPolygon(new int[]{x, x + w, x}, new int[]{y, y, y + h}, 3);
|
||||
g2d.setPaint(getPaint(mySecondColor));
|
||||
g2d.fillPolygon(new int[]{x + w, x + w, x}, new int[]{y, y + h, y + h}, 3);
|
||||
}
|
||||
catch (Exception e) {
|
||||
g2d.dispose();
|
||||
}
|
||||
finally {
|
||||
config.restore();
|
||||
}
|
||||
}
|
||||
|
||||
protected Paint getPaint(Color color) {
|
||||
return color == null || color.getAlpha() == 0 ? CHESS : color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
TwoColorsIcon icon = (TwoColorsIcon)o;
|
||||
|
||||
if (getIconWidth() != icon.getIconWidth()) return false;
|
||||
if (getIconHeight() != icon.getIconHeight()) return false;
|
||||
if (!mySecondColor.equals(icon.mySecondColor)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + mySecondColor.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user