mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Enable registry-free textfield and combobox error validation outline
This commit is contained in:
@@ -62,8 +62,8 @@ public class DarculaUIUtil {
|
||||
private static final Color MAC_INACTIVE_ERROR_COLOR = new Color(0x80f7bcbc, true);
|
||||
private static final JBColor DEFAULT_INACTIVE_ERROR_COLOR = new JBColor(0xebbcbc, 0x725252);
|
||||
|
||||
private static final Color ACTIVE_ERROR_COLOR = new JBColor(() -> UIUtil.isUnderDefaultMacTheme() ? MAC_ACTIVE_ERROR_COLOR : DEFAULT_ACTIVE_ERROR_COLOR);
|
||||
private static final Color INACTIVE_ERROR_COLOR = new JBColor(() -> UIUtil.isUnderDefaultMacTheme() ? MAC_INACTIVE_ERROR_COLOR : DEFAULT_INACTIVE_ERROR_COLOR);
|
||||
public static final Color ACTIVE_ERROR_COLOR = new JBColor(() -> UIUtil.isUnderDefaultMacTheme() ? MAC_ACTIVE_ERROR_COLOR : DEFAULT_ACTIVE_ERROR_COLOR);
|
||||
public static final Color INACTIVE_ERROR_COLOR = new JBColor(() -> UIUtil.isUnderDefaultMacTheme() ? MAC_INACTIVE_ERROR_COLOR : DEFAULT_INACTIVE_ERROR_COLOR);
|
||||
|
||||
@SuppressWarnings("UseJBColor")
|
||||
private static final Color MAC_REGULAR_COLOR = new Color(0x80479cfc, true);
|
||||
|
||||
+3
-3
@@ -363,17 +363,17 @@ public class DarculaComboBoxUI extends BasicComboBoxUI implements Border, ErrorB
|
||||
paintCurrentValueBackground(g2, r, hasFocus);
|
||||
paintCurrentValue(g2, r, false);
|
||||
|
||||
Object eop = ((JComponent)c).getClientProperty("JComponent.error.outline");
|
||||
boolean hasError = ((JComponent)c).getClientProperty("JComponent.error.outline") == Boolean.TRUE;
|
||||
if (hasFocus) {
|
||||
g2.setClip(clip);
|
||||
if (Registry.is("ide.inplace.errors.outline") && Boolean.parseBoolean(String.valueOf(eop))) {
|
||||
if (hasError) {
|
||||
DarculaUIUtil.paintErrorBorder(g2, width, height, 0, true, true);
|
||||
} else {
|
||||
DarculaUIUtil.paintFocusRing(g2, new Rectangle(JBUI.scale(2), JBUI.scale(2), width - JBUI.scale(4), height - JBUI.scale(4)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (Registry.is("ide.inplace.errors.outline") && Boolean.parseBoolean(String.valueOf(eop))) {
|
||||
if (hasError) {
|
||||
DarculaUIUtil.paintErrorBorder(g2, width, height, 0, true, false);
|
||||
} else {
|
||||
g2.setColor(borderColor);
|
||||
|
||||
+1
-3
@@ -17,7 +17,6 @@ package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.ui.ErrorBorderCapable;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.ColorPanel;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -65,8 +64,7 @@ public class DarculaTextBorder implements Border, UIResource, ErrorBorderCapable
|
||||
try {
|
||||
g2.translate(x, y);
|
||||
|
||||
Object eop = ((JComponent)c).getClientProperty("JComponent.error.outline");
|
||||
if (Registry.is("ide.inplace.errors.outline") && Boolean.parseBoolean(String.valueOf(eop))) {
|
||||
if (((JComponent)c).getClientProperty("JComponent.error.outline") == Boolean.TRUE) {
|
||||
DarculaUIUtil.paintErrorBorder(g2, width, height, JBUI.scale(5), true, c.hasFocus());
|
||||
} else if (c.hasFocus()) {
|
||||
DarculaUIUtil.paintFocusRing(g2, new Rectangle(JBUI.scale(1), JBUI.scale(1), width - JBUI.scale(2), height - JBUI.scale(2)));
|
||||
|
||||
+1
-3
@@ -18,7 +18,6 @@ package com.intellij.ide.ui.laf.intellij;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.ide.ui.laf.darcula.ui.TextFieldWithPopupHandlerUI;
|
||||
import com.intellij.openapi.ui.ErrorBorderCapable;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.ColorPanel;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -83,8 +82,7 @@ public class MacIntelliJTextBorder implements Border, UIResource, ErrorBorderCap
|
||||
public void paint(Component c, Graphics2D g2, int width, int height, int arc) {
|
||||
clipForBorder(c, g2, width, height);
|
||||
|
||||
Object eop = ((JComponent)c).getClientProperty("JComponent.error.outline");
|
||||
if (Registry.is("ide.inplace.errors.outline") && Boolean.parseBoolean(String.valueOf(eop))) {
|
||||
if (((JComponent)c).getClientProperty("JComponent.error.outline") == Boolean.TRUE) {
|
||||
DarculaUIUtil.paintErrorBorder(g2, width, height, arc, isSymmetric(), isFocused(c));
|
||||
} else if (isFocused(c)) {
|
||||
DarculaUIUtil.paintFocusBorder(g2, width, height, arc, isSymmetric());
|
||||
|
||||
+16
-10
@@ -18,7 +18,6 @@ package com.intellij.ide.ui.laf.intellij;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaComboBoxUI;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.PopupMenuListenerAdapter;
|
||||
import com.intellij.util.ui.JBDimension;
|
||||
@@ -43,6 +42,9 @@ import java.awt.geom.Path2D;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.ACTIVE_ERROR_COLOR;
|
||||
import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.INACTIVE_ERROR_COLOR;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@@ -428,11 +430,14 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
|
||||
try {
|
||||
g2.translate(x, y);
|
||||
|
||||
checkFocus();
|
||||
if (Registry.is("ide.inplace.errors.outline") && comboBox.getClientProperty("JComponent.error.outline") == Boolean.TRUE) {
|
||||
DarculaUIUtil.paintErrorBorder(g2, width, height, 0, true, hasFocus);
|
||||
|
||||
Rectangle r = new Rectangle(x, y, width, height);
|
||||
int bw = 1;
|
||||
|
||||
if (comboBox.getClientProperty("JComponent.error.outline") == Boolean.TRUE) {
|
||||
g2.setColor(hasFocus ? ACTIVE_ERROR_COLOR : INACTIVE_ERROR_COLOR);
|
||||
bw = 2;
|
||||
} else if (comboBox.isEnabled()) {
|
||||
if (comboBox.isEditable()) {
|
||||
if (hasFocus) {
|
||||
@@ -449,20 +454,21 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
g2.setColor(UIManager.getColor("Button.intellij.native.borderColor"));
|
||||
}
|
||||
}
|
||||
JBInsets.removeFrom(r, JBUI.insets(1));
|
||||
} else {
|
||||
g2.setColor(UIManager.getColor("Button.intellij.native.borderColor"));
|
||||
|
||||
float alpha = comboBox.isEditable() ? 0.35f : 0.47f;
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
||||
|
||||
JBInsets.removeFrom(r, JBUI.insets(1));
|
||||
}
|
||||
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
Rectangle outerRect = new Rectangle(width, height);
|
||||
JBInsets.removeFrom(outerRect, JBUI.insets(1));
|
||||
border.append(outerRect, false);
|
||||
border.append(r, false);
|
||||
|
||||
Rectangle innerRect = new Rectangle(outerRect);
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(1));
|
||||
Rectangle innerRect = new Rectangle(r);
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(bw));
|
||||
border.append(innerRect, false);
|
||||
g2.fill(border);
|
||||
} finally {
|
||||
|
||||
+14
-6
@@ -16,6 +16,7 @@
|
||||
package com.intellij.ide.ui.laf.intellij;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaSpinnerBorder;
|
||||
import com.intellij.openapi.ui.ErrorBorderCapable;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
||||
@@ -23,7 +24,10 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Path2D;
|
||||
|
||||
public class WinIntelliJSpinnerBorder extends DarculaSpinnerBorder {
|
||||
import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.ACTIVE_ERROR_COLOR;
|
||||
import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.INACTIVE_ERROR_COLOR;
|
||||
|
||||
public class WinIntelliJSpinnerBorder extends DarculaSpinnerBorder implements ErrorBorderCapable {
|
||||
@Override
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
if (!(c instanceof JSpinner)) return;
|
||||
@@ -32,26 +36,30 @@ public class WinIntelliJSpinnerBorder extends DarculaSpinnerBorder {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
Rectangle r = new Rectangle(x, y, width, height);
|
||||
JBInsets.removeFrom(r, JBUI.insets(1, 1, 1, WinIntelliJSpinnerUI.BUTTON_WIDTH - 1));
|
||||
|
||||
boolean hover = spinner.getClientProperty(WinIntelliJSpinnerUI.HOVER_PROPERTY) == Boolean.TRUE;
|
||||
if (c.isEnabled()) {
|
||||
|
||||
int bw = 1;
|
||||
if (spinner.getClientProperty("JComponent.error.outline") == Boolean.TRUE) {
|
||||
g2.setColor(c.hasFocus() ? ACTIVE_ERROR_COLOR : INACTIVE_ERROR_COLOR);
|
||||
bw = 2;
|
||||
} else if (c.isEnabled()) {
|
||||
boolean hover = spinner.getClientProperty(WinIntelliJSpinnerUI.HOVER_PROPERTY) == Boolean.TRUE;
|
||||
if (DarculaSpinnerBorder.isFocused(c)) {
|
||||
g2.setColor(UIManager.getColor("TextField.focusedBorderColor"));
|
||||
} else {
|
||||
g2.setColor(UIManager.getColor(hover ? "TextField.hoverBorderColor" : "TextField.borderColor"));
|
||||
}
|
||||
JBInsets.removeFrom(r, JBUI.insets(1, 1, 1, WinIntelliJSpinnerUI.BUTTON_WIDTH - 1));
|
||||
} else {
|
||||
g2.setColor(UIManager.getColor("Button.intellij.native.borderColor"));
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f));
|
||||
JBInsets.removeFrom(r, JBUI.insets(1, 1, 1, WinIntelliJSpinnerUI.BUTTON_WIDTH - 1));
|
||||
}
|
||||
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
border.append(r, false);
|
||||
|
||||
Rectangle innerRect = new Rectangle(r);
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(1));
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(bw));
|
||||
border.append(innerRect, false);
|
||||
|
||||
g2.fill(border);
|
||||
|
||||
+25
-22
@@ -15,10 +15,8 @@
|
||||
*/
|
||||
package com.intellij.ide.ui.laf.intellij;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder;
|
||||
import com.intellij.ide.ui.laf.darcula.ui.TextFieldWithPopupHandlerUI;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.ColorPanel;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -27,6 +25,8 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Path2D;
|
||||
|
||||
import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.ACTIVE_ERROR_COLOR;
|
||||
import static com.intellij.ide.ui.laf.darcula.DarculaUIUtil.INACTIVE_ERROR_COLOR;
|
||||
import static com.intellij.ide.ui.laf.intellij.WinIntelliJTextFieldUI.HOVER_PROPERTY;
|
||||
import static com.intellij.ide.ui.laf.intellij.WinIntelliJTextFieldUI.adjustInWrapperRect;
|
||||
|
||||
@@ -46,7 +46,8 @@ public class WinIntelliJTextBorder extends DarculaTextBorder {
|
||||
|
||||
@Override
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
if (((JComponent)c).getClientProperty("JTextField.Search.noBorderRing") == Boolean.TRUE) return;
|
||||
JComponent jc = (JComponent)c;
|
||||
if (jc.getClientProperty("JTextField.Search.noBorderRing") == Boolean.TRUE) return;
|
||||
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
@@ -54,19 +55,19 @@ public class WinIntelliJTextBorder extends DarculaTextBorder {
|
||||
|
||||
adjustInWrapperRect(r, c);
|
||||
|
||||
JBInsets.removeFrom(r, JBUI.insets(1));
|
||||
|
||||
Object eop = ((JComponent)c).getClientProperty("JComponent.error.outline");
|
||||
if (Registry.is("ide.inplace.errors.outline") && Boolean.parseBoolean(String.valueOf(eop))) {
|
||||
DarculaUIUtil.paintErrorBorder(g2, r.width, r.height, 0, true, c.hasFocus());
|
||||
int bw = 1;
|
||||
if (jc.getClientProperty("JComponent.error.outline") == Boolean.TRUE) {
|
||||
g2.setColor(c.hasFocus() ? ACTIVE_ERROR_COLOR : INACTIVE_ERROR_COLOR);
|
||||
bw = 2;
|
||||
} else {
|
||||
//boolean editable = !(c instanceof JTextComponent) || ((JTextComponent)c).isEditable();
|
||||
JComponent jc = (JComponent)c;
|
||||
if (c.hasFocus()) {
|
||||
g2.setColor(UIManager.getColor("TextField.focusedBorderColor"));
|
||||
} else if (jc.getClientProperty(HOVER_PROPERTY) == Boolean.TRUE) {
|
||||
}
|
||||
else if (jc.getClientProperty(HOVER_PROPERTY) == Boolean.TRUE) {
|
||||
g2.setColor(UIManager.getColor("TextField.hoverBorderColor"));
|
||||
} else{
|
||||
}
|
||||
else {
|
||||
g2.setColor(UIManager.getColor(jc.isEnabled() ? "TextField.borderColor" : "Button.intellij.native.borderColor"));
|
||||
}
|
||||
|
||||
@@ -74,18 +75,20 @@ public class WinIntelliJTextBorder extends DarculaTextBorder {
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.47f));
|
||||
}
|
||||
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
border.append(r, false);
|
||||
|
||||
Rectangle innerRect = new Rectangle(r);
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(1));
|
||||
border.append(innerRect, false);
|
||||
|
||||
g2.fill(border);
|
||||
JBInsets.removeFrom(r, JBUI.insets(1));
|
||||
}
|
||||
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
border.append(r, false);
|
||||
|
||||
Rectangle innerRect = new Rectangle(r);
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(bw));
|
||||
border.append(innerRect, false);
|
||||
|
||||
g2.fill(border);
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user