mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-18 00:20:10 +00:00
Theming - Fixed clients that want empty viewport space to match the
parent panel color
This commit is contained in:
parent
1ba77f6902
commit
4f1866d4cc
@ -21,7 +21,6 @@ import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.CellEditorListener;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.plaf.UIResource;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
@ -33,6 +32,7 @@ import docking.widgets.button.GButton;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.GThemeDefaults.Colors.Messages;
|
||||
import generic.theme.GThemeDefaults.Colors.Viewport;
|
||||
import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitAttributes;
|
||||
import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitFieldAllocation;
|
||||
import ghidra.app.services.DataTypeManagerService;
|
||||
@ -467,12 +467,7 @@ public class BitFieldEditorPanel extends JPanel {
|
||||
new JScrollPane(placementComponent, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
Color bg = getBackground();
|
||||
if (bg instanceof UIResource) {
|
||||
// Nimbus does not honor the color if it is a UIResource
|
||||
bg = new Color(bg.getRGB());
|
||||
}
|
||||
scrollPane.getViewport().setBackground(bg);
|
||||
scrollPane.getViewport().setBackground(Viewport.UNEDITABLE_BACKGROUND);
|
||||
scrollPane.setBorder(null);
|
||||
|
||||
bitViewPanel.add(scrollPane);
|
||||
|
@ -31,6 +31,7 @@ import docking.widgets.button.GRadioButton;
|
||||
import docking.widgets.fieldpanel.support.FieldSelection;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import generic.theme.GThemeDefaults.Colors.Viewport;
|
||||
import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitAttributes;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.data.Composite;
|
||||
@ -222,7 +223,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
new JScrollPane(bitViewComponent, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
bitViewScrollPane.getViewport().setBackground(getBackground());
|
||||
bitViewScrollPane.getViewport().setBackground(Viewport.UNEDITABLE_BACKGROUND);
|
||||
bitViewScrollPane.setBorder(null);
|
||||
|
||||
// establish default preferred size of panel based upon fixed preferred height of bitViewComponent
|
||||
@ -395,9 +396,8 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
String alignmentToolTip =
|
||||
"<HTML>The <B>align</B> control allows the overall minimum alignment of this<BR>" +
|
||||
"data type to be specified. The actual computed alignment<BR>" +
|
||||
"may be any multiple of this value. " +
|
||||
"<font color=\"" + Palette.BLUE.toHexString() +
|
||||
"\" size=\"-2\">(<F1> for help)</HTML>";
|
||||
"may be any multiple of this value. " + "<font color=\"" +
|
||||
Palette.BLUE.toHexString() + "\" size=\"-2\">(<F1> for help)</HTML>";
|
||||
alignPanel.setToolTipText(alignmentToolTip);
|
||||
|
||||
addMinimumAlignmentComponents();
|
||||
@ -449,11 +449,10 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
|
||||
private void setupDefaultMinAlignButton() {
|
||||
defaultAlignButton.setName("Default Alignment");
|
||||
String alignmentToolTip =
|
||||
"<HTML>Sets this data type to use <B>default</B> alignment.<BR>" +
|
||||
"If packing is disabled, the default will be 1 byte. If packing<BR>" +
|
||||
"is enabled, the alignment is computed based upon the pack<BR>" +
|
||||
"setting and the alignment of each component data type.</HTML>";
|
||||
String alignmentToolTip = "<HTML>Sets this data type to use <B>default</B> alignment.<BR>" +
|
||||
"If packing is disabled, the default will be 1 byte. If packing<BR>" +
|
||||
"is enabled, the alignment is computed based upon the pack<BR>" +
|
||||
"setting and the alignment of each component data type.</HTML>";
|
||||
|
||||
defaultAlignButton.addActionListener(e -> {
|
||||
((CompEditorModel) model).setAlignmentType(AlignmentType.DEFAULT, -1);
|
||||
@ -461,8 +460,8 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
|
||||
defaultAlignButton.setToolTipText(alignmentToolTip);
|
||||
if (helpManager != null) {
|
||||
helpManager.registerHelp(defaultAlignButton, new HelpLocation(
|
||||
provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));
|
||||
helpManager.registerHelp(defaultAlignButton,
|
||||
new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -480,8 +479,8 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
});
|
||||
|
||||
if (helpManager != null) {
|
||||
helpManager.registerHelp(machineAlignButton, new HelpLocation(
|
||||
provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));
|
||||
helpManager.registerHelp(machineAlignButton,
|
||||
new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,8 +497,8 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
});
|
||||
|
||||
if (helpManager != null) {
|
||||
helpManager.registerHelp(explicitAlignButton, new HelpLocation(
|
||||
provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));
|
||||
helpManager.registerHelp(explicitAlignButton,
|
||||
new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));
|
||||
}
|
||||
|
||||
explicitAlignTextField.setName("Explicit Alignment Value");
|
||||
@ -524,8 +523,8 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
|
||||
explicitAlignTextField.setToolTipText(alignmentToolTip);
|
||||
if (helpManager != null) {
|
||||
helpManager.registerHelp(explicitAlignTextField, new HelpLocation(
|
||||
provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));
|
||||
helpManager.registerHelp(explicitAlignTextField,
|
||||
new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));
|
||||
}
|
||||
|
||||
refreshGUIMinimumAlignmentValue(); // Display the initial value.
|
||||
@ -620,8 +619,8 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
packingGroup.add(explicitPackingButton);
|
||||
|
||||
if (helpManager != null) {
|
||||
helpManager.registerHelp(packingPanel, new HelpLocation(provider.getHelpTopic(),
|
||||
provider.getHelpName() + "_" + "Pack"));
|
||||
helpManager.registerHelp(packingPanel,
|
||||
new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Pack"));
|
||||
}
|
||||
|
||||
addPackingComponents(innerPanel);
|
||||
@ -674,8 +673,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
packingEnablementButton.setName("Packing Enablement");
|
||||
String packingToolTipText =
|
||||
"<HTML>Enable packing when details of all components are known (including sizing and" +
|
||||
" alignment).<BR>" +
|
||||
"Disable packing when Reverse Engineering composite. " +
|
||||
" alignment).<BR>" + "Disable packing when Reverse Engineering composite. " +
|
||||
"<font color=\"" + Palette.BLUE.toHexString() +
|
||||
"\" size=\"-2\">(<F1> for help)</font></HTML>";
|
||||
packingEnablementButton.addActionListener(e -> {
|
||||
@ -702,8 +700,8 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
|
||||
defaultPackingButton.setToolTipText(packingToolTipText);
|
||||
if (helpManager != null) {
|
||||
helpManager.registerHelp(defaultPackingButton, new HelpLocation(provider.getHelpTopic(),
|
||||
provider.getHelpName() + "_" + "Pack"));
|
||||
helpManager.registerHelp(defaultPackingButton,
|
||||
new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Pack"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -716,8 +714,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
explicitPackingButton.setToolTipText(packingToolTipText);
|
||||
if (helpManager != null) {
|
||||
helpManager.registerHelp(explicitPackingButton,
|
||||
new HelpLocation(provider.getHelpTopic(),
|
||||
provider.getHelpName() + "_" + "Pack"));
|
||||
new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Pack"));
|
||||
}
|
||||
|
||||
explicitPackingTextField.setName("Packing Value");
|
||||
@ -742,8 +739,8 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
|
||||
explicitPackingTextField.setToolTipText(packingToolTipText);
|
||||
if (helpManager != null) {
|
||||
helpManager.registerHelp(explicitPackingTextField, new HelpLocation(
|
||||
provider.getHelpTopic(), provider.getHelpName() + "_" + "Pack"));
|
||||
helpManager.registerHelp(explicitPackingTextField,
|
||||
new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Pack"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -979,8 +976,7 @@ public class CompEditorPanel extends CompositeEditorPanel {
|
||||
if (viewComposite.isPackingEnabled()) {
|
||||
defaultValue = viewComposite.getDataOrganization().getMachineAlignment();
|
||||
}
|
||||
((CompEditorModel) model).setAlignmentType(AlignmentType.EXPLICIT,
|
||||
defaultValue);
|
||||
((CompEditorModel) model).setAlignmentType(AlignmentType.EXPLICIT, defaultValue);
|
||||
}
|
||||
explicitAlignTextField.selectAll();
|
||||
explicitAlignTextField.requestFocus();
|
||||
|
@ -39,7 +39,6 @@ import docking.widgets.label.GLabel;
|
||||
import docking.widgets.table.*;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import generic.theme.GThemeDefaults.Colors.Palette;
|
||||
import generic.util.WindowUtilities;
|
||||
import ghidra.app.services.DataTypeManagerService;
|
||||
import ghidra.app.util.ToolTipUtils;
|
||||
@ -228,9 +227,6 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Mod
|
||||
scroll = new JScrollPane(verticalScrollPanel);
|
||||
scroll.setBorder(null);
|
||||
scroll.setOpaque(true);
|
||||
scroll.setBackground(Colors.BACKGROUND);
|
||||
scroll.getViewport().setBackground(Palette.NO_COLOR); // transparent
|
||||
scroll.getViewport().setBackground(Colors.BACKGROUND);
|
||||
previewPanel.add(scroll, BorderLayout.CENTER);
|
||||
previewPanel.setBorder(BorderFactory.createLoweredBevelBorder());
|
||||
scroll.getViewport().addMouseListener(new MouseAdapter() {
|
||||
|
@ -122,7 +122,6 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
|
||||
filterPanel = new GTableFilterPanel<>(bundleStatusTable, bundleStatusTableModel);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(bundleStatusTable);
|
||||
scrollPane.getViewport().setBackground(bundleStatusTable.getBackground());
|
||||
|
||||
panel.add(filterPanel, BorderLayout.SOUTH);
|
||||
panel.add(scrollPane, BorderLayout.CENTER);
|
||||
@ -159,8 +158,8 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
|
||||
addBundlesAction("DisableBundles", "Disable selected bundle(s)",
|
||||
new GIcon("icon.plugin.bundlemanager.disable"), this::doDisableBundles);
|
||||
|
||||
addBundlesAction("CleanBundles", "Clean selected bundle build cache(s)",
|
||||
Icons.CLEAR_ICON, this::doCleanBundleBuildCaches);
|
||||
addBundlesAction("CleanBundles", "Clean selected bundle build cache(s)", Icons.CLEAR_ICON,
|
||||
this::doCleanBundleBuildCaches);
|
||||
|
||||
icon = Icons.ADD_ICON;
|
||||
new ActionBuilder("AddBundles", this.getName()).popupMenuPath("Add bundle(s)")
|
||||
|
@ -239,7 +239,6 @@ public class PathManager {
|
||||
});
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(pathTable);
|
||||
scrollPane.getViewport().setBackground(pathTable.getBackground());
|
||||
|
||||
ListSelectionModel selModel = pathTable.getSelectionModel();
|
||||
selModel.addListSelectionListener(e -> {
|
||||
|
@ -232,7 +232,6 @@ public class PathnameTablePanel extends JPanel {
|
||||
pathnameTable.setTableHeader(null);
|
||||
pathnameTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
JScrollPane scrollPane = new JScrollPane(pathnameTable);
|
||||
scrollPane.getViewport().setBackground(pathnameTable.getBackground());
|
||||
|
||||
setDefaultCellRenderer();
|
||||
|
||||
|
@ -19,6 +19,9 @@ import static generic.theme.SystemThemeIds.*;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JViewport;
|
||||
|
||||
/**
|
||||
* This class contains many suitable default values for commonly used concepts. See each static
|
||||
* class below.
|
||||
@ -88,6 +91,19 @@ public class GThemeDefaults {
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
public static class Viewport {
|
||||
//@formatter:off
|
||||
/**
|
||||
* By default the system {@link JViewport}s use BACKGROUND for their background, which
|
||||
* is the primary background color (typically white on light themes). Some clients
|
||||
* would like the background color to match the uneditable background color used by
|
||||
* {@link JPanel}. This color allows the empty space in the viewport to match the
|
||||
* parent panel color.
|
||||
*/
|
||||
public static final GColor UNEDITABLE_BACKGROUND = new GColor("laf.color.Panel.background");
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
/**
|
||||
* Color values to use with tooltips
|
||||
*/
|
||||
|
@ -25,7 +25,6 @@ import docking.action.*;
|
||||
import docking.tool.ToolConstants;
|
||||
import docking.widgets.OptionDialog;
|
||||
import generic.theme.GIcon;
|
||||
import generic.theme.GThemeDefaults.Colors;
|
||||
import ghidra.app.util.GenericHelpTopics;
|
||||
import ghidra.framework.main.AppInfo;
|
||||
import ghidra.framework.plugintool.PluginConfigurationModel;
|
||||
@ -56,7 +55,6 @@ public class ManagePluginsDialog extends ReusableDialogComponentProvider {
|
||||
this.pluginConfigurationModel = pluginConfigurationModel;
|
||||
pluginComponent = new PluginManagerComponent(tool, pluginConfigurationModel);
|
||||
JScrollPane scrollPane = new JScrollPane(pluginComponent);
|
||||
scrollPane.getViewport().setBackground(Colors.BACKGROUND);
|
||||
scrollPane.getViewport().setViewPosition(new Point(0, 0));
|
||||
addWorkPanel(scrollPane);
|
||||
createActions(addSaveActions);
|
||||
|
@ -149,7 +149,6 @@ public class PluginInstallerDialog extends DialogComponentProvider {
|
||||
tableFilterPanel = new GTableFilterPanel<>(table, tableModel);
|
||||
|
||||
JScrollPane sp = new JScrollPane(table);
|
||||
sp.getViewport().setBackground(table.getBackground());
|
||||
|
||||
pluginTablePanel.add(sp, BorderLayout.CENTER);
|
||||
pluginTablePanel.add(tableFilterPanel, BorderLayout.SOUTH);
|
||||
@ -203,7 +202,6 @@ public class PluginInstallerDialog extends DialogComponentProvider {
|
||||
private class StatusCellRenderer extends GTableCellRenderer {
|
||||
|
||||
public StatusCellRenderer() {
|
||||
super();
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,6 @@ public class ExtensionTablePanel extends JPanel {
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
JScrollPane sp = new JScrollPane(table);
|
||||
sp.getViewport().setBackground(table.getBackground());
|
||||
add(sp, BorderLayout.CENTER);
|
||||
|
||||
tableFilterPanel = new GTableFilterPanel<>(table, tableModel);
|
||||
|
Loading…
Reference in New Issue
Block a user