private void OnMouseDown(MouseDownEvent e) { if (this.m_Active) { e.StopImmediatePropagation(); } else if (!MouseCaptureController.IsMouseCaptureTaken()) { GraphElement graphElement = base.parent as GraphElement; if (graphElement != null) { if (graphElement.IsResizable()) { if (e.button == (int)this.activateButton) { this.m_Start = this.ChangeCoordinatesTo(base.parent, e.localMousePosition); this.m_StartPos = base.parent.layout; if (base.parent.style.positionType != PositionType.Manual) { Debug.LogWarning("Attempting to resize an object with a non manual position"); } this.m_Active = true; this.TakeMouseCapture(); e.StopPropagation(); } } } } }
void OnValidateCommand(ValidateCommandEvent evt) { if (MouseCaptureController.IsMouseCaptureTaken()) { return; } if ((evt.commandName == EventCommandNames.Copy && canCopySelection) || (evt.commandName == EventCommandNames.Paste && canPaste) || (evt.commandName == EventCommandNames.Duplicate && canDuplicateSelection) || (evt.commandName == EventCommandNames.Cut && canCutSelection) || ((evt.commandName == EventCommandNames.Delete || evt.commandName == EventCommandNames.SoftDelete) && canDeleteSelection)) { evt.StopPropagation(); if (evt.imguiEvent != null) { evt.imguiEvent.Use(); } } else if (evt.commandName == EventCommandNames.FrameSelected) { evt.StopPropagation(); if (evt.imguiEvent != null) { evt.imguiEvent.Use(); } } }
public void RunBeforeAnyTests() { SetDisableInputEventsOnAllWindows(true); MouseCaptureController.ReleaseMouse(); DataWatchServiceDisableThrottling(true); }
private void OnWheel(WheelEvent evt) { GraphView graphView = base.target as GraphView; if (graphView != null) { if (!MouseCaptureController.IsMouseCaptureTaken()) { Vector3 vector = graphView.viewTransform.position; Vector3 scale = graphView.viewTransform.scale; Vector2 vector2 = base.target.ChangeCoordinatesTo(graphView.contentViewContainer, evt.localMousePosition); float x = vector2.x + graphView.contentViewContainer.layout.x; float y = vector2.y + graphView.contentViewContainer.layout.y; vector += Vector3.Scale(new Vector3(x, y, 0f), scale); float num = ContentZoomer.CalculateNewZoom(scale.y, -evt.delta.y, this.scaleStep, this.referenceScale, this.minScale, this.maxScale); scale.x = num; scale.y = num; scale.z = 1f; vector -= Vector3.Scale(new Vector3(x, y, 0f), scale); if (graphView.elementPanel != null && this.keepPixelCacheOnZoom) { graphView.elementPanel.keepPixelCacheOnWorldBoundChange = true; if (this.m_OnTimerTicker == null) { this.m_OnTimerTicker = graphView.schedule.Execute(new Action <TimerState>(this.OnTimer)); } this.m_OnTimerTicker.ExecuteLater(500L); this.delayRepaintScheduled = true; } graphView.UpdateViewTransform(vector, scale); evt.StopPropagation(); } } }
public IEnumerator SelectedElementsCanBeCopyPasted() { graphView.clipboard = "Unknown data"; SelectThreeElements(); MouseCaptureController.ReleaseMouse(); graphView.Focus(); yield return(null); bool used = helpers.ValidateCommand("Copy"); Assert.IsTrue(used); yield return(null); helpers.ExecuteCommand("Copy"); yield return(null); Assert.AreNotEqual("Unknown data", graphView.clipboard); used = helpers.ValidateCommand("Paste"); Assert.IsTrue(used); yield return(null); helpers.ExecuteCommand("Paste"); yield return(null); Assert.AreEqual(k_DefaultNodeCount + m_SelectedNodeCount, graphView.graphElements.ToList().Count); yield return(null); }
void OnMouseDown(MouseDownEvent e) { if (active) { e.StopPropagation(); return; } if (MouseCaptureController.IsMouseCaptured()) { return; } if (!IsMouseOverBorders(e.localMousePosition)) { return; } if (CanStartManipulation(e)) { active = true; target.CaptureMouse(); e.StopPropagation(); startComponentSize = new Vector2(elem.style.width, elem.style.height); startMousePosition = e.localMousePosition; startComponentPosition = elem.transform.position; } else { Debug.Log("can't start manipulation !"); } }
public void RunBeforeAnyTests() { SetDisableInputEventsOnAllWindows(true); MouseCaptureController.ReleaseMouse(); Debug.Assert(!GraphViewStaticBridge.GetDisableThrottling()); GraphViewStaticBridge.SetDisableThrottling(true); }
protected virtual void OnDisable() { if (this.imguiContainer.HasMouseCapture()) { MouseCaptureController.ReleaseMouseCapture(); } this.visualTree.Remove(this.imguiContainer); }
protected virtual void OnDisable() { if (imguiContainer.HasMouseCapture()) { MouseCaptureController.ReleaseMouseCapture(); } visualTree.Remove(imguiContainer); imguiContainer = null; }
void UpdateValueOnMouseUp(MouseUpEvent evt) { if (dragging) { dragging = false; MouseCaptureController.ReleaseMouse(); EditorGUIUtility.SetWantsMouseJumping(0); } }
void OnWheel(WheelEvent evt) { if (MouseCaptureController.IsMouseCaptured()) { return; } Zoom(-evt.delta.y, evt.localMousePosition); evt.StopPropagation(); }
void Clear() { // See case: https://fogbugz.unity3d.com/f/cases/998343/ // Clearing the capture needs to happen before closing the window MouseCaptureController.ReleaseMouse(); if (window != null) { window.Close(); } }
void UpdateValueOnKeyDown(KeyDownEvent evt) { if (dragging && evt.keyCode == KeyCode.Escape) { dragging = false; m_DrivenField.value = startValue; MouseCaptureController.ReleaseMouse(); EditorGUIUtility.SetWantsMouseJumping(0); } }
protected virtual IEnumerator TearDown() { ForceNewDocument(); MouseCaptureController.ReleaseMouse(); yield return(null); BuilderWindow?.Close(); yield return(null); }
void OnWheel(WheelEvent evt) { var graphView = target as GraphView; if (graphView == null) { return; } if (MouseCaptureController.IsMouseCaptured()) { return; } Vector3 position = graphView.viewTransform.position; Vector3 scale = graphView.viewTransform.scale; // TODO: augment the data to have the position as well, so we don't have to read in data from the target. // 0-1 ranged center relative to size Vector2 zoomCenter = target.ChangeCoordinatesTo(graphView.contentViewContainer, evt.localMousePosition); float x = zoomCenter.x + graphView.contentViewContainer.layout.x; float y = zoomCenter.y + graphView.contentViewContainer.layout.y; position += Vector3.Scale(new Vector3(x, y, 0), scale); // Apply the new zoom. float zoom = CalculateNewZoom(scale.y, -evt.delta.y, scaleStep, referenceScale, minScale, maxScale); scale.x = zoom; scale.y = zoom; scale.z = 1; position -= Vector3.Scale(new Vector3(x, y, 0), scale); position.x = GUIUtility.RoundToPixelGrid(position.x); position.y = GUIUtility.RoundToPixelGrid(position.y); // Delay updating of the pixel cache so the scrolling appears smooth. if (graphView.elementPanel != null && keepPixelCacheOnZoom) { graphView.elementPanel.keepPixelCacheOnWorldBoundChange = true; if (m_OnTimerTicker == null) { m_OnTimerTicker = graphView.schedule.Execute(OnTimer); } m_OnTimerTicker.ExecuteLater(500); delayRepaintScheduled = true; } graphView.UpdateViewTransform(position, scale); evt.StopPropagation(); }
protected void OnMouseMove(MouseMoveEvent e) { if (this.m_Active && MouseCaptureController.HasMouseCapture(base.target)) { Vector2 vector = e.localMousePosition - this.m_Last; float zoomScale = 1f + (vector.x + vector.y) * this.zoomStep; this.Zoom(this.m_ZoomCenter, zoomScale); e.StopPropagation(); this.m_Last = e.localMousePosition; } }
public virtual void TearDown() { // See case: https://fogbugz.unity3d.com/f/cases/998343/ // Clearing the capture needs to happen before closing the window MouseCaptureController.ReleaseMouse(); if (Window != null) { GraphModel?.QuickCleanup(); Window.Close(); } }
void OnExecuteCommand(ExecuteCommandEvent evt) { if (MouseCaptureController.IsMouseCaptured()) { return; } if (evt.commandName == "Find") { OnSearchInGraph(); evt.StopPropagation(); } }
protected void OnMouseUp(MouseUpEvent e) { if (this.m_Active) { if (base.CanStopManipulation(e)) { this.m_Active = false; MouseCaptureController.ReleaseMouseCapture(base.target); e.StopPropagation(); } } }
protected void OnMouseDown(MouseDownEvent e) { if (base.CanStartManipulation(e)) { this.m_Start = (this.m_Last = e.localMousePosition); this.m_ZoomCenter = VisualElementExtensions.ChangeCoordinatesTo(base.target, this.m_GraphUI, this.m_Start); this.m_Active = true; MouseCaptureController.TakeMouseCapture(base.target); e.StopPropagation(); } Debug.Log(e); }
void OnMouseDown(MouseDownEvent e) { if (m_Active) { e.StopImmediatePropagation(); return; } if (MouseCaptureController.IsMouseCaptureTaken()) { return; } var ce = parent as GraphElement; if (ce == null) { return; } if (!((StoryNode)ce).expanded) { return; } // if (!ce.IsResizable()) // return; if (e.button == (int)ActivateButton) { m_Start = this.ChangeCoordinatesTo(parent, e.localMousePosition); m_StartPos = parent.layout; // Warn user if target uses a relative CSS position type // if (parent.style.positionType != PositionType.Manual) // { // if (parent.style.positionType == PositionType.Absolute) // { // if (!(parent.style.flexDirection == FlexDirection.Column || parent.style.flexDirection == FlexDirection.Row)) // { // Debug.LogWarning("Attempting to resize an object with an absolute position but no layout direction (row or column)"); // } // } // else // { // Debug.LogWarning("Attempting to resize an object with a non manual position"); // } // } m_Active = true; this.TakeMouseCapture(); e.StopPropagation(); } }
protected virtual void OnDisable() { if (imguiContainer.HasMouseCapture()) { MouseCaptureController.ReleaseMouse(); } visualTree.Remove(imguiContainer); imguiContainer = null; if (m_Panel != null) { m_Panel.Dispose(); /// We don't set <c>m_Panel</c> to null to prevent it from being re-created from <c>panel</c>. } }
void OnExecuteCommand(ExecuteCommandEvent evt) { if (MouseCaptureController.IsMouseCaptureTaken()) { return; } if (evt.commandName == EventCommandNames.Copy) { CopySelectionCallback(); evt.StopPropagation(); } else if (evt.commandName == EventCommandNames.Paste) { PasteCallback(); evt.StopPropagation(); } else if (evt.commandName == EventCommandNames.Duplicate) { DuplicateSelectionCallback(); evt.StopPropagation(); } else if (evt.commandName == EventCommandNames.Cut) { CutSelectionCallback(); evt.StopPropagation(); } else if (evt.commandName == EventCommandNames.Delete) { DeleteSelectionCallback(AskUser.DontAskUser); evt.StopPropagation(); } else if (evt.commandName == EventCommandNames.SoftDelete) { DeleteSelectionCallback(AskUser.AskUser); evt.StopPropagation(); } else if (evt.commandName == EventCommandNames.FrameSelected) { FrameSelection(); evt.StopPropagation(); } if (evt.isPropagationStopped && evt.imguiEvent != null) { evt.imguiEvent.Use(); } }
static void OnValidateCommand(ValidateCommandEvent evt) { if (MouseCaptureController.IsMouseCaptured()) { return; } if (evt.commandName == "Find") { evt.StopPropagation(); if (evt.imguiEvent == null) { return; } evt.imguiEvent.Use(); } }
void OnKeyDownShortcut(KeyDownEvent evt) { if (!isReframable) { return; } if (MouseCaptureController.IsMouseCaptureTaken()) { return; } EventPropagation result = EventPropagation.Continue; switch (evt.character) { case 'a': result = FrameAll(); break; case 'o': result = FrameOrigin(); break; case '[': result = FramePrev(); break; case ']': result = FrameNext(); break; case ' ': result = OnInsertNodeKeyDown(evt); break; } if (result == EventPropagation.Stop) { evt.StopPropagation(); if (evt.imguiEvent != null) { evt.imguiEvent.Use(); } } }
private void OnKeyDown(KeyDownEvent evt) { if (!MouseCaptureController.IsMouseCaptureTaken()) { if (this.m_Dictionary.ContainsKey(evt.imguiEvent)) { EventPropagation eventPropagation = this.m_Dictionary[evt.imguiEvent](); if (eventPropagation == EventPropagation.Stop) { evt.StopPropagation(); if (evt.imguiEvent != null) { evt.imguiEvent.Use(); } } } } }
void OnWheel(WheelEvent evt) { if (MouseCaptureController.IsMouseCaptured()) { return; } if (wheelTarget != null) { wheelTarget.OnWheel(evt, GetWheelDelta(evt.delta.y)); } if (zoomTarget != null && evt.modifiers == zoomModifiers) { zoomCurrentScale = CalculateNewZoom(zoomCurrentScale, -evt.delta.y, zoomScaleStep, zoomMinScale, zoomMaxScale); zoomTarget.OnZoom(evt, new Vector3(zoomCurrentScale, zoomCurrentScale, 1f)); } }
protected virtual void OnDisable() { if (imguiContainer.HasMouseCapture()) { MouseCaptureController.ReleaseMouse(); } imguiContainer.RemoveFromHierarchy(); imguiContainer = null; if (m_Panel != null) { UpdateDrawChainRegistration(false); m_Panel.Dispose(); /// We don't set <c>m_Panel</c> to null to prevent it from being re-created from <c>panel</c>. } Panel.BeforeUpdaterChange -= OnBeforeUpdaterChange; Panel.AfterUpdaterChange -= OnAfterUpdaterChange; }
protected void OnMouseDown(MouseDownEvent e) { if (this.m_Active) { e.StopImmediatePropagation(); } else if (!MouseCaptureController.IsMouseCaptureTaken()) { this.m_Active = false; this.m_Dragging = false; this.m_AddedByMouseDown = false; if (base.target != null) { this.selectionContainer = base.target.GetFirstAncestorOfType <ISelection>(); if (this.selectionContainer != null) { this.selectedElement = base.target.GetFirstOfType <GraphElement>(); if (this.selectedElement != null) { if (!this.selectionContainer.selection.Contains(this.selectedElement)) { if (!e.ctrlKey) { this.selectionContainer.ClearSelection(); } this.selectionContainer.AddToSelection(this.selectedElement); this.m_AddedByMouseDown = true; } if (e.button == (int)this.activateButton) { if (this.selectedElement.IsDroppable()) { this.m_DragAndDropDelay.Init(e.localMousePosition); this.m_Active = true; base.target.TakeMouseCapture(); e.StopPropagation(); } } } } } } }
void OnKeyDown(KeyDownEvent evt) { if (MouseCaptureController.IsMouseCaptured()) { return; } if (m_Dictionary.ContainsKey(evt.imguiEvent)) { var result = m_Dictionary[evt.imguiEvent](); if (result == EventPropagation.Stop) { evt.StopPropagation(); if (evt.imguiEvent != null) { evt.imguiEvent.Use(); } } } }