diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java index 8687d252..58b756c2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java @@ -47,8 +47,6 @@ import java.beans.PropertyChangeListener; */ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyChangeListener { - private static final int BUTTON_PAD = 7; - private final MouseListener mouseListener = new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { @@ -69,7 +67,6 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC private Insets boxPadding; private Insets cellPadding; - public static ComponentUI createUI(final JComponent c) { return new DarkComboBoxUI(); } @@ -163,11 +160,14 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC } protected JButton createArrowButton() { + int buttonPad = UIManager.getInt("ComboBox.buttonPad"); JButton button = ArrowButton.createUpDownArrow(comboBox, - UIManager.getIcon("ComboBox.arrow.icon"), + new ComboIcon(comboBox, + UIManager.getIcon("ComboBox.arrowEditable.icon"), + UIManager.getIcon("ComboBox.arrow.icon")), UIManager.getIcon("ComboBox.arrowInactive.icon"), SwingConstants.SOUTH, true, false, - new Insets(0, BUTTON_PAD, 0, BUTTON_PAD)); + new Insets(0, buttonPad, 0, buttonPad)); button.setBorder(BorderFactory.createEmptyBorder()); button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); return button; @@ -325,7 +325,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC Area rect; Area iconRect; if (!isTableCellEditor && !isTreeCellEditor) { - rect = new Area(new RoundRectangle2D.Double(bSize, bSize, width - 2 * bSize, + rect = new Area(new RoundRectangle2D.Double(bSize - 1, bSize, width - 2 * bSize + 2, height - 2 * bSize, arc, arc)); iconRect = new Area(new Rectangle(off, 0, width, height)); } else { @@ -430,4 +430,36 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC comboBox.repaint(); } } + + private static class ComboIcon implements Icon { + + private final JComboBox box; + private final Icon editableIcon; + private final Icon icon; + + private ComboIcon(final JComboBox box, final Icon editableIcon, final Icon icon) { + this.box = box; + this.editableIcon = editableIcon; + this.icon = icon; + } + + private Icon getIcon() { + return box.isEditable() ? editableIcon : icon; + } + + @Override + public void paintIcon(final Component c, final Graphics g, final int x, final int y) { + getIcon().paintIcon(c, g, x, y); + } + + @Override + public int getIconWidth() { + return getIcon().getIconWidth(); + } + + @Override + public int getIconHeight() { + return getIcon().getIconHeight(); + } + } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java index 8056a050..bae16d44 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerBorder.java @@ -121,7 +121,8 @@ public class DarkSpinnerBorder implements Border, UIResource { if (DarkSpinnerUI.isTableCellEditor(c) || DarkSpinnerUI.isTreeCellEditor(c)) { return new InsetsUIResource(cellInsets.top, insets.left, insets.bottom, insets.right); } - return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); + return new InsetsUIResource(insets.top + borderSize, insets.left + borderSize, + insets.bottom + borderSize, insets.right + borderSize); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java index 3eeca669..65414919 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java @@ -35,12 +35,7 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicSpinnerUI; import java.awt.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; +import java.awt.event.*; import java.awt.geom.Area; import java.awt.geom.RoundRectangle2D; import java.beans.PropertyChangeEvent; @@ -52,7 +47,6 @@ import java.beans.PropertyChangeListener; */ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListener { - private static final int BUTTON_PAD = 7; private final FocusListener focusListener = new FocusAdapter() { @Override public void focusGained(final FocusEvent e) { @@ -204,7 +198,8 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe private JButton createArrow(final int direction) { - Insets insets = new Insets(0, BUTTON_PAD, 0, BUTTON_PAD); + int buttonPad = UIManager.getInt("Spinner.buttonPad"); + Insets insets = new Insets(0, buttonPad, 0, buttonPad); JButton button = ArrowButton.createUpDownArrow(spinner, getArrowIcon(direction), getArrowInactiveIcon(direction), direction, @@ -244,14 +239,7 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe int height = c.getHeight(); JComponent editor = spinner.getEditor(); if (editorComponent != null) { - if (!editorComponent.isEnabled()) { - if (compColor == null) { - compColor = editorComponent.getBackground(); - editorComponent.setBackground(getBackground(c)); - } else { - compColor = null; - } - } + editorComponent.setBackground(getBackground(c)); g.setColor(editorComponent.getBackground()); } else { ((Graphics2D) g).setPaint(getBackground(c)); @@ -292,7 +280,7 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe Rectangle bounds = prevButton.getBounds(); boolean leftToRight = spinner.getComponentOrientation().isLeftToRight(); int off = leftToRight ? bounds.x : bounds.x + bounds.width; - Area rect = new Area(new RoundRectangle2D.Double(bSize, bSize, width - 2 * bSize, height - 2 * bSize, + Area rect = new Area(new RoundRectangle2D.Double(bSize - 1, bSize - 1, width - 2 * bSize + 2, height - 2 * bSize + 1, arc, arc)); Area iconRect = new Area(new Rectangle(off, 0, width, height)); if (leftToRight) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java index 2b412086..5e87aa2f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java @@ -28,6 +28,7 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.ComponentUI; import javax.swing.text.Document; +import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.text.ParseException; @@ -54,6 +55,11 @@ public class DarkFormattedTextFieldUI extends DarkTextFieldUI implements Propert super.installUI(c); } + @Override + protected void paintBackground(final Graphics graphics) { + super.paintBackground(graphics); + } + @Override public void propertyChange(final PropertyChangeEvent evt) { super.propertyChange(evt); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java index 29c573c7..ee2b8ad7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java @@ -97,9 +97,14 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi @Override protected void paintBackground(final Graphics g) { - Container parent = editor.getParent(); - if (editor.isOpaque() && parent != null) { - g.setColor(parent.getBackground()); + if (editor.isOpaque()) { + Container parent = editor.getParent(); + if (parent != null) { + g.setColor(parent.getBackground()); + } + if (DarkTextBorder.isCellEditor(editor) || DarkUIUtil.isInCell(editor)) { + g.setColor(editor.getBackground()); + } g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); } @@ -113,6 +118,9 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi g.fillRect(ins.left, ins.top, editor.getWidth() - ins.left - ins.right, editor.getHeight() - ins.top - ins.bottom); } + } else { + g.setColor(editor.getBackground()); + g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java index f9d9e96d..d02f1a9f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java @@ -128,7 +128,9 @@ public final class DarkUIUtil { public static void fillRoundRect(final Graphics2D g, final float x, final float y, final float width, final float height, final int arc) { - g.fill(new RoundRectangle2D.Float(x, y, width, height, arc, arc)); + Stroke stroke = g.getStroke(); + float lw = stroke instanceof BasicStroke ? ((BasicStroke) stroke).getLineWidth() : 1; + g.fill(new RoundRectangle2D.Float(x - lw, y - lw, width + lw, height + lw, arc, arc)); } diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/comboBox.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/comboBox.properties index c0d61c83..3e6a1edc 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/comboBox.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/comboBox.properties @@ -39,10 +39,11 @@ ComboBox.selectionBackground = %highlightFillFocus ComboBox.arc = %arc ComboBox.borderThickness = %borderThickness ComboBox.selectionForeground = %textSelectionForeground -ComboBox.insets = 4,6,4,6 +ComboBox.insets = 2,2,2,2 ComboBox.cellEditorInsets = 2,5,2,5 - +ComboBox.buttonPad = 4 #Icons ComboBox.arrow.icon = navigation/arrowDown.svg[themed] +ComboBox.arrowEditable.icon = navigation/arrowDown.svg[themed] ComboBox.arrowInactive.icon = navigation/arrowDownDisabled.svg[themed] diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/spinner.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/spinner.properties index f2567969..74dacbe3 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/spinner.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/spinner.properties @@ -39,7 +39,8 @@ Spinner.arc = %arc Spinner.borderThickness = %borderThickness Spinner.cellEditorInsets = 2,5,2,5 -Spinner.insets = 7,7,7,7 +Spinner.insets = 2,2,2,2 +Spinner.buttonPad = 4 Spinner.plus.icon = misc/plus.svg[themed] Spinner.plusInactive.icon = misc/plus.svg[themed] diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_mac.properties b/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_mac.properties index 0c8b9d74..5232821a 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_mac.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_mac.properties @@ -23,11 +23,12 @@ # ComboBox.arrowBackgroundStart = 68B2FA ComboBox.arrowBackgroundEnd = 0E80FF -ComboBox.arrow.icon = navigation/arrowDownSelected.svg[themed] +ComboBox.arrow.icon = navigation/arrowDown.svg[themed] +ComboBox.arrowEditable.icon = navigation/arrowDownSelected.svg[themed] Spinner.arrowBackgroundStart = 68B2FA Spinner.arrowBackgroundEnd = 0E80FF Spinner.plus.icon = misc/plusSelected.svg[themed] Spinner.minus.icon = misc/minusSelected.svg[themed] Spinner.arrowUp.icon = navigation/arrowUpSelected.svg[themed] -Spinner.arrowDown.icon = navigation/arrowDownSelected.svg[themed] \ No newline at end of file +Spinner.arrowDown.icon = navigation/arrowDownSelected.svg[themed]