From d31c78cd9d87148b8227adf9b093a5de70fcc08f Mon Sep 17 00:00:00 2001
From: ghidragon <106987263+ghidragon@users.noreply.github.com>
Date: Fri, 6 Dec 2024 18:42:28 -0500
Subject: [PATCH] GP-5084 Adding ability to choose which corner the function
graph satellite appears in.
---
.../FunctionGraphPlugin/Function_Graph.html | 9 ++
.../Function_Call_Graph.html | 8 ++
.../featurette/VgSatelliteFeaturette.java | 91 ++++++++++++++++++-
.../ghidra/graph/viewer/GraphComponent.java | 40 ++++++--
.../ghidra/graph/viewer/VisualGraphView.java | 18 +++-
5 files changed, 155 insertions(+), 11 deletions(-)
diff --git a/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html b/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html
index 3be4d20758..c990795825 100644
--- a/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html
+++ b/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html
@@ -137,6 +137,15 @@
hand corner of the graph and is only visible if the Satellite View is hidden or
undocked.
+
+
+ Docked Satellite Location
+
+ When the Satellite View is attached, or docked, to the Primary View, you
+ can choose which corner to show the satellite view. To change the
+ corner, right-click in the graph, select Docked Satellite Position and then
+ select the appropriate sub-menu for the desired corner.
+
Vertices (Blocks)
diff --git a/Ghidra/Features/GraphFunctionCalls/src/main/help/help/topics/FunctionCallGraphPlugin/Function_Call_Graph.html b/Ghidra/Features/GraphFunctionCalls/src/main/help/help/topics/FunctionCallGraphPlugin/Function_Call_Graph.html
index bd40e55ce7..850de546be 100644
--- a/Ghidra/Features/GraphFunctionCalls/src/main/help/help/topics/FunctionCallGraphPlugin/Function_Call_Graph.html
+++ b/Ghidra/Features/GraphFunctionCalls/src/main/help/help/topics/FunctionCallGraphPlugin/Function_Call_Graph.html
@@ -266,6 +266,14 @@
hand corner of the graph and is only visible if the Satellite View is hidden or
undocked.
+
+ Docked Satellite Location
+
+ When the Satellite View is attached, or docked, to the Primary View, you
+ can choose which corner to show the satellite view. To change the
+ corner, right-click in the graph, select Docked Satellite Position and then
+ select the appropriate sub-menu for the desired corner.
+
Options
diff --git a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/featurette/VgSatelliteFeaturette.java b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/featurette/VgSatelliteFeaturette.java
index 8ad2748914..0dda9713d9 100644
--- a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/featurette/VgSatelliteFeaturette.java
+++ b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/featurette/VgSatelliteFeaturette.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.
@@ -15,6 +15,8 @@
*/
package ghidra.graph.featurette;
+import static ghidra.graph.viewer.GraphComponent.SatellitePosition.*;
+
import java.awt.Dimension;
import java.awt.event.MouseEvent;
@@ -29,6 +31,7 @@ import ghidra.framework.options.SaveState;
import ghidra.graph.VisualGraph;
import ghidra.graph.VisualGraphComponentProvider;
import ghidra.graph.viewer.*;
+import ghidra.graph.viewer.GraphComponent.SatellitePosition;
import ghidra.graph.viewer.actions.*;
import ghidra.util.HelpLocation;
@@ -56,9 +59,14 @@ public class VgSatelliteFeaturette view;
@@ -75,6 +83,7 @@ public class VgSatelliteFeaturette, G extends VisualGraph> {
+ public enum SatellitePosition {
+ UPPER_LEFT, UPPER_RIGHT, LOWER_LEFT, LOWER_RIGHT
+ }
private static final double PARENT_TO_SATELLITE_RATIO = 4;// 2.5 smaller view seems better
private static final int MINIMUM_SATELLITE_WIDTH = 150;
@@ -130,6 +133,7 @@ public class GraphComponent, G e
private Dimension lastSize;
protected VisualGraphOptions vgOptions = new VisualGraphOptions();
+ private SatellitePosition dockedSatellitePosition = SatellitePosition.UPPER_RIGHT;
public GraphComponent(G graph) {
@@ -782,6 +786,15 @@ public class GraphComponent, G e
updateSatellite(docked, true);
}
+ public SatellitePosition getSatellitePosition() {
+ return dockedSatellitePosition;
+ }
+
+ public void setSatellitePosition(SatellitePosition position) {
+ dockedSatellitePosition = position;
+ updateSatellite(satelliteViewer.isDocked(), isSatelliteShowing());
+ }
+
public void setSatelliteVisible(boolean visible) {
if (isSatelliteShowing() == visible) {
@@ -823,9 +836,8 @@ public class GraphComponent, G e
staleGraphViewPanel.setBounds(x, y, stalePanelSize.width, stalePanelSize.height);
Dimension buttonSize = showUndockedSatelliteButton.getPreferredSize();
- x = parentSize.width - buttonSize.width;
- y = parentSize.height - buttonSize.height;
- showUndockedSatelliteButton.setBounds(x, y, buttonSize.width, buttonSize.height);
+ Point p = getSatellitePosition(parentSize, buttonSize);
+ showUndockedSatelliteButton.setBounds(p.x, p.y, buttonSize.width, buttonSize.height);
lastSize = new Dimension(parentSize.width, parentSize.height);
}
@@ -843,15 +855,30 @@ public class GraphComponent, G e
int newWidth = getNewBoundsSize(parentSize, satelliteSize);
satelliteSize.width = newWidth;
satelliteSize.height = newWidth;
- int x = parentSize.width - satelliteSize.width;
- int y = parentSize.height - satelliteSize.height;
- satelliteViewer.setBounds(x, y, satelliteSize.width, satelliteSize.height);
+ Point p = getSatellitePosition(parentSize, satelliteSize);
+ satelliteViewer.setBounds(p.x, p.y, satelliteSize.width, satelliteSize.height);
}
VisualGraphViewUpdater viewUpdater = getViewUpdater();
viewUpdater.fitGraphToViewerNow(satelliteViewer);
}
+ private Point getSatellitePosition(Dimension parentSize, Dimension satelliteSize) {
+ int x = parentSize.width - satelliteSize.width;
+ int y = parentSize.height - satelliteSize.height;
+ switch (dockedSatellitePosition) {
+ case LOWER_LEFT:
+ return new Point(0, y);
+ case UPPER_LEFT:
+ return new Point(0, 0);
+ case UPPER_RIGHT:
+ return new Point(x, 0);
+ case LOWER_RIGHT:
+ default:
+ return new Point(x, y);
+ }
+ }
+
private int getNewBoundsSize(Dimension parentBounds, Dimension satelliteBounds) {
double newSatelliteHeight = parentBounds.height / PARENT_TO_SATELLITE_RATIO;
double newSatelliteWidth = parentBounds.width / PARENT_TO_SATELLITE_RATIO;
@@ -1259,4 +1286,5 @@ public class GraphComponent, G e
// stub
}
}
+
}
diff --git a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/VisualGraphView.java b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/VisualGraphView.java
index 7f8dab9d7f..405f074151 100644
--- a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/VisualGraphView.java
+++ b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/VisualGraphView.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.
@@ -29,6 +29,7 @@ import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.control.ScalingControl;
import generic.theme.Gui;
import ghidra.graph.VisualGraph;
+import ghidra.graph.viewer.GraphComponent.SatellitePosition;
import ghidra.graph.viewer.event.mouse.VertexTooltipProvider;
import ghidra.graph.viewer.event.mouse.VisualGraphMousePlugin;
import ghidra.graph.viewer.layout.LayoutProvider;
@@ -124,6 +125,7 @@ public class VisualGraphView layoutProvider;
private final ScalingControl scaler = new VisualGraphScalingControl();
+ private SatellitePosition satellitePosition = SatellitePosition.LOWER_RIGHT;
public VisualGraphView() {
build();
@@ -263,6 +265,7 @@ public class VisualGraphView