internal List <Rect> GetNotSelectedElementRectsInView() { List <Rect> notSelectedElementRects = new List <Rect>(); List <GraphElement> ignoreElements = new List <GraphElement>(); // If dragging a group we need to find all elements inside and disregard them // For Groups they derive from Scope in which have containedElements. // If we are dragging around a node that are inside a Group, // the groups border might adjust and we don't want to snap to that. // We also check if there are any GraphElement children of the selected graphelement // And add them to the ignore list. foreach (GraphElement ge in m_GraphView.selection.OfType <GraphElement>()) { if (ge is Group) { Group group = ge as Group; var grpElements = group.containedElements; foreach (GraphElement element in grpElements) { ignoreElements.AddRange(element.Query <GraphElement>("", "graphElement").ToList()); } } else if (ge.GetContainingScope() != null) { ignoreElements.Add(ge.GetContainingScope()); } else { ignoreElements.Add(ge); } ignoreElements.AddRange(ge.Query <GraphElement>("", "graphElement").ToList()); } // Consider only the visible nodes. Rect rectToFit = m_GraphView.layout; // a copy is necessary because Add To selection might cause a SendElementToFront which will change the order. List <ISelectable> checkOnlyInViewElements = new List <ISelectable>(); foreach (GraphElement element in m_GraphView.graphElements.ToList()) { var localSelRect = m_GraphView.ChangeCoordinatesTo(element, rectToFit); if (element.Overlaps(localSelRect)) { checkOnlyInViewElements.Add(element); } } foreach (GraphElement element in checkOnlyInViewElements) { if (!element.IsSelected(m_GraphView) && (element.capabilities & Capabilities.Snappable) != 0 && !(ignoreElements.Contains(element))) { Rect geomtryInContentViewContainerSpace = element.parent.ChangeCoordinatesTo(m_GraphView.contentViewContainer, element.GetPosition()); notSelectedElementRects.Add(geomtryInContentViewContainerSpace); } } return(notSelectedElementRects); }
public void OnMouseDown(MouseDownEvent e) { if (m_Active) { e.StopImmediatePropagation(); } else if (e.button != 1 && CanStartManipulation(e)) { GraphView graphView = target as GraphView; if (graphView != null) { m_Start = graphView.ChangeCoordinatesTo(graphView.contentViewContainer, e.localMousePosition); m_Active = true; target.CaptureMouse(); e.StopImmediatePropagation(); } } }
private void UpdateConnection(MouseMoveEvent e) { if (Connection == null) { return; } _panDiff = GetEffectivePanSpeed(GraphView.ChangeCoordinatesTo(GraphView.contentContainer, e.localMousePosition)); if (_panDiff != Vector3.zero) { _panSchedule.Resume(); } else { _panSchedule.Pause(); } _localMousePosition = e.localMousePosition; UpdateConnectionVisual(e.localMousePosition); }
public void OnMouseMove(MouseMoveEvent e) { if (m_Active) { GraphView graphView = target as GraphView; if (graphView != null) { Vector2 v = graphView.ChangeCoordinatesTo(graphView.contentViewContainer, e.localMousePosition) - m_Start; Vector3 scale = graphView.contentViewContainer.transform.scale; graphView.viewTransform.position += Vector3.Scale(v, scale); e.StopPropagation(); } } else { bool flag = e.button == 1 && CanStartManipulation(e); #if UNITY_2019_3_OR_NEWER if (!flag) { flag = e.pressedButtons == 2; } #endif if (flag) { GraphView graphView = target as GraphView; if (graphView != null) { m_Start = graphView.ChangeCoordinatesTo(graphView.contentViewContainer, e.localMousePosition); m_Active = true; _rightClickPressed = true; target.CaptureMouse(); e.StopImmediatePropagation(); return; } } } }
private void Pan(TimerState ts) { GraphView.viewTransform.position -= _panDiff; UpdateConnectionVisual(GraphView.ChangeCoordinatesTo(GraphView.contentContainer, _localMousePosition)); }