Provide fallback values for icon colors with System theme
This commit is contained in:
parent
2cb9b80815
commit
60b0926dd6
1 changed files with 65 additions and 10 deletions
|
@ -2,17 +2,17 @@ package the.bytecode.club.bytecodeviewer.gui.theme;
|
|||
|
||||
import com.github.weisj.darklaf.LafManager;
|
||||
import com.github.weisj.darklaf.listener.UIUpdater;
|
||||
import com.github.weisj.darklaf.theme.DarculaTheme;
|
||||
import com.github.weisj.darklaf.theme.HighContrastDarkTheme;
|
||||
import com.github.weisj.darklaf.theme.HighContrastLightTheme;
|
||||
import com.github.weisj.darklaf.theme.IntelliJTheme;
|
||||
import com.github.weisj.darklaf.theme.OneDarkTheme;
|
||||
import com.github.weisj.darklaf.theme.SolarizedDarkTheme;
|
||||
import com.github.weisj.darklaf.theme.SolarizedLightTheme;
|
||||
import com.github.weisj.darklaf.properties.icons.IconLoader;
|
||||
import com.github.weisj.darklaf.theme.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Properties;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import com.github.weisj.darklaf.theme.info.PresetIconRule;
|
||||
import com.github.weisj.darklaf.theme.spec.ColorToneRule;
|
||||
import org.checkerframework.checker.guieffect.qual.UI;
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.Configuration;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.SettingsDialog;
|
||||
|
@ -139,6 +139,13 @@ public enum LAFTheme
|
|||
if(darkLAF)
|
||||
failSafe();
|
||||
|
||||
if (!LafManager.isInstalled())
|
||||
{
|
||||
setupIconColors();
|
||||
// Invalidate themed icons
|
||||
IconLoader.updateThemeStatus(new Object());
|
||||
}
|
||||
|
||||
Configuration.showDarkLAFComponentIcons = darkLAF;
|
||||
|
||||
if(BytecodeViewer.viewer != null)
|
||||
|
@ -184,4 +191,52 @@ public enum LAFTheme
|
|||
UIUpdater.registerComponent(comp);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupIconColors()
|
||||
{
|
||||
Properties properties = new Properties();
|
||||
JTextComponent colorTemplateComponent = new JTextField();
|
||||
properties.put("textForeground", colorTemplateComponent.getForeground());
|
||||
colorTemplateComponent.setEnabled(false);
|
||||
properties.put("textForegroundInactive", colorTemplateComponent.getForeground());
|
||||
properties.put("textSelectionForeground", colorTemplateComponent.getSelectedTextColor());
|
||||
|
||||
new LightIconThemeSupplier().loadIconTheme(properties, UIManager.getDefaults(), IconLoader.get());
|
||||
|
||||
UIManager.getLookAndFeelDefaults().putAll(properties);
|
||||
}
|
||||
|
||||
private static class LightIconThemeSupplier extends Theme
|
||||
{
|
||||
|
||||
@Override
|
||||
protected PresetIconRule getPresetIconRule()
|
||||
{
|
||||
return PresetIconRule.LIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix()
|
||||
{
|
||||
return "DO NOT USE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return getPrefix();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends Theme> getLoaderClass()
|
||||
{
|
||||
return LightIconThemeSupplier.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorToneRule getColorToneRule()
|
||||
{
|
||||
return ColorToneRule.LIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue