From 6e2676556fe92586157e5af090e7a0f6f40272bf Mon Sep 17 00:00:00 2001 From: weisj Date: Sun, 16 Feb 2020 23:34:42 +0100 Subject: [PATCH] Replaced hard coded inset values with properties. Signed-off-by: weisj --- .../components/border/BubbleBorder.java | 7 ++--- .../darklaf/ui/button/DarkButtonBorder.java | 13 +++++++--- .../ui/checkbox/DarkCheckBoxBorder.java | 12 ++++++--- .../darklaf/ui/combobox/DarkComboBoxUI.java | 26 +++++++------------ .../ui/radiobutton/DarkRadioButtonBorder.java | 12 ++++++--- .../darklaf/ui/spinner/DarkSpinnerBorder.java | 8 ++++-- .../darklaf/ui/tabbedpane/MoreTabsButton.java | 9 ++++--- .../darklaf/ui/tabbedpane/NewTabButton.java | 2 +- .../darklaf/ui/tabframe/DarkPanelPopupUI.java | 5 ++-- .../darklaf/ui/text/DarkPasswordFieldUI.java | 23 +++++----------- .../weisj/darklaf/ui/text/DarkTextBorder.java | 17 +++++++----- .../darklaf/ui/text/DarkTextFieldUI.java | 15 ++++------- .../darklaf/ui/tree/DarkTreeCellBorder.java | 4 ++- .../github/weisj/darklaf/util/DarkUIUtil.java | 8 ++++++ .../weisj/darklaf/util/PropertyLoader.java | 19 +++++--------- .../properties/platform/mac.properties | 2 ++ .../darklaf/properties/ui/button.properties | 4 ++- .../darklaf/properties/ui/checkBox.properties | 3 ++- .../darklaf/properties/ui/comboBox.properties | 5 +++- .../properties/ui/radioButton.properties | 4 ++- .../darklaf/properties/ui/spinner.properties | 5 +++- .../darklaf/properties/ui/tabFrame.properties | 2 ++ .../properties/ui/tabbedPane.properties | 5 +++- .../darklaf/properties/ui/text.properties | 3 ++- .../darklaf/properties/ui/tree.properties | 4 ++- 25 files changed, 123 insertions(+), 94 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java b/core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java index 3d576281..78510a87 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java @@ -28,6 +28,7 @@ import com.github.weisj.darklaf.util.GraphicsContext; import com.github.weisj.darklaf.util.GraphicsUtil; import javax.swing.border.AbstractBorder; +import javax.swing.plaf.InsetsUIResource; import java.awt.*; import java.awt.geom.Area; import java.awt.geom.Path2D; @@ -74,7 +75,7 @@ public class BubbleBorder extends AbstractBorder { this.radius = radius; this.pointerSize = pointerSize; this.pointerWidth = pointerSize; - insets = new Insets(0, 0, 0, 0); + insets = new InsetsUIResource(0, 0, 0, 0); setThickness(thickness); } @@ -275,7 +276,7 @@ public class BubbleBorder extends AbstractBorder { @Override public Insets getBorderInsets(final Component c) { - return new Insets(insets.top, insets.left, insets.bottom, insets.right); + return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); } @@ -348,4 +349,4 @@ public class BubbleBorder extends AbstractBorder { pointer.closePath(); return pointer; } -} \ No newline at end of file +} diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java index fad90673..a8909064 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java @@ -57,6 +57,8 @@ public class DarkButtonBorder implements Border, UIResource { private Insets thinInsets; private Insets squareInsets; private Insets squareThinInsets; + private Insets labelInsets; + private Insets shadowInsets; public DarkButtonBorder() { shadowColor = UIManager.getColor("Button.shadow"); @@ -75,6 +77,8 @@ public class DarkButtonBorder implements Border, UIResource { thinInsets = UIManager.getInsets("Button.thinBorderInsets"); squareInsets = UIManager.getInsets("Button.squareBorderInsets"); squareThinInsets = UIManager.getInsets("Button.squareThinBorderInsets"); + labelInsets = UIManager.getInsets("Button.onlyLabelInsets"); + shadowInsets = UIManager.getInsets("Button.fullShadowInsets"); } @Override @@ -161,13 +165,16 @@ public class DarkButtonBorder implements Border, UIResource { } public Insets getBorderInsets(final Component c) { - if (DarkButtonUI.isFullShadow(c) || DarkButtonUI.isLabelButton(c)) { - return new InsetsUIResource(0, 0, 0, 0); + if (DarkButtonUI.isFullShadow(c)) { + return new InsetsUIResource(shadowInsets.top, shadowInsets.left, shadowInsets.bottom, shadowInsets.right); + } + if (DarkButtonUI.isLabelButton(c)) { + return new InsetsUIResource(labelInsets.top, labelInsets.left, labelInsets.bottom, labelInsets.right); } int shadow = DarkButtonUI.isShadowVariant(c) ? 0 : getShadowSize(); boolean square = DarkButtonUI.isSquare(c); Insets pad = isThin(c) ? square ? squareThinInsets : thinInsets - : square ? squareInsets : insets; + : square ? squareInsets : insets; return new InsetsUIResource(pad.top, pad.left, pad.bottom + shadow, pad.right); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxBorder.java index 029c262c..ebccbb3f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/checkbox/DarkCheckBoxBorder.java @@ -25,7 +25,6 @@ package com.github.weisj.darklaf.ui.checkbox; import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.platform.SystemInfo; import javax.swing.*; import javax.swing.border.Border; @@ -43,13 +42,18 @@ public class DarkCheckBoxBorder implements Border, UIResource { final int width, final int height) { } + private final Insets insets; + + public DarkCheckBoxBorder() { + insets = UIManager.getInsets("CheckBox.borderInsets"); + } + @Override public Insets getBorderInsets(final Component c) { if (isInCell(c)) { - return new Insets(0, 0, 0, 0); + return new InsetsUIResource(0, 0, 0, 0); } - final int a = SystemInfo.isMac ? 2 : 4; - return new InsetsUIResource(a, a, a, a); + return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); } protected static boolean isInCell(final Component c) { 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 fc55f146..8687d252 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 @@ -35,13 +35,7 @@ import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.basic.BasicComboBoxUI; import javax.swing.plaf.basic.ComboPopup; import java.awt.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -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; @@ -73,6 +67,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC protected Color arrowBackgroundStart; protected Color arrowBackgroundEnd; private Insets boxPadding; + private Insets cellPadding; public static ComponentUI createUI(final JComponent c) { @@ -83,7 +78,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC public void installUI(final JComponent c) { super.installUI(c); comboBox.setBorder(this); - boxPadding = UIManager.getInsets("ComboBox.padding"); + boxPadding = UIManager.getInsets("ComboBox.insets"); borderSize = UIManager.getInt("ComboBox.borderThickness"); background = UIManager.getColor("ComboBox.activeBackground"); editBackground = UIManager.getColor("ComboBox.editBackground"); @@ -94,6 +89,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC inactiveBorderColor = UIManager.getColor("ComboBox.inactiveBorderColor"); arrowBackgroundStart = UIManager.getColor("ComboBox.arrowBackgroundStart"); arrowBackgroundEnd = UIManager.getColor("ComboBox.arrowBackgroundEnd"); + cellPadding = UIManager.getInsets("ComboBox.cellEditorInsets"); } @Override @@ -265,14 +261,14 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC @Override protected Insets getInsets() { if (isTableCellEditor(comboBox)) { - return new Insets(2, 5, 2, 5); + return new InsetsUIResource(cellPadding.top, cellPadding.left, cellPadding.bottom, cellPadding.right); } if (comboBox.getComponentOrientation().isLeftToRight()) { - return new InsetsUIResource(borderSize + 4, borderSize + 6, - borderSize + 4, borderSize); + return new InsetsUIResource(borderSize + boxPadding.top, borderSize + boxPadding.left, + borderSize + boxPadding.bottom, borderSize); } else { - return new InsetsUIResource(borderSize + 4, borderSize, - borderSize + 4, borderSize + 6); + return new InsetsUIResource(borderSize + boxPadding.top, borderSize, + borderSize + boxPadding.bottom, borderSize + boxPadding.right); } } @@ -297,7 +293,6 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC boolean shouldValidate = c instanceof JPanel; Rectangle r = new Rectangle(bounds); - DarkUIUtil.applyInsets(r, boxPadding); if (isTableCellEditor(comboBox)) { r.x--; } @@ -409,7 +404,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC @Override public Insets getBorderInsets(final Component c) { if (isTableCellEditor(c) || isTreeCellEditor(c)) { - return new InsetsUIResource(0, 0, 0, 0); + return new InsetsUIResource(cellPadding.top, cellPadding.left, cellPadding.bottom, cellPadding.right); } return new InsetsUIResource(borderSize, borderSize, borderSize, borderSize); } @@ -429,7 +424,6 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements Border, PropertyC if ("componentOrientation".equals(key)) { comboBox.doLayout(); comboBox.repaint(); -// editor.setComponentOrientation(comboBox.getComponentOrientation()); } else if ("editable".equals(key)) { comboBox.repaint(); } else if ("JComboBox.isTableCellEditor".equals(key) || "JComboBox.isTreeCellEditor".equals(key)) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonBorder.java index 9743c840..82a953e1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/radiobutton/DarkRadioButtonBorder.java @@ -25,7 +25,6 @@ package com.github.weisj.darklaf.ui.radiobutton; import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.darklaf.platform.SystemInfo; import javax.swing.*; import javax.swing.border.Border; @@ -44,13 +43,18 @@ public class DarkRadioButtonBorder implements Border, UIResource { final int width, final int height) { } + private final Insets insets; + + public DarkRadioButtonBorder() { + insets = UIManager.getInsets("RadioButton.borderInsets"); + } + @Override public Insets getBorderInsets(final Component c) { if (isInCell(c)) { - return new Insets(0, 0, 0, 0); + return new InsetsUIResource(0, 0, 0, 0); } - final int a = SystemInfo.isMac ? 2 : 4; - return new InsetsUIResource(a, a, a, a); + return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); } protected static boolean isInCell(final Component c) { 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 2a51afa1..8056a050 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 @@ -43,6 +43,8 @@ public class DarkSpinnerBorder implements Border, UIResource { protected Color inactiveBorderColor; protected int arc; protected int borderSize; + protected Insets insets; + protected Insets cellInsets; public DarkSpinnerBorder() { focusBorderColor = UIManager.getColor("Spinner.focusBorderColor"); @@ -50,6 +52,8 @@ public class DarkSpinnerBorder implements Border, UIResource { inactiveBorderColor = UIManager.getColor("Spinner.inactiveBorderColor"); arc = UIManager.getInt("Spinner.arc"); borderSize = UIManager.getInt("Spinner.borderThickness"); + cellInsets = UIManager.getInsets("Spinner.cellEditorInsets"); + insets = UIManager.getInsets("Spinner.insets"); } @Override @@ -115,9 +119,9 @@ public class DarkSpinnerBorder implements Border, UIResource { @Override public Insets getBorderInsets(final Component c) { if (DarkSpinnerUI.isTableCellEditor(c) || DarkSpinnerUI.isTreeCellEditor(c)) { - return new InsetsUIResource(2, 5, 2, 5); + return new InsetsUIResource(cellInsets.top, insets.left, insets.bottom, insets.right); } - return new InsetsUIResource(7, 7, 7, 7); + return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/MoreTabsButton.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/MoreTabsButton.java index ff6bd551..872d9b2f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/MoreTabsButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/MoreTabsButton.java @@ -33,14 +33,15 @@ import java.awt.*; public class MoreTabsButton extends DarkTabAreaButton { protected final static String INFINITY = "\u221e"; - protected final static int PAD = 2; protected final Icon icon; protected DarkTabbedPaneUI ui; + protected final int pad; public MoreTabsButton(final DarkTabbedPaneUI ui) { super(ui); this.ui = ui; icon = ui.getMoreTabsIcon(); + pad = UIManager.getInt("TabbedPane.moreTabsButton.pad"); setIcon(EmptyIcon.create(icon.getIconWidth(), icon.getIconHeight())); putClientProperty("JButton.variant", "onlyLabel"); putClientProperty("JButton.square", true); @@ -57,7 +58,7 @@ public class MoreTabsButton extends DarkTabAreaButton { FontMetrics metrics = g.getFontMetrics(); String label = getLabelString(); int labelWidth = metrics.stringWidth(label); - int x = (getWidth() - (icon.getIconWidth() + labelWidth + PAD)) / 2 + PAD; + int x = (getWidth() - (icon.getIconWidth() + labelWidth + pad)) / 2 + pad; int y = (getHeight() - icon.getIconHeight()) / 2; @@ -78,7 +79,7 @@ public class MoreTabsButton extends DarkTabAreaButton { icon.paintIcon(this, g, x, y); config.restore(); config = GraphicsUtil.setupAntialiasing(g); - g.drawString(label, x + icon.getIconWidth() + PAD, y + icon.getIconHeight() - off); + g.drawString(label, x + icon.getIconWidth() + pad, y + icon.getIconHeight() - off); config.restore(); } @@ -92,7 +93,7 @@ public class MoreTabsButton extends DarkTabAreaButton { public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); FontMetrics metrics = getFontMetrics(getFont()); - size.width += metrics.stringWidth(getLabelString()) + 3 * PAD; + size.width += metrics.stringWidth(getLabelString()) + 3 * pad; return size; } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java index 0634ffe7..9e49d51b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java @@ -55,7 +55,7 @@ public class NewTabButton extends JPanel implements UIResource { button.putClientProperty("JButton.thin", Boolean.TRUE); button.setRolloverEnabled(true); button.setOpaque(false); - button.setMargin(new Insets(2, 2, 2, 2)); + button.setMargin(UIManager.getInsets("TabbedPane.newTabButton.insets")); return button; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java index 399f229d..ae7c5c50 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java @@ -36,7 +36,6 @@ import javax.swing.FocusManager; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.UIResource; import java.awt.*; import java.awt.event.AWTEventListener; @@ -375,10 +374,10 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe putClientProperty("JButton.alternativeArc", Boolean.TRUE); putClientProperty("JButton.variant", "shadow"); setRolloverEnabled(true); - setMargin(new InsetsUIResource(2, 2, 2, 2)); + setMargin(UIManager.getInsets("TabFramePopup.headerButton.insets")); setFocus(false); setOpaque(false); - context.setToolTipInsets(new Insets(2, 5, 2, 5)); + context.setToolTipInsets(UIManager.getInsets("TabFramePopup.headerButton.tooltipInsets")); } public void setFocus(final boolean focus) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java index 4a77b533..64ee9d41 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkPasswordFieldUI.java @@ -32,16 +32,7 @@ import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.text.JTextComponent; import java.awt.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; +import java.awt.event.*; import java.util.Arrays; /** @@ -50,8 +41,8 @@ import java.util.Arrays; */ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge { - protected static Icon show; - protected static Icon showPressed; + protected Icon show; + protected Icon showPressed; private final FocusListener focusListener = new FocusAdapter() { public void focusGained(final FocusEvent e) { getComponent().repaint(); @@ -185,24 +176,24 @@ public class DarkPasswordFieldUI extends DarkPasswordFieldUIBridge { return showPressed; } - public static boolean hasShowIcon(final Component c) { return c instanceof JPasswordField - && Boolean.TRUE.equals(((JComponent) c).getClientProperty("PasswordField.view")); + && Boolean.TRUE.equals(((JComponent) c).getClientProperty("PasswordField.view")); } private Point getShowIconCoord() { Rectangle r = getDrawingRect(getComponent()); int w = getShowIcon().getIconWidth(); - return new Point(r.x + r.width - w - DarkTextBorder.PADDING, r.y + (r.height - w) / 2); + Insets ins = DarkUIUtil.getBorderInsets(editor); + return new Point(r.x + r.width - w - ins.left, r.y + (r.height - w) / 2); } private boolean isOverEye(final Point p) { return showShowIcon() && DarkTextFieldUI.isOver(getShowIconCoord(), getShowIcon(), p); } - protected static Icon getShowIcon() { + protected Icon getShowIcon() { return show; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java index 12904e4d..7a5f0b10 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextBorder.java @@ -40,7 +40,6 @@ import java.awt.*; */ public class DarkTextBorder implements Border, UIResource { - public final static int PADDING = 4; private static final Border editorBorder = new TextFieldTableCellEditorBorder(); protected Color errorBorderColor; protected Color focusErrorBorderColor; @@ -52,6 +51,8 @@ public class DarkTextBorder implements Border, UIResource { protected int arc; protected int minimumArc; protected int searchArc; + protected Insets padding; + protected Icon showIcon; public DarkTextBorder() { focusErrorBorderColor = UIManager.getColor("TextField.border.focusError"); @@ -63,6 +64,8 @@ public class DarkTextBorder implements Border, UIResource { arc = UIManager.getInt("TextField.arc"); searchArc = UIManager.getInt("TextField.searchArc"); minimumArc = UIManager.getInt("TextField.minimumArc"); + padding = UIManager.getInsets("TextField.insets"); + showIcon = UIManager.getIcon("PasswordField.show.icon"); } public void paintBorder(final Component c, final Graphics g2, final int x, final int y, @@ -161,16 +164,16 @@ public class DarkTextBorder implements Border, UIResource { if (isCellEditor(c)) { return editorBorder.getBorderInsets(c); } - Insets insets = new Insets(borderSize + PADDING, borderSize + PADDING, - borderSize + PADDING, borderSize + PADDING); + Insets insets = new Insets(borderSize + padding.top, borderSize + padding.left, + borderSize + padding.bottom, borderSize + padding.right); if (DarkTextFieldUI.isSearchField(c)) { int searchWidth = DarkTextFieldUI.getSearchIcon(c).getIconWidth(); int clearWidth = DarkTextFieldUI.getClearIcon(false).getIconWidth(); - insets.left += PADDING + searchWidth; - insets.right += PADDING + clearWidth; + insets.left += padding.left + searchWidth; + insets.right += padding.right + clearWidth; } else if (DarkPasswordFieldUI.hasShowIcon(c)) { - int eyeWidth = DarkPasswordFieldUI.getShowIcon().getIconWidth(); - insets.right += PADDING + eyeWidth; + int eyeWidth = showIcon.getIconWidth(); + insets.right += padding.right + eyeWidth; } return insets; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java index 0f5d1d6f..7bf87da8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java @@ -35,14 +35,7 @@ import javax.swing.event.PopupMenuListener; import javax.swing.plaf.ComponentUI; import javax.swing.text.JTextComponent; import java.awt.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; +import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -170,7 +163,8 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh protected Point getSearchIconCoord() { Rectangle r = getDrawingRect(getComponent()); int w = getSearchIcon(getComponent()).getIconWidth(); - return new Point(r.x + DarkTextBorder.PADDING, r.y + (r.height - w) / 2); + Insets ins = DarkUIUtil.getBorderInsets(editor); + return new Point(r.x + ins.left, r.y + (r.height - w) / 2); } protected static Icon getSearchIcon(final Component c) { @@ -233,7 +227,8 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh protected Point getClearIconCoord() { Rectangle r = getDrawingRect(getComponent()); int w = getClearIcon(clearHovered).getIconWidth(); - return new Point(r.x + r.width - w - DarkTextBorder.PADDING, r.y + (r.height - w) / 2); + Insets ins = DarkUIUtil.getBorderInsets(editor); + return new Point(r.x + r.width - w - ins.left, r.y + (r.height - w) / 2); } protected void showSearchPopup() { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java index 722b4c33..f2d57f25 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java @@ -37,9 +37,11 @@ import java.awt.*; public class DarkTreeCellBorder implements Border, UIResource { protected Color borderColor; + protected Insets insets; public DarkTreeCellBorder() { borderColor = UIManager.getColor("Tree.editorBorderColor"); + insets = UIManager.getInsets("Tree.editorBorderInsets"); } @Override @@ -51,7 +53,7 @@ public class DarkTreeCellBorder implements Border, UIResource { @Override public Insets getBorderInsets(final Component c) { - return new InsetsUIResource(2, 5, 2, 5); + return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); } @Override 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 70d8fd4a..d6aaf3da 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 @@ -28,7 +28,9 @@ import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI; import sun.awt.SunToolkit; import javax.swing.*; +import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.InsetsUIResource; import javax.swing.table.TableCellRenderer; import javax.swing.tree.TreeCellRenderer; import java.awt.*; @@ -346,6 +348,12 @@ public final class DarkUIUtil { p.y = tmp; } + public static Insets getBorderInsets(final JComponent comp) { + Border border = comp.getBorder(); + if (border == null) return new InsetsUIResource(0, 0, 0, 0); + return border.getBorderInsets(comp); + } + public enum Outline { error { @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/util/PropertyLoader.java b/core/src/main/java/com/github/weisj/darklaf/util/PropertyLoader.java index 899c44a0..68571868 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/PropertyLoader.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/PropertyLoader.java @@ -35,13 +35,8 @@ import javax.swing.plaf.InsetsUIResource; import java.awt.*; import java.io.IOException; import java.io.InputStream; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; import java.util.List; -import java.util.Map; -import java.util.Properties; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; @@ -125,14 +120,14 @@ public final class PropertyLoader { } Object returnVal = new LoadError(); - if (key.endsWith("Insets")) { + if (key.endsWith("Insets") || key.endsWith(".insets")) { returnVal = parseInsets(value); } else if (!skipObjects - && (key.endsWith("Border") - || key.endsWith(".border") - || key.endsWith(".component") - || key.endsWith("Component") - || key.endsWith("Renderer"))) { + && (key.endsWith("Border") + || key.endsWith(".border") + || key.endsWith(".component") + || key.endsWith("Component") + || key.endsWith("Renderer"))) { return new ObjectRequest(key, value); } else if (key.endsWith(".font")) { returnVal = parseFont(value); diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties index aaba3013..afabc37d 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/platform/mac.properties @@ -18,3 +18,5 @@ Table.alternateRowColor = true Tree.alternateRowColor = true List.alternateRowColor = true FileChooser.listViewWindowsStyle = false +CheckBox.borderInsets = 2,2,2,2 +RadioButton.borderInsets = 2,2,2,2 diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties index cd1f4952..1a0e388d 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties @@ -52,6 +52,8 @@ Button.borderInsets = 8,16,8,16 Button.thinBorderInsets = 4,8,4,8 Button.squareThinBorderInsets = 4,4,4,4 Button.squareBorderInsets = 8,8,8,8 +Button.onlyLabelInsets = 0,0,0,0 +Button.fullShadowInsets = 0,0,0,0 Button.shadow.hover = %hoverHighlight -Button.shadow.click = %clickHighlight \ No newline at end of file +Button.shadow.click = %clickHighlight diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/checkBox.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/checkBox.properties index 5d5f1e13..8a54a342 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/checkBox.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/checkBox.properties @@ -37,6 +37,7 @@ CheckBox.selectionDisabledColor = %controlFillDisabled CheckBox.selectionFocusSelectedColor = %controlFillFocus CheckBox.arc = %arcSecondary CheckBox.borderThickness = %borderThickness +CheckBox.borderInsets = 4,4,4,4 #Icons CheckBox.unchecked.icon = control/checkBox.svg[themed](19,19) @@ -47,4 +48,4 @@ CheckBox.indeterminateDisabled.icon = control/checkBoxIndeterminateSelectedDisa CheckBox.indeterminateFocused.icon = control/checkBoxIndeterminateSelectedFocused.svg[themed](19,19) CheckBox.selected.icon = control/checkBoxSelected.svg[themed](19,19) CheckBox.selectedDisabled.icon = control/checkBoxSelectedDisabled.svg[themed](19,19) -CheckBox.selectedFocused.icon = control/checkBoxSelectedFocused.svg[themed](19,19) \ No newline at end of file +CheckBox.selectedFocused.icon = control/checkBoxSelectedFocused.svg[themed](19,19) 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 c46099cc..c0d61c83 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,7 +39,10 @@ ComboBox.selectionBackground = %highlightFillFocus ComboBox.arc = %arc ComboBox.borderThickness = %borderThickness ComboBox.selectionForeground = %textSelectionForeground +ComboBox.insets = 4,6,4,6 +ComboBox.cellEditorInsets = 2,5,2,5 + #Icons ComboBox.arrow.icon = navigation/arrowDown.svg[themed] -ComboBox.arrowInactive.icon = navigation/arrowDownDisabled.svg[themed] \ No newline at end of file +ComboBox.arrowInactive.icon = navigation/arrowDownDisabled.svg[themed] diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/radioButton.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/radioButton.properties index 5f17c557..22a02719 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/radioButton.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/radioButton.properties @@ -37,10 +37,12 @@ RadioButton.selectedBorderColor = %controlBorderSelected RadioButton.activeBorderColor = %controlBorder RadioButton.inactiveBorderColor = %controlBorderDisabled +RadioButton.borderInsets = 4,4,4,4 + #Icons RadioButton.unchecked.icon = control/radio.svg[themed](19,19) RadioButton.uncheckedDisabled.icon = control/radioDisabled.svg[themed](19,19) RadioButton.uncheckedFocused.icon = control/radioFocused.svg[themed](19,19) RadioButton.selected.icon = control/radioSelected.svg[themed](19,19) RadioButton.selectedDisabled.icon = control/radioSelectedDisabled.svg[themed](19,19) -RadioButton.selectedFocused.icon = control/radioSelectedFocused.svg[themed](19,19) \ No newline at end of file +RadioButton.selectedFocused.icon = control/radioSelectedFocused.svg[themed](19,19) 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 7932d3d8..bd46f451 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 @@ -38,6 +38,9 @@ Spinner.arrowButtonBorder = null Spinner.arc = %arc Spinner.borderThickness = %borderThickness +Spinner.cellEditorInsets = 2, 5, 2, 5 +Spinner.insets = 7, 7, 7, 7 + Spinner.plus.icon = misc/plus.svg[themed] Spinner.plusInactive.icon = misc/plus.svg[themed] Spinner.minus.icon = misc/minus.svg[themed] @@ -45,4 +48,4 @@ Spinner.minusInactive.icon = misc/minus.svg[themed] Spinner.arrowUp.icon = navigation/arrowUp.svg[themed] Spinner.arrowUpInactive.icon = navigation/arrowUpDisabled.svg[themed] Spinner.arrowDown.icon = navigation/arrowDown.svg[themed] -Spinner.arrowDownInactive.icon = navigation/arrowDownDisabled.svg[themed] \ No newline at end of file +Spinner.arrowDownInactive.icon = navigation/arrowDownDisabled.svg[themed] diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties index a8156d84..df1cf2ca 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties @@ -42,6 +42,8 @@ TabFramePopup.headerButtonFocusClickBackground = %clickHighlightColorful TabFramePopup.closeAccelerator = shift pressed ESCAPE TabFramePopup.closeTooltipText = Close (shift ESC) +TabFramePopup.headerButton.tooltipInsets = 2,5,2,5 +TabFramePopup.headerButton.insets = 2,2,2,2 TabFramePopup.minimumHeaderSize = null TabFramePopup.borderColor = %border diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabbedPane.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabbedPane.properties index e33eb867..4af4708d 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabbedPane.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabbedPane.properties @@ -47,7 +47,10 @@ TabbedPane.tabsOverlapBorder = false TabbedPane.labelShift = 0 TabbedPane.selectedLabelShift = 0 TabbedPane.selectedTabPadInsets = 0,0,0,0 -TabbedPane.tabAreaInsets = 0,0,0,0 +TabbedPane.tabAreaInsets = 0,0,0, + +TabbedPane.newTabButton.insets = 2,2,2,2 +TabbedPane.moreTabsButton.pad = 2 #Icons TabbedPane.newTab.icon = navigation/add.svg[themed] diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/text.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/text.properties index dfe69ce5..f282392d 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/text.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/text.properties @@ -40,6 +40,7 @@ TextField.inactiveBackground = %textBackgroundInactive TextField.background = %textBackground TextField.selectionBackground = %textSelectionBackground TextField.selectionForeground = %textSelectionForeground +TextField.insets = 4,4,4,4 TextField.arc = %arcSecondary TextField.minimumArc = %arcSecondary @@ -96,4 +97,4 @@ PasswordField.showPressed.icon = misc/eyeHovered.svg[themed] TextField.search.searchWithHistory.icon = navigation/searchWithHistory.svg[themed] TextField.search.search.icon = navigation/search.svg[themed] TextField.search.clear.icon = navigation/close.svg[themed] -TextField.search.clearHover.icon = navigation/closeHovered.svg[themed] \ No newline at end of file +TextField.search.clearHover.icon = navigation/closeHovered.svg[themed] diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tree.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tree.properties index a37d9824..bfd0c6e3 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tree.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/tree.properties @@ -49,6 +49,8 @@ Tree.alternateRowBackground = %backgroundAlternative Tree.renderBooleanAsCheckBox = true Tree.booleanRenderType = checkBox +Tree.editorBorderInsets = 2,5,2,5 + #Icons Tree.collapsedIcon = navigation/arrowRight.svg[themed] Tree.expandedIcon = navigation/arrowDown.svg[themed] @@ -63,4 +65,4 @@ Tree.collapsed.unselected.unfocused.icon = navigation/arrowRight.svg[themed] Tree.expanded.selected.focused.icon = navigation/arrowDownSelected.svg[themed] Tree.expanded.selected.unfocused.icon = navigation/arrowDown.svg[themed] Tree.expanded.unselected.focused.icon = navigation/arrowDown.svg[themed] -Tree.expanded.unselected.unfocused.icon = navigation/arrowDown.svg[themed] \ No newline at end of file +Tree.expanded.unselected.unfocused.icon = navigation/arrowDown.svg[themed]