Browse Source

Fixed foreground of selected togglebutton hard to read.

pull/127/head
weisj 5 years ago
parent
commit
5b7b947d23
  1. 4
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  2. 11
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkToggleButtonUI.java
  3. 1
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/toggleButton.properties

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

@ -122,7 +122,6 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g);
int mnemonicIndex = button.getDisplayedMnemonicIndex();
if (!model.isEnabled()) {
g.setColor(inactiveForeground);
mnemonicIndex = -1;
}
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, mnemonicIndex,
@ -149,6 +148,9 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
if (fg instanceof UIResource && isDefaultButton(button) && !isShadowVariant(button)) {
fg = defaultForeground;
}
if (fg instanceof UIResource && !button.getModel().isEnabled()) {
fg = inactiveForeground;
}
return fg;
}

11
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkToggleButtonUI.java

@ -31,6 +31,7 @@ import sun.swing.SwingUtilities2;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;
import java.beans.PropertyChangeListener;
@ -77,6 +78,7 @@ public class DarkToggleButtonUI extends DarkButtonUI {
protected Color inactiveSliderColor;
protected Color sliderBorderColor;
protected Color inactiveSliderBorderColor;
protected Color selectedForeground;
public static ComponentUI createUI(final JComponent c) {
@ -96,6 +98,7 @@ public class DarkToggleButtonUI extends DarkButtonUI {
inactiveSliderColor = UIManager.getColor("ToggleButton.disabledSliderKnobFillColor");
sliderBorderColor = UIManager.getColor("ToggleButton.sliderKnobBorderColor");
inactiveSliderBorderColor = UIManager.getColor("ToggleButton.disabledSliderKnobBorderColor");
selectedForeground = UIManager.getColor("ToggleButton.selectedForeground");
}
@Override
@ -115,6 +118,14 @@ public class DarkToggleButtonUI extends DarkButtonUI {
}
}
@Override
protected Color getForeground(final AbstractButton button) {
if (button.isSelected() && !isSlider(button) && button.getForeground() instanceof UIResource) {
return selectedForeground;
}
return super.getForeground(button);
}
protected Color getBackgroundColor(final JComponent c) {
AbstractButton b = (AbstractButton) c;
boolean rollOver = (b.isRolloverEnabled() || doConvertToShadow(b)) && (((JButton) c).getModel().isRollover());

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

@ -31,6 +31,7 @@ ToggleButton.sliderKnobFillColor = %controlFill
ToggleButton.sliderKnobBorderColor = %controlBorder
ToggleButton.disabledSliderKnobFillColor = %controlFillDisabled
ToggleButton.disabledSliderKnobBorderColor = %controlFillDisabled
ToggleButton.selectedForeground = %textContrastForeground
ToggleButton.inactiveFillColor = %widgetFill
ToggleButton.activeFillColor = %textForegroundInactive

Loading…
Cancel
Save