Browse Source

Fixed borders of JTabFrame not being applied correctly.

Fixed PopupColorChooser not being displayed.
Made ButtonConstants.KEY_SQUARE only affect the shape of the button without changing its arc.
ButtonConstants.VARIANT_BORDERLESS no longer leaves the default borderSize of space to the edge of the component. Use AbstractButton#setMargin instead.
pull/188/head
weisj 5 years ago
parent
commit
c62763702e
  1. 2
      core/src/main/java/com/github/weisj/darklaf/components/border/MutableLineBorder.java
  2. 4
      core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java
  3. 1
      core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java
  4. 20
      core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java
  5. 20
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java
  6. 32
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  7. 2
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java
  8. 2
      core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java
  9. 8
      core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java
  10. 3
      core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java
  11. 35
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java
  12. 4
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFramePopupHeaderBorder.java
  13. 3
      core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java
  14. 17
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java
  15. 1
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipConstants.java
  16. 3
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties
  17. 1
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/internalFrame.properties
  18. 2
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties
  19. 1
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabbedPane.properties
  20. 2
      core/src/test/java/ui/ComponentDemo.java

2
core/src/main/java/com/github/weisj/darklaf/components/border/MutableLineBorder.java

@ -83,7 +83,7 @@ public class MutableLineBorder extends AbstractBorder {
@Override
public Insets getBorderInsets(final Component c, final Insets insets) {
insets.left = getRight();
insets.left = getLeft();
insets.top = getTop();
insets.right = getRight();
insets.bottom = getBottom();

4
core/src/main/java/com/github/weisj/darklaf/components/color/PopupColorChooser.java

@ -35,6 +35,7 @@ import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.ui.DarkPopupFactory;
import com.github.weisj.darklaf.ui.tooltip.DarkToolTipUI;
import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder;
import com.github.weisj.darklaf.ui.tooltip.ToolTipConstants;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil;
@ -72,6 +73,7 @@ public class PopupColorChooser extends JToolTip {
@Override
public void updateUI() {
putClientProperty(DarkPopupFactory.KEY_FOCUSABLE_POPUP, true);
putClientProperty(DarkToolTipUI.KEY_STYLE, ToolTipConstants.VARIANT_BALLOON);
putClientProperty(DarkToolTipUI.KEY_CONTEXT, getContext());
super.updateUI();
setBackground(UIManager.getColor("ColorChooser.background"));
@ -154,7 +156,7 @@ public class PopupColorChooser extends JToolTip {
@Override
public String getTipText() {
return "";
return ToolTipConstants.NO_TEXT;
}
@Override

1
core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java

@ -190,7 +190,6 @@ public class SmallColorChooser extends JPanel {
c.getBlue()));
pipetteButton.putClientProperty(DarkButtonUI.KEY_THIN, Boolean.TRUE);
pipetteButton.putClientProperty(DarkButtonUI.KEY_SQUARE, Boolean.TRUE);
pipetteButton.putClientProperty(DarkButtonUI.KEY_ALT_ARC, Boolean.TRUE);
pipetteButton.setRolloverEnabled(true);
pipetteButton.setFocusable(false);
pipetteButton.setIcon(pipetteIcon);

20
core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java

@ -61,22 +61,17 @@ public interface ButtonConstants {
return PropertyUtil.getBooleanProperty(c, KEY_ALT_ARC);
}
static boolean isLabelButton(final Component c) {
return PropertyUtil.getBooleanProperty(c, KEY_VARIANT);
}
static int chooseArcWithBorder(final Component c, final int arc, final int minimum,
final int squareArc, final int borderSize) {
return chooseArc(c, arc, minimum, squareArc, c.getHeight() - 2 * borderSize);
final int altArc, final int borderSize) {
return chooseArc(c, arc, minimum, altArc, c.getHeight() - 2 * borderSize);
}
static int chooseArc(final Component c, final int arc, final int minimum,
final int squareArc, final int roundedArc) {
final int altArc, final int roundedArc) {
if (ButtonConstants.isNoArc(c)) return minimum;
if (ButtonConstants.isRound(c)) return roundedArc;
boolean square = ButtonConstants.isSquare(c);
boolean alt = ButtonConstants.chooseAlternativeArc(c);
return square ? alt ? arc : squareArc : alt ? squareArc : arc;
return alt ? altArc : arc;
}
static boolean isNoArc(final Component c) {
@ -99,12 +94,15 @@ public interface ButtonConstants {
static boolean isBorderlessVariant(final Component c) {
if (isBorderlessRectangular(c)) return true;
if (c instanceof JButton || c instanceof JToggleButton) {
return PropertyUtil.isPropertyEqual(c, KEY_VARIANT, VARIANT_BORDERLESS)
|| doConvertToBorderless((AbstractButton) c);
return isBorderless(c) || doConvertToBorderless((AbstractButton) c);
}
return false;
}
static boolean isBorderless(final Component c) {
return PropertyUtil.isPropertyEqual(c, KEY_VARIANT, VARIANT_BORDERLESS);
}
static boolean isBorderlessRectangular(final Component c) {
return PropertyUtil.isPropertyEqual(c, KEY_VARIANT, VARIANT_BORDERLESS_RECTANGULAR);
}

20
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java

@ -50,7 +50,7 @@ public class DarkButtonBorder implements Border, UIResource {
private final int arc;
private final int focusArc;
private final int squareFocusArc;
private final int squareArc;
private final int altArc;
private final int minimumArc;
private final int borderSize;
private final int shadowSize;
@ -58,7 +58,6 @@ public class DarkButtonBorder implements Border, UIResource {
private Insets thinInsets;
private Insets squareInsets;
private Insets squareThinInsets;
private Insets labelInsets;
private Insets borderlessRectangularInsets;
public DarkButtonBorder() {
@ -69,7 +68,7 @@ public class DarkButtonBorder implements Border, UIResource {
arc = UIManager.getInt("Button.arc");
focusArc = UIManager.getInt("Button.focusArc");
squareFocusArc = UIManager.getInt("Button.squareFocusArc");
squareArc = UIManager.getInt("Button.squareArc");
altArc = UIManager.getInt("Button.altArc");
minimumArc = UIManager.getInt("Button.minimumArc");
borderSize = UIManager.getInt("Button.borderThickness");
shadowSize = UIManager.getInt("Button.shadowHeight");
@ -77,18 +76,16 @@ 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");
borderlessRectangularInsets = UIManager.getInsets("Button.borderlessRectangularInsets");
if (insets == null) insets = new Insets(0, 0, 0, 0);
if (thinInsets == null) thinInsets = new Insets(0, 0, 0, 0);
if (squareThinInsets == null) squareThinInsets = new Insets(0, 0, 0, 0);
if (squareInsets == null) squareInsets = new Insets(0, 0, 0, 0);
if (borderlessRectangularInsets == null) borderlessRectangularInsets = new Insets(0, 0, 0, 0);
if (labelInsets == null) labelInsets = new Insets(0, 0, 0, 0);
}
public static boolean showDropShadow(final JComponent c) {
return showDropShadow(getCornerFlag(c));
return showDropShadow(getCornerFlag(c)) && !ButtonConstants.isBorderlessVariant(c);
}
public static boolean showDropShadow(final AlignmentExt a) {
@ -103,7 +100,7 @@ public class DarkButtonBorder implements Border, UIResource {
}
protected int getArc(final Component c) {
return ButtonConstants.chooseArcWithBorder(c, arc, 0, squareArc, getBorderSize());
return ButtonConstants.chooseArcWithBorder(c, arc, 0, altArc, getBorderSize());
}
protected int getFocusArc(final Component c) {
@ -129,7 +126,7 @@ public class DarkButtonBorder implements Border, UIResource {
@Override
public void paintBorder(final Component c, final Graphics g,
final int x, final int y, final int width, final int height) {
if (ButtonConstants.isBorderlessVariant(c) || ButtonConstants.isLabelButton(c)) {
if (ButtonConstants.isBorderlessVariant(c)) {
return;
}
Graphics2D g2 = (Graphics2D) g;
@ -298,10 +295,6 @@ public class DarkButtonBorder implements Border, UIResource {
borderlessRectangularInsets.bottom, borderlessRectangularInsets.right);
return getInsets(ins, margins);
}
if (ButtonConstants.isLabelButton(c)) {
Insets ins = new InsetsUIResource(labelInsets.top, labelInsets.left, labelInsets.bottom, labelInsets.right);
return getInsets(ins, margins);
}
boolean shadowVariant = ButtonConstants.isBorderlessVariant(c);
int shadow = shadowVariant ? 0 : getShadowSize();
boolean square = ButtonConstants.isSquare(c);
@ -314,9 +307,6 @@ public class DarkButtonBorder implements Border, UIResource {
}
protected Insets getInsets(final Insets ins, final Insets margin) {
if (margin != null && !(margin instanceof UIResource)) {
return margin;
}
return ins;
}

32
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

@ -80,7 +80,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
protected Color shadowColor;
protected AbstractButton button;
protected int arc;
protected int squareArc;
protected int altArc;
protected KeyListener keyListener;
public static ComponentUI createUI(final JComponent c) {
@ -116,7 +116,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
borderlessOutlineHover = UIManager.getColor("Button.borderless.outline.hover");
borderlessOutlineClick = UIManager.getColor("Button.borderless.outline.click");
arc = UIManager.getInt("Button.arc");
squareArc = UIManager.getInt("Button.squareArc");
altArc = UIManager.getInt("Button.altArc");
drawOutline = UIManager.getBoolean("Button.borderless.drawOutline");
}
@ -149,9 +149,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
public void paint(final Graphics g, final JComponent c) {
GraphicsContext config = new GraphicsContext(g);
AbstractButton b = (AbstractButton) c;
if (!ButtonConstants.isNoBackground(b)) {
paintButtonBackground(g, c);
}
paintButtonBackground(g, c);
prepareDelegate(b);
String text = layout(layoutDelegate, b, SwingUtilities2.getFontMetrics(b, g, layoutDelegate.getFont()),
@ -164,8 +162,8 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
protected void paintButtonBackground(final Graphics g, final JComponent c) {
Graphics2D g2 = (Graphics2D) g;
if (shouldDrawBackground(c)) {
AbstractButton b = (AbstractButton) c;
AbstractButton b = (AbstractButton) c;
if (shouldDrawBackground(b)) {
int arc = getArc(c);
int width = c.getWidth();
int height = c.getHeight();
@ -232,8 +230,6 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
if (isRolloverBorderless(b)) {
GraphicsUtil.setupAAPainting(g);
g.setColor(getBorderlessBackground(b));
boolean borderlessRectangular = ButtonConstants.isBorderlessRectangular(b);
if (!borderlessRectangular) DarkUIUtil.addInsets(margin, borderSize);
if (ButtonConstants.isBorderlessRectangular(b)) {
g.fillRect(margin.left, margin.top, width - margin.left - margin.right,
height - margin.top - margin.bottom);
@ -296,15 +292,14 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
DarkUIUtil.repaint(ButtonConstants.getNeighbour(KEY_BOTTOM_LEFT_NEIGHBOUR, button));
}
protected boolean shouldDrawBackground(final JComponent c) {
if (ButtonConstants.isLabelButton(c)) return false;
AbstractButton button = (AbstractButton) c;
protected boolean shouldDrawBackground(final AbstractButton c) {
if (ButtonConstants.isNoBackground(c)) return false;
Border border = c.getBorder();
return c.isEnabled() && border != null && button.isContentAreaFilled();
}
protected int getArc(final Component c) {
return ButtonConstants.chooseArc(c, arc, 0, squareArc, borderSize);
return ButtonConstants.chooseArc(c, arc, 0, altArc, borderSize);
}
protected Color getForeground(final AbstractButton button) {
@ -407,7 +402,12 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
public Dimension getPreferredSize(final JComponent c) {
AbstractButton b = (AbstractButton) c;
prepareDelegate(b);
return BasicGraphicsUtils.getPreferredButtonSize(layoutDelegate, b.getIconTextGap());
Dimension dim = BasicGraphicsUtils.getPreferredButtonSize(layoutDelegate, b.getIconTextGap());
if (ButtonConstants.isSquare(b)) {
int size = Math.max(dim.width, dim.height);
dim.setSize(size, size);
}
return dim;
}
protected void prepareDelegate(final AbstractButton b) {
@ -422,11 +422,11 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
@Override
public boolean contains(final JComponent c, final int x, final int y) {
if (ButtonConstants.isLabelButton(c)) {
if (ButtonConstants.isBorderlessRectangular(c)) {
return super.contains(c, x, y);
}
if (!(x >= 0 && x <= c.getWidth() && y >= 0 && y <= c.getHeight())) return false;
int bs = c.getBorder() instanceof DarkButtonBorder ? borderSize : 0;
int bs = c.getBorder() instanceof DarkButtonBorder && !ButtonConstants.isBorderless(c) ? borderSize : 0;
int arc = getArc(c);
hitArea.setRoundRect(bs, bs, c.getWidth() - 2 * bs, c.getHeight() - 2 * bs, arc, arc);
return hitArea.contains(x, y);

2
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java

@ -318,9 +318,7 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements
private JButton createPipetteButton() {
JButton pipetteButton = new JButton();
pipetteButton.putClientProperty(DarkButtonUI.KEY_THIN, Boolean.TRUE);
pipetteButton.putClientProperty(DarkButtonUI.KEY_SQUARE, Boolean.TRUE);
pipetteButton.putClientProperty(DarkButtonUI.KEY_ALT_ARC, Boolean.TRUE);
pipetteButton.setRolloverEnabled(true);
pipetteButton.setFocusable(false);

2
core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFileChooserUI.java

@ -345,8 +345,6 @@ public class DarkFileChooserUI extends DarkFileChooserUIBridge {
protected void setupButton(final AbstractButton button, final String accessibleName, final String tipText) {
button.putClientProperty(DarkButtonUI.KEY_NO_BORDERLESS_OVERWRITE, true);
button.putClientProperty(DarkButtonUI.KEY_SQUARE, true);
button.putClientProperty(DarkButtonUI.KEY_ALT_ARC, true);
button.putClientProperty(DarkButtonUI.KEY_SQUARE, true);
button.setAlignmentX(JComponent.LEFT_ALIGNMENT);
button.setAlignmentY(JComponent.CENTER_ALIGNMENT);
button.setToolTipText(tipText);

8
core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java

@ -62,6 +62,8 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane impl
private ToggleIcon maximizeIcon;
private ToggleIcon iconifyIcon;
private int buttonMarginPad;
private boolean useExternalMenuBar;
public DarkInternalFrameTitlePane(final JInternalFrame f) {
@ -132,6 +134,8 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane impl
buttonColorClick = UIManager.getColor("InternalFrameTitlePane.buttonClickColor");
border = UIManager.getColor("InternalFrameTitlePane.borderColor");
buttonMarginPad = UIManager.getInt("InternalFrameTitlePane.buttonPad");
}
@Override
@ -204,7 +208,7 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane impl
return frame.isSelected() ? selectedTitleColor : notSelectedTitleColor;
}
private static JButton createButton(final String accessibleName) {
private JButton createButton(final String accessibleName) {
JButton button = new JButtonUIResource() {
@Override
public boolean isRolloverEnabled() {
@ -216,7 +220,7 @@ public class DarkInternalFrameTitlePane extends BasicInternalFrameTitlePane impl
button.putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_BORDERLESS);
button.putClientProperty(DarkButtonUI.KEY_SQUARE, true);
button.putClientProperty(DarkButtonUI.KEY_THIN, true);
button.putClientProperty(DarkButtonUI.KEY_ALT_ARC, true);
button.setMargin(new Insets(buttonMarginPad, buttonMarginPad, buttonMarginPad, buttonMarginPad));
button.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName);
button.setText(null);
return button;

3
core/src/main/java/com/github/weisj/darklaf/ui/tabbedpane/NewTabButton.java

@ -57,8 +57,9 @@ public class NewTabButton extends JPanel implements UIResource {
button.setFocusable(false);
button.putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_BORDERLESS);
button.putClientProperty(DarkButtonUI.KEY_SQUARE, Boolean.TRUE);
button.putClientProperty(DarkButtonUI.KEY_ALT_ARC, Boolean.TRUE);
button.putClientProperty(DarkButtonUI.KEY_THIN, Boolean.TRUE);
int pad = UIManager.getInt("TabbedPane.newTabButton.pad");
button.setMargin(new Insets(pad, pad, pad, pad));
button.setRolloverEnabled(true);
button.setOpaque(false);
return button;

35
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java

@ -38,10 +38,7 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import com.github.weisj.darklaf.components.border.MutableLineBorder;
import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.PanelPopup;
import com.github.weisj.darklaf.components.tabframe.TabFramePopup;
import com.github.weisj.darklaf.components.tabframe.TabFramePopupUI;
import com.github.weisj.darklaf.components.tabframe.*;
import com.github.weisj.darklaf.components.uiresource.JLabelUIResource;
import com.github.weisj.darklaf.ui.button.DarkButtonUI;
import com.github.weisj.darklaf.ui.panel.DarkPanelUI;
@ -185,6 +182,7 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
super.uninstallUI(c);
uninstallComponents();
uninstallListeners();
popupComponent.removeAll();
popupComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
.remove(KeyStroke.getKeyStroke(accelerator));
popupComponent.getActionMap().remove(accelerator);
@ -274,11 +272,24 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
JTabFrame tabFrame = popupComponent.getTabFrame();
boolean[] status = tabFrame.getContentPane().getStatus();
Alignment alignment = popupComponent.getAlignment();
Insets insets = getBorderSize(alignment, status);
Insets insets = getBorderSize(tabFrame, alignment, status);
applyBorderInsets(insets);
Component component = popupComponent.getComponent();
popupComponent.doLayout();
popupComponent.repaint();
if (component != null && component != popupComponent) {
component.doLayout();
component.repaint();
}
if (header != null) {
Component headerParent = header.getParent();
if (headerParent != null) {
headerParent.doLayout();
headerParent.repaint();
}
}
if (notifyPeer) {
try {
Component peer = tabFrame.getPopupComponentAt(tabFrame.getPeer(popupComponent.getAlignment()));
@ -288,12 +299,12 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
}
}
protected Insets getBorderSize(final Alignment a, final boolean[] info) {
protected Insets getBorderSize(final JTabFrame tabFrame, final Alignment a, final boolean[] info) {
Insets insets = new Insets(0, 0, 0, 0);
switch (a) {
case NORTH :
case NORTH_EAST :
if (info[Alignment.NORTH.getIndex()] || info[Alignment.NORTH_EAST.getIndex()]) {
if (info[a.getIndex()] || info[tabFrame.getPeer(a).getIndex()]) {
insets.bottom = 1;
}
if (info[Alignment.NORTH.getIndex()] && a == Alignment.NORTH_EAST) {
@ -302,7 +313,7 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
return insets;
case SOUTH :
case SOUTH_WEST :
if (info[Alignment.SOUTH_WEST.getIndex()] || info[Alignment.SOUTH.getIndex()]) {
if (info[a.getIndex()] || info[tabFrame.getPeer(a).getIndex()]) {
insets.top = 1;
}
if (info[Alignment.SOUTH_WEST.getIndex()] && a == Alignment.SOUTH) {
@ -311,7 +322,7 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
return insets;
case EAST :
case SOUTH_EAST :
if (info[Alignment.EAST.getIndex()] || info[Alignment.SOUTH_EAST.getIndex()]) {
if (info[a.getIndex()] || info[tabFrame.getPeer(a).getIndex()]) {
insets.left = 1;
}
if (info[Alignment.EAST.getIndex()] && a == Alignment.SOUTH_EAST) {
@ -320,7 +331,7 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
return insets;
case WEST :
case NORTH_WEST :
if (info[Alignment.NORTH_WEST.getIndex()] || info[Alignment.WEST.getIndex()]) {
if (info[a.getIndex()] || info[tabFrame.getPeer(a).getIndex()]) {
insets.right = 1;
}
if (info[Alignment.NORTH_WEST.getIndex()] && a == Alignment.WEST) {
@ -365,12 +376,12 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
super(icon);
this.ui = ui;
putClientProperty(DarkButtonUI.KEY_SQUARE, true);
putClientProperty(DarkButtonUI.KEY_ALT_ARC, true);
putClientProperty(DarkButtonUI.KEY_THIN, true);
putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_BORDERLESS);
putClientProperty(ToolTipConstants.KEY_STYLE, ToolTipConstants.VARIANT_BALLOON);
setRolloverEnabled(true);
setMargin(UIManager.getInsets("TabFramePopup.headerButton.insets"));
Insets ins = UIManager.getInsets("TabFramePopup.headerButton.insets");
setMargin(new Insets(ins.top, ins.left, ins.bottom, ins.right));
setFocus(false);
setFocusable(false);
setOpaque(false);

4
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFramePopupHeaderBorder.java

@ -24,9 +24,9 @@
*/
package com.github.weisj.darklaf.ui.tabframe;
import javax.swing.plaf.BorderUIResource;
import javax.swing.border.EmptyBorder;
public class DarkTabFramePopupHeaderBorder extends BorderUIResource.EmptyBorderUIResource {
public class DarkTabFramePopupHeaderBorder extends EmptyBorder {
public DarkTabFramePopupHeaderBorder() {
super(1, 0, 1, 0);

3
core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java

@ -43,6 +43,7 @@ import javax.swing.text.JTextComponent;
import javax.swing.text.Keymap;
import com.github.weisj.darklaf.components.border.MarginBorderWrapper;
import com.github.weisj.darklaf.components.tooltip.ToolTipStyle;
import com.github.weisj.darklaf.graphics.GraphicsContext;
import com.github.weisj.darklaf.graphics.GraphicsUtil;
import com.github.weisj.darklaf.graphics.PaintUtil;
@ -52,6 +53,7 @@ import com.github.weisj.darklaf.ui.table.TextTableCellEditorBorder;
import com.github.weisj.darklaf.ui.text.action.DarkKeyTypedAction;
import com.github.weisj.darklaf.ui.text.action.ToggleInsertAction;
import com.github.weisj.darklaf.ui.text.popup.DarkTextPopupMenu;
import com.github.weisj.darklaf.ui.tooltip.ToolTipConstants;
import com.github.weisj.darklaf.ui.tree.DarkTreeUI;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyUtil;
@ -115,6 +117,7 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi
editor.setBorder(null);
}
if (editor != null) {
PropertyUtil.installProperty(editor, ToolTipConstants.KEY_STYLE, ToolTipStyle.PLAIN);
PropertyUtil.installBooleanProperty(editor, KEY_ROUNDED_SELECTION, "TextComponent.roundedSelection");
PropertyUtil.installBooleanProperty(editor, KEY_EXTEND_LINE_SELECTION,
getPropertyPrefix() + ".extendSelection");

17
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java

@ -170,7 +170,9 @@ public class DarkToolTipUI extends BasicToolTipUI implements PropertyChangeListe
@Override
public void paint(final Graphics g, final JComponent c) {
if (getTipText().isEmpty()) return;
if (getTipText().isEmpty()) {
return;
}
boolean isPlain = style == ToolTipStyle.PLAIN;
if (animationScheduled) {
startAnimation();
@ -205,11 +207,14 @@ public class DarkToolTipUI extends BasicToolTipUI implements PropertyChangeListe
g.setColor(c.getForeground());
String tipText = getTipText();
Insets insets = c.getInsets();
Rectangle paintTextR = new Rectangle(insets.left, insets.top,
size.width - (insets.left + insets.right),
size.height - (insets.top + insets.bottom));
PaintUtil.drawString(g, c, tipText, paintTextR);
// noinspection StringEquality
if (tipText != NO_TEXT) {
Insets insets = c.getInsets();
Rectangle paintTextR = new Rectangle(insets.left, insets.top,
size.width - (insets.left + insets.right),
size.height - (insets.top + insets.bottom));
PaintUtil.drawString(g, c, tipText, paintTextR);
}
}
protected String getTipText() {

1
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipConstants.java

@ -36,4 +36,5 @@ public interface ToolTipConstants {
String VARIANT_PLAIN_BALLOON = "plainBalloon";
String TIP_TEXT_PROPERTY = "tiptext";
String KEY_CONTEXT = "JToolTip.toolTipContext";
String NO_TEXT = "NO_TEXT";
}

3
core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties

@ -42,7 +42,7 @@ Button.activeFillColorRollOver = %hoverHighlight
Button.activeFillColorClick = %clickHighlight
Button.arc = %arc
Button.squareArc = 0
Button.altArc = 0
Button.focusArc = %arcFocus
Button.squareFocusArc = 0
Button.minimumArc = 0
@ -53,7 +53,6 @@ Button.borderInsets = 7,16,7,16
Button.thinBorderInsets = 4,8,4,8
Button.squareThinBorderInsets = 4,4,4,4
Button.squareBorderInsets = 7,7,7,7
Button.onlyLabelInsets = 0,0,0,0
Button.borderlessRectangularInsets = 0,0,0,0
Button.borderless.hover = %hoverHighlight

1
core/src/main/resources/com/github/weisj/darklaf/properties/ui/internalFrame.properties

@ -43,6 +43,7 @@ InternalFrameTitlePane.selectedButtonClickColor = %clickHighlightColorful
InternalFrameTitlePane.buttonColor = %background
InternalFrameTitlePane.buttonHoverColor = %hoverHighlight
InternalFrameTitlePane.buttonClickColor = %clickHighlight
InternalFrameTitlePane.buttonPad = 2
InternalFrame.activeTitleForeground = %textForeground
InternalFrame.inactiveTitleForeground = %textForegroundInactive

2
core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties

@ -45,7 +45,7 @@ TabFramePopup.closeAccelerator = shift pressed ESCAPE
TabFramePopup.closeTooltipText = Close (shift ESC)
TabFramePopup.headerButton.tooltipInsets = 5,5,5,5
TabFramePopup.headerButton.insets = 2,2,2,2
TabFramePopup.headerButton.insets = 1,1,1,1
TabFramePopup.minimumHeaderSize = null
TabFramePopup.borderColor = %border

1
core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabbedPane.properties

@ -57,6 +57,7 @@ TabbedPane.tabAreaInsets = 0,0,0,0
TabbedPane.moreTabsButton.fontSize = 8
TabbedPane.moreTabsButton.pad = 2
TabbedPane.newTabButton.pad = 2
#Icons
TabbedPane.newTab.icon = navigation/add.svg[themed]

2
core/src/test/java/ui/ComponentDemo.java

@ -39,12 +39,14 @@ import javax.swing.event.MenuListener;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.graphics.ImageUtil;
import com.github.weisj.darklaf.settings.ThemeSettings;
import com.github.weisj.darklaf.theme.IntelliJTheme;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.theme.info.PreferredThemeStyle;
public interface ComponentDemo {
static Theme getTheme() {
if (true) return new IntelliJTheme();
PreferredThemeStyle themeStyle = LafManager.getPreferredThemeStyle();
return LafManager.themeForPreferredStyle(new PreferredThemeStyle(themeStyle.getContrastRule(),
themeStyle.getColorToneRule()));

Loading…
Cancel
Save