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