GP-1981 Review fixes

This commit is contained in:
ghidragon 2022-11-02 14:11:32 -04:00
parent 9679752523
commit a92a27e9f1
90 changed files with 375 additions and 381 deletions

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.ImmutableList;
import generic.ComparableTupleRecord;
import generic.theme.GColor;
import ghidra.framework.options.annotation.*;
import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool;
@ -165,6 +166,7 @@ public interface AutoOptions {
catch (IllegalArgumentException | IllegalAccessException e) {
throw new AssertionError(e);
}
OptionType type = annotation.type();
if (type == OptionType.NO_TYPE) {
type = OptionType.getOptionType(defaultValue);
@ -175,6 +177,7 @@ public interface AutoOptions {
"Could not determine option type from default value: " + f + " = " +
defaultValue);
}
String description = annotation.description();
Class<? extends PropertyEditor> editorClass = annotation.editor();
final PropertyEditor editor;
@ -191,7 +194,26 @@ public interface AutoOptions {
"editor class must have accessible default constructor", e);
}
}
options.registerOption(key.getName(), type, defaultValue, help, description, editor);
if (defaultValue instanceof GColor gColor) {
options.registerThemeColorBinding(key.getName(), gColor.getId(), help, description);
}
/*
else if ( is font option ) {
// Note: there is no font value to check against for fonts in the new Theme system.
// If annotation fonts are needed, then they should be bound by String id. Likely,
// annotation fonts are not needed now that have themes. We also probably no
// longer need annotation colors either.
options.registerThemeFontBinding(description, fontId, help, description);
}
*/
else {
options.registerOption(key.getName(), type, defaultValue, help, description,
editor);
}
// TODO: Wish Ghidra would do this upon any option registration
options.putObject(key.getName(), defaultValue, type);
}

View File

@ -3,7 +3,7 @@
##MODULE IP: Oxygen Icons - LGPL 3.0
Module.manifest||GHIDRA||reviewed||END|
data/ExtensionPoint.manifest||GHIDRA||||END|
data/sample.plugin.theme.properties||GHIDRA||||END|
data/sampletableplugin.theme.properties||GHIDRA||||END|
extension.properties||GHIDRA||||END|
src/main/help/help/TOC_Source.xml||GHIDRA||||END|
src/main/help/help/shared/arrow.gif||GHIDRA||reviewed||END|

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -20,7 +20,6 @@ data/base.icons.theme.properties||GHIDRA||||END|
data/base.listing.theme.properties||GHIDRA||||END|
data/base.programgraph.theme.properties||GHIDRA||||END|
data/base.theme.properties||GHIDRA||||END|
data/file_extension_icons.xml||GHIDRA||||END|
data/functionTags.xml||GHIDRA||||END|
data/ms_pe_rich_products.xml||GHIDRA||||END|
data/noReturnFunctionConstraints.xml||GHIDRA||||END|
@ -81,7 +80,7 @@ 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/file.extensions.icons.theme.properties||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

@ -1,44 +0,0 @@
<file_extensions>
<!-- Only single level file exts supported right now -->
<file_extension extension="" icon="images/famfamfam_silk_icons_v013/page_white.png" />
<file_extension extension=".apk" icon="images/famfamfam_silk_icons_v013/package.png" />
<file_extension extension=".c" icon="images/text-x-csrc.png" />
<file_extension extension=".cpp" icon="images/oxygen/16x16/text-x-c++src.png" />
<file_extension extension=".class" icon="images/famfamfam_silk_icons_v013/cup.png" />
<file_extension extension=".cs" icon="images/oxygen/16x16/text-x-csharp.png" />
<file_extension extension=".css" icon="images/famfamfam_silk_icons_v013/css.png" />
<file_extension extension=".data" icon="images/famfamfam_silk_icons_v013/database.png" />
<file_extension extension=".dfu" icon="images/famfamfam_silk_icons_v013/bullet_blue.png" />
<file_extension extension=".dmg" icon="images/famfamfam_silk_icons_v013/bullet_green.png" />
<file_extension extension=".f" icon="images/F.gif" />
<file_extension extension=".h" icon="images/oxygen/16x16/text-x-chdr.png" />
<file_extension extension=".html" icon="images/famfamfam_silk_icons_v013/html.png" />
<file_extension extension=".img" icon="images/famfamfam_silk_icons_v013/images.png" />
<file_extension extension=".img3" icon="images/famfamfam_silk_icons_v013/bullet_orange.png" />
<file_extension extension=".index" icon="images/oxygen/16x16/bookmarks.png" />
<file_extension extension=".ipsw" icon="images/oxygen/16x16/multimedia-player-apple-ipod.png" />
<file_extension extension=".iso" icon="images/nuvola/16x16/cdimage.png" />
<file_extension extension=".jar" icon="images/oxygen/16x16/application-x-java-archive.png" />
<file_extension extension=".java" icon="images/famfamfam_silk_icons_v013/page_white_cup.png" />
<file_extension extension=".kext" icon="images/famfamfam_silk_icons_v013/bullet_pink.png" />
<file_extension extension=".lib" icon="images/famfamfam_silk_icons_v013/server.png" />
<file_extension extension=".obj" icon="images/oxygen/16x16/application-x-subrip.png" />
<file_extension extension=".p" icon="images/oxygen/16x16/text-x-pascal.png" />
<file_extension extension=".pdf" icon="images/oxygen/16x16/application-pdf.png" />
<file_extension extension=".plist" icon="images/oxygen/16x16/insert-table.png" />
<file_extension extension=".png" icon="images/famfamfam_silk_icons_v013/bullet_red.png" />
<file_extension extension=".release." icon="images/famfamfam_silk_icons_v013/bullet_purple.png" />
<file_extension extension=".rss" icon="images/famfamfam_silk_icons_v013/rss.png" />
<file_extension extension=".strings" icon="images/oxygen/16x16/insert-text.png" />
<file_extension extension=".txt" icon="images/oxygen/16x16/text-x-bibtex.png" />
<file_extension extension=".usb" icon="images/nuvola/16x16/usb.png" />
<file_extension extension=".xhtml" icon="images/famfamfam_silk_icons_v013/xhtml.png" />
<file_extension extension=".xml" icon="images/oxygen/16x16/text-xml.png" />
<file_extension extension=".zip" icon="images/oxygen/16x16/application-x-bzip.png" />
<file_overlay name="imported" icon="images/checkmark_green.gif" />
<file_overlay name="filesystem" icon="images/nuvola/16x16/ledgreen.png" quadrant="LL" />
<file_overlay name="password_missing" icon="images/lock.png" quadrant="UR" />
</file_extensions>

View File

@ -1,6 +1,5 @@
[Defaults]
// Only single level file exts supported right now
icon.fsbrowser.file.extension.default = images/famfamfam_silk_icons_v013/page_white.png
icon.fsbrowser.file.extension.apk = images/famfamfam_silk_icons_v013/package.png
icon.fsbrowser.file.extension.c = images/text-x-csrc.png

View File

