mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-15 00:07:12 -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;
|
Object aquaMenuBarUI = useScreenMenuBar ? defaults.get( "MenuBarUI" ) : null;
|
||||||
|
|
||||||
initFonts( defaults );
|
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
|
// use Aqua MenuBarUI if Mac screen menubar is enabled
|
||||||
if( useScreenMenuBar )
|
if( useScreenMenuBar )
|
||||||
@@ -195,6 +201,10 @@ public abstract class FlatLaf
|
|||||||
return defaults;
|
return defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Class<?>> getLafClassesForDefaultsLoading() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void initFonts( UIDefaults defaults ) {
|
private void initFonts( UIDefaults defaults ) {
|
||||||
FontUIResource uiFont = null;
|
FontUIResource uiFont = null;
|
||||||
|
|
||||||
|
|||||||
@@ -66,10 +66,7 @@ public class IntelliJTheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FlatLaf createLaf( IntelliJTheme theme ) {
|
public static FlatLaf createLaf( IntelliJTheme theme ) {
|
||||||
FlatLaf laf = theme.dark
|
return new ThemeLaf( theme );
|
||||||
? new DarkLaf( theme )
|
|
||||||
: new LightLaf( theme );
|
|
||||||
return laf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" )
|
||||||
@@ -233,14 +230,14 @@ public class IntelliJTheme
|
|||||||
checkboxKeyMapping.put( "Checkbox.Focus.Thin.Selected", "CheckBox.icon.selectedFocusedBorderColor" );
|
checkboxKeyMapping.put( "Checkbox.Focus.Thin.Selected", "CheckBox.icon.selectedFocusedBorderColor" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- class LightLaf -----------------------------------------------------
|
//---- class ThemeLaf -----------------------------------------------------
|
||||||
|
|
||||||
public static class LightLaf
|
public static class ThemeLaf
|
||||||
extends FlatIntelliJLaf
|
extends FlatLaf
|
||||||
{
|
{
|
||||||
private final IntelliJTheme theme;
|
private final IntelliJTheme theme;
|
||||||
|
|
||||||
public LightLaf( IntelliJTheme theme ) {
|
public ThemeLaf( IntelliJTheme theme ) {
|
||||||
this.theme = theme;
|
this.theme = theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,32 +252,8 @@ public class IntelliJTheme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UIDefaults getDefaults() {
|
public boolean isDark() {
|
||||||
UIDefaults defaults = super.getDefaults();
|
return theme.dark;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -289,5 +262,15 @@ public class IntelliJTheme
|
|||||||
theme.applyProperties( defaults );
|
theme.applyProperties( defaults );
|
||||||
return 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 );
|
lafClasses.add( 0, lafClass );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadDefaultsFromProperties( lafClasses, defaults );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void loadDefaultsFromProperties( List<Class<?>> lafClasses, UIDefaults defaults ) {
|
||||||
try {
|
try {
|
||||||
// load properties files
|
// load properties files
|
||||||
Properties properties = new Properties();
|
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