mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Support semi-transparent colors in editor color schemes
GitOrigin-RevId: a733f5df2a0156724e0383ff1035f4ca991afe15
This commit is contained in:
committed by
intellij-monorepo-bot
parent
63b7bb0490
commit
cb8768af6a
@@ -28,7 +28,17 @@ public final class ColorDescriptor extends AbstractKeyDescriptor<ColorKey> {
|
||||
|
||||
public enum Kind {
|
||||
BACKGROUND,
|
||||
FOREGROUND
|
||||
FOREGROUND,
|
||||
BACKGROUND_WITH_TRANSPARENCY,
|
||||
FOREGROUND_WITH_TRANSPARENCY;
|
||||
|
||||
public boolean isBackground() {
|
||||
return this == BACKGROUND || this == BACKGROUND_WITH_TRANSPARENCY;
|
||||
}
|
||||
|
||||
public boolean isForeground() {
|
||||
return this == FOREGROUND || this == FOREGROUND_WITH_TRANSPARENCY;
|
||||
}
|
||||
}
|
||||
|
||||
private final Kind myKind;
|
||||
|
||||
+4
@@ -127,6 +127,10 @@ public abstract class ColorAndFontDescription extends TextAttributes implements
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTransparencyEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setBackgroundColor(Color col) {
|
||||
super.setBackgroundColor(col);
|
||||
|
||||
+14
-4
@@ -140,6 +140,15 @@ public class ColorAndFontDescriptionPanel extends JPanel implements OptionsPanel
|
||||
boolean isEnabled,
|
||||
boolean isChecked,
|
||||
@Nullable Color color) {
|
||||
updateColorChooser(checkBox, colorPanel, isEnabled, isChecked, color, false);
|
||||
}
|
||||
|
||||
private static void updateColorChooser(JCheckBox checkBox,
|
||||
ColorPanel colorPanel,
|
||||
boolean isEnabled,
|
||||
boolean isChecked,
|
||||
@Nullable Color color,
|
||||
boolean supportTransparency) {
|
||||
checkBox.setEnabled(isEnabled);
|
||||
checkBox.setSelected(isChecked);
|
||||
if (color != null) {
|
||||
@@ -148,6 +157,7 @@ public class ColorAndFontDescriptionPanel extends JPanel implements OptionsPanel
|
||||
else {
|
||||
colorPanel.setSelectedColor(JBColor.WHITE);
|
||||
}
|
||||
colorPanel.setSupportTransparency(supportTransparency);
|
||||
colorPanel.setEnabled(isChecked);
|
||||
}
|
||||
|
||||
@@ -175,17 +185,17 @@ public class ColorAndFontDescriptionPanel extends JPanel implements OptionsPanel
|
||||
}
|
||||
|
||||
updateColorChooser(myCbForeground, myForegroundChooser, description.isForegroundEnabled(),
|
||||
description.isForegroundChecked(), description.getForegroundColor());
|
||||
description.isForegroundChecked(), description.getForegroundColor(), description.isTransparencyEnabled());
|
||||
|
||||
updateColorChooser(myCbBackground, myBackgroundChooser, description.isBackgroundEnabled(),
|
||||
description.isBackgroundChecked(), description.getBackgroundColor());
|
||||
description.isBackgroundChecked(), description.getBackgroundColor(), description.isTransparencyEnabled());
|
||||
|
||||
updateColorChooser(myCbErrorStripe, myErrorStripeColorChooser, description.isErrorStripeEnabled(),
|
||||
description.isErrorStripeChecked(), description.getErrorStripeColor());
|
||||
description.isErrorStripeChecked(), description.getErrorStripeColor(), description.isTransparencyEnabled());
|
||||
|
||||
EffectType effectType = description.getEffectType();
|
||||
updateColorChooser(myCbEffects, myEffectsColorChooser, description.isEffectsColorEnabled(),
|
||||
description.isEffectsColorChecked(), description.getEffectColor());
|
||||
description.isEffectsColorChecked(), description.getEffectColor(), description.isTransparencyEnabled());
|
||||
|
||||
String name = ContainerUtil.reverseMap(myEffectsMap).get(effectType);
|
||||
myEffectsCombo.getModel().setSelectedItem(name);
|
||||
|
||||
+13
-6
@@ -800,6 +800,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
|
||||
private static class EditorSettingColorDescription extends ColorAndFontDescription {
|
||||
private final ColorKey myColorKey;
|
||||
@NotNull
|
||||
private final ColorDescriptor.Kind myKind;
|
||||
private final Color myInitialColor;
|
||||
|
||||
@@ -854,24 +855,24 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
|
||||
@Override
|
||||
public Color getExternalForeground() {
|
||||
return myKind == ColorDescriptor.Kind.FOREGROUND ? myColor : null;
|
||||
return myKind.isForeground() ? myColor : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExternalForeground(Color col) {
|
||||
if (myKind != ColorDescriptor.Kind.FOREGROUND) return;
|
||||
if (!myKind.isForeground()) return;
|
||||
if (myColor != null && myColor.equals(col)) return;
|
||||
myColor = col;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getExternalBackground() {
|
||||
return myKind == ColorDescriptor.Kind.BACKGROUND ? myColor : null;
|
||||
return myKind.isBackground() ? myColor : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExternalBackground(Color col) {
|
||||
if (myKind != ColorDescriptor.Kind.BACKGROUND) return;
|
||||
if (!myKind.isBackground()) return;
|
||||
if (myColor != null && myColor.equals(col)) return;
|
||||
myColor = col;
|
||||
}
|
||||
@@ -892,12 +893,18 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
|
||||
@Override
|
||||
public boolean isForegroundEnabled() {
|
||||
return myKind == ColorDescriptor.Kind.FOREGROUND;
|
||||
return myKind.isForeground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBackgroundEnabled() {
|
||||
return myKind == ColorDescriptor.Kind.BACKGROUND;
|
||||
return myKind.isBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransparencyEnabled() {
|
||||
return myKind == ColorDescriptor.Kind.BACKGROUND_WITH_TRANSPARENCY ||
|
||||
myKind == ColorDescriptor.Kind.FOREGROUND_WITH_TRANSPARENCY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,6 +41,7 @@ public class ColorPanel extends JComponent {
|
||||
private boolean myEditable;
|
||||
private ActionEvent myEvent;
|
||||
private Color myColor;
|
||||
private boolean mySupportTransparency;
|
||||
|
||||
public ColorPanel() {
|
||||
addImpl(myTextField, null, 0);
|
||||
@@ -62,7 +63,7 @@ public class ColorPanel extends JComponent {
|
||||
|
||||
public void onPressed() {
|
||||
if (myEditable && isEnabled()) {
|
||||
Color color = ColorChooser.chooseColor(this, UIBundle.message("color.panel.select.color.dialog.description"), myColor);
|
||||
Color color = ColorChooser.chooseColor(this, UIBundle.message("color.panel.select.color.dialog.description"), myColor, mySupportTransparency);
|
||||
if (color != null) {
|
||||
setSelectedColor(color);
|
||||
if (!myListeners.isEmpty() && (myEvent == null)) {
|
||||
@@ -165,6 +166,10 @@ public class ColorPanel extends JComponent {
|
||||
updateSelectedColor();
|
||||
}
|
||||
|
||||
public void setSupportTransparency(boolean supportTransparency) {
|
||||
mySupportTransparency = supportTransparency;
|
||||
}
|
||||
|
||||
private static class Painter implements Highlighter.HighlightPainter, PropertyChangeListener {
|
||||
private static final String PROPERTY = "highlighter";
|
||||
private static final Painter BACKGROUND = new Painter();
|
||||
|
||||
Reference in New Issue
Block a user