Browse Source

Ensure default buttons don't get lost after theme change.

Ensure sliders are properly layed out after theme change.
Ensure title pane foreground color is correct after theme change.
pull/188/head
weisj 5 years ago
parent
commit
333f8a4b90
  1. 4
      core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java
  2. 2
      core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java
  3. 10
      core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java
  4. 4
      macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java
  5. 4
      property-loader/src/main/java/com/github/weisj/darklaf/icons/ToggleIcon.java
  6. 4
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java

4
core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettingsPanel.java

@ -40,6 +40,7 @@ import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.components.tristate.TristateCheckBox;
import com.github.weisj.darklaf.components.tristate.TristateState;
import com.github.weisj.darklaf.graphics.ThemedColor;
import com.github.weisj.darklaf.listener.UIUpdater;
import com.github.weisj.darklaf.platform.ThemePreferencesHandler;
import com.github.weisj.darklaf.platform.macos.theme.MacOSColors;
import com.github.weisj.darklaf.theme.Theme;
@ -491,11 +492,13 @@ public class ThemeSettingsPanel extends JPanel {
int tickSpacing = 25;
Dictionary<Integer, JComponent> dict = fontSlider.createStandardLabels(tickSpacing);
JLabel min = ((JLabel) dict.get(fontSlider.getMinimum()));
UIUpdater.registerComponent(min);
min.setText(resourceBundle.getString("label_font_smaller"));
min.setAlignmentX(JComponent.LEFT_ALIGNMENT);
min.putClientProperty(DarkSliderUI.KEY_MANUAL_LABEL_ALIGN, true);
JLabel mid = ((JLabel) dict.get(fontSlider.getMinimum() + tickSpacing));
UIUpdater.registerComponent(mid);
dict.remove(fontSlider.getMinimum() + tickSpacing);
dict.put(FontSizePreset.NORMAL.getPercentage(), mid);
mid.setText(resourceBundle.getString("label_font_default"));
@ -507,6 +510,7 @@ public class ThemeSettingsPanel extends JPanel {
max.setText(resourceBundle.getString("label_font_bigger"));
max.setAlignmentX(JComponent.RIGHT_ALIGNMENT);
max.putClientProperty(DarkSliderUI.KEY_MANUAL_LABEL_ALIGN, true);
UIUpdater.registerComponent(max);
dict.remove(FontSizePreset.Small.getPercentage());
dict.remove(FontSizePreset.SMALL.getPercentage());

2
core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java

@ -156,11 +156,13 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
@Override
protected void installListeners(final JRootPane root) {
root.addPropertyChangeListener(this);
root.addHierarchyListener(this);
}
@Override
protected void uninstallListeners(final JRootPane root) {
root.removePropertyChangeListener(this);
root.removeHierarchyListener(this);
}

10
core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java

@ -160,7 +160,15 @@ public class DarkSliderUI extends BasicSliderUI implements PropertyChangeListene
@Override
protected void calculateGeometry() {
super.calculateGeometry();
// Thumb size should be calculated before content rect.
calculateFocusRect();
calculateThumbSize();
calculateContentRect();
calculateTrackBuffer();
calculateTrackRect();
calculateTickRect();
calculateLabelRect();
calculateThumbLocation();
if (showVolumeIcon(slider)) {
calculateIconRect();
} else {

4
macos/src/main/java/com/github/weisj/darklaf/platform/macos/ui/MacOSTitlePane.java

@ -82,6 +82,10 @@ public class MacOSTitlePane extends CustomTitlePane {
inactiveBackground = UIManager.getColor("MacOS.TitlePane.inactiveBackground");
inactiveForeground = UIManager.getColor("MacOS.TitlePane.inactiveForeground");
border = UIManager.getColor("MacOS.TitlePane.borderColor");
// Ensure they don't get overwritten by ui updated.
activeForeground = new Color(activeForeground.getRGB());
inactiveForeground = new Color(inactiveForeground.getRGB());
}
@Override

4
property-loader/src/main/java/com/github/weisj/darklaf/icons/ToggleIcon.java

@ -46,6 +46,10 @@ public class ToggleIcon implements Icon {
this.active = active;
}
public boolean isActive() {
return active;
}
@Override
public void paintIcon(final Component c, final Graphics g, final int x, final int y) {
currentIcon().paintIcon(c, g, x, y);

4
windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java

@ -316,6 +316,10 @@ public class WindowsTitlePane extends CustomTitlePane {
inactiveHover = UIManager.getColor("Windows.TitlePane.inactiveBackgroundHover");
inactiveClick = UIManager.getColor("Windows.TitlePane.inactiveBackgroundClick");
border = UIManager.getColor("Windows.TitlePane.borderColor");
// Ensure they don't get overwritten by ui updated.
activeForeground = new Color(activeForeground.getRGB());
inactiveForeground = new Color(inactiveForeground.getRGB());
}
private void installDefaults() {

Loading…
Cancel
Save