Merge remote-tracking branch 'origin/GP-1-dragonmacher-renderer-font-fix'

This commit is contained in:
Ryan Kurtz
2024-03-06 07:01:52 -05:00
2 changed files with 20 additions and 8 deletions

View File

@@ -16,7 +16,6 @@
package ghidra.app.plugin.core.function.tags; package ghidra.app.plugin.core.function.tags;
import java.awt.Component; import java.awt.Component;
import java.awt.Font;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Set; import java.util.Set;
@@ -36,8 +35,8 @@ import ghidra.util.table.GhidraTableCellRenderer;
*/ */
public class FunctionTagTable extends GhidraTable { public class FunctionTagTable extends GhidraTable {
/** /**
* If true, disable any rows that have already been assigned * If true, disable any rows that have already been assigned
* to a function (and thus cannot be added again) * to a function (and thus cannot be added again)
*/ */
private boolean disable = false; private boolean disable = false;
@@ -49,7 +48,7 @@ public class FunctionTagTable extends GhidraTable {
/** /**
* Constructor * Constructor
* *
* @param model the table model * @param model the table model
*/ */
public FunctionTagTable(FunctionTagTableModel model) { public FunctionTagTable(FunctionTagTableModel model) {
@@ -109,12 +108,10 @@ public class FunctionTagTable extends GhidraTable {
} }
c.setEnabled(enableRow); c.setEnabled(enableRow);
c.setFont(getFont().deriveFont(Font.PLAIN));
int column = data.getColumnViewIndex(); int column = data.getColumnViewIndex();
if (column == nameColumn) { if (column == nameColumn) {
if (rowObject.isImmutable()) { if (rowObject.isImmutable()) {
c.setFont(getFont().deriveFont(Font.ITALIC)); setItalic();
} }
} }

View File

@@ -66,6 +66,7 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
protected Font defaultFont; protected Font defaultFont;
protected Font fixedWidthFont; protected Font fixedWidthFont;
protected Font boldFont; protected Font boldFont;
protected Font italicFont;
protected int dropRow = -1; protected int dropRow = -1;
private boolean instanceAlternateRowColors = true; private boolean instanceAlternateRowColors = true;
@@ -138,6 +139,7 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
defaultFont = f; defaultFont = f;
fixedWidthFont = new Font("monospaced", f.getStyle(), f.getSize()); fixedWidthFont = new Font("monospaced", f.getStyle(), f.getSize());
boldFont = f.deriveFont(Font.BOLD); boldFont = f.deriveFont(Font.BOLD);
italicFont = f.deriveFont(Font.ITALIC);
Gui.registerFont(this, fontId); Gui.registerFont(this, fontId);
} }
@@ -157,7 +159,7 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
// fonts, as some clients may do that from the getTableCellRendererComponent() method. // fonts, as some clients may do that from the getTableCellRendererComponent() method.
// //
if (defaultFont == null || if (defaultFont == null ||
CollectionUtils.isOneOf(f, defaultFont, fixedWidthFont, boldFont)) { CollectionUtils.isOneOf(f, defaultFont, fixedWidthFont, boldFont, italicFont)) {
return; return;
} }
@@ -180,6 +182,15 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
super.setFont(boldFont); super.setFont(boldFont);
} }
/**
* Sets the font of this renderer to be italic until the next time that getTableCellRenderer()
* is called, as it resets the font to the default font on each pass.
* @see #getDefaultFont()
*/
protected void setItalic() {
super.setFont(italicFont);
}
protected Font getDefaultFont() { protected Font getDefaultFont() {
return defaultFont; return defaultFont;
} }
@@ -192,6 +203,10 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
return boldFont; return boldFont;
} }
public Font getItalicFont() {
return italicFont;
}
/** /**
* Sets the row where DnD would perform drop operation. * Sets the row where DnD would perform drop operation.
* @param dropRow the drop row * @param dropRow the drop row