GP-1981 - Checkpoint - Conversions for FilterTextField, GenericHeader,

and OptionsGui; Moves some resources to Docking from Base; Moved the
theme plugin so it is available to generic applications
This commit is contained in:
dragonmacher 2022-08-05 17:40:13 -04:00 committed by ghidragon
parent 703a7beb8d
commit d588daaca6
17 changed files with 99 additions and 62 deletions

View file

@ -18,7 +18,7 @@ color.fg.listing.entrypoint = magenta
color.fg.listing.comment.auto = lightGray
color.fg.listing.comment.eol = blue
color.fg.listing.comment.repeatable = darkOrange
color.fg.listing.comment.ref-repeatable = comflowerBlue
color.fg.listing.comment.ref-repeatable = cornflowerBlue
color.fg.listing.comment.plate = gray
color.fg.listing.comment.post = blue
color.fg.listing.comment.pre = indigo
@ -38,6 +38,8 @@ color.fg.listing.label.primary = darkBlue
color.fg.listing.mnemonic.override = deepPink
color.fg.listing.mnemonic = navy
color.fg.listing.mnemonic.unimplemented = navy
// TODO
color.fg.listing.flow-arrow.inactive = lightGray
color.fg.listing.flow-arrow.active = color.fg
color.fg.listing.flow-arrow.selected = limeGreen
@ -50,7 +52,7 @@ color.fg.listing.xref.read = blue
color.fg.listing.xref.write = darkOrange
color.fg.listing.xref.other = color.fg
color.fg.listing.register = olive
color.fg.listing.underline = comflowerBlue
color.fg.listing.underline = cornflowerBlue
color.fg.listing.pcode.label = blue
color.fg.listing.pcode.space = blue
color.fg.listing.pcode.varnode = blue
@ -69,7 +71,7 @@ color.fg.listing.pcode.userop = blue
#color.fg.listing.comment.auto = rgb(95,129,157)
#color.fg.listing.comment.eol = blue
#color.fg.listing.comment.repeatable = darkOrange
#color.fg.listing.comment.ref-repeatable = comflowerBlue
#color.fg.listing.comment.ref-repeatable = cornflowerBlue
#color.fg.listing.comment.plate = gray
#color.fg.listing.comment.post = blue
#color.fg.listing.comment.pre = indigo
@ -101,7 +103,7 @@ color.fg.listing.pcode.userop = blue
#color.fg.listing.xref.write = darkOrange
#color.fg.listing.xref.other = color.fg
#color.fg.listing.register = olive
#color.fg.listing.underline = comflowerBlue
#color.fg.listing.underline = cornflowerBlue
#color.fg.listing.pcode.label = blue
#color.fg.listing.pcode.space = blue
#color.fg.listing.pcode.varnode = blue

View file

