mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GP-3129 fixed issues with theme font changes not taking hold. Also, fixed some Nimbus font issues.
Fixing bug where saved font/icon changes to a theme don't take effect when loading theme
This commit is contained in:
parent
bdc6f56c40
commit
c252433f18
6 changed files with 22 additions and 44 deletions
|
@ -443,20 +443,6 @@ public abstract class ThemeManager {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns application defaults values (does not include java default values)
|
|
||||||
* @return application defaults values (does not include java default values)
|
|
||||||
*/
|
|
||||||
public GThemeValueMap getApplicationOverrides() {
|
|
||||||
GThemeValueMap currentDefaults = new GThemeValueMap();
|
|
||||||
currentDefaults.load(applicationDefaults.getLightValues());
|
|
||||||
if (useDarkDefaults) {
|
|
||||||
currentDefaults.load(applicationDefaults.getDarkValues());
|
|
||||||
}
|
|
||||||
currentDefaults.load(applicationDefaults.getLookAndFeelValues(getLookAndFeelType()));
|
|
||||||
return currentDefaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link GThemeValueMap} containing all default values for the current theme. It
|
* Returns a {@link GThemeValueMap} containing all default values for the current theme. It
|
||||||
* is a combination of application defined defaults and java {@link LookAndFeel} defaults.
|
* is a combination of application defined defaults and java {@link LookAndFeel} defaults.
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class CustomNimbusLookAndFeel extends NimbusLookAndFeel {
|
||||||
// normally all of this wiring is handled by the LookAndFeelManager (see above)
|
// normally all of this wiring is handled by the LookAndFeelManager (see above)
|
||||||
UiDefaultsMapper uiDefaultsMapper = new NimbusUiDefaultsMapper(defaults);
|
UiDefaultsMapper uiDefaultsMapper = new NimbusUiDefaultsMapper(defaults);
|
||||||
installJavaDefaultsIntoThemeManager(uiDefaultsMapper);
|
installJavaDefaultsIntoThemeManager(uiDefaultsMapper);
|
||||||
uiDefaultsMapper.installValuesIntoUIDefaults(getApplicationOverrides());
|
uiDefaultsMapper.installValuesIntoUIDefaults(themeManager.getCurrentValues());
|
||||||
|
|
||||||
normalizedIdToLafIdMap = uiDefaultsMapper.getNormalizedIdToLafIdMap();
|
normalizedIdToLafIdMap = uiDefaultsMapper.getNormalizedIdToLafIdMap();
|
||||||
return defaults;
|
return defaults;
|
||||||
|
@ -78,8 +78,4 @@ public class CustomNimbusLookAndFeel extends NimbusLookAndFeel {
|
||||||
public Map<String, String> getNormalizedIdToLafIdMap() {
|
public Map<String, String> getNormalizedIdToLafIdMap() {
|
||||||
return normalizedIdToLafIdMap;
|
return normalizedIdToLafIdMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected GThemeValueMap getApplicationOverrides() {
|
|
||||||
return themeManager.getApplicationOverrides();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ public abstract class LookAndFeelManager {
|
||||||
|
|
||||||
GThemeValueMap javaDefaults = uiDefaultsMapper.getJavaDefaults();
|
GThemeValueMap javaDefaults = uiDefaultsMapper.getJavaDefaults();
|
||||||
themeManager.setJavaDefaults(javaDefaults);
|
themeManager.setJavaDefaults(javaDefaults);
|
||||||
uiDefaultsMapper.installValuesIntoUIDefaults(themeManager.getApplicationOverrides());
|
uiDefaultsMapper.installValuesIntoUIDefaults(themeManager.getCurrentValues());
|
||||||
normalizedIdToLafIdMap = uiDefaultsMapper.getNormalizedIdToLafIdMap();
|
normalizedIdToLafIdMap = uiDefaultsMapper.getNormalizedIdToLafIdMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,14 +76,6 @@ public class NimbusLookAndFeelManager extends LookAndFeelManager {
|
||||||
// as explained above, don't change the java defaults in the theme manager
|
// as explained above, don't change the java defaults in the theme manager
|
||||||
// on a reinstall
|
// on a reinstall
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected GThemeValueMap getApplicationOverrides() {
|
|
||||||
// on a reinstall, we may also have overrides in the current values and not
|
|
||||||
// just the theme.property files
|
|
||||||
return themeManager.getCurrentValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (UnsupportedLookAndFeelException e) {
|
catch (UnsupportedLookAndFeelException e) {
|
||||||
|
|
|
@ -47,8 +47,6 @@ public class NimbusUiDefaultsMapper extends UiDefaultsMapper {
|
||||||
ignoredLafIds.add("nimbusSelection");
|
ignoredLafIds.add("nimbusSelection");
|
||||||
ignoredLafIds.add("nimbusSelectionBackground");
|
ignoredLafIds.add("nimbusSelectionBackground");
|
||||||
|
|
||||||
ignoredLafIds.add("defaultFont");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -153,18 +153,19 @@ public class UiDefaultsMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the UIDefaults file with indirect colors (GColors) and any overridden font or icon
|
* Updates the UIDefaults file with indirect colors (GColors) and any overridden font or icon
|
||||||
* values as defined in theme.properites files
|
* values as defined in theme.properites files and saved themes.
|
||||||
* @param overrides a Map that contains possible LookAndFeel value overridess
|
* @param currentValues a Map that contains all the values including those the may have
|
||||||
|
* been overridden by the theme.properties files or saved themes
|
||||||
*/
|
*/
|
||||||
public void installValuesIntoUIDefaults(GThemeValueMap overrides) {
|
public void installValuesIntoUIDefaults(GThemeValueMap currentValues) {
|
||||||
//
|
//
|
||||||
// In the UI Defaults, colors use indirect values and fonts and icons use direct values.
|
// In the UI Defaults, colors use indirect values and fonts and icons use direct values.
|
||||||
// Here we install our GColors for the indirect colors. Then we set any font and icon
|
// Here we install our GColors for the indirect colors. Then we set any font and icon
|
||||||
// values that are different than the defaults.
|
// values that are different than the defaults.
|
||||||
//
|
//
|
||||||
installGColorsIntoUIDefaults();
|
installGColorsIntoUIDefaults();
|
||||||
installOverriddenFontsIntoUIDefaults(overrides);
|
installOverriddenFontsIntoUIDefaults(currentValues);
|
||||||
installOverriddenIconsIntoUIDefaults(overrides);
|
installOverriddenIconsIntoUIDefaults(currentValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -550,27 +551,32 @@ public class UiDefaultsMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces any theme overridden icons into the UiDefaults.
|
* Replace UiDefault values with theme overridden values.
|
||||||
* @param overrides the theme values that potentially override a laf icon value
|
* @param currentValues the theme values that potentially override a laf icon value
|
||||||
*/
|
*/
|
||||||
private void installOverriddenIconsIntoUIDefaults(GThemeValueMap overrides) {
|
private void installOverriddenIconsIntoUIDefaults(GThemeValueMap currentValues) {
|
||||||
for (String lafId : extractedValues.getIconIds()) {
|
for (String lafId : extractedValues.getIconIds()) {
|
||||||
|
Icon currentIcon = extractedValues.getResolvedIcon(lafId);
|
||||||
String standardId = lafIdToNormalizedIdMap.get(lafId);
|
String standardId = lafIdToNormalizedIdMap.get(lafId);
|
||||||
if (overrides.containsIcon(standardId)) {
|
Icon overriddenIcon = currentValues.getResolvedIcon(standardId);
|
||||||
defaults.put(lafId, overrides.getResolvedIcon(standardId));
|
if (overriddenIcon != null && currentIcon != overriddenIcon) {
|
||||||
|
defaults.put(lafId, overriddenIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces any theme overridden fonts into the UiDefaults.
|
* Replaces any theme overridden fonts into the UiDefaults.
|
||||||
* @param overrides the theme values that potentially override a laf font value
|
* @param currentValues the theme values that potentially override a laf font value
|
||||||
*/
|
*/
|
||||||
private void installOverriddenFontsIntoUIDefaults(GThemeValueMap overrides) {
|
private void installOverriddenFontsIntoUIDefaults(GThemeValueMap currentValues) {
|
||||||
for (String lafId : extractedValues.getFontIds()) {
|
for (String lafId : extractedValues.getFontIds()) {
|
||||||
|
Font currentFont = extractedValues.getResolvedFont(lafId);
|
||||||
String standardId = lafIdToNormalizedIdMap.get(lafId);
|
String standardId = lafIdToNormalizedIdMap.get(lafId);
|
||||||
if (overrides.containsFont(standardId)) {
|
Font overriddenFont = currentValues.getResolvedFont(standardId);
|
||||||
defaults.put(lafId, new FontUIResource(overrides.getResolvedFont(standardId)));
|
if (overriddenFont != null && overriddenFont != currentFont) {
|
||||||
|
defaults.put(lafId, new FontUIResource(overriddenFont));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue