public IEnumerator DraggingEdgeToOrOverBorderStartsPanningInPositiveY() { bool needsMouseUp = false; var portCenter = Vector2.zero; var worldY = 0.0f; try { var port = window.graphView.Q <Port>(); portCenter = port.GetGlobalCenter(); helpers.MouseDownEvent(portCenter); needsMouseUp = true; yield return(null); long timePassed = 0; GraphViewStaticBridge.SetTimeSinceStartupCB(() => timePassed); worldY = graphView.LocalToWorld(new Vector2(0, graphView.layout.height - EdgeDragHelper.k_PanAreaWidth)).y; helpers.MouseDragEvent(portCenter, new Vector2(portCenter.x, worldY)); yield return(null); Assert.AreEqual(0, graphView.viewTransform.position.x); Assert.AreEqual(0, graphView.viewTransform.position.y); timePassed += EdgeDragHelper.k_PanInterval; graphView.UpdateScheduledEvents(); float panSpeedAtLocation = -EdgeDragHelper.k_PanSpeed * EdgeDragHelper.k_MinSpeedFactor; float totalDisplacement = panSpeedAtLocation; Assert.AreEqual(0, graphView.viewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.viewTransform.position.y); timePassed += EdgeDragHelper.k_PanInterval; graphView.UpdateScheduledEvents(); totalDisplacement += panSpeedAtLocation; Assert.AreEqual(0, graphView.viewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.viewTransform.position.y); // Move outside window helpers.MouseDragEvent( new Vector2(portCenter.x, worldY), new Vector2(portCenter.x, worldY + 2 * EdgeDragHelper.k_PanAreaWidth)); yield return(null); Assert.AreEqual(0, graphView.viewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.viewTransform.position.y); timePassed += EdgeDragHelper.k_PanInterval; graphView.UpdateScheduledEvents(); panSpeedAtLocation = -EdgeDragHelper.k_MaxPanSpeed; totalDisplacement += panSpeedAtLocation; Assert.AreEqual(0, graphView.viewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.viewTransform.position.y); timePassed += EdgeDragHelper.k_PanInterval; graphView.UpdateScheduledEvents(); totalDisplacement += panSpeedAtLocation; Assert.AreEqual(0, graphView.viewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.viewTransform.position.y); helpers.MouseUpEvent(new Vector2(portCenter.x, worldY + 2 * EdgeDragHelper.k_PanAreaWidth)); needsMouseUp = false; yield return(null); Assert.AreEqual(0, graphView.viewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.viewTransform.position.y); } finally { if (needsMouseUp) { helpers.MouseUpEvent(new Vector2(portCenter.x, worldY + 2 * EdgeDragHelper.k_PanAreaWidth)); } } yield return(null); }
public IEnumerator MovableElementCanBeDraggedAtTheBorderToStartPanningInPositiveY() { bool needsMouseUp = false; Vector2 worldNodePos = graphView.contentViewContainer.LocalToWorld(k_NodePos); Vector2 start = worldNodePos + k_SelectionOffset; float worldY = graphView.LocalToWorld(new Vector2(0, graphView.layout.height - SelectionDragger.k_PanAreaWidth)).y; Vector2 panPos = new Vector2(start.x, worldY); try { // Move the movable element. helpers.MouseDownEvent(start); needsMouseUp = true; yield return(null); long timePassed = 0; GraphViewStaticBridge.SetTimeSinceStartupCB(() => timePassed); helpers.MouseDragEvent(start, panPos); yield return(null); float deltaY = start.y - panPos.y; Vector2 newPos = new Vector2(k_NodePos.x, k_NodePos.y - deltaY); GraphElement elem = graphView.Q <GraphElement>(); Assert.AreEqual(newPos, elem.GetPosition().position); Assert.AreEqual(0, graphView.viewTransform.position.x); Assert.AreEqual(0, graphView.viewTransform.position.y); timePassed += SelectionDragger.k_PanInterval; graphView.UpdateScheduledEvents(); float panSpeedAtLocation = SelectionDragger.k_PanSpeed * SelectionDragger.k_MinSpeedFactor; yield return(null); newPos.y += panSpeedAtLocation; Assert.AreEqual(newPos, elem.GetPosition().position); Assert.AreEqual(0, graphView.viewTransform.position.x); Assert.AreEqual(-panSpeedAtLocation, graphView.viewTransform.position.y); timePassed += SelectionDragger.k_PanInterval; graphView.UpdateScheduledEvents(); yield return(null); newPos.y += panSpeedAtLocation; Assert.AreEqual(newPos, elem.GetPosition().position); Assert.AreEqual(0, graphView.viewTransform.position.x); Assert.AreEqual(-panSpeedAtLocation * 2, graphView.viewTransform.position.y); helpers.MouseUpEvent(panPos); needsMouseUp = false; yield return(null); Assert.AreEqual(newPos, node.GetPosition().position); Assert.AreEqual(0, graphView.contentViewContainer.transform.position.x); Assert.AreEqual(-panSpeedAtLocation * 2, graphView.contentViewContainer.transform.position.y); } finally { if (needsMouseUp) { helpers.MouseUpEvent(panPos); } } yield return(null); }
public override void TearDown() { base.TearDown(); GraphViewStaticBridge.SetTimeSinceStartupCB(null); }
public override void TearDown() { AssetDatabase.DeleteAsset(k_FilePath); base.TearDown(); GraphViewStaticBridge.SetTimeSinceStartupCB(null); }
public IEnumerator DraggingEdgeToOrOverBorderStartsPanningInNegativeY() { MarkGraphViewStateDirty(); yield return(null); bool needsMouseUp = false; var portCenter = Vector2.zero; try { var port = window.GraphView.SafeQ <Port>(); portCenter = port.GetGlobalCenter(); helpers.MouseDownEvent(portCenter); needsMouseUp = true; yield return(null); long timePassed = 0; GraphViewStaticBridge.SetTimeSinceStartupCB(() => timePassed); Vector2 originalWorldNodePos = graphView.ContentViewContainer.LocalToWorld(new Vector2(portCenter.x, EdgeDragHelper.panAreaWidth)); helpers.MouseDragEvent(portCenter, originalWorldNodePos); yield return(null); Assert.AreEqual(0, graphView.ViewTransform.position.x); Assert.AreEqual(0, graphView.ViewTransform.position.y); timePassed += EdgeDragHelper.panInterval; graphView.UpdateScheduledEvents(); float panSpeedAtLocation = EdgeDragHelper.panSpeed * 0.5f; float totalDisplacement = panSpeedAtLocation; Assert.AreEqual(0, graphView.ViewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.ViewTransform.position.y); timePassed += EdgeDragHelper.panInterval; graphView.UpdateScheduledEvents(); totalDisplacement += panSpeedAtLocation; Assert.AreEqual(0, graphView.ViewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.ViewTransform.position.y); // Move outside window Vector2 newWorldNodePos = new Vector2(portCenter.x, -EdgeDragHelper.panAreaWidth); helpers.MouseDragEvent(originalWorldNodePos, newWorldNodePos); yield return(null); Assert.AreEqual(0, graphView.ViewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.ViewTransform.position.y); timePassed += EdgeDragHelper.panInterval; graphView.UpdateScheduledEvents(); panSpeedAtLocation = EdgeDragHelper.maxPanSpeed; totalDisplacement += panSpeedAtLocation; Assert.AreEqual(0, graphView.ViewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.ViewTransform.position.y); timePassed += EdgeDragHelper.panInterval; graphView.UpdateScheduledEvents(); totalDisplacement += panSpeedAtLocation; Assert.AreEqual(0, graphView.ViewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.ViewTransform.position.y); helpers.MouseUpEvent(newWorldNodePos); needsMouseUp = false; yield return(null); Assert.AreEqual(0, graphView.ViewTransform.position.x); Assert.AreEqual(totalDisplacement, graphView.ViewTransform.position.y); } finally { if (needsMouseUp) { helpers.MouseUpEvent(new Vector2(portCenter.x, -EdgeDragHelper.panAreaWidth)); } } yield return(null); }
public IEnumerator MovableElementCanBeDraggedAtTheBorderToStartPanningInPositiveX() { MarkGraphViewStateDirty(); yield return(null); var node = m_NodeModel.GetUI <Node>(graphView); bool needsMouseUp = false; Vector2 worldNodePos = graphView.ContentViewContainer.LocalToWorld(k_NodePos); Vector2 start = worldNodePos + k_SelectionOffset; Vector2 panPos = new Vector2(window.position.width - SelectionDragger.panAreaWidth, start.y); try { // Move the movable element. helpers.MouseDownEvent(start); needsMouseUp = true; yield return(null); long timePassed = 0; GraphViewStaticBridge.SetTimeSinceStartupCB(() => timePassed); helpers.MouseDragEvent(start, panPos); yield return(null); GraphElement elem = graphView.SafeQ <GraphElement>(); float deltaX = start.x - panPos.x; var newPos = new Vector2(k_NodePos.x - deltaX, k_NodePos.y); Assert.AreEqual(newPos, elem.GetPosition().position); Assert.AreEqual(0, graphView.ViewTransform.position.x); Assert.AreEqual(0, graphView.ViewTransform.position.y); timePassed += SelectionDragger.panInterval; graphView.UpdateScheduledEvents(); float panSpeedAtLocation = SelectionDragger.panSpeed * SelectionDragger.minSpeedFactor; yield return(null); newPos.x += panSpeedAtLocation; Assert.AreEqual(newPos, elem.GetPosition().position); Assert.AreEqual(-panSpeedAtLocation, graphView.ViewTransform.position.x); Assert.AreEqual(0, graphView.ViewTransform.position.y); timePassed += SelectionDragger.panInterval; graphView.UpdateScheduledEvents(); yield return(null); newPos.x += panSpeedAtLocation; Assert.AreEqual(newPos, elem.GetPosition().position); Assert.AreEqual(-panSpeedAtLocation * 2, graphView.ViewTransform.position.x); Assert.AreEqual(0, graphView.ViewTransform.position.y); helpers.MouseUpEvent(panPos); needsMouseUp = false; yield return(null); Assert.AreEqual(newPos, node.GetPosition().position); Assert.AreEqual(-panSpeedAtLocation * 2, graphView.ContentViewContainer.transform.position.x); Assert.AreEqual(0, graphView.ContentViewContainer.transform.position.y); } finally { if (needsMouseUp) { helpers.MouseUpEvent(panPos); } } yield return(null); }