@ -62,15 +62,17 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> ex
implements CodeViewerService, CodeFormatService, OptionsChangeListener, FormatModelListener,
DomainObjectListener, CodeBrowserPluginInterface {
private static final String CURSOR_COLOR = "Cursor.Cursor Color - Focused";
private static final String UNFOCUSED_CURSOR_COLOR = "Cursor.Cursor Color - Unfocused";
private static final String BLINK_CURSOR = "Cursor.Blink Cursor";
private static final String MOUSE_WHEEL_HORIZONTAL_SCROLLING = "Mouse.Horizontal Scrolling";
private static final String CURSOR_COLOR_OPTIONS_NAME = "Cursor.Cursor Color - Focused";
private static final String UNFOCUSED_CURSOR_COLOR_OPTIONS_NAME =
"Cursor.Cursor Color - Unfocused";
private static final String BLINK_CURSOR_OPTIONS_NAME = "Cursor.Blink Cursor";
private static final String MOUSE_WHEEL_HORIZONTAL_SCROLLING_OPTIONS_NAME =
"Mouse.Horizontal Scrolling";
//@formatter:off
public static final GColor IFOCUSED_CURSOR_COLOR = new GColor("color.cursor.focused.listing");
public static final GColor IUNFOCUSED_CURSOR_COLOR = new GColor("color.cursor.unfocused.listing");
public static final GColor ICURRENT_LINE_HIGHLIGHT_COLOR = new GColor("color.bg.currentline.listing");
private static final GColor FOCUSED_CURSOR_COLOR = new GColor("color.cursor.focused.listing");
private static final GColor UNFOCUSED_CURSOR_COLOR = new GColor("color.cursor.unfocused.listing");
private static final GColor CURRENT_LINE_HIGHLIGHT_COLOR = new GColor("color.bg.currentline.listing");
//@formatter:on
// - Icon -
@ -412,15 +414,15 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> ex
highlightMarkers.setMarkerColor(color);
}
}
else if (optionName.equals(CURSOR_COLOR)) {
else if (optionName.equals(CURSOR_COLOR_OPTIONS_NAME)) {
Color color = ((Color) newValue);
fieldPanel.setFocusedCursorColor(color);
}
else if (optionName.equals(UNFOCUSED_CURSOR_COLOR)) {
else if (optionName.equals(UNFOCUSED_CURSOR_COLOR_OPTIONS_NAME)) {
Color color = ((Color) newValue);
fieldPanel.setNonFocusCursorColor(color);
}
else if (optionName.equals(BLINK_CURSOR)) {
else if (optionName.equals(BLINK_CURSOR_OPTIONS_NAME)) {
Boolean isBlinkCursor = ((Boolean) newValue);
fieldPanel.setBlinkCursor(isBlinkCursor);
}
@ -436,7 +438,7 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> ex
currentCursorMarkers.setColoringBackground(isHighlightCursorLine);
}
}
else if (optionName.equals(MOUSE_WHEEL_HORIZONTAL_SCROLLING)) {
else if (optionName.equals(MOUSE_WHEEL_HORIZONTAL_SCROLLING_OPTIONS_NAME)) {
fieldPanel.setHorizontalScrollingEnabled((Boolean) newValue);
}
@ -560,23 +562,25 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> ex
GhidraOptions.DEFAULT_HIGHLIGHT_COLOR.getId(), helpLocation,
"The highlight color in the browser.");
fieldOptions.registerThemeColorBinding(CURSOR_COLOR, IFOCUSED_CURSOR_COLOR.getId(),
fieldOptions.registerThemeColorBinding(CURSOR_COLOR_OPTIONS_NAME,
FOCUSED_CURSOR_COLOR.getId(),
helpLocation,
"The color of the cursor in the browser.");
fieldOptions.registerThemeColorBinding(UNFOCUSED_CURSOR_COLOR,
IUNFOCUSED_CURSOR_COLOR.getId(),
fieldOptions.registerThemeColorBinding(UNFOCUSED_CURSOR_COLOR_OPTIONS_NAME,
UNFOCUSED_CURSOR_COLOR.getId(),
helpLocation,
"The color of the cursor in the browser when the browser does not have focus.");
fieldOptions.registerOption(BLINK_CURSOR, true, helpLocation,
fieldOptions.registerOption(BLINK_CURSOR_OPTIONS_NAME, true, helpLocation,
"When selected, the cursor will blink when the containing window is focused.");
fieldOptions.registerThemeColorBinding(GhidraOptions.HIGHLIGHT_CURSOR_LINE_COLOR,
ICURRENT_LINE_HIGHLIGHT_COLOR.getId(), helpLocation,
CURRENT_LINE_HIGHLIGHT_COLOR.getId(), helpLocation,
"The background color of the line where the cursor is located");
fieldOptions.registerOption(GhidraOptions.HIGHLIGHT_CURSOR_LINE, true, helpLocation,
"Toggles highlighting background color of line containing the cursor");
helpLocation = new HelpLocation(getName(), "Keyboard_Controls_Shift");
fieldOptions.registerOption(MOUSE_WHEEL_HORIZONTAL_SCROLLING, true, helpLocation,
fieldOptions.registerOption(MOUSE_WHEEL_HORIZONTAL_SCROLLING_OPTIONS_NAME, true,
helpLocation,
"Enables horizontal scrolling by holding the Shift key while " +
"using the mouse scroll wheel");
@ -599,21 +603,21 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> ex
highlightMarkers.setMarkerColor(color);
}
color = fieldOptions.getColor(CURSOR_COLOR, IFOCUSED_CURSOR_COLOR);
color = fieldOptions.getColor(CURSOR_COLOR_OPTIONS_NAME, FOCUSED_CURSOR_COLOR);
fieldPanel.setFocusedCursorColor(color);
color = fieldOptions.getColor(UNFOCUSED_CURSOR_COLOR, IUNFOCUSED_CURSOR_COLOR);
color = fieldOptions.getColor(UNFOCUSED_CURSOR_COLOR_OPTIONS_NAME, UNFOCUSED_CURSOR_COLOR);
fieldPanel.setNonFocusCursorColor(color);
Boolean isBlinkCursor = fieldOptions.getBoolean(BLINK_CURSOR, true);
Boolean isBlinkCursor = fieldOptions.getBoolean(BLINK_CURSOR_OPTIONS_NAME, true);
fieldPanel.setBlinkCursor(isBlinkCursor);
boolean horizontalScrollingEnabled =
fieldOptions.getBoolean(MOUSE_WHEEL_HORIZONTAL_SCROLLING, true);
fieldOptions.getBoolean(MOUSE_WHEEL_HORIZONTAL_SCROLLING_OPTIONS_NAME, true);
fieldPanel.setHorizontalScrollingEnabled(horizontalScrollingEnabled);
cursorHighlightColor = fieldOptions.getColor(GhidraOptions.HIGHLIGHT_CURSOR_LINE_COLOR,
ICURRENT_LINE_HIGHLIGHT_COLOR);
CURRENT_LINE_HIGHLIGHT_COLOR);
isHighlightCursorLine = fieldOptions.getBoolean(GhidraOptions.HIGHLIGHT_CURSOR_LINE, true);
}

View File

@ -29,7 +29,6 @@ import docking.action.*;
import docking.dnd.DropTgtAdapter;
import docking.dnd.Droppable;
import docking.widgets.table.AbstractSortedTableModel;
import generic.theme.GIcon;
import ghidra.app.CorePluginPackage;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.ProgramPlugin;
@ -317,7 +316,7 @@ public class DataTypePreviewPlugin extends ProgramPlugin {
}
};
deleteAction.setPopupMenuData(new MenuData(new String[] { "Delete" }));
deleteAction.setToolBarData(new ToolBarData(new GIcon("icon.delete")));
deleteAction.setToolBarData(new ToolBarData(Icons.DELETE_ICON));
deleteAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_DELETE, 0));
deleteAction.setDescription("Delete Selected Datatypes");

View File

