Auto-detect UI theme based on OS preference
This commit is contained in:
parent
e2993a68f9
commit
b1d0f8933b
@ -403,7 +403,8 @@ PreferencesOptionPanel.checkbox.windowInfo = Export window information (position
|
||||
PreferencesOptionPanel.checkbox.windowInfo.ttip = If unchecked, window information (position, size\u2026) will not be exported.
|
||||
|
||||
! UI Themes
|
||||
UITheme.Light = Light (Default)
|
||||
UITheme.Auto = Auto (detect)
|
||||
UITheme.Light = Light (default)
|
||||
UITheme.Dark = Dark
|
||||
|
||||
! Welcome dialog
|
||||
|
@ -11,6 +11,13 @@
|
||||
<classpathentry kind="lib" path="lib/iText-5.0.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jcommon-1.0.18.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jfreechart-1.0.15.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jSystemThemeDetector-3.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/oshi-core-6.4.4.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jna-5.13.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jna-platform-5.13.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/annotations-24.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jfa-1.2.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/versioncompare-1.4.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/darklaf/*.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jogl/gluegen-rt.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/OpenRocket Core"/>
|
||||
|
@ -5,6 +5,13 @@
|
||||
<libelement value="jar://$MODULE_DIR$/lib/iText-5.0.2.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/jcommon-1.0.18.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/jfreechart-1.0.15.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/jSystemThemeDetector-3.8.jar!/" />$
|
||||
<libelement value="jar://$MODULE_DIR$/lib/oshi-core-6.4.4.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/jna-5.13.0.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/jna-platform-5.13.0.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/annotations-24.0.1.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/jfa-1.2.0.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/versioncompare-1.4.1.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/darklaf/*.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/OrangeExtensions-1.2.jar!/" />
|
||||
<libelement value="jar://$MODULE_DIR$/lib/jogl/gluegen-rt.jar!/" />
|
||||
@ -109,9 +116,63 @@
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="flatlaf-3.1.1.jar">
|
||||
<library name="jSystemThemeDetector-3.8.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/flatlaf-3.1.1.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/jSystemThemeDetector-3.8.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="oshi-core-6.4.4.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/oshi-core-6.4.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="jna-5.13.0.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/jna-5.13.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="jna-platform-5.13.0.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/jna-platform-5.13.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="versioncompare-1.4.1.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/versioncompare-1.4.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="annotations-24.0.1.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/annotations-24.0.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="jfa-1.2.0.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/jfa-1.2.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
|
@ -116,6 +116,13 @@
|
||||
<zipfileset src="${core.dir}/lib/jaxb-runtime.2.3.1.jar"/>
|
||||
<zipfileset src="${lib.dir}/jcommon-1.0.18.jar"/>
|
||||
<zipfileset src="${lib.dir}/jfreechart-1.0.15.jar"/>
|
||||
<zipfileset src="${lib.dir}/jSystemThemeDetector-3.8.jar"/>
|
||||
<zipfileset src="${lib.dir}/oshi-core-6.4.4.jar"/>
|
||||
<zipfileset src="${lib.dir}/jna-5.13.0.jar"/>
|
||||
<zipfileset src="${lib.dir}/jna-platform-5.13.0.jar"/>
|
||||
<zipfileset src="${lib.dir}/annotations-24.0.1.jar"/>
|
||||
<zipfileset src="${lib.dir}/jfa-1.2.0.jar"/>
|
||||
<zipfileset src="${lib.dir}/versioncompare-1.4.1.jar"/>
|
||||
<zipfileset src="${lib.dir}/darklaf/darklaf-compatibility-3.0.3-SNAPSHOT.jar"/>
|
||||
<zipfileset src="${lib.dir}/darklaf/darklaf-core-3.0.3-SNAPSHOT.jar"/>
|
||||
<zipfileset src="${lib.dir}/darklaf/darklaf-iconset-3.0.3-SNAPSHOT.jar"/>
|
||||
|
BIN
swing/lib/annotations-24.0.1.jar
Normal file
BIN
swing/lib/annotations-24.0.1.jar
Normal file
Binary file not shown.
BIN
swing/lib/jSystemThemeDetector-3.8.jar
Normal file
BIN
swing/lib/jSystemThemeDetector-3.8.jar
Normal file
Binary file not shown.
BIN
swing/lib/jfa-1.2.0.jar
Normal file
BIN
swing/lib/jfa-1.2.0.jar
Normal file
Binary file not shown.
BIN
swing/lib/jna-5.13.0.jar
Normal file
BIN
swing/lib/jna-5.13.0.jar
Normal file
Binary file not shown.
BIN
swing/lib/jna-platform-5.13.0.jar
Normal file
BIN
swing/lib/jna-platform-5.13.0.jar
Normal file
Binary file not shown.
BIN
swing/lib/oshi-core-6.4.4.jar
Normal file
BIN
swing/lib/oshi-core-6.4.4.jar
Normal file
Binary file not shown.
BIN
swing/lib/versioncompare-1.4.1.jar
Normal file
BIN
swing/lib/versioncompare-1.4.1.jar
Normal file
Binary file not shown.
@ -76,6 +76,7 @@ public class AboutDialog extends JDialog {
|
||||
"Java library for parsing and rendering CommonMark" + href("https://github.com/commonmark/commonmark-java", true, true) + "<br>" +
|
||||
"RSyntaxTextArea" + href("http://bobbylight.github.io/RSyntaxTextArea", true, true) + "<br>" +
|
||||
"Darklaf (dark theme)" + href("https://github.com/weisJ/darklaf", true, true) + "<br>" +
|
||||
"jSystemThemeDetector" + href("https://github.com/Dansoftowner/jSystemThemeDetector", true, true) + "<br>" +
|
||||
"<br>" +
|
||||
"<b>OpenRocket gratefully acknowledges our use of the following databases:</b><br>" +
|
||||
"<br>" +
|
||||
|
@ -337,8 +337,8 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
||||
}
|
||||
|
||||
private UITheme.Theme getUIThemeAsTheme() {
|
||||
String themeName = getString(net.sf.openrocket.startup.Preferences.UI_THEME, UITheme.Themes.LIGHT.name());
|
||||
if (themeName == null) return UITheme.Themes.LIGHT; // Default theme
|
||||
String themeName = getString(net.sf.openrocket.startup.Preferences.UI_THEME, UITheme.Themes.AUTO.name());
|
||||
if (themeName == null) return UITheme.Themes.AUTO; // Default theme
|
||||
return UITheme.Themes.valueOf(themeName);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.sf.openrocket.gui.util;
|
||||
|
||||
import com.github.weisj.darklaf.LafManager;
|
||||
import com.github.weisj.darklaf.theme.DarculaTheme;
|
||||
import com.jthemedetecor.OsThemeDetector;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
@ -10,14 +11,17 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class UITheme {
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
@ -527,6 +531,243 @@ public class UITheme {
|
||||
log.warn("Unable to load RSyntaxTextArea theme", ioe);
|
||||
}
|
||||
}
|
||||
},
|
||||
AUTO {
|
||||
private final String displayName = trans.get("UITheme.Auto");
|
||||
|
||||
private Theme getCurrentTheme() {
|
||||
try {
|
||||
final OsThemeDetector detector = OsThemeDetector.getDetector();
|
||||
final boolean isDarkThemeUsed = detector.isDark();
|
||||
if (isDarkThemeUsed) {
|
||||
return Themes.DARK;
|
||||
} else {
|
||||
return Themes.LIGHT;
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
|
||||
return Themes.LIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTheme() {
|
||||
getCurrentTheme().applyTheme();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBackgroundColor() {
|
||||
return getCurrentTheme().getBackgroundColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBorderColor() {
|
||||
return getCurrentTheme().getBorderColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getTextColor() {
|
||||
return getCurrentTheme().getTextColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getDimTextColor() {
|
||||
return getCurrentTheme().getDimTextColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getTextSelectionForegroundColor() {
|
||||
return getCurrentTheme().getTextSelectionForegroundColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getTextSelectionBackgroundColor() {
|
||||
return getCurrentTheme().getTextSelectionBackgroundColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getWarningColor() {
|
||||
return getCurrentTheme().getWarningColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getDarkWarningColor() {
|
||||
return getCurrentTheme().getDarkWarningColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getRowBackgroundLighterColor() {
|
||||
return getCurrentTheme().getRowBackgroundLighterColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getRowBackgroundDarkerColor() {
|
||||
return getCurrentTheme().getRowBackgroundDarkerColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFlightDataTextActiveColor() {
|
||||
return getCurrentTheme().getFlightDataTextActiveColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFlightDataTextInactiveColor() {
|
||||
return getCurrentTheme().getFlightDataTextInactiveColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultBodyComponentColor() {
|
||||
return getCurrentTheme().getDefaultBodyComponentColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultTubeFinSetColor() {
|
||||
return getCurrentTheme().getDefaultTubeFinSetColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultFinSetColor() {
|
||||
return getCurrentTheme().getDefaultFinSetColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLaunchLugColor() {
|
||||
return getCurrentTheme().getDefaultLaunchLugColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultRailButtonColor() {
|
||||
return getCurrentTheme().getDefaultRailButtonColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultInternalComponentColor() {
|
||||
return getCurrentTheme().getDefaultInternalComponentColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultMassObjectColor() {
|
||||
return getCurrentTheme().getDefaultMassObjectColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultRecoveryDeviceColor() {
|
||||
return getCurrentTheme().getDefaultRecoveryDeviceColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultPodSetColor() {
|
||||
return getCurrentTheme().getDefaultPodSetColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultParallelStageColor() {
|
||||
return getCurrentTheme().getDefaultParallelStageColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getMotorBorderColor() {
|
||||
return getCurrentTheme().getMotorBorderColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getMotorFillColor() {
|
||||
return getCurrentTheme().getMotorFillColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getCGColor() {
|
||||
return getCurrentTheme().getCGColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getCPColor() {
|
||||
return getCurrentTheme().getCPColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getURLColor() {
|
||||
return getCurrentTheme().getURLColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getComponentTreeBackgroundColor() {
|
||||
return getCurrentTheme().getComponentTreeBackgroundColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getComponentTreeForegroundColor() {
|
||||
return getCurrentTheme().getComponentTreeForegroundColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFinPointGridMajorLineColor() {
|
||||
return getCurrentTheme().getFinPointGridMajorLineColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFinPointGridMinorLineColor() {
|
||||
return getCurrentTheme().getFinPointGridMinorLineColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFinPointPointColor() {
|
||||
return getCurrentTheme().getFinPointPointColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFinPointSelectedPointColor() {
|
||||
return getCurrentTheme().getFinPointSelectedPointColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getFinPointBodyLineColor() {
|
||||
return getCurrentTheme().getFinPointBodyLineColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getMassOverrideIcon() {
|
||||
return getCurrentTheme().getMassOverrideIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getMassOverrideSubcomponentIcon() {
|
||||
return getCurrentTheme().getMassOverrideSubcomponentIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getCGOverrideIcon() {
|
||||
return getCurrentTheme().getCGOverrideIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getCGOverrideSubcomponentIcon() {
|
||||
return getCurrentTheme().getCGOverrideSubcomponentIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getCDOverrideIcon() {
|
||||
return getCurrentTheme().getCDOverrideIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getCDOverrideSubcomponentIcon() {
|
||||
return getCurrentTheme().getCDOverrideSubcomponentIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Border getBorder() {
|
||||
return getCurrentTheme().getBorder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void formatScriptTextArea(RSyntaxTextArea textArea) {
|
||||
getCurrentTheme().formatScriptTextArea(textArea);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user