private bool AcceptsElementInternal(GraphElement element, ref int proposedIndex, int maxIndex) { // TODO: we probably need a "Stackable" capability return(element != null && !(element is Scope) && !(element is StackNode) && !(element is TokenNode) && !(element is Placemat) && (element.GetContainingScope() as Group) == null && AcceptsElement(element, ref proposedIndex, maxIndex)); }
protected new void OnMouseMove(MouseMoveEvent e) { if (!m_Active) { return; } if (m_GraphView == null) { return; } var ve = (VisualElement)e.target; Vector2 gvMousePos = ve.ChangeCoordinatesTo(m_GraphView.contentContainer, e.localMousePosition); m_PanDiff = GetEffectivePanSpeed(gvMousePos); #if USE_DRAG_RESET_WHEN_OUT_OF_GRAPH_VIEW // We currently don't have a real use case for this and it just appears to annoy users. // If and when the use case arise, we can revive this functionality. if (gvMousePos.x < 0 || gvMousePos.y < 0 || gvMousePos.x > m_GraphView.layout.width || gvMousePos.y > m_GraphView.layout.height) { if (!m_GoneOut) { m_PanSchedule.Pause(); foreach (KeyValuePair <GraphElement, Rect> v in m_OriginalPos) { v.Key.SetPosition(v.Value); } m_GoneOut = true; } e.StopPropagation(); return; } if (m_GoneOut) { m_GoneOut = false; } #endif if (m_PanDiff != Vector3.zero) { m_PanSchedule.Resume(); } else { m_PanSchedule.Pause(); } // We need to monitor the mouse diff "by hand" because we stop positioning the graph elements once the // mouse has gone out. m_MouseDiff = m_originalMouse - e.mousePosition; var groupElementsDraggedOut = e.shiftKey ? new Dictionary <Group, List <GraphElement> >() : null; foreach (KeyValuePair <GraphElement, OriginalPos> v in m_OriginalPos) { GraphElement ce = v.Key; // Protect against stale visual elements that have been deparented since the start of the manipulation if (ce.hierarchy.parent == null) { continue; } if (!v.Value.dragStarted) { // TODO Would probably be a good idea to batch stack items as we do for group ones. var stackParent = ce.GetFirstAncestorOfType <StackNode>(); if (stackParent != null) { stackParent.OnStartDragging(ce); } if (groupElementsDraggedOut != null) { var groupParent = ce.GetContainingScope() as Group; if (groupParent != null) { if (!groupElementsDraggedOut.ContainsKey(groupParent)) { groupElementsDraggedOut[groupParent] = new List <GraphElement>(); } groupElementsDraggedOut[groupParent].Add(ce); } } v.Value.dragStarted = true; } MoveElement(ce, v.Value.pos); } foreach (var edge in m_EdgesToUpdate) { UpdateEdge(edge); } // Needed to ensure nodes can be dragged out of multiple groups all at once. if (groupElementsDraggedOut != null) { foreach (KeyValuePair <Group, List <GraphElement> > kvp in groupElementsDraggedOut) { kvp.Key.OnStartDragging(e, kvp.Value); } } List <ISelectable> selection = m_GraphView.selection; // TODO: Replace with a temp drawing or something...maybe manipulator could fake position // all this to let operation know which element sits under cursor...or is there another way to draw stuff that is being dragged? IDropTarget dropTarget = GetDropTargetAt(e.mousePosition, selection.OfType <VisualElement>()); if (m_PrevDropTarget != dropTarget) { if (m_PrevDropTarget != null) { using (DragLeaveEvent eexit = DragLeaveEvent.GetPooled(e)) { SendDragAndDropEvent(eexit, selection, m_PrevDropTarget, m_GraphView); } } using (DragEnterEvent eenter = DragEnterEvent.GetPooled(e)) { SendDragAndDropEvent(eenter, selection, dropTarget, m_GraphView); } } using (DragUpdatedEvent eupdated = DragUpdatedEvent.GetPooled(e)) { SendDragAndDropEvent(eupdated, selection, dropTarget, m_GraphView); } m_PrevDropTarget = dropTarget; selectedElement = null; e.StopPropagation(); }