@ -192,7 +192,8 @@ public class OptionsGui extends JPanel {
static ScreenElement[] elements = { ADDRESS, BACKGROUND, BAD_REF_ADDR, BYTES, COMMENT_AUTO,
COMMENT_EOL, COMMENT_PLATE, COMMENT_POST, COMMENT_PRE, COMMENT_REPEATABLE,
COMMENT_REF_REPEAT, CONSTANT, ENTRY_POINT, EXT_REF_RESOLVED, FIELD_NAME, FLOW_ARROW_ACTIVE,
FLOW_ARROW_NON_ACTIVE, FUN_CALL_FIXUP, FUN_NAME, FUN_PARAMS, FUN_AUTO_PARAMS, FUN_RET_TYPE,
FLOW_ARROW_NON_ACTIVE, FLOW_ARROW_SELECTED, FUN_CALL_FIXUP, FUN_NAME, FUN_PARAMS,
FUN_AUTO_PARAMS, FUN_RET_TYPE,
FUN_TAG, LABELS_LOCAL, LABELS_NON_PRIMARY, LABELS_PRIMARY, LABELS_UNREFD, MNEMONIC,
MNEMONIC_OVERRIDE, PARAMETER_CUSTOM, PARAMETER_DYNAMIC, PCODE_LINE_LABEL, PCODE_ADDR_SPACE,
PCODE_RAW_VARNODE, PCODE_USEROP, REGISTERS, SEPARATOR, UNDERLINE, UNIMPL, VARIABLE,

View file

@ -42,6 +42,7 @@ src/main/resources/images/bullet_delete.png||FAMFAMFAM Icons - CC 2.5||||END|
src/main/resources/images/checkmark_green.gif||GHIDRA||reviewed||END|
src/main/resources/images/close16.gif||GHIDRA||reviewed||END|
src/main/resources/images/closedFolder.png||Modified Nuvola Icons - LGPL 2.1||||END|
src/main/resources/images/collapse_all.png||GHIDRA||||END|
src/main/resources/images/computer.png||Tango Icons - Public Domain|||tango|END|
src/main/resources/images/desktop.png||Nuvola Icons - LGPL 2.1|||Nuvola icon set|END|
src/main/resources/images/dialog-cancel.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
@ -84,6 +85,8 @@ src/main/resources/images/information.png||FAMFAMFAM Icons - CC 2.5|||famfamfam
src/main/resources/images/inode-directory.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
src/main/resources/images/left.alternate.png||GHIDRA||||END|
src/main/resources/images/left.png||GHIDRA||reviewed||END|
src/main/resources/images/locationIn.gif||GHIDRA||||END|
src/main/resources/images/locationOut.gif||GHIDRA||||END|
src/main/resources/images/magnifier.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/resources/images/media-playback-start.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
src/main/resources/images/menu16.gif||GHIDRA||reviewed||END|
@ -111,6 +114,7 @@ src/main/resources/images/undo.png||GHIDRA||||END|
src/main/resources/images/up.png||GHIDRA||reviewed||END|
src/main/resources/images/user-home.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
src/main/resources/images/view-filter.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
src/main/resources/images/viewmagfit.png||Nuvola Icons - LGPL 2.1|||Nuvola icon set|END|
src/main/resources/images/warning.help.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
src/main/resources/images/warning.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/resources/images/weather-clear.png||Tango Icons - Public Domain|||tango icon set|END|

View file

@ -4,6 +4,7 @@
color.palette.material.primary = #6200EE
color.palette.material.primary.variant = #3700B3
color.palette.material.secondary = #03DAC6
color.palette.material.secondary.variant = #018786

View file

@ -36,4 +36,5 @@ color.palette.white = white
[Dark Defaults]
// TODO replace values above with dark values
color.palette.black = lightgray
#color.palette.black = lightgray
#color.palette.yellow = rgb(191, 191, 64) // olive

View file

@ -5,6 +5,11 @@ color.fg = black
color.fg.error = red
color.fg.disabled = lightGray
color.bg.header.active = steelblue
color.bg.header.inactive = rgb(150, 150, 150)
color.fg.header.active = ivory
color.fg.header.inactive = black
color.bg.selection = rgb(180, 255, 180) // pale green
color.bg.highlight = rgb(255,255,150) // pale yellow
color.bg.tooltip = rgb(255, 255, 230)
@ -25,6 +30,9 @@ color.bg.textfield.hint.valid = color.bg
color.bg.textfield.hint.invalid = rgb(255,225,225)
color.fg.textfield.hint = color.fg
color.bg.filterfield = yellow
color.fg.filterfield = black
color.bg.selection.help = lightSteelBlue
// generic component items
@ -58,7 +66,7 @@ icon.notallowed = images/dialog-cancel.png
icon.folder.open = images/openSmallFolder.png
icon.refresh = images/reload3.png
icon.sort.ascending = images/sortascending.png
icon.sort.descending = images/process-stop.png
icon.sort.descending = images/sortdescending.png
icon.stop = images/process-stop.png
icon.warning.strong = images/software-update-urgent.png
icon.left = images/left.png
@ -77,6 +85,11 @@ icon.checkmark.green = images/checkmark_green.gif
color.bg = rgb(40, 42, 46)
color.fg = lightgray
color.bg.header.active = steelblue // color.palette.material.primary // lightcoral
color.bg.header.inactive = dimGray
color.fg.header.active = lightGray
color.fg.header.inactive = black
color.bg.currentline = rgb(60,60,70) // dark gray
color.cursor.focused = indianRed
@ -84,8 +97,11 @@ color.cursor.unfocussed = darkGray
color.bg.textfield.hint.invalid = maroon
color.bg.filterfield = beige
color.fg.filterfield = darkSlateGray
color.bg.selection = teal
color.bg.highlight = rgb(110,110,0)
color.bg.highlight = olive
color.bg.fieldpanel.selection-highlight = darkGreen

View file

@ -26,6 +26,7 @@ import org.jdesktop.animation.timing.TimingTargetAdapter;
import org.jdesktop.animation.timing.interpolation.PropertySetter;
import docking.action.DockingActionIf;
import docking.theme.GColor;
import docking.util.AnimationUtils;
import docking.widgets.VariableHeightPanel;
import docking.widgets.label.GDLabel;
@ -33,12 +34,14 @@ import docking.widgets.label.GDLabel;
// TODO: should this be put into generic?
public class GenericHeader extends JPanel {
private static final Color NON_FOCUS_START_COLOR = new Color(150, 150, 150);
private static final Color FOCUS_START_COLOR = new Color(30, 30, 150);
private static final Color NON_FOCUS_START_COLOR = new GColor("color.bg.header.inactive");
private static final Color FOCUS_START_COLOR = new GColor("color.bg.header.active");
private static final int MINIMUM_TITLE_SIZE = 80;
private Color nonFocusColor = NON_FOCUS_START_COLOR;
private Color focusColor = FOCUS_START_COLOR;
private Color activeForeground = new GColor("color.fg.header.active");
private Color inactiveForeground = new GColor("color.fg.header.inactive");
protected Component component;
protected DockableToolBarManager toolBarMgr;
@ -419,7 +422,7 @@ public class GenericHeader extends JPanel {
*/
void setSelected(boolean state) {
isSelected = state;
titleLabel.setForeground(state ? Color.WHITE : Color.BLACK);
titleLabel.setForeground(state ? activeForeground : inactiveForeground);
repaint();
}

View file

@ -21,7 +21,6 @@ import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import com.formdev.flatlaf.*;
@ -54,6 +53,7 @@ public class Gui {
private static Map<String, GColorUIResource> gColorMap = new HashMap<>();
private static Map<String, GIconUIResource> gIconMap = new HashMap<>();
private static boolean isInitialzed;
static void setPropertiesLoader(ThemePropertiesLoader loader) {
themePropertiesLoader = loader;
@ -64,8 +64,9 @@ public class Gui {
}
public static void initialize() {
isInitialzed = true;
installFlatLookAndFeels();
loadGhidraDefaults();
loadThemeDefaults();
setTheme(getThemeFromPreferences());
// LookAndFeelUtils.installGlobalOverrides();
platformSpecificFixups();
@ -78,14 +79,14 @@ public class Gui {
FlatDarculaLaf.class.getName());
}
private static void loadGhidraDefaults() {
private static void loadThemeDefaults() {
themePropertiesLoader.load();
ghidraLightDefaults = themePropertiesLoader.getDefaults();
ghidraDarkDefaults = themePropertiesLoader.getDarkDefaults();
}
public static void reloadGhidraDefaults() {
loadGhidraDefaults();
loadThemeDefaults();
buildCurrentValues();
}
@ -220,7 +221,7 @@ public class Gui {
ColorValue color = currentValues.getColor(id);
if (color == null) {
if (validate) {
if (validate && isInitialzed) {
// Throwable t = getFilteredTrace();
Msg.error(Gui.class, "No color value registered for: " + id);
}
@ -232,9 +233,9 @@ public class Gui {
public static Icon getRawIcon(String id, boolean validate) {
IconValue icon = currentValues.getIcon(id);
if (icon == null) {
if (validate) {
if (validate && isInitialzed) {
Throwable t = getFilteredTrace();
Msg.error(Gui.class, "No color value registered for: " + id, t);
Msg.error(Gui.class, "No icon value registered for: " + id, t);
}
return ResourceManager.getDefaultIcon();
}
@ -265,15 +266,6 @@ public class Gui {
repaintAll();
}
private static Color getUIColor(String id) {
// Not sure, but for now, make sure colors are not UIResource
Color color = UIManager.getColor(id);
if (color instanceof UIResource) {
return new Color(color.getRGB(), true);
}
return color;
}
private static Set<GTheme> findThemes() {
Set<GTheme> set = new HashSet<>();
set.addAll(findDiscoverableThemes());

View file

@ -135,8 +135,6 @@ public class LookAndFeelInstaller {
ids = LookAndFeelUtils.getLookAndFeelIdsForType(defaults, Icon.class);
for (String id : ids) {
Icon icon = UIManager.getIcon(id);
Msg.debug(LookAndFeelInstaller.class,
"adding " + id + " icon class = " + icon.getClass().getName());
values.addIcon(new IconValue(id, icon));
}

View file

@ -23,6 +23,8 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import docking.DockingUtils;
import docking.theme.GColor;
import docking.theme.GThemeDefaults.Colors.Palette;
import ghidra.util.SystemUtilities;
import ghidra.util.datastruct.WeakDataStructureFactory;
import ghidra.util.datastruct.WeakSet;
@ -42,11 +44,14 @@ public class FilterTextField extends JPanel {
private static final long MINIMUM_TIME_BETWEEN_FLASHES_MS = 5000;
private static final int FLASH_FREQUENCY_MS = 250;
private static Color FLASH_BACKGROUND_COLOR = Color.WHITE;
private static Color FILTERED_BACKGROUND_COLOR = Color.YELLOW;
/*package*/ static Color UNEDITABLE_BACKGROUND_COLOR = Color.LIGHT_GRAY;
private static Color FLASH_FOREGROUND_COLOR = new GColor("color.fg");
private static Color FILTERED_BACKGROUND_COLOR = new GColor("color.bg.filterfield");
private static Color FILTERED_FOREGROUND_COLOR = new GColor("color.fg.filterfield");
private Color noFlashColor;
/*package*/ static Color UNEDITABLE_BACKGROUND_COLOR = Palette.LIGHT_GRAY;
private Color noFlashBgColor;
private Color noFlashFgColor;
/** Signals the last flash time (used to prevent excessive flashing) */
private long lastFlashTime = 0;
@ -153,11 +158,18 @@ public class FilterTextField extends JPanel {
flashTimer.restart();
}
private Color getDefaultBackgroundColor() {
if (noFlashColor == null) {
noFlashColor = textField.getBackground(); // lazy init to default bg color
private Color getDefaultBgColor() {
if (noFlashBgColor == null) {
noFlashBgColor = textField.getBackground(); // lazy init to default bg color
}
return noFlashColor;
return noFlashBgColor;
}
private Color getDefaultFgColor() {
if (noFlashFgColor == null) {
noFlashFgColor = textField.getForeground(); // lazy init to default fg color
}
return noFlashFgColor;
}
/**
@ -209,28 +221,36 @@ public class FilterTextField extends JPanel {
public void setEditable(boolean b) {
textField.setEditable(b);
updateBackgroundColor();
updateColor();
}
private void updateBackgroundColor() {
private void updateColor() {
// this is purposely done here (before the isEditable() check below) in order to make
// sure that the default color has been properly initialized
Color defaultBackgroundColor = getDefaultBackgroundColor();
Color defaultBackgroundColor = getDefaultBgColor();
Color defaultFgColor = getDefaultFgColor();
Color bgColor = UNEDITABLE_BACKGROUND_COLOR;
Color fgColor = getDefaultFgColor();
if (isEditable() && isEnabled()) {
bgColor = hasText ? FILTERED_BACKGROUND_COLOR : defaultBackgroundColor;
fgColor = hasText ? FILTERED_FOREGROUND_COLOR : defaultFgColor;
}
doSetBackground(bgColor);
doSetForeground(fgColor);
}
private void contrastBackground() {
Color contrastColor = FLASH_BACKGROUND_COLOR;
if (textField.getBackground() == FLASH_BACKGROUND_COLOR) {
contrastColor = FILTERED_BACKGROUND_COLOR;
private void contrastColors() {
Color contrastBg = noFlashBgColor;
Color contrastFg = FLASH_FOREGROUND_COLOR;
if (textField.getBackground() == noFlashBgColor) {
contrastBg = FILTERED_BACKGROUND_COLOR;
contrastFg = FILTERED_FOREGROUND_COLOR;
}
doSetBackground(contrastColor);
doSetBackground(contrastBg);
doSetForeground(contrastFg);
}
public String getText() {
@ -307,6 +327,10 @@ public class FilterTextField extends JPanel {
textField.setBackground(c);
}
/*package*/ void doSetForeground(Color c) {
textField.setForeground(c);
}
/*package*/ JLabel getClearLabel() {
return clearLabel;
}
@ -333,7 +357,7 @@ public class FilterTextField extends JPanel {
updateFocusFlashing();
updateBackgroundColor();
updateColor();
if (fireEvent) {
fireFilterChanged(text);
@ -434,7 +458,7 @@ public class FilterTextField extends JPanel {
@Override
public void actionPerformed(ActionEvent event) {
if (flashCount < MAX_FLASH_COUNT) {
contrastBackground();
contrastColors();
flashCount++;
}
else {
@ -452,7 +476,7 @@ public class FilterTextField extends JPanel {
@Override
public void stop() {
super.stop();
updateBackgroundColor(); // set to the proper non-flashing color
updateColor(); // set to the proper non-flashing color
flashCount = 0;
}
}

View file

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 771 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 219 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 220 B

After

Width:  |  Height:  |  Size: 220 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 975 B

After

Width:  |  Height:  |  Size: 975 B

Before After
Before After

View file

@ -15,10 +15,9 @@
*/
package docking.widgets.filter;
import static docking.test.AbstractDockingTest.triggerEnter;
import static docking.test.AbstractDockingTest.triggerKey;
import static generic.test.AbstractGTest.sleep;
import static generic.test.AbstractGenericTest.runSwing;
import static docking.test.AbstractDockingTest.*;
import static generic.test.AbstractGTest.*;
import static generic.test.AbstractGenericTest.*;
import static org.junit.Assert.*;
import java.awt.BorderLayout;
@ -32,6 +31,7 @@ import javax.swing.*;
import org.junit.Before;
import org.junit.Test;
import generic.test.AbstractGTest;
import generic.test.AbstractGenericTest;
import utility.function.Callback;
@ -291,7 +291,7 @@ public class FilterTextFieldTest {
private void waitForTimer() {
Timer timer = filter.getFlashTimer();
AbstractGenericTest.waitForCondition(() -> {
AbstractGTest.waitForCondition(() -> {
boolean running = runSwing(() -> timer.isRunning());
return !running;
}, "Timed-out waiting for flash timer to finish");

View file

@ -170,7 +170,7 @@ public abstract class WebColors {
public static final Color MEDUM_AQUA_MARINE = registerColor("MediumAquaMarine", Color.decode("0x66CDAA"));
public static final Color MEDIUM_TURQOISE = registerColor("MediumTurquoise", Color.decode("0x48D1CC"));
public static final Color DARK_OLIVE_GREEN = registerColor("DarkOliveGreen", Color.decode("0x556B2F"));
public static final Color COMFLOWER_BLUE = registerColor("ComflowerBlue", Color.decode("0x6495ED"));
public static final Color CORNFLOWER_BLUE = registerColor("CornflowerBlue", Color.decode("0x6495ED"));
//@formatter:on
// cannot instantiate nor extend

View file

@ -17,18 +17,16 @@ package ghidra.app.plugin.gui;
import docking.action.builder.ActionBuilder;
import docking.theme.gui.ThemeDialog;
import ghidra.app.CorePluginPackage;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.framework.main.ApplicationLevelOnlyPlugin;
import ghidra.framework.main.FrontEndTool;
import ghidra.framework.main.UtilityPluginPackage;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.util.SystemUtilities;
//@formatter:off
@PluginInfo(
status = PluginStatus.RELEASED,
packageName = CorePluginPackage.NAME,
packageName = UtilityPluginPackage.NAME,
category = PluginCategoryNames.SUPPORT,
shortDescription = "Manages themes for the Ghdira GUI",
description = "Adds actions and options to manage Themes within Ghidra. " +
@ -39,9 +37,6 @@ public class ThemeManagerPlugin extends Plugin implements ApplicationLevelOnlyPl
public ThemeManagerPlugin(PluginTool tool) {
super(tool);
SystemUtilities.assertTrue(tool instanceof FrontEndTool,
"Plugin added to the wrong type of tool");
}
@Override