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;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.MouseEvent;
import java.util.Set;
@@ -36,8 +35,8 @@ import ghidra.util.table.GhidraTableCellRenderer;
*/
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)
*/
private boolean disable = false;
@@ -49,7 +48,7 @@ public class FunctionTagTable extends GhidraTable {
/**
* Constructor
*
*
* @param model the table model
*/
public FunctionTagTable(FunctionTagTableModel model) {
@@ -109,12 +108,10 @@ public class FunctionTagTable extends GhidraTable {
}
c.setEnabled(enableRow);
c.setFont(getFont().deriveFont(Font.PLAIN));
int column = data.getColumnViewIndex();
if (column == nameColumn) {
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 fixedWidthFont;
protected Font boldFont;
protected Font italicFont;
protected int dropRow = -1;
private boolean instanceAlternateRowColors = true;
@@ -138,6 +139,7 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
defaultFont = f;
fixedWidthFont = new Font("monospaced", f.getStyle(), f.getSize());
boldFont = f.deriveFont(Font.BOLD);
italicFont = f.deriveFont(Font.ITALIC);
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.
//
if (defaultFont == null ||
CollectionUtils.isOneOf(f, defaultFont, fixedWidthFont, boldFont)) {
CollectionUtils.isOneOf(f, defaultFont, fixedWidthFont, boldFont, italicFont)) {
return;
}
@@ -180,6 +182,15 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
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() {
return defaultFont;
}
@@ -192,6 +203,10 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
return boldFont;
}
public Font getItalicFont() {
return italicFont;
}
/**
* Sets the row where DnD would perform drop operation.
* @param dropRow the drop row