Merge pull request #2535 from SiboVG/ui-improvements

Small UI improvements
This commit is contained in:
Sibo Van Gool 2024-08-12 22:27:31 +02:00 committed by GitHub
commit 4c8abd14bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 25 additions and 15 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<install4j version="10.0.4" transformSequenceNumber="10"> <install4j version="10.0.8" transformSequenceNumber="10">
<directoryPresets config="../../core/resources/pix/icon" /> <directoryPresets config="../../core/resources/pix/icon" />
<application name="OpenRocket" applicationId="8434-9327-1469-6373" mediaDir="media" mediaFilePattern="${compiler:sys.shortName}_${compiler:sys.version}_${compiler:sys.platform}" shortName="OpenRocket" publisher="OpenRocket" publisherWeb="http://openrocket.info" version="23.09" allPathsRelative="true" convertDotsToUnderscores="false" macVolumeId="5f58a2be20d8e22f" javaMinVersion="17" javaMaxVersion="17" jdkMode="jdk" jdkName="JDK 11.0"> <application name="OpenRocket" applicationId="8434-9327-1469-6373" mediaDir="media" mediaFilePattern="${compiler:sys.shortName}_${compiler:sys.version}_${compiler:sys.platform}" shortName="OpenRocket" publisher="OpenRocket" publisherWeb="http://openrocket.info" version="23.09" allPathsRelative="true" convertDotsToUnderscores="false" macVolumeId="5f58a2be20d8e22f" javaMinVersion="17" javaMaxVersion="17" jdkMode="jdk" jdkName="JDK 11.0">
<codeSigning macEnabled="true" macPkcs12File="./code_signing/OpenRocket_macOS.p12" windowsEnabled="true" windowsPkcs12File="./code_signing/OpenRocket_Windows.pfx" macNotarize="true" appleId="sibo.vangool@hotmail.com" /> <codeSigning macEnabled="true" macPkcs12File="./code_signing/OpenRocket_macOS.p12" windowsEnabled="true" windowsPkcs12File="./code_signing/OpenRocket_Windows.pfx" macNotarize="true" appleId="sibo.vangool@hotmail.com" />
@ -29,7 +29,7 @@
<versionLine x="489" y="143" text="version ${compiler:sys.version}" fontSize="10" fontColor="255,255,255" /> <versionLine x="489" y="143" text="version ${compiler:sys.version}" fontSize="10" fontColor="255,255,255" />
</text> </text>
</splashScreen> </splashScreen>
<java mainClass="info.openrocket.swing.startup.OpenRocket" vmParameters="--add-exports java.base/java.lang=ALL-UNNAMED --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.desktop/sun.java2d=ALL-UNNAMED"> <java mainClass="info.openrocket.swing.startup.OpenRocket" vmParameters="-Dapple.awt.application.appearance=&quot;system&quot; --add-exports java.base/java.lang=ALL-UNNAMED --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.desktop/sun.java2d=ALL-UNNAMED">
<classPath> <classPath>
<archive location="OpenRocket.jar" failOnError="false" /> <archive location="OpenRocket.jar" failOnError="false" />
</classPath> </classPath>

View File