@ -22,7 +22,6 @@ import ghidra.app.CorePluginPackage;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.util.Msg;
/**
* Manages the markers to display areas where changes have occurred
@ -55,7 +54,6 @@ public class FontAdjustPlugin extends Plugin {
}
private void incrementFont(ActionContext context) {
Msg.debug(this, "incrementFont");
ComponentProvider provider = context.getComponentProvider();
if (provider != null) {
provider.adjustFontSize(true);
@ -63,7 +61,6 @@ public class FontAdjustPlugin extends Plugin {
}
private void decrementFont(ActionContext context) {
Msg.debug(this, "decrementFont");
ComponentProvider provider = context.getComponentProvider();
if (provider != null) {
provider.adjustFontSize(false);

View File

@ -49,7 +49,7 @@ import ghidra.util.layout.PairLayout;
class EditMemoryReferencePanel extends EditReferencePanel {
private static final Color BUTTON_COLOR = new GColor("color.fg.button");
private static final Icon MENU_ICON = new DropDownMenuIcon(16, 4, 4, BUTTON_COLOR);
private static final Icon MENU_ICON = new DropDownMenuIcon(BUTTON_COLOR);
private static final RefType[] MEM_REF_TYPES = RefTypeFactory.getMemoryRefTypes();

View File

@ -66,7 +66,7 @@ public class FixedBitSizeValueField extends JPanel {
}
add(valueField, BorderLayout.CENTER);
Font f2 = Gui.getFont("font.monospaced");
Font f2 = Gui.getFont(Font.MONOSPACED);
valueField.setFont(f2);
valueField.setMargin(new Insets(0, 2, 0, 2));

View File

@ -44,7 +44,7 @@ public class GhidraApplicationConfiguration extends HeadlessGhidraApplicationCon
@Override
protected void initializeApplication() {
Gui.initialize();
LookAndFeelUtils.platformSpecificFixups();
LookAndFeelUtils.performPlatformSpecificFixups();
if (showSplashScreen) {
showUserAgreement();

View File

@ -22,6 +22,7 @@ import javax.swing.JTextPane;
import javax.swing.text.*;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Ids.Fonts;
import generic.theme.Gui;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
@ -203,7 +204,7 @@ public class ConsoleTextPane extends JTextPane implements OptionsChangeListener
}
private void createAttribtues() {
createAttributes(Gui.getFont("font.monospaced"));
createAttributes(Gui.getFont(Fonts.MONOSPACED));
}
private void createAttributes(Font font) {

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -21,6 +21,7 @@ import java.awt.event.ActionListener;
import javax.swing.*;
import docking.widgets.label.GDLabel;
import generic.theme.GThemeDefaults;
import generic.theme.Gui;
import ghidra.feature.fid.db.*;
import ghidra.feature.fid.service.FidService;
@ -56,7 +57,7 @@ public class FidFunctionDebugPanel extends JPanel {
JButton button = new JButton(text);
button.addActionListener(listener);
button.setHorizontalAlignment(SwingConstants.LEFT);
button.setFont(Gui.getFont("font.monospaced"));
Gui.registerFont(button, GThemeDefaults.Ids.Fonts.MONOSPACED);
add(button);
}

View File

@ -21,6 +21,7 @@ import javax.swing.*;
import docking.DialogComponentProvider;
import docking.widgets.label.GDLabel;
import generic.theme.GThemeDefaults.Ids.Fonts;
import generic.theme.Gui;
import ghidra.feature.fid.db.FidFileManager;
import ghidra.feature.fid.db.FidQueryService;
@ -76,13 +77,13 @@ public class FidSearchDebugDialog extends DialogComponentProvider {
private JLabel getPreparedLabel(String text) {
JLabel label = new GDLabel(text, SwingConstants.RIGHT);
label.setFont(Gui.getFont("font.monospaced"));
label.setFont(Gui.getFont(Fonts.MONOSPACED));
return label;
}
private JTextField getPreparedTextField() {
JTextField textField = new JTextField(25);
textField.setFont(Gui.getFont("font.monospaced"));
textField.setFont(Gui.getFont(Fonts.MONOSPACED));
return textField;
}

View File

@ -26,6 +26,7 @@ import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import docking.widgets.table.*;
import generic.theme.GThemeDefaults.Ids.Fonts;
import generic.theme.Gui;
import ghidra.feature.fid.db.*;
import ghidra.feature.fid.service.FidService;
@ -65,7 +66,7 @@ public class FidSearchResultFrame extends JFrame implements FidQueryCloseListene
private void buildFrame() {
GTableCellRenderer renderer = new GTableCellRenderer();
renderer.setFont(Gui.getFont("font.monospaced"));
renderer.setFont(Gui.getFont(Fonts.MONOSPACED));
int columnCount = table.getColumnCount();
for (int ii = 0; ii < columnCount; ++ii) {
Class<?> columnClass = table.getColumnClass(ii);

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -30,6 +30,7 @@ import docking.action.DockingAction;
import docking.action.ToolBarData;
import docking.widgets.checkbox.GCheckBox;
import generic.theme.GIcon;
import generic.theme.GThemeDefaults.Ids.Fonts;
import generic.theme.Gui;
import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.ComponentProviderAdapter;
@ -294,7 +295,7 @@ public class DiffDetailsProvider extends ComponentProviderAdapter {
textPane.setName(DIFF_DETAILS_TEXT_AREA);
textPane.setEditable(false);
textPane.setMargin(new Insets(5, 5, 5, 5));
Gui.registerFont(textPane, "font.monospaced");
Gui.registerFont(textPane, Fonts.MONOSPACED);
textPane.setOpaque(true);
textPane.setCaretPosition(0);
JScrollPane scrolledDetails = new JScrollPane(textPane);

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -73,7 +73,7 @@ public class NewSessionPanel extends AbstractMageJPanel<VTWizardStateKey> {
folderLabel.setHorizontalAlignment(SwingConstants.RIGHT);
folderLabel.setToolTipText("The folder to store the new Version Tracking Session");
folderNameField = new JTextField();
Gui.registerFont(folderNameField, GThemeDefaults.Fonts.MONOSPACED);
Gui.registerFont(folderNameField, GThemeDefaults.Ids.Fonts.MONOSPACED);
folderNameField.setEditable(false); // force user to browse to choose
JButton browseFolderButton =

View File

@ -1,2 +1,2 @@
MODULE FILE LICENSE: lib/flatlaf-2.1.jar Apache License 2.0

View File

@ -26,8 +26,6 @@ eclipse.project.name = 'Framework Docking'
dependencies {
api project(':Generic')
api project(':Help')
api 'com.formdev:flatlaf:2.2'
// include code from src/test in Generic
testImplementation project(path: ':Generic', configuration: 'testArtifacts')

View File

@ -124,8 +124,6 @@ icon.dragon.256 = GhidraIcon256.png
icon.help.navigation.aid.disabled.overlay = icon.not.allowed
icon.help.navigation.aid.enabled = software-update-available.png
icon.options.node.leaf = icon.properties
icon.filechooser.places.my.computer = computer.png
icon.filechooser.places.desktop = desktop.png
icon.filechooser.places.home = user-home.png

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -11,8 +11,6 @@
</HEAD>
<BODY>
Theming Development Documentation
<H1>Ghidra Theming Developer Documentation</H1>
<P>This document provides everything an application developer should know when developing

View File

@ -16,6 +16,7 @@
package docking;
import java.awt.*;
import java.awt.geom.GeneralPath;
import javax.swing.Icon;
@ -24,34 +25,86 @@ import javax.swing.Icon;
*/
public class CloseIcon implements Icon {
private int size;
private int margin;
private Color color;
private Shape shape;
/**
* Creates a close icon.
* @param size the width and height of the icon
* @param margin the margin around the "x"
* @param color the color of the "x"
*/
public CloseIcon(int size, int margin, Color color) {
this.size = size;
this.margin = margin;
* Creates a close icon.
* @param isSmall false signals to use a 16x16 size; true signals to use an 8x8 size
* @param color the color of the "x"
*/
public CloseIcon(boolean isSmall, Color color) {
this.size = isSmall ? 8 : 16;
this.color = color;
this.shape = buildShape();
}
private Shape buildShape() {
GeneralPath path = new GeneralPath();
/*
We use trial and error sizing. This class allows clients to specify the icon size. At
the time of writing, there were only 2 sizes in use: 16 and 8 pixels. If more size
needs arise, we can revisit how the values below are chosen.
*/
double margin = 2;
double shapeSize = 11;
double thickness = 1.7;
if (size == 8) {
margin = 0;
shapeSize = 7;
thickness = 1;
}
double p1x = margin;
double p1y = margin + thickness;
double p2x = margin + thickness;
double p2y = margin;
double p3x = margin + shapeSize;
double p3y = margin + shapeSize - thickness;
double p4x = margin + shapeSize - thickness;
double p4y = margin + shapeSize;
path.moveTo(p1x, p1y);
path.lineTo(p2x, p2y);
path.lineTo(p3x, p3y);
path.lineTo(p4x, p4y);
path.lineTo(p1x, p1y);
p1x = margin + shapeSize - thickness;
p1y = margin;
p2x = margin + shapeSize;
p2y = margin + thickness;
p3x = margin + thickness;
p3y = margin + shapeSize;
p4x = margin;
p4y = margin + shapeSize - thickness;
path.moveTo(p1x, p1y);
path.lineTo(p2x, p2y);
path.lineTo(p3x, p3y);
path.lineTo(p4x, p4y);
path.lineTo(p1x, p1y);
path.closePath();
return path;
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(color);
int xStart = x + margin;
int yStart = y + margin;
int xEnd = x + size - margin;
int yEnd = y + size - margin;
g.drawLine(xStart, yStart, xEnd, yEnd);
g.drawLine(xStart, yEnd, xEnd, yStart);
g.drawLine(xStart + 1, yStart, xEnd + 1, yEnd);
g.drawLine(xStart + 1, yEnd, xEnd + 1, yStart);
g.drawLine(xStart - 1, yStart, xEnd - 1, yEnd);
g.drawLine(xStart - 1, yEnd, xEnd - 1, yStart);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
try {
g2d.translate(x, y);
g2d.setColor(color);
g2d.fill(shape);
}
finally {
g2d.translate(-x, -y);
}
}
@Override

View File

@ -32,8 +32,8 @@ import ghidra.util.task.SwingUpdateManager;
*/
class DockableToolBarManager {
private static final Color BUTTON_COLOR = new GColor("color.fg.button");
private static final Icon CLOSE_ICON = new CloseIcon(16, 4, BUTTON_COLOR);
private static final Icon MENU_ICON = new DropDownMenuIcon(16, 4, 4, BUTTON_COLOR);
private static final Icon CLOSE_ICON = new CloseIcon(false, BUTTON_COLOR);
private Icon MENU_ICON = new DropDownMenuIcon(BUTTON_COLOR);
private GenericHeader dockableHeader;
private ToolBarManager toolBarManager;

View File

@ -16,6 +16,7 @@
package docking;
import java.awt.*;
import java.awt.geom.GeneralPath;
import javax.swing.Icon;
@ -23,49 +24,71 @@ import javax.swing.Icon;
* Icon for a drop down menu button (triangle pointing down)
*/
public class DropDownMenuIcon implements Icon {
private int size;
private int xMargin;
private int yMargin;
private static final int ICON_SIZE = 16;
private Color color;
private Shape shape;
/**
* Creates a drop down menu icon.
* @param size the width and height of the icon
* @param xMargin the margin around triangle base
* @param yMargin the margin around triangle height
* @param color the color of the triangle
*/
public DropDownMenuIcon(int size, int xMargin, int yMargin, Color color) {
this.size = size;
this.xMargin = xMargin;
this.yMargin = yMargin;
public DropDownMenuIcon(Color color) {
this.color = color;
this.shape = buildShape();
}
private Shape buildShape() {
GeneralPath path = new GeneralPath();
double iconSize = 16;
double height = 6;
double width = 10;
double leftMargin = (iconSize - width) / 2;
double topMargin = (iconSize - height) / 2;
// draw a triangle pointing down; p1 is the bottom; p2 is the left
double p1x = leftMargin + (width / 2);
double p1y = topMargin + height;
double p2x = leftMargin;
double p2y = topMargin;
double p3x = leftMargin + width;
double p3y = topMargin;
path.moveTo(p1x, p1y);
path.lineTo(p2x, p2y);
path.lineTo(p3x, p3y);
path.lineTo(p1x, p1y);
path.closePath();
return path;
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(color);
// draw a triangle pointing down
int p1x = x + size / 2;
int p1y = y + size - yMargin;
int p2x = x + xMargin;
int p2y = y + yMargin;
int p3x = x + size - xMargin + 1;
int p3y = y + yMargin;
int xPoints[] = { p1x, p2x, p3x };
int yPoints[] = { p1y, p2y, p3y };
g.fillPolygon(xPoints, yPoints, 3);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
try {
g2d.translate(x, y);
g2d.setColor(color);
g2d.fill(shape);
}
finally {
g2d.translate(-x, -y);
}
}
@Override
public int getIconWidth() {
return size;
return ICON_SIZE;
}
@Override
public int getIconHeight() {
return size;
return ICON_SIZE;
}
}

View File

@ -50,7 +50,7 @@ public class DockingApplicationConfiguration extends ApplicationConfiguration {
super.initializeApplication();
Gui.initialize();
LookAndFeelUtils.platformSpecificFixups();
LookAndFeelUtils.performPlatformSpecificFixups();
if (showSplashScreen) {
SplashScreen.showSplashScreen();

View File

@ -133,12 +133,6 @@ public class IconPropertyEditor extends PropertyEditorSupport {
return panel;
}
// private void iconChanged() {
// Icon icon = dropDown.getSelectedValue();
// Msg.debug(this, "action listener: icon changed " + icon);
// dropDown.getSelectedValue();
// }
private void iconChanged(Icon icon) {
boolean isDropDownWindowShowing = dropDown.isMatchingListShowing();
if (!isDropDownWindowShowing) {
@ -216,10 +210,8 @@ public class IconPropertyEditor extends PropertyEditorSupport {
previewLabel = new GDLabel("");
previewLabel.setIcon(ResourceManager.getDefaultIcon());
// previewLabel.setPreferredSize(new Dimension(350, 50));
previewLabel.setHorizontalAlignment(SwingConstants.CENTER);
previewLabel.setVerticalAlignment(SwingConstants.CENTER);
// previewLabel.setMinimumSize(new Dimension(300, 50));
panel.add(previewLabel, BorderLayout.CENTER);
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
return panel;

View File

@ -23,11 +23,12 @@ import docking.widgets.tree.GTreeLazyNode;
import docking.widgets.tree.GTreeNode;
import generic.theme.GIcon;
import ghidra.framework.options.Options;
import resources.Icons;
class OptionsTreeNode extends GTreeLazyNode {
private final static Icon OPEN_FOLDER_ICON = new GIcon("icon.folder.open");
private final static Icon CLOSED_FOLDER_ICON = new GIcon("icon.folder.closed");
private final static Icon PROPERTIES_ICON = new GIcon("icon.options.node.leaf");
private final static Icon OPEN_FOLDER_ICON = Icons.OPEN_FOLDER_ICON;
private final static Icon CLOSED_FOLDER_ICON = Icons.CLOSED_FOLDER_ICON;
private final static Icon PROPERTIES_ICON = new GIcon("icon.properties");
private final Options options;
private final String name;

View File

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

View File

@ -79,7 +79,7 @@ public class ThemeDialog extends DialogComponentProvider {
.enabledWhen(c -> c.isChanged())
.popupWhen(c -> true)
.helpLocation(new HelpLocation("Theming", "Restore_Value"))
.onAction(c -> c.getThemeValue().makeCurrentValue())
.onAction(c -> c.getThemeValue().installValue())
.build();
addAction(resetValueAction);
}

View File

@ -25,7 +25,7 @@ import docking.DockingWindowManager;
import generic.theme.ThemeValue;
/**
* Base class for Theme properties (Colors, Fonts, and Icons)
* Base class for Theme property Editors (Colors, Fonts, and Icons)
*
* @param <T> the base property (Color, Font, or Icon)
*/

View File

@ -1152,6 +1152,7 @@ public class FieldPanel extends JPanel
}
private Color blend(Color primary, Color secondary) {
return ColorUtils.blend(primary, secondary, 0.75);
}

View File

@ -32,9 +32,7 @@ import generic.theme.GColor;
public class DockingTabRenderer extends JPanel {
private static final int MAX_TITLE_LENGTH = 25;
private Icon CLOSE_ICON = new CloseIcon(8, 1, new GColor("color.fg.button"));
private Icon EMPTY_ICON = CLOSE_ICON;
//TODO if we don't want the close icon to come and go, then this class can be greatly simplified
private Icon CLOSE_ICON = new CloseIcon(true, new GColor("color.fg.button"));
private JLabel titleLabel;
private JLabel iconLabel;
@ -56,9 +54,9 @@ public class DockingTabRenderer extends JPanel {
setTitle(tabTitle, fullTitle);
closeButton.setToolTipText("Close " + tabTitle);
closeButton.setIcon(EMPTY_ICON); // no icon until we rollover the tab
closeButton.setFocusable(false);
closeButton.addActionListener(closeListener);
closeButton.setIcon(CLOSE_ICON);
closeButton.setRolloverIcon(CLOSE_ICON);
JPanel container = new JPanel();
@ -84,20 +82,10 @@ public class DockingTabRenderer extends JPanel {
titleLabel.addMouseListener(eventForwardingListener);
titleLabel.addMouseMotionListener(eventForwardingListener);
// listeners to know when to hide our close button (from the tabbed pane)
final ButtonIconSwapperMouseListener iconListener =
new ButtonIconSwapperMouseListener(tabbedPane);
installIconListener(container, tabbedPane, iconListener);
// listeners to know when to hide our close button (from this panel)
addMouseListener(iconListener);
addMouseMotionListener(iconListener);
installMouseForwardingListenerWorkaround(tabbedPane, iconListener);
installMouseForwardingListenerWorkaround(tabbedPane);
}
private void installMouseForwardingListenerWorkaround(final JTabbedPane tabbedPane,
final ButtonIconSwapperMouseListener iconListener) {
private void installMouseForwardingListenerWorkaround(final JTabbedPane tabbedPane) {
forwardingListener = new TabContainerForwardingMouseListener(tabbedPane);
@ -114,20 +102,14 @@ public class DockingTabRenderer extends JPanel {
boolean isDisplayable = isDisplayable();
if (isDisplayable) {
// remove and add in order to prevent duplicate adding
myParent.removeMouseListener(iconListener);
myParent.removeMouseMotionListener(iconListener);
myParent.removeMouseListener(forwardingListener);
myParent.removeMouseMotionListener(forwardingListener);
myParent.addMouseListener(iconListener);
myParent.addMouseMotionListener(iconListener);
myParent.addMouseListener(forwardingListener);
myParent.addMouseMotionListener(forwardingListener);
hierarchyListener = this;
}
else if (hierarchyListener != null) {
myParent.removeMouseListener(iconListener);
myParent.removeMouseMotionListener(iconListener);
myParent.removeMouseListener(forwardingListener);
myParent.removeMouseMotionListener(forwardingListener);
@ -145,20 +127,6 @@ public class DockingTabRenderer extends JPanel {
return title;
}
// add listeners to the tabbed pane so that the icon for closing appears (and disappears) as
// needed
private void installIconListener(Container container, JTabbedPane tabbedPane,
ButtonIconSwapperMouseListener iconListener) {
Component[] components = container.getComponents();
for (Component component : components) {
component.addMouseListener(iconListener);
}
tabbedPane.addMouseListener(iconListener);
// we need this due to the gaps between the renderer and the tabbed pane
tabbedPane.addMouseMotionListener(iconListener);
}
public void installRenameAction(MouseListener listener) {
this.renameListener = listener;
}
@ -193,57 +161,6 @@ public class DockingTabRenderer extends JPanel {
// Inner Classes
//==================================================================================================
/**
* A class to hide/show the close button's icon to make it appear that the button is hidden
* and removed.
*/
private class ButtonIconSwapperMouseListener extends MouseAdapter {
private final JTabbedPane tabbedPane;
ButtonIconSwapperMouseListener(JTabbedPane tabbedPane) {
this.tabbedPane = tabbedPane;
}
private void updateButton(MouseEvent e) {
Point point = e.getPoint();
Point tabbedPaneRelativePoint =
SwingUtilities.convertPoint(e.getComponent(), point, tabbedPane);
int x = tabbedPaneRelativePoint.x;
int y = tabbedPaneRelativePoint.y;
int tabIndex = tabbedPane.indexAtLocation(x, y);
if (tabIndex < 0) {
// no tab for the given point (can happen when over the tabbed pane, but not
// over any tab)
closeButton.setIcon(EMPTY_ICON);
return;
}
Component tabComponent = tabbedPane.getTabComponentAt(tabIndex);
if (SwingUtilities.isDescendingFrom(closeButton, tabComponent)) {
closeButton.setIcon(CLOSE_ICON);
}
else {
closeButton.setIcon(EMPTY_ICON);
}
}
@Override
public void mouseMoved(MouseEvent e) {
updateButton(e);
}
@Override
public void mouseEntered(MouseEvent e) {
updateButton(e);
}
@Override
public void mouseExited(MouseEvent e) {
closeButton.setIcon(EMPTY_ICON);
}
}
/**
* A class designed to listen for mouse events on this renderer component which it will then
* forward on to the given component.

View File

@ -72,7 +72,7 @@ public class LookAndFeelUtils {
}
}
public static void platformSpecificFixups() {
public static void performPlatformSpecificFixups() {
// Set the dock icon for macOS
if (Taskbar.isTaskbarSupported()) {
Taskbar taskbar = Taskbar.getTaskbar();

View File

@ -204,8 +204,8 @@ public class ThemeUtilsTest extends AbstractDockingTest {
}
@Test
public void testParseGroupingsParseError() {
String source = "(ab (cd))(ef)( gh))";
public void testParseGroupingsWithUnbalancedGroups() {
String source = "(ab (cd))(ef)( gh))"; // note the groupings are unbalanced
try {
ThemeValueUtils.parseGroupings(source, '(', ')');
fail("Expected parse Exception");
@ -216,8 +216,8 @@ public class ThemeUtilsTest extends AbstractDockingTest {
}
@Test
public void testParseGroupingsParseError2() {
String source = " xx";
public void testParseGroupingsWhenNoGroupingsExist() {
String source = "xx yy"; // note there are no grouping chars
try {
ThemeValueUtils.parseGroupings(source, '(', ')');
fail("Expected parse Exception");

View File

@ -10,3 +10,4 @@ MODULE FILE LICENSE: lib/gson-2.9.0.jar Apache License 2.0
MODULE FILE LICENSE: lib/bcpkix-jdk15on-1.69.jar Bouncy Castle License
MODULE FILE LICENSE: lib/bcprov-jdk15on-1.69.jar Bouncy Castle License
MODULE FILE LICENSE: lib/bcutil-jdk15on-1.69.jar Bouncy Castle License
MODULE FILE LICENSE: lib/flatlaf-2.6.jar Apache License 2.0

View File

@ -38,7 +38,7 @@ dependencies {
api 'org.bouncycastle:bcpkix-jdk15on:1.69' // requires bcutil and bcprov
api 'org.bouncycastle:bcprov-jdk15on:1.69'
api 'org.bouncycastle:bcutil-jdk15on:1.69'
api 'com.formdev:flatlaf:2.2'
api 'com.formdev:flatlaf:2.6'
compileOnly "junit:junit:4.12"

View File

@ -291,7 +291,7 @@ public abstract class AbstractThemeReader {
error(lineNumber, "Missing key for propery line: \"" + line + "\"");
return;
}
if (key.isBlank()) {
if (value.isBlank()) {
error(lineNumber, "Missing value for propery line: \"" + line + "\"");
return;
}

View File

@ -104,7 +104,8 @@ public class ColorValue extends ThemeValue<Color> {
Msg.error(this,
"Could not resolve indirect color path for \"" + unresolvedId +
"\" for primary id \"" + id + "\", using last resort default");
"\" for primary id \"" + id + "\", using last resort default",
t);
return LAST_RESORT_DEFAULT;
}
@ -149,7 +150,7 @@ public class ColorValue extends ThemeValue<Color> {
}
@Override
public void makeCurrentValue() {
public void installValue() {
Gui.setColor(this);
}

View File

@ -18,7 +18,6 @@ package generic.theme;
import java.awt.Font;
import java.text.ParseException;
import java.util.List;
import java.util.regex.Pattern;
/**
* Class that can transform one font into another. For example if want a font that is the same
@ -26,8 +25,6 @@ import java.util.regex.Pattern;
* FontModifier
*/
public class FontModifier {
private static final Pattern MODIFIER_PATTERN = Pattern.compile("(\\[([a-zA-Z]+|[0-9]+)\\])*");
private String family;
private Integer style;
private Integer size;

View File

@ -121,6 +121,11 @@ public class FontValue extends ThemeValue<Font> {
return font == null ? null : new FontValue(id, font);
}
/**
* Returns the Font style int for the given style string
* @param styleString the string to convert to a Font style int
* @return the Font style int for the given style string
*/
public static int getStyle(String styleString) {
if ("plain".equalsIgnoreCase(styleString)) {
return Font.PLAIN;
@ -227,7 +232,7 @@ public class FontValue extends ThemeValue<Font> {
}
@Override
public void makeCurrentValue() {
public void installValue() {
Gui.setFont(this);
}

View File

@ -30,7 +30,7 @@ import ghidra.util.datastruct.WeakStore;
* color table that is determined by the active {@link GTheme}.
* <P>The idea is for developers to
* not use specific colors in their code, but to instead use a GColor with an id that hints at
* its use. For example, instead of harding code a component's background color to white by coding
* its use. For example, instead of hard coding a component's background color to white by coding
* "component.setBackground(Color.white)", you would do something like
* "component.setBackground(new GColor("color.mywidget.bg"). Then in a
* "[module name].theme.properties" file (located in the module's data directory), you would
@ -127,6 +127,11 @@ public class GColor extends Color {
return delegate.darker();
}
/**
* Returns true if this GColor could not find a value for its color id in the current theme
* and is using the default color as its delegate
* @return true if this GColor could not find a value for its color id in the current theme
*/
public boolean isUnresolved() {
return delegate == ColorValue.LAST_RESORT_DEFAULT;
}
@ -144,20 +149,17 @@ public class GColor extends Color {
return WebColors.toString(this, false);
}
/**
* Generates a more verbose toString()
* @return a more verbose toString()
*/
public String toDebugString() {
Color c = delegate;
String rgb =
"(" + c.getRed() + "," + c.getGreen() + "," + c.getBlue() + "," + c.getAlpha() + ")";
String hexrgb = "(" + WebColors.toString(c, true) + ")";
return getClass().getSimpleName() + " [id = " + id + ", color = " +
c.getClass().getSimpleName() + rgb + "]";
}
public String toDebugHexString() {
Color c = delegate;
String rgb =
"(" + WebColors.toString(c, true) + ")";
return getClass().getSimpleName() + " [id = " + id + ", color = " +
c.getClass().getSimpleName() + rgb + "]";
c.getClass().getSimpleName() + rgb + hexrgb + "]";
}
@Override

View File

@ -31,8 +31,8 @@ import resources.icons.*;
* icon table that is determined by the active {@link GTheme}.
* <P> The idea is for developers to
* not use specific icons in their code, but to instead use a GIcon with an id that hints at
* its use. For example, instead of harding code a label's icon by coding
* "lable.setIcon(ResourceManager.loadImage("images/refresh.png", you would do something like
* its use. For example, instead of hard coding a label's icon by coding
* "label.setIcon(ResourceManager.loadImage("images/refresh.png", you would do something like
* label.setIcon(new GIcon("icon.refresh"). Then in a "[module name].theme.properties" file
* (located in the module's data directory), you would set the default value by adding this
* line "icon.refresh = images/refresh.png".

View File

@ -41,7 +41,7 @@ public class GTheme extends GThemeValueMap {
private final File file;
/**
* Creates an new GTheme with the given name, the default {@link LookAndFeel} for the the
* Creates a new GTheme with the given name, the default {@link LookAndFeel} for the the
* platform and not using dark defaults. This theme will be using all the standard defaults
* from the theme.property files and the defaults from the default LookAndFeel.
* @param name the name for this GTheme

View File

@ -32,6 +32,14 @@ public class GThemeDefaults {
public static class Java {
public static final String BORDER = "system.color.border"; // TODO
}
public static class Fonts {
public static final String STANDARD = "font.standard";
public static final String BOLD = "font.bold";
public static final String ITALIC = "font.italic";
public static final String BOLD_ITALIC = "font.bold.italic";
public static final String MONOSPACED = "font.monospaced";
}
}
/**
@ -125,12 +133,4 @@ public class GThemeDefaults {
}
}
}
public static class Fonts {
public static final String STANDARD = "font.standard";
public static final String BOLD = "font.bold";
public static final String ITALIC = "font.italic";
public static final String BOLD_ITALIC = "font.bold.italic";
public static final String MONOSPACED = "font.monospaced";
}
}

View File

@ -23,7 +23,8 @@ import java.util.List;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import com.formdev.flatlaf.*;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatLightLaf;
import generic.theme.builtin.*;
import generic.theme.laf.LookAndFeelManager;
@ -92,7 +93,6 @@ public class Gui {
installFlatLookAndFeels();
loadThemeDefaults();
setTheme(themePreferenceManager.getTheme());
// LookAndFeelUtils.installGlobalOverrides();
}
/**
@ -489,6 +489,7 @@ public class Gui {
return gIcon;
}
// used by
public static void setSystemDefaults(GThemeValueMap map) {
systemValues = map;
}
@ -730,8 +731,6 @@ public class Gui {
private static void installFlatLookAndFeels() {
UIManager.installLookAndFeel(LafType.FLAT_LIGHT.getName(), FlatLightLaf.class.getName());
UIManager.installLookAndFeel(LafType.FLAT_DARK.getName(), FlatDarkLaf.class.getName());
UIManager.installLookAndFeel(LafType.FLAT_DARCULA.getName(),
FlatDarculaLaf.class.getName());
}
private static void loadThemeDefaults() {

View File

@ -247,7 +247,7 @@ public class IconValue extends ThemeValue<Icon> {
}
@Override
public void makeCurrentValue() {
public void installValue() {
Gui.setIcon(this);
}

View File

@ -34,7 +34,6 @@ public enum LafType {
MOTIF("CDE/Motif"),
FLAT_LIGHT("Flat Light"),
FLAT_DARK("Flat Dark"),
FLAT_DARCULA("Flat Darcula"),
WINDOWS("Windows"),
WINDOWS_CLASSIC("Windows Classic"),
MAC("Mac OS X");
@ -109,7 +108,6 @@ public enum LafType {
return new MotifLookAndFeelManager();
case NIMBUS:
return new NimbusLookAndFeelManager();
case FLAT_DARCULA:
case FLAT_DARK:
case FLAT_LIGHT:
return new FlatLookAndFeelManager(lookAndFeel);

View File

@ -52,7 +52,7 @@ public class ThemeFileLoader {
}
catch (IOException e) {
Msg.error(this,
"Error reading theme properties file: " + resourceFile.getAbsolutePath());
"Error reading theme properties file: " + resourceFile.getAbsolutePath(), e);
}
}
}

View File

@ -52,7 +52,7 @@ public class ThemePreferenceManager {
}
catch (Exception e) {
Msg.showError(GTheme.class, null, "Can't Load Previous Theme",
"Can't find or instantiate class: " + className);
"Can't find or instantiate class: " + className, e);
}
}
return Gui.getDefaultTheme();

View File

@ -207,8 +207,8 @@ public abstract class ThemeValue<T> implements Comparable<ThemeValue<T>> {
}
/**
* Makes this value the current value for the application
* Install this value as the current value for the application
*/
public abstract void makeCurrentValue();
public abstract void installValue();
}

View File

@ -24,37 +24,35 @@ public class FlatThemeGrouper extends ThemeGrouper {
@Override
public void group(GThemeValueMap values) {
// we made up a source property for a common Flat color. Picked one of them as
// an exemplar (menu.foreground)
// @formatter:off
defineCustomColorGroup(values, "color.flat.menu.hover.bg", "MenuBar.hoverBackground");
defineCustomColorGroup(values, "color.flat.button.hover.bg", "Button.hoverBackground");
defineCustomColorGroup(values, "color.flat.button.selected.bg","Button.selectedBackground");
defineCustomColorGroup(values, "color.flat.button.toolbar.hover.bg","Button.toolbar.hoverBackground");
defineCustomColorGroup(values, "color.flat.button.toolbar.pressed.bg","Button.toolbar.pressedBackground");
defineCustomColorGroup(values, "color.flat.checkbox.icon.focus.border","CheckBox.icon.focusedBorderColor");
defineCustomColorGroup(values, "color.flat.menu.accelerator.fg","Menu.acceleratorForeground");
defineCustomColorGroup("color.flat.menu.hover.bg", "MenuBar.hoverBackground", values);
defineCustomColorGroup("color.flat.button.hover.bg", "Button.hoverBackground", values);
defineCustomColorGroup("color.flat.button.selected.bg", "Button.selectedBackground",values);
defineCustomColorGroup("color.flat.button.toolbar.hover.bg", "Button.toolbar.hoverBackground",values);
defineCustomColorGroup("color.flat.button.toolbar.pressed.bg", "Button.toolbar.pressedBackground",values);
defineCustomColorGroup("color.flat.checkbox.icon.focus.border", "CheckBox.icon.focusedBorderColor",values);
defineCustomColorGroup("color.flat.menu.accelerator.fg", "Menu.acceleratorForeground",values);
defineCustomColorGroup(values, "color.flat.focus.border", "Button.focusedBorderColor");
defineCustomColorGroup(values, "color.flat.focus", "Component.focusColor");
defineCustomColorGroup(values, "color.flat.focus.bg", "Button.focusedBackground");
defineCustomColorGroup(values, "color.flat.checkmark", "CheckBox.icon.checkmarkColor");
defineCustomColorGroup(values, "color.flat.disabled", "Button.disabledBorderColor");
defineCustomColorGroup(values, "color.flat.disabled.selected","Button.disabledSelectedBackground");
defineCustomColorGroup(values, "color.flat.arrow","Spinner.buttonArrowColor");
defineCustomColorGroup(values, "color.flat.arrow.disabled","Spinner.buttonDisabledArrowColor");
defineCustomColorGroup(values, "color.flat.arrow.hover","Spinner.buttonHoverArrowColor");
defineCustomColorGroup(values, "color.flat.arrow.pressed","Spinner.buttonPressedArrowColor");
defineCustomColorGroup("color.flat.focus.border", "Button.focusedBorderColor", values);
defineCustomColorGroup("color.flat.focus", "Component.focusColor", values);
defineCustomColorGroup("color.flat.focus.bg", "Button.focusedBackground", values);
defineCustomColorGroup("color.flat.checkmark", "CheckBox.icon.checkmarkColor", values);
defineCustomColorGroup("color.flat.disabled", "Button.disabledBorderColor", values);
defineCustomColorGroup("color.flat.disabled.selected", "Button.disabledSelectedBackground",values);
defineCustomColorGroup("color.flat.arrow", "Spinner.buttonArrowColor",values);
defineCustomColorGroup("color.flat.arrow.disabled", "Spinner.buttonDisabledArrowColor",values);
defineCustomColorGroup("color.flat.arrow.hover", "Spinner.buttonHoverArrowColor",values);
defineCustomColorGroup("color.flat.arrow.pressed", "Spinner.buttonPressedArrowColor",values);
defineCustomColorGroup(values, "color.flat.dropcell.bg","List.dropCellBackground");
defineCustomColorGroup(values, "color.flat.dropline","List.dropLineColor");
defineCustomColorGroup(values, "color.flat.underline","MenuItem.underlineSelectionColor");
defineCustomColorGroup(values, "color.flat.docking.bg","ToolBar.dockingBackground");
defineCustomColorGroup(values, "color.flat.progressbar.bg","ProgressBar.background");
defineCustomColorGroup(values, "color.flat.progressbar.fg","ProgressBar.foreground");
defineCustomColorGroup(values, "color.flat.icon.bg","Tree.icon.openColor");
defineCustomColorGroup(values, "color.flat.selection.inactive","Tree.selectionInactiveBackground");
defineCustomColorGroup("color.flat.dropcell.bg", "List.dropCellBackground",values);
defineCustomColorGroup("color.flat.dropline", "List.dropLineColor",values);
defineCustomColorGroup("color.flat.underline", "MenuItem.underlineSelectionColor",values);
defineCustomColorGroup("color.flat.docking.bg", "ToolBar.dockingBackground",values);
defineCustomColorGroup("color.flat.progressbar.bg", "ProgressBar.background",values);
defineCustomColorGroup("color.flat.progressbar.fg", "ProgressBar.foreground",values);
defineCustomColorGroup("color.flat.icon.bg", "Tree.icon.openColor",values);
defineCustomColorGroup("color.flat.selection.inactive", "Tree.selectionInactiveBackground",values);
// @formatter:on

View File

@ -39,7 +39,7 @@ public abstract class LookAndFeelManager {
/**
* These are color ids (see {@link GColor} used to represent general concepts that
* application developers can use to get the color for that concept as defined by
* a specific {@link LookAndFeel}. This class will define some standard defaults
* a specific {@link LookAndFeel}. This class will define some standard default
* mappings in the constructor, but it is expected that each specific LookAndFeelManager
* will override these mappings with values appropriate for that LookAndFeel.
*/

View File

@ -25,12 +25,12 @@ public class MacThemeGrouper extends ThemeGrouper {
@Override
public void group(GThemeValueMap values) {
// @formatter:off
defineCustomColorGroup(values, "color.mac.disabled.fg", "Menu.disabledForeground");
defineCustomColorGroup(values, "color.mac.button.select", "Button.select");
defineCustomColorGroup(values, "color.mac.menu.select","Menu.selectionBackground");
defineCustomColorGroup(values, "color.mac.seletion.inactive.bg","List.selectionInactiveBackground");//d4d4d4
defineCustomColorGroup("color.mac.disabled.fg", "Menu.disabledForeground", values);
defineCustomColorGroup("color.mac.button.select", "Button.select", values);
defineCustomColorGroup("color.mac.menu.select", "Menu.selectionBackground",values);
defineCustomColorGroup("color.mac.seletion.inactive.bg", "List.selectionInactiveBackground",values);//d4d4d4
defineCustomFontGroup(values, "font.mac.smallFont", "IconButton.font");
defineCustomFontGroup("font.mac.small.font", "IconButton.font", values);
// @formatter:on
super.group(values);
}

View File

@ -27,7 +27,7 @@ public class MotifThemeGrouper extends ThemeGrouper {
@Override
public void group(GThemeValueMap values) {
defineCustomFontGroup(values, "font.monospaced", "Spinner.font");
defineCustomFontGroup("font.monospaced", "Spinner.font", values);
super.group(values);
}

View File

@ -34,8 +34,8 @@ public class NimbusThemeGrouper extends ThemeGrouper {
@Override
public void group(GThemeValueMap values) {
defineCustomColorGroup(values, "color.nimbus.text.alt", "Menu.foreground");
defineCustomFontGroup(values, "font.titledborder", "TitledBorder.font");
defineCustomColorGroup("color.nimbus.text.alt", "Menu.foreground", values);
defineCustomFontGroup("font.titledborder", "TitledBorder.font", values);
super.group(values);
}

View File

@ -31,12 +31,17 @@ import generic.theme.*;
* organize the properties internally and this class attempts to restore that organization
* as much as possible by using the values defined in the {@link BasicLookAndFeel} such as
* "control", "window", "controlShadlow", etc. The fonts don't appear to have any such internal
* organization, so we created our own groups and used an exemplar property to initialize each
* group source value. Then whenever the font matched a group source value, the color is replace
* with an indirect reference to the group source property value.
* organization, so we created our own groups and used a lookAndFeel property to initialize each
* group source value. Then whenever the font matched a group source value, the font is replace
* with an indirect reference to the group source font value.
* <p>
* This class is sometimes sub-classed for a particular {@link LookAndFeel}. The subclass can
* create new groups and mappings that are unique to that LookAndFeel.
*
* Often, many of the various group source ids have the same color value. To try to group
* properties as defined in BasicLookAndFeel, the preferred source ids are
* defined for each group. These will be tried first, but if a match isn't found among the
* preferred sources, then all the sources will be searched for a match
*/
public class ThemeGrouper {
private static String DEFAULT_FONT_GROUP_ID = "font.default";
@ -141,10 +146,6 @@ public class ThemeGrouper {
"ToolTip"
};
// often the many of the various group source ids have the same color value. To try and group
// properties as defined in BasicLookAndFeel, the preferred source ids are
// defined for each group. These will be tried first, but if a match isn't found among the
// preferred sources, then all the sources will be searched for a match
private static final String[] BUTTON_PREFERRED_SOURCES = {
"control",
"controlText",
@ -225,24 +226,42 @@ public class ThemeGrouper {
groupFonts(values, groupMap);
}
protected void defineCustomColorGroup(GThemeValueMap values, String customGroupName,
String exemplarComponentId) {
/**
* Defines a new color id that will be used as the reference value for any specific color ids that
* have the same color value. This will allow all those specific colors to be changed at once.
* @param customGroupColorName name of a higher level group color id that will be used as the
* value for more specific color ids defined by the lookAndFeel.
* @param lookAndFeelSourceId the lookAndFeel color id whose value will be used as the value
* for the new custom group color id
* @param values the map where we store the default theme value mappings
*/
protected void defineCustomColorGroup(String customGroupColorName, String lookAndFeelSourceId,
GThemeValueMap values) {
colorSourceProperties.add(customGroupName);
ColorValue colorValue = values.getColor(exemplarComponentId);
colorSourceProperties.add(customGroupColorName);
ColorValue colorValue = values.getColor(lookAndFeelSourceId);
if (colorValue != null) {
Color color = colorValue.get(values);
values.addColor(new ColorValue(customGroupName, color));
values.addColor(new ColorValue(customGroupColorName, color));
}
}
protected void defineCustomFontGroup(GThemeValueMap values, String customGroupName,
String exemplarComponentId) {
fontSourceProperties.add(customGroupName);
FontValue fontValue = values.getFont(exemplarComponentId);
/**
* Defines a new font id that will be used as the reference value for any specific font ids that
* have the same font value. This will allow all those specific fonts to be changed at once.
* @param customGroupFontName name of a higher level group font id that will be used as the
* value of more specific font ids defined by the lookAndFeel.
* @param lookAndFeelSourceId the lookAndFeel font id whose value will be used as the value
* for the new custom group font id
* @param values the map where we store the default theme value mappings
*/
protected void defineCustomFontGroup(String customGroupFontName, String lookAndFeelSourceId,
GThemeValueMap values) {
fontSourceProperties.add(customGroupFontName);
FontValue fontValue = values.getFont(lookAndFeelSourceId);
if (fontValue != null) {
Font font = fontValue.get(values);
values.addFont(new FontValue(customGroupName, font));
values.addFont(new FontValue(customGroupFontName, font));
}
}

View File

@ -854,6 +854,10 @@ public abstract class AbstractOptions implements Options {
}
private void themeChanged(ThemeEvent e) {
// We are only sending out OptionsChangedEvents in response to Font theme changes. We
// don't notify options changed for colors because we expect clients are using GColor
// which updates automatically, so should need to be notified via options.
if (!e.hasAnyFontChanged()) {
return;
}

View File

@ -64,6 +64,13 @@ public enum OptionType {
return stringAdapter.objectToString(object);
}
/**
* Return true if the give value is of the correct type for this option type. Note that a
* value of null is compatible with any class type
* since it is an acceptable value for any class type.
* @param object the object to see if it is compatible with this option type
* @return true if the give value is of the correct type for this option type.
*/
public boolean isCompatible(Object object) {
return object == null || clazz.isAssignableFrom(object.getClass());
}

View File

@ -185,7 +185,7 @@ public class ColorUtils {
private static int blend(int colorValue1, int colorValue2, double ratio) {
double value = colorValue1 * ratio + colorValue2 * (1.0 - ratio);
int result = (int) (value + 0.5);
return Math.max(result, 255);
return Math.min(result, 255);
}
/**

View File

@ -25,7 +25,6 @@ import java.util.Map;
* those strings back to a color.
*/
public abstract class WebColors {
// private static final Pattern HEX_PATTERN = Pattern.compile("(0x|#)[0-9A-Fa-f]{6}");
private static final Map<String, Color> nameToColorMap = new HashMap<>();
private static final Map<Color, String> colorToNameMap = new HashMap<>();
@ -391,10 +390,13 @@ public abstract class WebColors {
}
private static int parseAlpha(String string) {
// alpha strings can either be a float between 0.0 and 1.0 or an integer from 0 to 255.
// if it is a float, treat that value as a percentage of the 255 max value
// if it is an int, don't allow the value to be bigger than 255.
if (string.contains(".")) {
float value = Float.parseFloat(string);
return (int) (value * 0xff + 0.5) & 0xff;
return (int) (value * 0xff + 0.5) & 0xff; // convert to value in range (0-255)
}
return Integer.parseInt(string) & 0xff;
return Integer.parseInt(string) & 0xff; // truncate any bits that would make it bigger than 255
}
}

View File

@ -20,11 +20,11 @@ import java.lang.ref.WeakReference;
import java.util.*;
/**
* Class for storing weak reference to object instances. Objects of type T can be place in this
* store and they will remain there until there are no references to that object remaining. Note
* Class for storing a weak reference to object instances. Objects of type T can be placed in this
* store and they will remain there until there are no references to that object. Note
* that this is not a Set and you can have multiple instances that are "equal" in this store.The
* main purpose of this store is to be able to get all objects in the store that are still
* referenced. This is useful when you need to visit all remaining items.
* referenced. This is useful when you need to visit all in use items.
* <p>
* This class is thread safe.
*

View File

@ -53,7 +53,7 @@ public class Icons {
public static final Icon NOT_ALLOWED_ICON = new GIcon("icon.not.allowed");
public static final Icon OPEN_FOLDER_ICON = new GIcon("icon.folder.open");
public static final Icon CLOSED_FOLDER_ICON = new GIcon("icon.folder.open");
public static final Icon CLOSED_FOLDER_ICON = new GIcon("icon.folder.closed");
public static final Icon REFRESH_ICON = new GIcon("icon.refresh");
public static final Icon SORT_ASCENDING_ICON = new GIcon("icon.sort.ascending");

View File

@ -482,7 +482,9 @@ public class ResourceManager {
/**
* Attempts to load an icon from the given path. Returns the icon or null if no icon was
* found from the given path.
* found from the given path. This differs from {@link #loadImage(String)} in that
* loadImage will return the default Icon if one can't be found. Further, loadImage will cache
* even the default value, while findIcon only caches resolved icons.
* <p>
*
* @param path the icon to load, e.g., "images/home.gif"

View File

@ -57,7 +57,7 @@ public class ColorValueTest {
}
@Test
public void TestIndirectMultiHopValue() {
public void testIndirectMultiHopValue() {
values.addColor(new ColorValue("color.grandparent", Color.RED));
values.addColor(new ColorValue("color.parent", "color.grandparent"));
ColorValue value = new ColorValue("color.test", "color.parent");
@ -69,7 +69,7 @@ public class ColorValueTest {
}
@Test
public void TestUnresolvedIndirectValue() {
public void testUnresolvedIndirectValue() {
ColorValue value = new ColorValue("color.test", "color.parent");
values.addColor(value);

View File

@ -18,6 +18,8 @@ package ghidra.util;
import static ghidra.util.HTMLUtilities.*;
import static org.junit.Assert.*;
import java.awt.Color;
import org.junit.Before;
import org.junit.Test;
@ -126,13 +128,13 @@ public class HTMLUtilitiesTest {
@Test
public void testToRGBString() {
String rgb = HTMLUtilities.toRGBString(WebColors.RED);
String rgb = HTMLUtilities.toRGBString(Color.RED);
assertEquals("255000000", rgb);
}
@Test
public void testToHexString() {
String rgb = HTMLUtilities.toHexString(WebColors.RED);
String rgb = HTMLUtilities.toHexString(Color.RED);
assertEquals("#FF0000", rgb);
}

View File

@ -321,7 +321,7 @@ class ArticulatedEdgeRouter<V extends VisualVertex, E extends VisualEdge<V>>
private Color getRoutingBoxColor(E edge) {
if (isTrueEdge(edge)) {
return new GColor("color.palette.magenta");
return Palette.MAGENTA;
}
return Palette.ORANGE;
}

View File

@ -23,7 +23,6 @@ import java.beans.PropertyChangeListener;
import javax.swing.*;
import docking.GenericHeader;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.graph.graphs.AbstractTestVertex;
@ -41,7 +40,7 @@ public class TextAreaTestVertex extends AbstractTestVertex {
textArea.setText(name);
textArea.setPreferredSize(new Dimension(200, 50));
textArea.setBackground(new GColor("color.palette.darkkhaki"));
textArea.setBackground(Palette.getColor("darkkhaki"));
textArea.setCaretColor(Palette.PINK);
textArea.setBorder(BorderFactory.createRaisedBevelBorder());
textArea.setLineWrap(true);

View File

@ -483,7 +483,7 @@ public class GHelpHTMLEditorKit extends HTMLEditorKit {
String srcString = src.toString();
//check if the icon is a defined icon theme id
// check if the srcString is a defined theme icon id
if (Gui.hasIcon(srcString)) {
return new GIcon(srcString).getUrl();
}

View File

@ -25,18 +25,15 @@ src/main/resources/images/allInTool.gif||GHIDRA||reviewed||END|
src/main/resources/images/applications-development-web.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
src/main/resources/images/applications-science.png||Oxygen Icons - LGPL 3.0||||END|
src/main/resources/images/bug.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/resources/images/check.png||GHIDRA||reviewed||END|
src/main/resources/images/checkNotLatest.gif||GHIDRA||reviewed||END|
src/main/resources/images/checkex.png||GHIDRA||reviewed||END|
src/main/resources/images/checkmark_green.gif||GHIDRA||reviewed||END|
src/main/resources/images/closedSmallFolder.png||Modified Nuvola Icons - LGPL 2.1||||END|
src/main/resources/images/connected.gif||GHIDRA||reviewed||END|
src/main/resources/images/cut_red.png||FAMFAMFAM Icons - CC 2.5||||END|
src/main/resources/images/defaultIndicator.png||GHIDRA||reviewed||END|
src/main/resources/images/dialog-cancel.png||Oxygen Icons - LGPL 3.0||||END|
src/main/resources/images/disconnected.gif||GHIDRA||reviewed||END|
src/main/resources/images/disk.png||FAMFAMFAM Icons - CC 2.5||||END|
src/main/resources/images/disk_save_as.png||FAMFAMFAM Icons - CC 2.5|||modified silk icon disk_multiple.png|END|
src/main/resources/images/face-glasses.png||Tango Icons - Public Domain|||tango icon set|END|
src/main/resources/images/folder_add.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
src/main/resources/images/lock.png||FAMFAMFAM Icons - CC 2.5|||famfamfam silk icon set|END|
@ -46,7 +43,6 @@ src/main/resources/images/page_add.png||FAMFAMFAM Icons - CC 2.5||||END|
src/main/resources/images/page_copy.png||FAMFAMFAM Icons - CC 2.5||||END|
src/main/resources/images/page_delete.png||FAMFAMFAM Icons - CC 2.5||||END|
src/main/resources/images/page_edit.png||FAMFAMFAM Icons - CC 2.5||||END|
src/main/resources/images/page_paste.png||FAMFAMFAM Icons - CC 2.5||||END|
src/main/resources/images/plasma.png||Oxygen Icons - LGPL 3.0|||Oxygen icon theme (dual license; LGPL or CC-SA-3.0)|END|
src/main/resources/images/plugin.png||GHIDRA||reviewed||END|
src/main/resources/images/small_hijack.gif||GHIDRA||reviewed||END|

View File

@ -83,9 +83,9 @@ icon.extension.configure = plugin.png
icon.plugin.manager.default = plasma.png
font.help.about = font.monospaced
font.keybindings.status = SansSerif-PLAIN-11
font.task.viewer = SansSerif-BOLD-36
font.user.agreement = SansSerif-PLAIN-16
font.keybindings.status = sansserif-plain-11
font.task.viewer = sansserif-bold-36
font.user.agreement = sansserif-plain-16
[Dark Defaults]

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -28,7 +28,7 @@ body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 1
li { font-family:times new roman; font-size:14pt; }
h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; `font-size:14pt; font-weight:bold; }
h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
/*

View File

@ -142,7 +142,7 @@ task buildHelp(type: JavaExec, dependsOn: indexHelp) {
inputs.dir file('src/main/help');
File resourcesDir = file('src/main/resources')
if (resourcesDir.exists()) {
inputs.dir file('src/main/resources');
inputs.dir resourcesDir
}
outputs.dir outputDir