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 !"); } }
void OnWheel(WheelEvent evt) { if (MouseCaptureController.IsMouseCaptured()) { return; } Zoom(-evt.delta.y, evt.localMousePosition); evt.StopPropagation(); }
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(); }
void OnExecuteCommand(ExecuteCommandEvent evt) { if (MouseCaptureController.IsMouseCaptured()) { return; } if (evt.commandName == "Find") { OnSearchInGraph(); evt.StopPropagation(); } }
void OnMouseDown(MouseDownEvent e) { if (m_Active) { e.StopImmediatePropagation(); return; } if (MouseCaptureController.IsMouseCaptured()) { return; } var ce = parent as GraphElement; if (ce == null) { 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.CaptureMouse(); e.StopPropagation(); } }
static void OnValidateCommand(ValidateCommandEvent evt) { if (MouseCaptureController.IsMouseCaptured()) { return; } if (evt.commandName == "Find") { evt.StopPropagation(); if (evt.imguiEvent == null) { return; } 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)); } }
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(); } } } }
void OnMouseDown(MouseDownEvent e) { if (m_Active) { e.StopImmediatePropagation(); return; } if (MouseCaptureController.IsMouseCaptured()) { return; } var ce = parent as GraphElement; if (ce == null) { 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.isLayoutManual && parent.resolvedStyle.position == Position.Relative) { Debug.LogWarning("Attempting to resize an object with a non absolute position"); } m_Active = true; this.CaptureMouse(); e.StopPropagation(); } }
// ######################## FUNCTIONALITY ######################## // #region FUNCTIONALITY #region EVENT HANDLING private void OnMouseWheel(WheelEvent evt) { // do nothing if the mouse is captured if (MouseCaptureController.IsMouseCaptured()) { return; } // update zoom origin Vector2 localMousePos = this.ChangeCoordinatesTo(_origin, evt.localMousePosition); _origin.style.left = evt.localMousePosition.x; _origin.style.top = evt.localMousePosition.y; _contentContainer.style.left = _contentContainer.layout.xMin - localMousePos.x; _contentContainer.style.top = _contentContainer.layout.yMin - localMousePos.y; // calculate zoom value int wheelDir = (int)Mathf.Sign(-evt.delta.y); float scrollValue = wheelDir * _zoomSpeed; // zoom UpdateZoom(scrollValue); }