@ -40,6 +40,7 @@ public class UITheme {
// TODO: replace a bunch of this with the FlatLaf properties files, see https://www.formdev.com/flatlaf/properties-files // TODO: replace a bunch of this with the FlatLaf properties files, see https://www.formdev.com/flatlaf/properties-files
// For FlatLaf theme properties, check out swing/src/main/resources/themes
public interface Theme { public interface Theme {
void applyTheme(); void applyTheme();
@ -1814,9 +1815,6 @@ public class UITheme {
private static void postApplyTheme(Theme theme) { private static void postApplyTheme(Theme theme) {
final SwingPreferences prefs = (SwingPreferences) Application.getPreferences(); final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
// TODO: For some reason, FlatLaf does not take the correct values from the properties file
UIManager.put("OR.ScrollPane.borderColor", theme.getBorderColor());
// Clear custom default font when switching to non-FlatLaf LaF // Clear custom default font when switching to non-FlatLaf LaF
if (!(UIManager.getLookAndFeel() instanceof FlatLaf)) { if (!(UIManager.getLookAndFeel() instanceof FlatLaf)) {
UIManager.put("defaultFont", null); UIManager.put("defaultFont", null);

View File

@ -89,12 +89,7 @@ final class OSXSetup {
} }
log.debug("Setting up OSX UI Elements"); log.debug("Setting up OSX UI Elements");
try { try {
// Put the menu bar at the top of the screen setupOSXProperties();
System.setProperty("apple.laf.useScreenMenuBar", "true");
// Fix window title bar color
System.setProperty("apple.awt.application.appearance", "system");
// Set the name in the menu
System.setProperty("com.apple.mrj.application.apple.menu.about.name", APP_NAME);
// This line must come AFTER the above properties are set, otherwise // This line must come AFTER the above properties are set, otherwise
// the name will not appear // the name will not appear
@ -125,6 +120,20 @@ final class OSXSetup {
} }
} }
public static void setupOSXProperties() {
if (SystemInfo.getPlatform() != Platform.MAC_OS) {
log.warn("Attempting to set up OSX properties on non-MAC_OS");
return;
}
// Put the menu bar at the top of the screen
System.setProperty("apple.laf.useScreenMenuBar", "true");
// Fix window title bar color
System.setProperty("apple.awt.application.appearance", "system");
// Set the name in the menu
System.setProperty("com.apple.mrj.application.apple.menu.about.name", APP_NAME);
}
/** /**
* Sets up the open file handler, which handles file association on macOS. * Sets up the open file handler, which handles file association on macOS.
*/ */

View File

@ -28,6 +28,9 @@ public class OpenRocket {
private static final String STARTUP_CLASS = "info.openrocket.swing.startup.SwingStartup"; private static final String STARTUP_CLASS = "info.openrocket.swing.startup.SwingStartup";
public static void main(String[] args) { public static void main(String[] args) {
// Set OSX-specific properties
OSXSetup.setupOSXProperties();
// This property works around some fundamental bugs in TimSort in the java library which has had known issues // This property works around some fundamental bugs in TimSort in the java library which has had known issues
// since it was introduced in JDK 1.7. In OpenRocket it manifests when you sort the motors in the motor chooser dialog // since it was introduced in JDK 1.7. In OpenRocket it manifests when you sort the motors in the motor chooser dialog
// by designation. // by designation.

View File

@ -6,4 +6,4 @@ Slider.trackColor = #a3a3a3cc
SplitPaneDivider.hoverColor = lighten(@background, 5%) SplitPaneDivider.hoverColor = lighten(@background, 5%)
# Custom OpenRocket keys # Custom OpenRocket keys
OR.ScrollPane.borderColor = #a3a3a3cc OR.ScrollPane.borderColor = #8a8a8acc

View File

@ -18,8 +18,9 @@ Tree.rendererMargins = 2, 0, 3, 0
TextArea.margin = 10, 10, 10, 10 TextArea.margin = 10, 10, 10, 10
ScrollPane.smoothScrolling = true ScrollPane.smoothScrolling = true
ScrollPane.border = info.openrocket.swing.gui.theme.ORScrollPaneBorder ScrollPane.border = info.openrocket.swing.gui.theme.ORScrollPaneBorder
TextField.border = info.openrocket.swing.gui.theme.ORScrollPaneBorder
Slider.trackWidth = 3 Slider.trackWidth = 3
# Custom OpenRocket keys # Custom OpenRocket keys
OR.ScrollPane.borderColor = #000000 OR.ScrollPane.borderColor = #969696

View File

@ -6,5 +6,4 @@
[One_Dark]SplitPaneDivider.hoverColor = lighten(@background, 5%) [One_Dark]SplitPaneDivider.hoverColor = lighten(@background, 5%)
# Custom OpenRocket keys # Custom OpenRocket keys
#[One_Dark]OR.ScrollPane.borderColor = #616365 [One_Dark]OR.ScrollPane.borderColor = #6e7275
[One_Dark]ScrollPane.borderColor = #FF0000