mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-171869 Win10 LaF fix combobox background and better textfield/combobox positioning
This commit is contained in:
@@ -25,6 +25,8 @@ import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.components.panels.Wrapper;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.MacUIUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -43,6 +45,7 @@ import java.awt.geom.Rectangle2D;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.ide.ui.laf.darcula.ui.TextFieldWithPopupHandlerUI.isSearchFieldWithHistoryPopup;
|
||||
import static com.intellij.ide.ui.laf.intellij.WinIntelliJTextFieldUI.HOVER_PROPERTY;
|
||||
import static com.intellij.util.ui.MacUIUtil.MAC_FILL_BORDER;
|
||||
import static javax.swing.SwingConstants.EAST;
|
||||
@@ -284,45 +287,72 @@ public class DarculaUIUtil {
|
||||
|
||||
@Override
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
g.setColor(c.getBackground());
|
||||
g.fillRect(x, y, width, height);
|
||||
if (isComboBoxEditor(c)) {
|
||||
g.setColor(c.getBackground());
|
||||
g.fillRect(x, y, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isComboBoxEditor(c) && UIUtil.getParentOfType(EditorTextField.class, c) != null) {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
g2.translate(x, y);
|
||||
if (UIUtil.getParentOfType(EditorTextField.class, c) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasFocus(editorTextField)) {
|
||||
g2.setColor(UIManager.getColor("TextField.focusedBorderColor"));
|
||||
} else if (editorTextField.isEnabled() &&
|
||||
editorComponent != null && editorComponent.getClientProperty(HOVER_PROPERTY) == Boolean.TRUE) {
|
||||
g2.setColor(UIManager.getColor("TextField.hoverBorderColor"));
|
||||
} else {
|
||||
g2.setColor(UIManager.getColor("TextField.borderColor"));
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
Rectangle r = new Rectangle(x, y, width, height);
|
||||
|
||||
if (!editorTextField.isEnabled()) {
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f));
|
||||
}
|
||||
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
int bw = JBUI.scale(1);
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
border.append(new Rectangle2D.Double(0, 0, width, height), false);
|
||||
border.append(new Rectangle2D.Double(bw, bw, width - bw*2, height - bw*2), false);
|
||||
|
||||
g2.fill(border);
|
||||
} finally {
|
||||
g2.dispose();
|
||||
if (UIUtil.getParentOfType(Wrapper.class, c) != null && isSearchFieldWithHistoryPopup(c)) {
|
||||
JBInsets.removeFrom(r, JBUI.insets(2, 0));
|
||||
}
|
||||
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
// Fill background area of border
|
||||
if (isBorderOpaque() || c.getParent() != null) {
|
||||
g2.setColor(c.getParent().getBackground());
|
||||
|
||||
Path2D borderArea = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
borderArea.append(r, false);
|
||||
|
||||
Rectangle innerRect = new Rectangle(r);
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(2));
|
||||
borderArea.append(innerRect, false);
|
||||
g2.fill(borderArea);
|
||||
}
|
||||
|
||||
// draw border itself
|
||||
if (hasFocus(editorTextField)) {
|
||||
g2.setColor(UIManager.getColor("TextField.focusedBorderColor"));
|
||||
} else if (editorTextField.isEnabled() &&
|
||||
editorComponent != null && editorComponent.getClientProperty(HOVER_PROPERTY) == Boolean.TRUE) {
|
||||
g2.setColor(UIManager.getColor("TextField.hoverBorderColor"));
|
||||
} else {
|
||||
g2.setColor(UIManager.getColor("TextField.borderColor"));
|
||||
}
|
||||
|
||||
if (!editorTextField.isEnabled()) {
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.47f));
|
||||
}
|
||||
|
||||
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
JBInsets.removeFrom(r, JBUI.insets(1));
|
||||
border.append(r, false);
|
||||
|
||||
Rectangle innerRect = new Rectangle(r);
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(1));
|
||||
border.append(innerRect, false);
|
||||
|
||||
g2.fill(border);
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return isComboBoxEditor(c) ? JBUI.insets(0, 5).asUIResource() : JBUI.insets(3, 5).asUIResource();
|
||||
return isComboBoxEditor(c) ? JBUI.insets(1, 6).asUIResource() : JBUI.insets(4, 6).asUIResource();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -17,10 +17,8 @@ package com.intellij.ide.ui.laf.intellij;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.ui.components.panels.Wrapper;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
@@ -88,9 +86,8 @@ public class WinIntelliJButtonBorder implements Border, UIResource {
|
||||
public Insets getBorderInsets(Component c) {
|
||||
if (c.getParent() instanceof ActionToolbar) {
|
||||
return JBUI.insets(4, 16).asUIResource();
|
||||
} else if (DarculaButtonUI.isSquare(c)) {
|
||||
int i = (UIUtil.getParentOfType(Wrapper.class, c) != null) ? 1 : 0;
|
||||
return JBUI.insets(i).asUIResource();
|
||||
} else if (isSquare(c)) {
|
||||
return JBUI.insets(1).asUIResource();
|
||||
} else if (DarculaButtonUI.isHelpButton((JComponent)c)) {
|
||||
return JBUI.insets(0, 0, 0, 10).asUIResource();
|
||||
} else {
|
||||
|
||||
+98
-95
@@ -20,7 +20,6 @@ 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.components.panels.Wrapper;
|
||||
import com.intellij.util.ui.JBDimension;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -35,7 +34,6 @@ import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
/**
|
||||
@@ -45,7 +43,7 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
private static final String HOVER_PROPERTY = "JComboBox.mouseHover";
|
||||
private static final String PRESSED_PROPERTY = "JComboBox.mousePressed";
|
||||
private static final Border DEFAULT_EDITOR_BORDER = JBUI.Borders.empty(1, 0);
|
||||
private static final int IN_PANEL_OFFSET = 1;
|
||||
private static final Dimension ARROW_BUTTON_SIZE = new JBDimension(21, 24); // Count borders
|
||||
|
||||
private MouseListener mouseListener;
|
||||
|
||||
@@ -75,7 +73,10 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
|
||||
propertyListener = (evt) -> {
|
||||
if("enabled".equals(evt.getPropertyName())) {
|
||||
setEditorTextFieldBackground();
|
||||
EditorTextField etf = UIUtil.findComponentOfType((JComponent)editor, EditorTextField.class);
|
||||
if (etf != null) {
|
||||
etf.setBackground(getComboBackground(true));
|
||||
}
|
||||
} else if ("editable".equals(evt.getPropertyName())) {
|
||||
if (evt.getNewValue() == Boolean.TRUE) {
|
||||
comboBox.removeMouseListener(mouseListener);
|
||||
@@ -111,14 +112,18 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
}
|
||||
}
|
||||
|
||||
g2.setColor(getComboBackground());
|
||||
resizeInPanel(r);
|
||||
JBInsets.removeFrom(r, JBUI.insets(1));
|
||||
g2.setColor(getComboBackground(editor != null && editor.isOpaque()));
|
||||
JBInsets.removeFrom(r, JBUI.insets(2));
|
||||
|
||||
if (!comboBox.isEnabled()) {
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.47f));
|
||||
}
|
||||
|
||||
g2.fill(r);
|
||||
|
||||
if (!comboBox.isEditable()) {
|
||||
hasFocus = comboBox.hasFocus();
|
||||
paintCurrentValue(g, rectangleForCurrentValue(), hasFocus);
|
||||
paintCurrentValue(g2, rectangleForCurrentValue(), hasFocus);
|
||||
}
|
||||
} finally {
|
||||
g2.dispose();
|
||||
@@ -128,18 +133,20 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
@Override protected Rectangle rectangleForCurrentValue() {
|
||||
int w = comboBox.getWidth();
|
||||
int h = comboBox.getHeight();
|
||||
Insets i = getInsets();
|
||||
int buttonSize = h - (i.top + i.bottom);
|
||||
Insets i = comboBox.getInsets();
|
||||
|
||||
int buttonWidth = h;
|
||||
if (arrowButton != null) {
|
||||
buttonSize = arrowButton.getWidth();
|
||||
buttonWidth = comboBox.getComponentOrientation().isLeftToRight() ?
|
||||
arrowButton.getWidth() - i.right: arrowButton.getWidth() - i.left;
|
||||
}
|
||||
|
||||
Rectangle rect = (comboBox.getComponentOrientation().isLeftToRight()) ?
|
||||
new Rectangle(i.left, i.top,
|
||||
w - (i.left + i.right + buttonSize),
|
||||
w - (i.left + i.right + buttonWidth),
|
||||
h - (i.top + i.bottom)) :
|
||||
new Rectangle(i.left + buttonSize, i.top,
|
||||
w - (i.left + i.right + buttonSize),
|
||||
new Rectangle(i.left + buttonWidth, i.top,
|
||||
w - (i.left + i.right + buttonWidth),
|
||||
h - (i.top + i.bottom));
|
||||
|
||||
if (editor instanceof JComponent) {
|
||||
@@ -155,12 +162,15 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
ListCellRenderer<Object> renderer = comboBox.getRenderer();
|
||||
Component c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
|
||||
|
||||
c.setBackground(getComboBackground());
|
||||
c.setFont(comboBox.getFont());
|
||||
c.setForeground(comboBox.isEnabled() ? UIManager.getColor("Label.foreground") : UIManager.getColor("Label.disabledForeground"));
|
||||
|
||||
if (c instanceof JComponent) {
|
||||
((JComponent)c).setBorder(DEFAULT_EDITOR_BORDER);
|
||||
}
|
||||
|
||||
// paint selection in table-cell-editor mode correctly
|
||||
boolean changeOpaque = c instanceof JComponent && isTableCellEditor(comboBox) && c.isOpaque();
|
||||
boolean changeOpaque = c instanceof JComponent && c.isOpaque();
|
||||
if (changeOpaque) {
|
||||
((JComponent)c).setOpaque(false);
|
||||
}
|
||||
@@ -181,12 +191,12 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
}
|
||||
}
|
||||
|
||||
private Color getComboBackground() {
|
||||
private Color getComboBackground(boolean opaque) {
|
||||
if (comboBox != null) {
|
||||
if (comboBox.isEnabled() && comboBox.isEditable()) {
|
||||
return UIManager.getColor("TextField.background");
|
||||
} else if (!comboBox.isEnabled()) {
|
||||
return UIManager.getColor("Button.background");
|
||||
return opaque ? UIManager.getColor("Button.background.opaque") : UIManager.getColor("Button.background");
|
||||
} else if (!comboBox.isEditable()) {
|
||||
if (isPressed()) {
|
||||
return UIManager.getColor("Button.intellij.native.pressedBackgroundColor");
|
||||
@@ -203,44 +213,34 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
JButton button = new BasicArrowButton(SwingConstants.SOUTH) {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new JBDimension(20, 22);
|
||||
return ARROW_BUTTON_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
int bw = JBUI.scale(1);
|
||||
Rectangle innerRect = new Rectangle(getSize());
|
||||
JBInsets.removeFrom(innerRect, getInsets());
|
||||
|
||||
// paint background
|
||||
Rectangle2D innerRect = new Rectangle2D.Double(bw, bw, getWidth() - bw*2, getHeight() - bw*2);
|
||||
if (comboBox.isEditable() && comboBox.isEnabled()) {
|
||||
if (isPressed()) {
|
||||
g2.setColor(UIManager.getColor("Button.intellij.native.pressedBackgroundColor"));
|
||||
} else if (comboBox.hasFocus() || isHover()) {
|
||||
g2.setColor(UIManager.getColor("Button.intellij.native.focusedBackgroundColor"));
|
||||
} else {
|
||||
g2.setColor(getComboBackground());
|
||||
g2.setColor(getComboBackground(false));
|
||||
}
|
||||
} else {
|
||||
g2.setColor(getComboBackground());
|
||||
g2.fill(innerRect);
|
||||
}
|
||||
|
||||
if (!comboBox.isEnabled()) {
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f));
|
||||
}
|
||||
|
||||
g2.fill(innerRect);
|
||||
|
||||
Icon icon = MacIntelliJIconCache.getIcon("comboDropTriangle", false, false, isEnabled());
|
||||
int x = (getWidth() - icon.getIconWidth()) / 2;
|
||||
int y = (getHeight() - icon.getIconHeight()) / 2 + JBUI.scale(1);
|
||||
icon.paintIcon(this, g2, x, y);
|
||||
|
||||
// paint border around button when combobox is editable
|
||||
if (comboBox.isEditable() && comboBox.isEnabled()) {
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
border.append(new Rectangle2D.Double(0, 0, getWidth(), getHeight()), false);
|
||||
Rectangle outerRect = new Rectangle(innerRect);
|
||||
JBInsets.addTo(outerRect, JBUI.insets(1));
|
||||
border.append(outerRect, false);
|
||||
border.append(innerRect, false);
|
||||
|
||||
if (getModel().isPressed()) {
|
||||
@@ -252,6 +252,15 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
}
|
||||
}
|
||||
|
||||
if (!comboBox.isEnabled()) {
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
|
||||
}
|
||||
|
||||
Icon icon = MacIntelliJIconCache.getIcon("comboDropTriangle", false, false, isEnabled());
|
||||
int x = JBUI.scale(5);
|
||||
int y = (getHeight() - icon.getIconHeight()) / 2;
|
||||
icon.paintIcon(this, g2, x, y);
|
||||
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
@@ -260,8 +269,8 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
|
||||
button.setOpaque(false);
|
||||
|
||||
int vOffset = inPanel() ? IN_PANEL_OFFSET : 0;
|
||||
button.setBorder(JBUI.Borders.empty(1 + vOffset, 0, 1 + vOffset, 1));
|
||||
button.setBorder(comboBox.getComponentOrientation().isLeftToRight() ?
|
||||
JBUI.Borders.empty(2, 1, 2, 2) : JBUI.Borders.empty(2, 2, 2, 1));
|
||||
buttonReleaseListener = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
@@ -293,11 +302,6 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
@Override
|
||||
protected JTextField createEditorComponent() {
|
||||
return new JTextField() {
|
||||
{
|
||||
setOpaque(false);
|
||||
setBorder(DEFAULT_EDITOR_BORDER);
|
||||
}
|
||||
|
||||
public void setText(String s) {
|
||||
if (getText().equals(s)) {
|
||||
return;
|
||||
@@ -306,17 +310,21 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
}
|
||||
|
||||
@Override public Color getBackground() {
|
||||
return getComboBackground();
|
||||
return getComboBackground(false);
|
||||
}
|
||||
@Override public void setBorder(Border border) {}
|
||||
|
||||
@Override public Border getBorder() {
|
||||
return DEFAULT_EDITOR_BORDER;
|
||||
}
|
||||
|
||||
@Override public Insets getInsets() {
|
||||
return DEFAULT_EDITOR_BORDER.getBorderInsets(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension size = super.getPreferredSize();
|
||||
return new Dimension(size.width, JBUI.scale(22));
|
||||
return new Dimension(size.width, Math.max(JBUI.scale(18), size.height));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -374,20 +382,13 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
if (etf != null) {
|
||||
etf.addFocusListener(editorFocusListener);
|
||||
etf.addMouseListener(editorHoverListener);
|
||||
etf.setBackground(getComboBackground(true));
|
||||
}
|
||||
}
|
||||
|
||||
((JComponent)editor).setBorder(DEFAULT_EDITOR_BORDER);
|
||||
((JComponent)editor).setOpaque(false);
|
||||
|
||||
setEditorTextFieldBackground();
|
||||
}
|
||||
}
|
||||
|
||||
private void setEditorTextFieldBackground() {
|
||||
EditorTextField etf = UIUtil.findComponentOfType((JComponent)editor, EditorTextField.class);
|
||||
if (etf != null && comboBox.isEditable()) {
|
||||
etf.setBackground(getComboBackground());
|
||||
JComponent jc = (JComponent)editor;
|
||||
jc.setBorder(DEFAULT_EDITOR_BORDER);
|
||||
jc.setOpaque(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,23 +421,20 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
if (comboBox == null || arrowButton == null) {
|
||||
return; //NPE on LaF change
|
||||
}
|
||||
|
||||
Rectangle r = new Rectangle(x, y, width, height);
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
|
||||
try {
|
||||
resizeInPanel(r);
|
||||
g2.translate(r.x, r.y);
|
||||
g2.translate(x, y);
|
||||
|
||||
checkFocus();
|
||||
if (Registry.is("ide.inplace.errors.outline") && comboBox.getClientProperty("JComponent.error.outline") == Boolean.TRUE) {
|
||||
DarculaUIUtil.paintErrorBorder(g2, r.width, r.height, 0, true, hasFocus);
|
||||
DarculaUIUtil.paintErrorBorder(g2, width, height, 0, true, hasFocus);
|
||||
} else if (comboBox.isEnabled()) {
|
||||
if (comboBox.isEditable()) {
|
||||
if (hasFocus) {
|
||||
@@ -455,36 +453,23 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
}
|
||||
} else {
|
||||
g2.setColor(UIManager.getColor("Button.intellij.native.borderColor"));
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f));
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.47f));
|
||||
}
|
||||
|
||||
|
||||
int bw = JBUI.scale(1);
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
border.append(new Rectangle2D.Double(0, 0, r.width, r.height), false);
|
||||
border.append(new Rectangle2D.Double(bw, bw, r.width - bw*2, r.height - bw*2), false);
|
||||
Rectangle outerRect = new Rectangle(width, height);
|
||||
JBInsets.removeFrom(outerRect, JBUI.insets(1));
|
||||
border.append(outerRect, false);
|
||||
|
||||
Rectangle innerRect = new Rectangle(outerRect);
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(1));
|
||||
border.append(innerRect, false);
|
||||
g2.fill(border);
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean inPanel() {
|
||||
return UIUtil.getParentOfType(Wrapper.class, comboBox) != null;
|
||||
}
|
||||
|
||||
private void resizeInPanel(Rectangle r) {
|
||||
if (inPanel()) {
|
||||
Insets i = comboBox.getInsets();
|
||||
r.y += i.top;
|
||||
r.height -= i.top + i.bottom;
|
||||
|
||||
int offset = JBUI.scale(IN_PANEL_OFFSET);
|
||||
r.x += offset;
|
||||
r.width -= offset;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isHover() {
|
||||
return comboBox != null && comboBox.getClientProperty(HOVER_PROPERTY) == Boolean.TRUE ||
|
||||
arrowButton != null && arrowButton.getClientProperty(HOVER_PROPERTY) == Boolean.TRUE;
|
||||
@@ -505,24 +490,16 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
arrowButton != null && arrowButton.getModel().isPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Insets getInsets() {
|
||||
boolean inPanel = inPanel();
|
||||
int vOffset = inPanel ? IN_PANEL_OFFSET : 0;
|
||||
int hOffset = 5 + (inPanel ? IN_PANEL_OFFSET : 0);
|
||||
return JBUI.insets(vOffset, hOffset, vOffset, 0).asUIResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return getInsets();
|
||||
return c.getComponentOrientation().isLeftToRight() ?
|
||||
JBUI.insets(2, 6, 2, 2).asUIResource() : JBUI.insets(2, 2, 2, 6).asUIResource();
|
||||
}
|
||||
|
||||
private Dimension getSizeWithButton(Dimension d) {
|
||||
Insets i = comboBox.getInsets();
|
||||
int iconWidth = JBUI.scale(20) + i.right;
|
||||
int iconHeight = JBUI.scale(22) + i.top + i.bottom;
|
||||
return new Dimension(Math.max(d.width + JBUI.scale(7), iconWidth), iconHeight);
|
||||
int width = ARROW_BUTTON_SIZE.width + i.left;
|
||||
return new Dimension(Math.max(d.width + JBUI.scale(10), width), ARROW_BUTTON_SIZE.height);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -535,6 +512,32 @@ public class WinIntelliJComboBoxUI extends DarculaComboBoxUI {
|
||||
return getSizeWithButton(super.getMinimumSize(c));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LayoutManager createLayoutManager() {
|
||||
return new ComboBoxLayoutManager() {
|
||||
@Override
|
||||
public void layoutContainer(Container parent) {
|
||||
JComboBox cb = (JComboBox)parent;
|
||||
|
||||
int buttonHeight = cb.getHeight();
|
||||
int buttonWidth = ARROW_BUTTON_SIZE.width;
|
||||
|
||||
if (arrowButton != null) {
|
||||
if (cb.getComponentOrientation().isLeftToRight()) {
|
||||
arrowButton.setBounds(cb.getWidth() - buttonWidth, 0, buttonWidth, buttonHeight);
|
||||
} else {
|
||||
arrowButton.setBounds(0, 0, buttonWidth, buttonHeight);
|
||||
}
|
||||
}
|
||||
|
||||
if (editor != null) {
|
||||
Rectangle er = rectangleForCurrentValue();
|
||||
editor.setBounds(er);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class ComboBoxMouseListener extends MouseAdapter {
|
||||
@Override public void mousePressed(MouseEvent e) {
|
||||
setPressedProperty(true);
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ public class WinIntelliJSpinnerUI extends DarculaSpinnerUI {
|
||||
}
|
||||
} else {
|
||||
g2.setColor(UIManager.getColor("Button.background"));
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f));
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.47f));
|
||||
}
|
||||
|
||||
g2.fill(outerRect);
|
||||
|
||||
+18
-11
@@ -20,16 +20,17 @@ 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.ui.components.panels.Wrapper;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import static com.intellij.ide.ui.laf.darcula.ui.TextFieldWithPopupHandlerUI.isSearchFieldWithHistoryPopup;
|
||||
import static com.intellij.ide.ui.laf.intellij.WinIntelliJTextFieldUI.HOVER_PROPERTY;
|
||||
import static com.intellij.ide.ui.laf.intellij.WinIntelliJTextFieldUI.adjustVerticalInsets;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
@@ -38,13 +39,13 @@ public class WinIntelliJTextBorder extends DarculaTextBorder {
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
if (isSearchFieldWithHistoryPopup(c)) {
|
||||
return JBUI.insets(3, 26, 3, 23).asUIResource();
|
||||
return JBUI.insets(4, 27, 4, 24).asUIResource();
|
||||
} else if (TextFieldWithPopupHandlerUI.isSearchField(c)) {
|
||||
return JBUI.insets(3, 20, 3, 23).asUIResource();
|
||||
return JBUI.insets(4, 21, 4, 24).asUIResource();
|
||||
} else if (c instanceof JTextField && c.getParent() instanceof ColorPanel) {
|
||||
return JBUI.insets(3, 3, 2, 2).asUIResource();
|
||||
} else {
|
||||
return JBUI.insets(3, 5).asUIResource();
|
||||
return JBUI.insets(4, 6).asUIResource();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +54,13 @@ public class WinIntelliJTextBorder extends DarculaTextBorder {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
Rectangle r = new Rectangle(x, y, width, height);
|
||||
adjustVerticalInsets(r, (JComponent)c);
|
||||
|
||||
g2.translate(r.x, r.y);
|
||||
if (UIUtil.getParentOfType(Wrapper.class, c) != null && isSearchFieldWithHistoryPopup(c)) {
|
||||
JBInsets.removeFrom(r, JBUI.insets(2, 0));
|
||||
}
|
||||
|
||||
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());
|
||||
@@ -71,16 +76,18 @@ public class WinIntelliJTextBorder extends DarculaTextBorder {
|
||||
}
|
||||
|
||||
if (!jc.isEnabled()) {
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f));
|
||||
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);
|
||||
|
||||
int bw = JBUI.scale(1);
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
border.append(new Rectangle2D.Double(0, 0, r.width, r.height), false);
|
||||
border.append(new Rectangle2D.Double(bw, bw, r.width - bw*2, r.height - bw*2), false);
|
||||
border.append(r, false);
|
||||
|
||||
Rectangle innerRect = new Rectangle(r);
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(1));
|
||||
border.append(innerRect, false);
|
||||
|
||||
g2.fill(border);
|
||||
}
|
||||
|
||||
+18
-14
@@ -66,6 +66,9 @@ public class WinIntelliJTextFieldUI extends DarculaTextFieldUI {
|
||||
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
Container parent = c.getParent();
|
||||
if (c.isOpaque() && parent != null) {
|
||||
g2.setColor(parent.getBackground());
|
||||
@@ -85,25 +88,22 @@ public class WinIntelliJTextFieldUI extends DarculaTextFieldUI {
|
||||
g2.setColor(c.isEnabled() ? c.getBackground() : UIManager.getColor("TextField.inactiveBackground"));
|
||||
|
||||
if (!c.isEnabled()) {
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.35f));
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.47f));
|
||||
}
|
||||
|
||||
Rectangle r = new Rectangle(c.getSize());
|
||||
adjustVerticalInsets(r, c);
|
||||
g2.fill(r);
|
||||
}
|
||||
JBInsets.removeFrom(r, JBUI.insets(2));
|
||||
|
||||
static void adjustVerticalInsets(Rectangle r, JComponent c) {
|
||||
if (UIUtil.getParentOfType(Wrapper.class, c) != null && isSearchFieldWithHistoryPopup(c)) {
|
||||
Insets i = c.getInsets();
|
||||
i.left = i.right = 0;
|
||||
JBInsets.removeFrom(r, i);
|
||||
JBInsets.removeFrom(r, JBUI.insets(2, 0));
|
||||
}
|
||||
|
||||
g2.fill(r);
|
||||
}
|
||||
|
||||
@Override public Dimension getPreferredSize(JComponent c) {
|
||||
Dimension size = super.getPreferredSize(c);
|
||||
size.height = JBUI.scale(22);
|
||||
size.height = Math.max(JBUI.scale(24), size.height);
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -115,17 +115,21 @@ public class WinIntelliJTextFieldUI extends DarculaTextFieldUI {
|
||||
searchIcon = IconLoader.findIcon("/com/intellij/ide/ui/laf/icons/search.png", DarculaTextFieldUI.class, true);
|
||||
}
|
||||
|
||||
int yOffset = isSearchFieldWithHistoryPopup(c) ? JBUI.scale(1) : 0;
|
||||
|
||||
searchIcon.paintIcon(c, g, JBUI.scale(4), (c.getHeight() - searchIcon.getIconHeight()) / 2 + yOffset);
|
||||
if (searchIcon != null) {
|
||||
int yOffset = isSearchFieldWithHistoryPopup(c) ? JBUI.scale(1) : 0;
|
||||
searchIcon.paintIcon(c, g, JBUI.scale(5), (c.getHeight() - searchIcon.getIconHeight()) / 2 + yOffset);
|
||||
}
|
||||
|
||||
if (hasText()) {
|
||||
Icon clearIcon = UIManager.getIcon("TextField.darcula.clear.icon");
|
||||
if (clearIcon == null) {
|
||||
clearIcon = IconLoader.findIcon("/com/intellij/ide/ui/laf/icons/clear.png", DarculaTextFieldUI.class, true);
|
||||
}
|
||||
clearIcon.paintIcon(c, g, c.getWidth() - clearIcon.getIconWidth() - JBUI.scale(4),
|
||||
(c.getHeight() - searchIcon.getIconHeight()) / 2);
|
||||
|
||||
if (clearIcon != null) {
|
||||
clearIcon.paintIcon(c, g, c.getWidth() - clearIcon.getIconWidth() - JBUI.scale(5),
|
||||
(c.getHeight() - clearIcon.getIconHeight()) / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ StatusBar.bottomColor=2c2c2c
|
||||
Button.border=com.intellij.ide.ui.laf.intellij.WinIntelliJButtonBorder
|
||||
ButtonUI=com.intellij.ide.ui.laf.intellij.WinIntelliJButtonUI
|
||||
Button.background=e3e3e3
|
||||
Button.background.opaque=ededed
|
||||
Button.disabledText=8a8a8a
|
||||
Button.intellij.native.borderColor=adadad
|
||||
Button.intellij.native.focusDottedRingColor=000000
|
||||
|
||||
Reference in New Issue
Block a user