mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Theme Editor: support macOS light and dark themes
This commit is contained in:
@@ -10,6 +10,7 @@ FlatLaf Change Log
|
||||
#639, issue #638)
|
||||
- Updated **JetBrains Mono** to
|
||||
[v2.304](https://github.com/JetBrains/JetBrainsMono/releases/tag/v2.304).
|
||||
- Theme Editor: Support macOS light and dark themes.
|
||||
|
||||
#### Fixed bugs
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@ import com.formdev.flatlaf.fonts.jetbrains_mono.FlatJetBrainsMonoFont;
|
||||
import com.formdev.flatlaf.fonts.roboto.FlatRobotoFont;
|
||||
import com.formdev.flatlaf.fonts.roboto_mono.FlatRobotoMonoFont;
|
||||
import com.formdev.flatlaf.icons.FlatClearIcon;
|
||||
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
|
||||
import com.formdev.flatlaf.themes.FlatMacLightLaf;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.util.StringUtils;
|
||||
import com.formdev.flatlaf.util.SystemInfo;
|
||||
@@ -415,6 +417,8 @@ class FlatThemeFileEditor
|
||||
case "FlatDarkLaf.properties": return "\0\2";
|
||||
case "FlatIntelliJLaf.properties": return "\0\3";
|
||||
case "FlatDarculaLaf.properties": return "\0\4";
|
||||
case "FlatMacLightLaf.properties": return "\0\5";
|
||||
case "FlatMacDarkLaf.properties": return "\0\6";
|
||||
default: return name;
|
||||
}
|
||||
}
|
||||
@@ -491,6 +495,8 @@ class FlatThemeFileEditor
|
||||
FlatDarkLaf.NAME,
|
||||
FlatIntelliJLaf.NAME,
|
||||
FlatDarculaLaf.NAME,
|
||||
FlatMacLightLaf.NAME,
|
||||
FlatMacDarkLaf.NAME,
|
||||
} );
|
||||
JCheckBox genJavaClassCheckBox = new JCheckBox( "Generate Java class" );
|
||||
genJavaClassCheckBox.setMnemonic( 'G' );
|
||||
@@ -564,12 +570,14 @@ class FlatThemeFileEditor
|
||||
throws IOException
|
||||
{
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append( "# base theme (light, dark, intellij or darcula); only used by theme editor\n" );
|
||||
buf.append( "# base theme (light, dark, intellij, darcula, maclight or macdark); only used by theme editor\n" );
|
||||
switch( baseTheme ) {
|
||||
case FlatLightLaf.NAME: buf.append( "@baseTheme = light\n" ); break;
|
||||
case FlatDarkLaf.NAME: buf.append( "@baseTheme = dark\n" ); break;
|
||||
case FlatIntelliJLaf.NAME: buf.append( "@baseTheme = intellij\n" ); break;
|
||||
case FlatDarculaLaf.NAME: buf.append( "@baseTheme = darcula\n" ); break;
|
||||
case FlatMacLightLaf.NAME: buf.append( "@baseTheme = maclight\n" ); break;
|
||||
case FlatMacDarkLaf.NAME: buf.append( "@baseTheme = macdark\n" ); break;
|
||||
}
|
||||
|
||||
writeFile( file, buf.toString() );
|
||||
@@ -621,18 +629,29 @@ class FlatThemeFileEditor
|
||||
case FlatDarkLaf.NAME: themeBaseClass = "FlatDarkLaf"; break;
|
||||
case FlatIntelliJLaf.NAME: themeBaseClass = "FlatIntelliJLaf"; break;
|
||||
case FlatDarculaLaf.NAME: themeBaseClass = "FlatDarculaLaf"; break;
|
||||
case FlatMacLightLaf.NAME: themeBaseClass = "FlatMacLightLaf"; break;
|
||||
case FlatMacDarkLaf.NAME: themeBaseClass = "FlatMacDarkLaf"; break;
|
||||
}
|
||||
|
||||
String themeBasePackage = "";
|
||||
switch( baseTheme ) {
|
||||
case FlatMacLightLaf.NAME:
|
||||
case FlatMacDarkLaf.NAME:
|
||||
themeBasePackage = "themes.";
|
||||
break;
|
||||
}
|
||||
|
||||
String pkgStmt = (pkg != null) ? "package " + pkg + ";\n\n" : "";
|
||||
String classBody = CLASS_TEMPLATE
|
||||
.replace( "${themeClass}", themeName )
|
||||
.replace( "${themeBasePackage}", themeBasePackage )
|
||||
.replace( "${themeBaseClass}", themeBaseClass );
|
||||
|
||||
writeFile( file, pkgStmt + classBody );
|
||||
}
|
||||
|
||||
private static final String CLASS_TEMPLATE =
|
||||
"import com.formdev.flatlaf.${themeBaseClass};\n" +
|
||||
"import com.formdev.flatlaf.${themeBasePackage}${themeBaseClass};\n" +
|
||||
"\n" +
|
||||
"public class ${themeClass}\n" +
|
||||
" extends ${themeBaseClass}\n" +
|
||||
|
||||
@@ -33,6 +33,8 @@ import com.formdev.flatlaf.FlatIconColors;
|
||||
import com.formdev.flatlaf.FlatIntelliJLaf;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.FlatLightLaf;
|
||||
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
|
||||
import com.formdev.flatlaf.themes.FlatMacLightLaf;
|
||||
import com.formdev.flatlaf.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -46,6 +48,8 @@ class FlatThemePropertiesBaseManager
|
||||
FlatDarkLaf.class,
|
||||
FlatIntelliJLaf.class,
|
||||
FlatDarculaLaf.class,
|
||||
FlatMacLightLaf.class,
|
||||
FlatMacDarkLaf.class,
|
||||
};
|
||||
|
||||
private final Map<String, MyBasePropertyProvider> providers = new HashMap<>();
|
||||
@@ -118,11 +122,13 @@ class FlatThemePropertiesBaseManager
|
||||
break;
|
||||
|
||||
case "FlatIntelliJLaf":
|
||||
case "FlatMacLightLaf":
|
||||
result.add( "FlatLightLaf" );
|
||||
result.add( "FlatLaf" );
|
||||
break;
|
||||
|
||||
case "FlatDarculaLaf":
|
||||
case "FlatMacDarkLaf":
|
||||
result.add( "FlatDarkLaf" );
|
||||
result.add( "FlatLaf" );
|
||||
break;
|
||||
@@ -156,6 +162,18 @@ class FlatThemePropertiesBaseManager
|
||||
result.add( "FlatDarkLaf" );
|
||||
result.add( "FlatLaf" );
|
||||
break;
|
||||
|
||||
case "maclight":
|
||||
result.add( "FlatMacLightLaf" );
|
||||
result.add( "FlatLightLaf" );
|
||||
result.add( "FlatLaf" );
|
||||
break;
|
||||
|
||||
case "macdark":
|
||||
result.add( "FlatMacDarkLaf" );
|
||||
result.add( "FlatDarkLaf" );
|
||||
result.add( "FlatLaf" );
|
||||
break;
|
||||
}
|
||||
|
||||
// exclude base properties if editing base properties
|
||||
@@ -189,6 +207,8 @@ class FlatThemePropertiesBaseManager
|
||||
case "FlatDarkLaf": coreBaseTheme = "dark"; break;
|
||||
case "FlatIntelliJLaf": coreBaseTheme = "intellij"; break;
|
||||
case "FlatDarculaLaf": coreBaseTheme = "darcula"; break;
|
||||
case "FlatMacLightLaf": coreBaseTheme = "maclight"; break;
|
||||
case "FlatMacDarkLaf": coreBaseTheme = "macdark"; break;
|
||||
default: coreBaseTheme = null; break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user