Browse Source

Fixes ColorUIResource#brighter and ColorUIResource#brighter not returning a ColorUIResource.

pull/154/head
weisj 5 years ago
parent
commit
0f6835c45e
  1. 5
      core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java
  2. 1
      core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java
  3. 58
      property-loader/src/main/java/com/github/weisj/darklaf/DarkColorUIResource.java
  4. 3
      property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java
  5. 1
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java

5
core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java

@ -29,8 +29,7 @@ import java.util.List;
import java.util.Properties;
import java.util.logging.Logger;
import javax.swing.plaf.ColorUIResource;
import com.github.weisj.darklaf.DarkColorUIResource;
import com.github.weisj.darklaf.color.DarkColorModelHSB;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.util.Pair;
@ -113,7 +112,7 @@ public class AccentColorAdjustmentTask extends ColorAdjustmentTask {
Color color = DarkColorModelHSB.getColorFromHSBValues(mapValue(hsbMatch[0], info.hAdj),
mapValue(hsbMatch[1], info.sAdj),
mapValue(hsbMatch[2], info.bAdj));
return new ColorUIResource(color);
return new DarkColorUIResource(color);
}
return obj;
}

1
core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java

@ -152,6 +152,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
@Override
protected void installDefaults() {
super.installDefaults();
LookAndFeel.installColors(tree, "Tree.background", "Tree.foreground");
selectionBackground = UIManager.getColor("Tree.unfocusedSelectionBackground");
focusSelectionBackground = UIManager.getColor("Tree.selectionBackground");
focusSelectedLineColor = UIManager.getColor("Tree.lineFocusSelected");

58
property-loader/src/main/java/com/github/weisj/darklaf/DarkColorUIResource.java

@ -0,0 +1,58 @@
/*
* MIT License
*
* Copyright (c) 2020 Jannis Weis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.weisj.darklaf;
import java.awt.*;
import javax.swing.plaf.ColorUIResource;
public class DarkColorUIResource extends ColorUIResource {
public DarkColorUIResource(final int r, final int g, final int b) {
super(r, g, b);
}
public DarkColorUIResource(final int rgb) {
super(rgb);
}
public DarkColorUIResource(final float r, final float g, final float b) {
super(r, g, b);
}
public DarkColorUIResource(final Color c) {
super(c);
}
@Override
public Color darker() {
return new DarkColorUIResource(super.darker());
}
@Override
public Color brighter() {
return new DarkColorUIResource(super.brighter());
}
}

3
property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java

@ -37,7 +37,6 @@ import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.swing.*;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.DimensionUIResource;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.InsetsUIResource;
@ -217,7 +216,7 @@ public final class PropertyLoader {
? Boolean.TRUE
: PropertyValue.FALSE.equalsIgnoreCase(value) ? Boolean.FALSE : null;
if (color != null && (value.length() == 6 || value.length() == 8)) {
return new ColorUIResource(color);
return new DarkColorUIResource(color);
} else if (invVal != null) {
return invVal;
} else if (boolVal != null) {

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

@ -782,6 +782,7 @@ public class WindowsTitlePane extends CustomTitlePane {
}
} else if (PropertyKey.TITLE.equals(name)) {
titleLabel.setText(pce.getNewValue() == null ? "" : pce.getNewValue().toString());
doLayout();
repaint();
} else if (PropertyKey.COMPONENT_ORIENTATION.equals(name)) {
revalidate();

Loading…
Cancel
Save