GP-1 Fixed a few minor issues with new theming code

This commit is contained in:
ghidragon 2022-11-16 14:37:10 -05:00
parent e657a70141
commit 4763ce6e8a
8 changed files with 31 additions and 8 deletions

View File

@ -16,6 +16,7 @@ data/ElfFunctionsThatDoNotReturn||GHIDRA||||END|
data/ExtensionPoint.manifest||GHIDRA||||END|
data/MachOFunctionsThatDoNotReturn||GHIDRA||||END|
data/PEFunctionsThatDoNotReturn||GHIDRA||||END|
data/base.file.extensions.icons.theme.properties||GHIDRA||||END|
data/base.icons.theme.properties||GHIDRA||||END|
data/base.listing.theme.properties||GHIDRA||||END|
data/base.programgraph.theme.properties||GHIDRA||||END|
@ -80,7 +81,6 @@ data/symbols/win64/mfc80u.exports||GHIDRA||||END|
data/symbols/win64/mfc90.exports||GHIDRA||||END|
data/symbols/win64/mfc90u.exports||GHIDRA||||END|
data/symbols/win64/msvcrt.hints||GHIDRA||||END|
data/typeinfo/base.file.extensions.icons.theme.properties||GHIDRA||||END|
data/typeinfo/generic/generic_clib.gdt||GHIDRA||||END|
data/typeinfo/generic/generic_clib_64.gdt||GHIDRA||||END|
data/typeinfo/mac_10.9/mac_osx.gdt||GHIDRA||||END|

View File

@ -108,10 +108,7 @@ public class ThemeFontTable extends JPanel implements ActionContextProvider {
@Override
public ActionContext getActionContext(MouseEvent e) {
if (e == null) {
return null;
}
if (e.getSource() == table) {
if (e != null && e.getSource() == table) {
FontValue currentValue = filterTable.getSelectedRowObject();
if (currentValue == null) {
return null;

View File

@ -104,7 +104,7 @@ public class ThemeIconTable extends JPanel implements ActionContextProvider {
@Override
public ActionContext getActionContext(MouseEvent e) {
if (e.getSource() == table) {
if (e != null && e.getSource() == table) {
IconValue currentValue = filterTable.getSelectedRowObject();
if (currentValue == null) {
return null;

View File

@ -215,6 +215,9 @@ public class ThemeUtils {
private static boolean saveCurrentValues(ThemeManager themeManager, String themeName) {
GTheme activeTheme = themeManager.getActiveTheme();
File file = getSaveFile(themeName);
if (!file.exists()) {
Msg.info(ThemeUtils.class, "Saving theme to " + file);
}
GTheme newTheme = new GTheme(file, themeName, activeTheme.getLookAndFeelType(),
activeTheme.useDarkDefaults());

View File

@ -44,7 +44,6 @@ public class ThemeFileLoader {
Application.findFilesByExtensionInApplication(".theme.properties");
for (ResourceFile resourceFile : themeDefaultFiles) {
Msg.debug(this, "found theme file: " + resourceFile.getAbsolutePath());
try {
ThemePropertyFileReader reader = new ThemePropertyFileReader(resourceFile);
defaults.load(reader.getDefaultValues());

View File

@ -93,7 +93,7 @@ public abstract class ThemeValue<T> implements Comparable<ThemeValue<T>> {
// loop resolving indirect references
while (referred != null) {
if (referred.value != null) {
return referred.value;
return referred.get(values);
}
visitedKeys.add(referred.id);
if (visitedKeys.contains(referred.referenceId)) {

View File

@ -123,6 +123,30 @@ public class IconValueTest {
@Test
public void testParseWithOverlays() throws ParseException {
IconValue value = IconValue.parse("icon.foo", "EMPTY_ICON{Plus2.png}");
values.addIcon(value);
value = IconValue.parse("icon.test",
"images/core.png[size(25,25)]{icon.foo[move(4,4)]}");
assertEquals("icon.test", value.getId());
Icon icon = value.get(values);
assertTrue(icon instanceof MultiIcon);
MultiIcon multiIcon = (MultiIcon) icon;
Icon[] icons = multiIcon.getIcons();
assertEquals(2, icons.length);
assertEquals(25, icons[0].getIconWidth());
assertEquals(25, icons[0].getIconWidth());
assertEquals(16, icons[1].getIconWidth());
assertEquals(16, icons[1].getIconWidth());
assertTrue(icons[1] instanceof TranslateIcon);
TranslateIcon tIcon = (TranslateIcon) icons[1];
Icon baseIcon = tIcon.getBaseIcon();
assertTrue(baseIcon instanceof MultiIcon);
}
@Test
public void testParseWithModifiedOverlay() throws ParseException {
IconValue value = IconValue.parse("icon.test",
"images/core.png[size(25,25)]{images/flag.png[size(8,8)][move(4,4)]}");
assertEquals("icon.test", value.getId());