GP-2860 - Theming - Updated header colors to match the current LaF

This commit is contained in:
dragonmacher 2022-12-12 18:53:24 -05:00
parent e47bfa4f51
commit 956e7ac6ff
7 changed files with 52 additions and 35 deletions

View File

@ -5,12 +5,12 @@ color.bg.currentline.listing = color.bg.currentline
color.bg.selection.listing = color.bg.selection
color.bg.highlight.listing = color.bg.highlight
color.bg.listing.tabs.selected = #788CBD
color.bg.listing.tabs.selected = [color]textHighlight
color.bg.listing.tabs.unselected = system.color.bg.application
color.bg.listing.tabs.highlighted = #ABC8FF
color.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]textHighlightText
color.fg.listing.tabs.text.unselected = color.fg
color.fg.listing.tabs.list = black

View File

@ -28,9 +28,9 @@ color.fg.help.selector.code.path = #4682B4
color.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]textHighlightText
color.fg.header.inactive = black
color.header.drag.cursor = black
@ -190,6 +190,12 @@ font.splash.status = Serif-BOLD-12
font.table.header.number = arial-BOLD-12
font.input.hint = monospaced-PLAIN-10
[Dark Defaults]
color.bg = #1c1d1e
@ -210,10 +216,7 @@ color.fg.help.selector.code.path = #5BA5E3
color.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 = #6A6A6A
color.header.drag.cursor = lightGray
color.fg.dialog.status.alert = orange
@ -253,3 +256,4 @@ color.bg.filechooser.shortcut = system.color.bg.widget
color.bg.tree = color.bg
color.bg.tree.selected = [color]Tree.selectionBackground

View File

@ -121,7 +121,7 @@
tab for the appropriate type and double-click on the ID column or Current Value column of the
item 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 the
main 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 the
theme 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 useful
for developers who are actively making changes to theme.properties files. To activate this

View File

@ -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);

View File

@ -166,6 +166,7 @@ public class ThemeColorTableModel extends GDynamicColumnTableModel<ColorValue, O
return renderer;
}
@Override
public Comparator<ResolvedColor> getComparator() {
return (v1, v2) -> {
if (v1 == null && v2 == null) {
@ -201,6 +202,11 @@ public class ThemeColorTableModel extends GDynamicColumnTableModel<ColorValue, O
String 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) {
//
}
}

View File

@ -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() {

View File

@ -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:off
public 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.