mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 14:37:13 -06:00
IntelliJ Themes: use single Laf class for light and dark IntelliJ themes and added IntelliJTheme$ThemeLaf.properties to allow (re-)setting UI defaults before .theme.json is applied
This commit is contained in:
@@ -186,7 +186,13 @@ public abstract class FlatLaf
|
||||
Object aquaMenuBarUI = useScreenMenuBar ? defaults.get( "MenuBarUI" ) : null;
|
||||
|
||||
initFonts( defaults );
|
||||
UIDefaultsLoader.loadDefaultsFromProperties( getClass(), defaults );
|
||||
|
||||
// load defaults from properties
|
||||
List<Class<?>> lafClassesForDefaultsLoading = getLafClassesForDefaultsLoading();
|
||||
if( lafClassesForDefaultsLoading != null )
|
||||
UIDefaultsLoader.loadDefaultsFromProperties( lafClassesForDefaultsLoading, defaults );
|
||||
else
|
||||
UIDefaultsLoader.loadDefaultsFromProperties( getClass(), defaults );
|
||||
|
||||
// use Aqua MenuBarUI if Mac screen menubar is enabled
|
||||
if( useScreenMenuBar )
|
||||
@@ -195,6 +201,10 @@ public abstract class FlatLaf
|
||||
return defaults;
|
||||
}
|
||||
|
||||
List<Class<?>> getLafClassesForDefaultsLoading() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void initFonts( UIDefaults defaults ) {
|
||||
FontUIResource uiFont = null;
|
||||
|
||||
|
||||
@@ -66,10 +66,7 @@ public class IntelliJTheme
|
||||
}
|
||||
|
||||
public static FlatLaf createLaf( IntelliJTheme theme ) {
|
||||
FlatLaf laf = theme.dark
|
||||
? new DarkLaf( theme )
|
||||
: new LightLaf( theme );
|
||||
return laf;
|
||||
return new ThemeLaf( theme );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@@ -233,14 +230,14 @@ public class IntelliJTheme
|
||||
checkboxKeyMapping.put( "Checkbox.Focus.Thin.Selected", "CheckBox.icon.selectedFocusedBorderColor" );
|
||||
}
|
||||
|
||||
//---- class LightLaf -----------------------------------------------------
|
||||
//---- class ThemeLaf -----------------------------------------------------
|
||||
|
||||
public static class LightLaf
|
||||
extends FlatIntelliJLaf
|
||||
public static class ThemeLaf
|
||||
extends FlatLaf
|
||||
{
|
||||
private final IntelliJTheme theme;
|
||||
|
||||
public LightLaf( IntelliJTheme theme ) {
|
||||
public ThemeLaf( IntelliJTheme theme ) {
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
@@ -255,32 +252,8 @@ public class IntelliJTheme
|
||||
}
|
||||
|
||||
@Override
|
||||
public UIDefaults getDefaults() {
|
||||
UIDefaults defaults = super.getDefaults();
|
||||
theme.applyProperties( defaults );
|
||||
return defaults;
|
||||
}
|
||||
}
|
||||
|
||||
//---- class DarkLaf ------------------------------------------------------
|
||||
|
||||
public static class DarkLaf
|
||||
extends FlatDarculaLaf
|
||||
{
|
||||
private final IntelliJTheme theme;
|
||||
|
||||
public DarkLaf( IntelliJTheme theme ) {
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return theme.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return theme.name;
|
||||
public boolean isDark() {
|
||||
return theme.dark;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -289,5 +262,15 @@ public class IntelliJTheme
|
||||
theme.applyProperties( defaults );
|
||||
return defaults;
|
||||
}
|
||||
|
||||
@Override
|
||||
ArrayList<Class<?>> getLafClassesForDefaultsLoading() {
|
||||
ArrayList<Class<?>> lafClasses = new ArrayList<>();
|
||||
lafClasses.add( FlatLaf.class );
|
||||
lafClasses.add( theme.dark ? FlatDarkLaf.class : FlatLightLaf.class );
|
||||
lafClasses.add( theme.dark ? FlatDarculaLaf.class : FlatIntelliJLaf.class );
|
||||
lafClasses.add( ThemeLaf.class );
|
||||
return lafClasses;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,10 @@ class UIDefaultsLoader
|
||||
lafClasses.add( 0, lafClass );
|
||||
}
|
||||
|
||||
loadDefaultsFromProperties( lafClasses, defaults );
|
||||
}
|
||||
|
||||
static void loadDefaultsFromProperties( List<Class<?>> lafClasses, UIDefaults defaults ) {
|
||||
try {
|
||||
// load properties files
|
||||
Properties properties = new Properties();
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# Copyright 2019 FormDev Software GmbH
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
Reference in New Issue
Block a user