Ghidra is a software reverse engineering (SRE) framework
Fixed table row height not resizing correctly as the font size is changed
dragonmacherb6a1a35f26a4
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsoleProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsoleProvider.javaindex 2915c0afa7..94ce3140c8 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsoleProvider.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/console/DebuggerConsoleProvider.java@@ -354,8 +354,8 @@ public class DebuggerConsoleProvider extends ComponentProviderAdapter}}- protected static class LogTableModel extends DebouncedRowWrappedEnumeratedColumnTableModel<- LogTableColumns, ActionContext, LogRow<?>, LogRow<?>> {+ protected static class LogTableModel extends+ DebouncedRowWrappedEnumeratedColumnTableModel<LogTableColumns, ActionContext, LogRow<?>, LogRow<?>> {public LogTableModel(PluginTool tool) {super(tool, "Log", LogTableColumns.class, r -> r == null ? null : r.actionContext(),@@ -431,7 +431,8 @@ public class DebuggerConsoleProvider extends ComponentProviderAdapter@AutoOptionDefined(name = DebuggerResources.OPTION_NAME_LOG_BUFFER_LIMIT,description = "The maximum number of entries in the console log (0 or less for unlimited)",- help = @HelpInfo(anchor = "buffer_limit"))+ help = @HelpInfo(anchor = "buffer_limit")+ )private int logBufferLimit = DebuggerResources.DEFAULT_LOG_BUFFER_LIMIT;@SuppressWarnings("unused")private final AutoOptions.Wiring autoOptionsWiring;@@ -511,7 +512,7 @@ public class DebuggerConsoleProvider extends ComponentProviderAdapter}});- logTable.setRowHeight(ACTION_BUTTON_SIZE + 2);+ logTable.setPreferredRowHeight(ACTION_BUTTON_SIZE + 2);}protected boolean activateSelectedRow() {diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyIntoProgramDialog.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyIntoProgramDialog.javaindex 6c91edbecf..7d2b484c87 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyIntoProgramDialog.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/copying/DebuggerCopyIntoProgramDialog.java@@ -176,8 +176,7 @@ public class DebuggerCopyIntoProgramDialog extends ReusableDialogComponentProvidSECTIONS("Sections", String.class, RangeEntry::getSectionNames),SRC_MIN("SrcMin", Address.class, RangeEntry::getSrcMinAddress),SRC_MAX("SrcMax", Address.class, RangeEntry::getSrcMaxAddress),- BLOCK("Block", String.class, RangeEntry::getBlockName, RangeEntry::setBlockName,- RangeEntry::isCreate),+ BLOCK("Block", String.class, RangeEntry::getBlockName, RangeEntry::setBlockName, RangeEntry::isCreate),OVERLAY("Overlay", Boolean.class, RangeEntry::isOverlay),DST_MIN("DstMin", Address.class, RangeEntry::getDstMinAddress),DST_MAX("DstMax", Address.class, RangeEntry::getDstMaxAddress);@@ -470,7 +469,7 @@ public class DebuggerCopyIntoProgramDialog extends ReusableDialogComponentProvidaddCancelButton();addResetButton();- table.setRowHeight(BUTTON_SIZE);+ table.setPreferredRowHeight(BUTTON_SIZE);}protected void addResetButton() {diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionMapProposalDialog.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionMapProposalDialog.javaindex 2ec8b398dc..54dadb92cd 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionMapProposalDialog.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionMapProposalDialog.java@@ -207,7 +207,7 @@ public class DebuggerRegionMapProposalDialogprotected void populateComponents() {super.populateComponents();setPreferredSize(600, 300);- table.setRowHeight(BUTTON_SIZE);+ table.setPreferredRowHeight(BUTTON_SIZE);}private void chooseAndSetBlock(RegionMapEntry entry) {diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModuleMapProposalDialog.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModuleMapProposalDialog.javaindex 155058c496..b73397389d 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModuleMapProposalDialog.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModuleMapProposalDialog.java@@ -127,8 +127,7 @@ public class DebuggerModuleMapProposalDialogreturn CustomToStringCellRenderer.MONO_ULONG_HEX;}},- MEMORIZE("Memorize", Boolean.class, ModuleMapEntry::isMemorize,- ModuleMapEntry::setMemorize);+ MEMORIZE("Memorize", Boolean.class, ModuleMapEntry::isMemorize, ModuleMapEntry::setMemorize);private final String header;private final Class<?> cls;@@ -208,7 +207,7 @@ public class DebuggerModuleMapProposalDialogprotected void populateComponents() {super.populateComponents();setPreferredSize(600, 300);- table.setRowHeight(BUTTON_SIZE);+ table.setPreferredRowHeight(BUTTON_SIZE);}private void chooseAndSetProgram(ModuleMapEntry entry) {diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerSectionMapProposalDialog.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerSectionMapProposalDialog.javaindex 25d5b81540..70ed6c9b62 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerSectionMapProposalDialog.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerSectionMapProposalDialog.java@@ -20,7 +20,7 @@ import java.util.Map;import java.util.function.BiConsumer;import java.util.function.Function;-import javax.swing.table.*;+import javax.swing.table.TableCellEditor;import docking.widgets.table.*;import ghidra.app.plugin.core.debug.gui.AbstractDebuggerMapProposalDialog;@@ -209,7 +209,7 @@ public class DebuggerSectionMapProposalDialogprotected void populateComponents() {super.populateComponents();setPreferredSize(600, 300);- table.setRowHeight(BUTTON_SIZE);+ table.setPreferredRowHeight(BUTTON_SIZE);}private void chooseAndSetBlock(SectionMapEntry entry) {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/data/AbstractSettingsDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/data/AbstractSettingsDialog.javaindex df334d0ce0..37af5e8650 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/data/AbstractSettingsDialog.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/data/AbstractSettingsDialog.java@@ -215,7 +215,7 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {settingsTable.setColumnSelectionAllowed(false);// make the rows a bit taller to allow the integer text field editor to render correctly- settingsTable.setRowHeight(22);+ settingsTable.setRowPadding(4);// disable user sorting and column adding (we don't expect enough data to require sorting)settingsTable.getTableHeader().setReorderingAllowed(false);@@ -730,7 +730,6 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {class StringSettingsComboBox extends GComboBox<String> {StringSettingsComboBox() {- super();}}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorPanel.javaindex 00378209df..914b54c376 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorPanel.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorPanel.java@@ -41,7 +41,7 @@ import ghidra.util.table.GhidraTable;class EnumEditorPanel extends JPanel {- private JTable table;+ private GTable table;private JTextField nameField;private JTextField descField;private JLabel descLabel;@@ -301,7 +301,7 @@ class EnumEditorPanel extends JPanel {table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);add(sp, BorderLayout.CENTER);- table.setRowHeight(table.getRowHeight() + 4);+ table.setRowPadding(4);table.setDefaultEditor(String.class, new EnumStringCellEditor());table.getColumnModel().getColumn(EnumTableModel.VALUE_COL)diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/AbstractInstructionTable.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/AbstractInstructionTable.javaindex 31ff691576..852c4b0d99 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/AbstractInstructionTable.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/AbstractInstructionTable.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -41,7 +41,7 @@ public abstract class AbstractInstructionTable extends GhidraTable {// The standard cell height is a bit too small for our liking, so we expand it vertically a// bit.- private int CELL_HEIGHT_PADDING = 6;+ private int CELL_HEIGHT_PADDING = 9;/*** {@link InstructionTableDataObject} instances constitute the contents of@@ -76,11 +76,11 @@ public abstract class AbstractInstructionTable extends GhidraTable {// Disable reorder of columns. Allowing this would cause the table// to become unstable; we rely on knowing that mnemonics are always in// the first column, and that operand columns are in a particular order.- this.getTableHeader().setReorderingAllowed(false);+ getTableHeader().setReorderingAllowed(false);// The default cell size is a bit small and makes the text a bit hard// to read, so increase it to provide some space around the text.- this.setRowHeight(this.getRowHeight() + CELL_HEIGHT_PADDING);+ setRowPadding(CELL_HEIGHT_PADDING);}InstructionSearchPlugin getPlugin() {diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.javaindex 6b8ba7e24b..cbdd359538 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java@@ -123,6 +123,7 @@ public class GTable extends JTable {private SelectionManager selectionManager;private Integer visibleRowCount;+ private int userDefinedRowPadding;private int userDefinedRowHeight;private TableModelListener rowHeightListener;@@ -576,12 +577,13 @@ public class GTable extends JTable {}private int calculatePreferredRowHeight() {- if (userDefinedRowHeight != 16) { // default size- return userDefinedRowHeight; // prefer user-defined settings+ int padding = 3; // default padding to look nicer+ if (userDefinedRowPadding != 0) {+ padding = userDefinedRowPadding;}if (getColumnCount() == 0) {- return userDefinedRowHeight; // no columns yet defined+ return super.getRowHeight() + padding; // no columns yet defined}TableCellRenderer defaultRenderer = getDefaultRenderer(String.class);@@ -589,7 +591,7 @@ public class GTable extends JTable {Component component =defaultRenderer.getTableCellRendererComponent(this, "Ghidra", false, false, 0, 0);Dimension preferredSize = component.getPreferredSize();- return preferredSize.height + 3; // What is this fudge?+ return preferredSize.height + padding;}catch (Throwable t) {// some renderers can't handle being asked to render with dummy data; use default value@@ -613,8 +615,18 @@ public class GTable extends JTable {return linesPerRow;}- @Override- public void setRowHeight(int height) {+ /**+ * Sets the value to add to the table's preferred row height. This allows clients to add some+ * padding to the height without hard-coding an actual height. Use this method instead of+ * {@link #setRowHeight(int)} to allow font size changes to resize the table rows correctly.+ * @param padding the padding+ */+ public void setRowPadding(int padding) {+ userDefinedRowPadding = padding;+ adjustRowHeight();+ }++ public void setPreferredRowHeight(int height) {doSetRowHeight(height);userDefinedRowHeight = height;}diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableCellRenderer.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableCellRenderer.javaindex 65bf574f38..8b423664ad 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableCellRenderer.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableCellRenderer.java@@ -70,6 +70,9 @@ public class GTableCellRenderer extends AbstractGCellRenderer implements TableCeif (e.isLookAndFeelChanged()) {updateUI();}+ else if (e.hasGlobalFontChanged()) {+ updateUI();+ }};/**diff --git a/Ghidra/Framework/Gui/src/main/java/generic/theme/FontChangedThemeEvent.java b/Ghidra/Framework/Gui/src/main/java/generic/theme/FontChangedThemeEvent.javaindex 0cebe15464..8308fa6380 100644--- a/Ghidra/Framework/Gui/src/main/java/generic/theme/FontChangedThemeEvent.java+++ b/Ghidra/Framework/Gui/src/main/java/generic/theme/FontChangedThemeEvent.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -48,4 +48,9 @@ public class FontChangedThemeEvent extends ThemeEvent {public boolean hasAnyFontChanged() {return true;}++ @Override+ public boolean hasGlobalFontChanged() {+ return isFontChanged(SystemThemeIds.FONT_CONTROL_ID);+ }}diff --git a/Ghidra/Framework/Gui/src/main/java/generic/theme/ThemeEvent.java b/Ghidra/Framework/Gui/src/main/java/generic/theme/ThemeEvent.javaindex 5fee8d029b..4d40afcaab 100644--- a/Ghidra/Framework/Gui/src/main/java/generic/theme/ThemeEvent.java+++ b/Ghidra/Framework/Gui/src/main/java/generic/theme/ThemeEvent.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -65,6 +65,13 @@ public class ThemeEvent {return false;}+ /**+ * {@return true if the user has changed the global font size}+ */+ public boolean hasGlobalFontChanged() {+ return false;+ }+/*** Returns true if any font value changed.* @return true if any font value changed.diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/PickToolDialog.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/PickToolDialog.javaindex b50cd5322e..e97595d01c 100644--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/PickToolDialog.java+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/PickToolDialog.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -58,7 +58,7 @@ public class PickToolDialog extends DialogComponentProvider {model = new ToolTableModel();table = new GTable(model);- table.setRowHeight(28); // make big enough for tool icons+ table.setPreferredRowHeight(28); // make big enough for tool iconstable.setColumnHeaderPopupEnabled(false); // don't allow column configurationtable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);table.setDefaultRenderer(GhidraToolTemplate.class, new ToolTemplateRenderer());diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/SetToolAssociationsDialog.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/SetToolAssociationsDialog.javaindex 0e2ccea7ab..e361ab103d 100644--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/SetToolAssociationsDialog.java+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/SetToolAssociationsDialog.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -91,7 +91,7 @@ class SetToolAssociationsDialog extends DialogComponentProvider {});resetButton.setEnabled(false);- table.setRowHeight(28); // make big enough for tool icons+ table.setPreferredRowHeight(28); // make big enough for tool iconstable.setColumnHeaderPopupEnabled(false); // don't allow column configurationtable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);table.setDefaultRenderer(ContentHandler.class, new ContentHandlerRenderer());