mirror of
https://github.com/Siccity/xNode.git
synced 2026-02-06 15:24:55 +08:00
Support for DoubleClick on node to center it.
Added support for double clciking on Node header to center that node within the editor window.
This commit is contained in:
parent
932ff74663
commit
0f5539e077
@ -22,11 +22,12 @@ namespace XNodeEditor {
|
|||||||
[NonSerialized] private List<Vector2> draggedOutputReroutes = new List<Vector2>();
|
[NonSerialized] private List<Vector2> draggedOutputReroutes = new List<Vector2>();
|
||||||
private RerouteReference hoveredReroute = new RerouteReference();
|
private RerouteReference hoveredReroute = new RerouteReference();
|
||||||
private List<RerouteReference> selectedReroutes = new List<RerouteReference>();
|
private List<RerouteReference> selectedReroutes = new List<RerouteReference>();
|
||||||
private Rect nodeRects;
|
private Rect nodeRects; // Is this used?
|
||||||
private Vector2 dragBoxStart;
|
private Vector2 dragBoxStart;
|
||||||
private UnityEngine.Object[] preBoxSelection;
|
private UnityEngine.Object[] preBoxSelection;
|
||||||
private RerouteReference[] preBoxSelectionReroute;
|
private RerouteReference[] preBoxSelectionReroute;
|
||||||
private Rect selectionBox;
|
private Rect selectionBox;
|
||||||
|
private bool isDoubleClick = false;
|
||||||
|
|
||||||
private struct RerouteReference {
|
private struct RerouteReference {
|
||||||
public XNode.NodePort port;
|
public XNode.NodePort port;
|
||||||
@ -172,6 +173,10 @@ namespace XNodeEditor {
|
|||||||
SelectNode(hoveredNode, e.control || e.shift);
|
SelectNode(hoveredNode, e.control || e.shift);
|
||||||
if (!e.control && !e.shift) selectedReroutes.Clear();
|
if (!e.control && !e.shift) selectedReroutes.Clear();
|
||||||
} else if (e.control || e.shift) DeselectNode(hoveredNode);
|
} else if (e.control || e.shift) DeselectNode(hoveredNode);
|
||||||
|
|
||||||
|
// Cache double click state, but only act on it in MouseUp - Except ClickCount only works in mouseDown.
|
||||||
|
isDoubleClick = ( e.clickCount == 2 );
|
||||||
|
|
||||||
e.Use();
|
e.Use();
|
||||||
currentActivity = NodeActivity.HoldNode;
|
currentActivity = NodeActivity.HoldNode;
|
||||||
} else if (IsHoveringReroute) {
|
} else if (IsHoveringReroute) {
|
||||||
@ -239,6 +244,13 @@ namespace XNodeEditor {
|
|||||||
if (currentActivity == NodeActivity.HoldNode && !(e.control || e.shift)) {
|
if (currentActivity == NodeActivity.HoldNode && !(e.control || e.shift)) {
|
||||||
selectedReroutes.Clear();
|
selectedReroutes.Clear();
|
||||||
SelectNode(hoveredNode, false);
|
SelectNode(hoveredNode, false);
|
||||||
|
|
||||||
|
// Double click to center node
|
||||||
|
if ( isDoubleClick )
|
||||||
|
{
|
||||||
|
Vector2 nodeDimension = nodeSizes.ContainsKey( hoveredNode ) ? nodeSizes[ hoveredNode ] / 2 : new Vector2(0f, 0f);
|
||||||
|
panOffset = -hoveredNode.position - nodeDimension;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If click reroute, select it.
|
// If click reroute, select it.
|
||||||
@ -273,6 +285,8 @@ namespace XNodeEditor {
|
|||||||
}
|
}
|
||||||
isPanning = false;
|
isPanning = false;
|
||||||
}
|
}
|
||||||
|
// Reset DoubleClick
|
||||||
|
isDoubleClick = false;
|
||||||
break;
|
break;
|
||||||
case EventType.KeyDown:
|
case EventType.KeyDown:
|
||||||
if (EditorGUIUtility.editingTextField) break;
|
if (EditorGUIUtility.editingTextField) break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user