Merge remote-tracking branch

'origin/GT-3105_dragonmacher_PR-451_Escapingbug_Fix_horizontal_scrolling_in_Field_Panels'

Conflicts:
	Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeBrowserPlugin.java
This commit is contained in:
ghidra1 2019-08-23 19:18:03 -04:00
commit f5a366fa5c
3 changed files with 97 additions and 21 deletions

View file

@ -58,6 +58,7 @@ public class FieldPanel extends JPanel
private KeyHandler keyHandler = new KeyHandler();
private HoverHandler hoverHandler;
private SelectionHandler selectionHandler = new SelectionHandler();
private boolean horizontalScrollingEnabled = true;
private FieldLocation cursorPosition = new FieldLocation();
private FieldSelection selection = new FieldSelection();
@ -380,6 +381,14 @@ public class FieldPanel extends JPanel
cursorHandler.setBlinkCursor(blinkCursor);
}
public void enableSelection(boolean b) {
selectionHandler.enableSelection(b);
}
public void setHorizontalScrollingEnabled(boolean enabled) {
horizontalScrollingEnabled = enabled;
}
/**
* Returns the default background color.
*/
@ -1222,15 +1231,11 @@ public class FieldPanel extends JPanel
private JViewport getViewport() {
Container c = getParent();
if (c == null) {
return null;
}
if (c instanceof JViewport) {
return (JViewport) c;
}
c = c.getParent();
if (c instanceof JViewport) {
return (JViewport) c;
while (c != null) {
if (c instanceof JViewport) {
return (JViewport) c;
}
c = c.getParent();
}
return null;
}
@ -1479,10 +1484,29 @@ public class FieldPanel extends JPanel
}
else {
hoverHandler.stopHover();
scrollView(scrollAmount);
if (e.isShiftDown() && horizontalScrollingEnabled) {
scrollViewHorizontally(scrollAmount);
}
else {
scrollView(scrollAmount);
}
}
e.consume();
}
private void scrollViewHorizontally(int scrollAmount) {
JViewport vp = getViewport();
if (vp == null) {
// this will happen for Field Panels not placed inside of scroll panes
return;
}
// horizontal scroll (only move viewport)
Point pos = vp.getViewPosition();
vp.setViewPosition(new Point(Math.max(0, pos.x + scrollAmount), pos.y));
}
}
public class MouseHandler implements ActionListener {
@ -2101,8 +2125,4 @@ public class FieldPanel extends JPanel
}
}
}
public void enableSelection(boolean b) {
selectionHandler.enableSelection(b);
}
}