Ghidra is a software reverse engineering (SRE) framework
GP-2860 - Theming - Updated header colors to match the current LaF
dragonmacher956e7ac6ff57
diff --git a/Ghidra/Features/Base/data/base.listing.theme.properties b/Ghidra/Features/Base/data/base.listing.theme.propertiesindex f9fc4a35c4..60c1dac9a3 100644--- a/Ghidra/Features/Base/data/base.listing.theme.properties+++ b/Ghidra/Features/Base/data/base.listing.theme.properties@@ -5,12 +5,12 @@ color.bg.currentline.listing = color.bg.currentlinecolor.bg.selection.listing = color.bg.selectioncolor.bg.highlight.listing = color.bg.highlight-color.bg.listing.tabs.selected = #788CBD+color.bg.listing.tabs.selected = [color]textHighlightcolor.bg.listing.tabs.unselected = system.color.bg.applicationcolor.bg.listing.tabs.highlighted = #ABC8FFcolor.bg.listing.tabs.list = rgb(255, 255, 230)color.bg.listing.tabs.more.tabs.hover = rgb(255, 226, 213)-color.fg.listing.tabs.text.selected = black+color.fg.listing.tabs.text.selected = [color]textHighlightTextcolor.fg.listing.tabs.text.unselected = color.fgcolor.fg.listing.tabs.list = blackdiff --git a/Ghidra/Framework/Docking/data/docking.theme.properties b/Ghidra/Framework/Docking/data/docking.theme.propertiesindex 6fdd1754d1..51aa835e9f 100644--- a/Ghidra/Framework/Docking/data/docking.theme.properties+++ b/Ghidra/Framework/Docking/data/docking.theme.properties@@ -28,9 +28,9 @@ color.fg.help.selector.code.path = #4682B4color.bg.splashscreen = black-color.bg.header.active = mintcream-color.bg.header.inactive = rgb(150, 150, 150)-color.fg.header.active = black+color.bg.header.active = [color]textHighlight+color.bg.header.inactive = #A1A1A1+color.fg.header.active = [color]textHighlightTextcolor.fg.header.inactive = blackcolor.header.drag.cursor = black@@ -190,6 +190,12 @@ font.splash.status = Serif-BOLD-12font.table.header.number = arial-BOLD-12font.input.hint = monospaced-PLAIN-10++++++[Dark Defaults]color.bg = #1c1d1e@@ -210,10 +216,7 @@ color.fg.help.selector.code.path = #5BA5E3color.bg.splashscreen = black-color.bg.header.active = #4c87c8-color.bg.header.inactive = #466a92-color.fg.header.active = lightGray-color.fg.header.inactive = black+color.bg.header.inactive = #6A6A6Acolor.header.drag.cursor = lightGraycolor.fg.dialog.status.alert = orange@@ -253,3 +256,4 @@ color.bg.filechooser.shortcut = system.color.bg.widgetcolor.bg.tree = color.bgcolor.bg.tree.selected = [color]Tree.selectionBackground+diff --git a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.htmlindex eb9ff2d102..7aa4168930 100644--- a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html+++ b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html@@ -121,7 +121,7 @@tab for the appropriate type and double-click on the ID column or Current Value column of theitem you want to change. An editor for that type will appear.</P>- <H3>Reseting Theme Values</H3>+ <H3>Reseting Theme Values<A NAME="Restore_Value"></A></H3><P>To reset an individual value back to its original theme value, from themain application menu invoke the <A href=@@ -173,7 +173,7 @@to import. The selected file can be either a standard theme file or a Zip file containing thetheme file and any non-standard icon files defined by that theme.</P>- <H3>Reloading Default Values</H3>+ <H3>Reloading Default Values<A NAME="Reload_Ghidra_Defaults"></A></H3><P>This action causes Ghidra to reload all theme default values. It is really only usefulfor developers who are actively making changes to theme.properties files. To activate thisdiff --git a/Ghidra/Framework/Docking/src/main/java/docking/GenericHeader.java b/Ghidra/Framework/Docking/src/main/java/docking/GenericHeader.javaindex 8252b8598a..7131b1086f 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/GenericHeader.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/GenericHeader.java@@ -30,7 +30,6 @@ import docking.util.AnimationUtils;import docking.widgets.VariableHeightPanel;import docking.widgets.label.GDLabel;import generic.theme.GColor;-import generic.theme.GThemeDefaults.Colors;import generic.theme.GThemeDefaults.Colors.Java;import generic.theme.GThemeDefaults.Colors.Palette;@@ -106,7 +105,7 @@ public class GenericHeader extends JPanel {/*** Signals whether or not to break the toolbar actions into multiple rows. The default is- * to wrap as necessary.+ * to wrap as necessary.* @param noWrap true signals not to break the actions into multiple rows*/public void setNoWrapToolbar(boolean noWrap) {@@ -292,7 +291,7 @@ public class GenericHeader extends JPanel {//==================================================================================================// Inner Classes-//==================================================================================================+//==================================================================================================public class TitleFlasher {@@ -349,7 +348,7 @@ public class GenericHeader extends JPanel {setFocusable(false);titleLabel = new GDLabel();titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));- titleLabel.setForeground(Colors.FOREGROUND);+ titleLabel.setForeground(inactiveForeground);titleLabel.setFocusable(false);add(titleLabel, BorderLayout.CENTER);}@@ -371,13 +370,17 @@ public class GenericHeader extends JPanel {Graphics2D g2d = (Graphics2D) g;Rectangle r = getBounds();+ // use full color from 0 to the gradient start so the title text is painted over the+ // full color, which makes it a bit more readable+ int gradientStartOffset = 100;+ int x = r.x + gradientStartOffset;+ int y = r.y;GradientPaint gp;if (isSelected) {- gp = new GradientPaint(r.x, r.y, focusColor, r.x + r.width, r.y, getBackground());+ gp = new GradientPaint(x, y, focusColor, r.x + r.width, r.y, getBackground());}else {- gp = new GradientPaint(r.x, r.y, nonFocusColor, r.x + r.width, r.y,- getBackground());+ gp = new GradientPaint(x, y, nonFocusColor, r.x + r.width, r.y, getBackground());}g2d.setPaint(gp);diff --git a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeColorTableModel.java b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeColorTableModel.javaindex cba8f3dc41..99ad128350 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeColorTableModel.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeColorTableModel.java@@ -166,6 +166,7 @@ public class ThemeColorTableModel extends GDynamicColumnTableModel<ColorValue, Oreturn renderer;}+ @Overridepublic Comparator<ResolvedColor> getComparator() {return (v1, v2) -> {if (v1 == null && v2 == null) {@@ -201,6 +202,11 @@ public class ThemeColorTableModel extends GDynamicColumnTableModel<ColorValue, OString text = getValueText(resolved);Color color = resolved == null ? GThemeDefaults.Colors.BACKGROUND : resolved.color();++ String webName = WebColors.toWebColorName(color);+ String hex = WebColors.toString(color, false);+ String toolTipText = (webName == null ? "" : webName.toLowerCase()) + " " + hex;+ label.setToolTipText(toolTipText);label.setText(text);label.setIcon(new SwatchIcon(color, label.getForeground()));label.setOpaque(true);@@ -258,6 +264,8 @@ public class ThemeColorTableModel extends GDynamicColumnTableModel<ColorValue, O}}- record ResolvedColor(String id, String refId, Color color) {/**/}+ record ResolvedColor(String id, String refId, Color color) {+ //+ }}diff --git a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeDialog.java b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeDialog.javaindex d6330a0607..956839eeeb 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeDialog.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeDialog.java@@ -118,20 +118,22 @@ public class ThemeDialog extends DialogComponentProvider {if (themeManager.hasThemeChanges()) {int result = OptionDialog.showYesNoDialog(null, "Discard Theme Changes?","This will discard all of your theme changes. Continue?");- if (result == OptionDialog.YES_OPTION) {- themeManager.restoreThemeValues();+ if (result != OptionDialog.YES_OPTION) {+ return;}}+ themeManager.restoreThemeValues();}private void reloadDefaultsCallback() {if (themeManager.hasThemeChanges()) {int result = OptionDialog.showYesNoDialog(null, "Reload Default Theme Values?","This will discard all of your theme changes. Continue?");- if (result == OptionDialog.YES_OPTION) {- themeManager.reloadApplicationDefaults();+ if (result != OptionDialog.YES_OPTION) {+ return;}}+ themeManager.reloadApplicationDefaults();}private void reset() {diff --git a/Ghidra/Framework/Gui/src/main/java/ghidra/util/WebColors.java b/Ghidra/Framework/Gui/src/main/java/ghidra/util/WebColors.javaindex e8ba4ef344..789fc4057a 100644--- a/Ghidra/Framework/Gui/src/main/java/ghidra/util/WebColors.java+++ b/Ghidra/Framework/Gui/src/main/java/ghidra/util/WebColors.java@@ -26,7 +26,7 @@ import java.util.Map;*/public abstract class WebColors {private static final Map<String, Color> nameToColorMap = new HashMap<>();- private static final Map<Color, String> colorToNameMap = new HashMap<>();+ private static final Map<Integer, String> colorToNameMap = new HashMap<>();//@formatter:offpublic static final Color BLACK = registerColor("Black", Color.black);@@ -180,7 +180,7 @@ public abstract class WebColors {* Tries to find a color for the given String value. The String value can either be* a hex string (see {@link Color#decode(String)}) or a web color name as defined* above- *+ ** @param value the string value to interpret as a color* @param defaultColor a default color to return if the string can't be converted to a color* @return a color for the given string value or the default color if the string can't be translated@@ -195,7 +195,7 @@ public abstract class WebColors {* the color name will be returned. Otherwise, it will return a hex string for the color as* follows. If the color has an non-opaque alpha value, it will be of the form #rrggbb. If* it has an alpha value,then the format will be #rrggbbaa.- *+ ** @param color the color to convert to a string.* @return the string representation for the given color.*/@@ -208,7 +208,7 @@ public abstract class WebColors {* is true, the name of the color will be returned. OOtherwise, it will return a hex string for the color as* follows. If the color has an non-opaque alpha value, it will be of the form #rrggbb. If* it has an alpha value ,then the format will be #rrggbbaa.- *+ ** @param color the color to convert to a string.* @param useNameIfPossible if true, the name of the color will be returned if the color is* a WebColor@@ -216,7 +216,7 @@ public abstract class WebColors {*/public static String toString(Color color, boolean useNameIfPossible) {if (useNameIfPossible) {- String name = colorToNameMap.get(color);+ String name = colorToNameMap.get(color.getRGB());if (name != null) {return name;}@@ -235,12 +235,12 @@ public abstract class WebColors {* @return the WebColor name for the given color. Returns null if the color is not a WebColor*/public static String toWebColorName(Color color) {- return colorToNameMap.get(color);+ return colorToNameMap.get(color.getRGB());}private static Color registerColor(String name, Color color) {nameToColorMap.put(name.toLowerCase(), color);- colorToNameMap.put(color, name);+ colorToNameMap.put(color.getRGB(), name);return color;}@@ -290,12 +290,12 @@ public abstract class WebColors {* <pre>* #rrggbb* #rrggbbaa- * 0xrrggbb+ * 0xrrggbb* 0xrrggbbaa- * </pre>- *+ * </pre>+ ** Each of the hex digits "rr", "gg", "bb", and "aa" specify the red, green, blue, and alpha- * values respectively.+ * values respectively.* <br><br>** @param hexString the string to parse into a color.@@ -337,7 +337,7 @@ public abstract class WebColors {* <pre>* rgb(red, green, blue)* rgb(red, green, blue, alpha)- * </pre>+ * </pre>* Each of the values "red", "green", "blue", and "alpha" must be integer values between 0-255* <br><br>* @param rgbString the string to parse into a color.