Skip to content

Commit

Permalink
Load base icon colors for high contrast themes to make sure all value…
Browse files Browse the repository at this point in the history
…s are present.
  • Loading branch information
weisJ committed May 27, 2021
1 parent ceec942 commit b01ef6a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
7 changes: 6 additions & 1 deletion core/src/test/java/documentation/CreateUITable.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import javax.imageio.ImageIO;
Expand All @@ -50,6 +51,7 @@
import com.github.weisj.darklaf.parser.PrimitiveParser;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.util.ImageUtil;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.StringUtil;
import com.github.weisj.darklaf.util.SystemInfo;
import com.kitfox.svg.LinearGradient;
Expand All @@ -60,6 +62,8 @@

public class CreateUITable {

private static final Logger LOGGER = LogUtil.getLogger(CreateUITable.class);

private static final int SAMPLE_WIDTH = 150;
private static final int SAMPLE_HEIGHT = 25;

Expand All @@ -74,6 +78,7 @@ public class CreateUITable {

public static void main(final String[] args) throws IOException {
for (Theme theme : LafManager.getRegisteredThemes()) {
LOGGER.info("Creating defaults table for " + theme.getDisplayName());
createThemeDefaultsPage(theme);
}
}
Expand Down Expand Up @@ -260,7 +265,7 @@ private String parseImage(final String key, final Object value, final int ident)
}

private String createImage(final Object value, final String name, final Dimension size) throws IOException {
//noinspection ResultOfMethodCallIgnored
// noinspection ResultOfMethodCallIgnored
new File(workingFolder + "img/").mkdirs();
String fileName = "img/" + name + "_" + SystemInfo.getOsName() + ".png";
File imageFile = new File(workingFolder + fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import javax.swing.*;

import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.annotations.SynthesiseLaf;
import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.ContrastRule;
Expand All @@ -37,7 +38,7 @@ public class HighContrastDarkTheme extends Theme {

@Override
protected PresetIconRule getPresetIconRule() {
return PresetIconRule.NONE;
return PresetIconRule.DARK;
}

@Override
Expand Down Expand Up @@ -70,6 +71,14 @@ public ContrastRule getContrastRule() {
return ContrastRule.HIGH_CONTRAST;
}

@Override
public void loadIconTheme(Properties properties, UIDefaults currentDefaults) {
// First load base theme
super.loadIconTheme(properties, currentDefaults);
// Then customize using our own values.
PropertyLoader.putProperties(loadPropertyFile("icons"), properties, currentDefaults);
}

@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) {
super.customizeUIProperties(properties, currentDefaults);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import javax.swing.*;

import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.annotations.SynthesiseLaf;
import com.github.weisj.darklaf.theme.info.ColorToneRule;
import com.github.weisj.darklaf.theme.info.ContrastRule;
Expand All @@ -37,7 +38,7 @@ public class HighContrastLightTheme extends Theme {

@Override
protected PresetIconRule getPresetIconRule() {
return PresetIconRule.NONE;
return PresetIconRule.LIGHT;
}

@Override
Expand Down Expand Up @@ -70,6 +71,14 @@ public ContrastRule getContrastRule() {
return ContrastRule.HIGH_CONTRAST;
}

@Override
public void loadIconTheme(Properties properties, UIDefaults currentDefaults) {
// First load base theme
super.loadIconTheme(properties, currentDefaults);
// Then customize using our own values.
PropertyLoader.putProperties(loadPropertyFile("icons"), properties, currentDefaults);
}

@Override
public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) {
super.customizeUIProperties(properties, currentDefaults);
Expand Down

0 comments on commit b01ef6a

Please sign in to comment.