Browse Source

Fixed layout for square icon only buttons.

pull/109/head
weisj 5 years ago
parent
commit
e7d1b01e4e
  1. 16
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  2. 2
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties

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

@ -222,17 +222,19 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
viewRect.y = i.top;
viewRect.width = width - (i.right + viewRect.x);
viewRect.height = height - (i.bottom + viewRect.y);
if (isSquare(c) && isIconOnly(b)) {
int size = Math.min(viewRect.width, viewRect.height);
viewRect.width = viewRect.height = size;
}
textRect.x = textRect.y = textRect.width = textRect.height = 0;
iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
// layout the text and icon
return SwingUtilities.layoutCompoundLabel(
b, fm, b.getText(), b.getIcon(),
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewRect, iconRect, textRect,
b.getText() == null ? 0 : b.getIconTextGap());
return SwingUtilities.layoutCompoundLabel(b, fm, b.getText(), b.getIcon(),
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewRect, iconRect, textRect,
b.getText() == null || isIconOnly(b) ? 0 : b.getIconTextGap());
}
protected void paintText(final Graphics g, final AbstractButton b, final JComponent c, final String text) {

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

@ -48,7 +48,7 @@ Button.borderThickness = %borderThickness
Button.shadowHeight = %shadowHeight
Button.rolloverEnabled = false
Button.borderInsets = 6,16,7,16
Button.borderInsets = 7,16,7,16
Button.thinBorderInsets = 4,8,4,8
Button.squareThinBorderInsets = 4,4,4,4
Button.squareBorderInsets = 6,6,6,6

Loading…
Cancel
Save