Example #1
0
        protected void OnMouseMove(MouseMoveEvent e)
        {
            GraphElement ce = e.target as GraphElement;

            if (ce != null && !ce.IsMovable())
            {
                return;
            }

            if (m_Active)
            {
                Vector2 diff = e.localMousePosition - m_Start;

                if (ce != null)
                {
                    var targetScale = ce.transform.scale;
                    diff.x *= targetScale.x;
                    diff.y *= targetScale.y;
                }

                Rect rect = CalculatePosition(target.layout.x + diff.x, target.layout.y + diff.y, target.layout.width, target.layout.height);

                if (target.IsLayoutManual())
                {
                    target.SetLayout(rect);
                }
                else if (target.resolvedStyle.position == Position.Absolute)
                {
                    target.style.left = rect.x;
                    target.style.top  = rect.y;
                }

                e.StopPropagation();
            }
        }
Example #2
0
 private void OnMouseMove(MouseMoveEvent evt)
 {
     if (evt.button == 0)
     {
         if (base.textInputField.HasMouseCapture())
         {
             base.textInputField.SyncTextEngine();
             this.m_Changed = false;
             if (!evt.shiftKey && base.editorEngine.hasSelection && this.m_DragToPosition)
             {
                 base.editorEngine.MoveAltCursorToPosition(evt.localMousePosition);
             }
             else
             {
                 if (evt.shiftKey)
                 {
                     base.editorEngine.MoveCursorToPosition_Internal(evt.localMousePosition, evt.shiftKey);
                 }
                 else
                 {
                     base.editorEngine.SelectToPosition(evt.localMousePosition);
                 }
                 this.m_DragToPosition     = false;
                 this.m_SelectAllOnMouseUp = !base.editorEngine.hasSelection;
             }
             this.m_Dragged = true;
             evt.StopPropagation();
             base.editorEngine.UpdateScrollOffset();
         }
     }
 }
Example #3
0
        protected void OnMouseMove(MouseMoveEvent e)
        {
            GraphElement ce = e.target as GraphElement;

            if (ce != null && !ce.IsMovable())
            {
                return;
            }

            if (m_Active)
            {
                Vector2 diff = e.localMousePosition - m_Start;
                Rect    rect = CalculatePosition(target.layout.x + diff.x, target.layout.y + diff.y, target.layout.width, target.layout.height);

                if (target.style.positionType == PositionType.Manual)
                {
                    target.layout = rect;
                }
                else if (target.style.positionType == PositionType.Absolute)
                {
                    target.style.positionLeft = rect.x;
                    target.style.positionTop  = rect.y;
                }

                e.StopPropagation();
            }
        }
Example #4
0
        private void OnMouseDrag(MouseMoveEvent evt)
        {
            if (!m_mouseDrag || evt.button != 0)
            {
                return;
            }

            m_serializedNoise.ApplyModifiedProperties();
            m_serializedNoise.Update();
            {
                Rect rect = m_image.worldBound;

                Vector3 t = m_translation.vector3Value;
                Vector3 r = m_rotation.vector3Value;
                Vector3 s = m_scale.vector3Value;

                Vector2 previewDims = new Vector2(rect.width, rect.height);
                Vector2 abs         = new Vector2(Mathf.Abs(s.x), Mathf.Abs(s.z));

                // change noise offset panning icon
                Vector2 sign  = new Vector2(-Mathf.Sign(s.x), Mathf.Sign(s.z));
                Vector2 delta = evt.mouseDelta / previewDims * abs * sign;
                Vector3 d3    = new Vector3(delta.x, 0, delta.y);

                d3 = Quaternion.Euler(r) * d3;

                t += d3;

                m_translation.vector3Value = t;

                evt.StopPropagation();
            }
            m_serializedNoise.ApplyModifiedProperties();
            m_serializedNoise.Update();
        }
Example #5
0
        void HandleResizeFromTopLeft(MouseMoveEvent mouseMoveEvent)
        {
            if (!m_Dragging)
            {
                return;
            }

            Vector2 relativeMousePosition = mouseMoveEvent.mousePosition - m_ResizeBeginMousePosition;

            // Set anchor points for positioning
            m_Container.style.positionTop = StyleValue <float> .Create(float.NaN);

            m_Container.style.positionBottom = StyleValue <float> .Create(m_Container.parent.layout.height - m_Container.layout.yMax);

            m_Container.style.positionLeft = StyleValue <float> .Create(float.NaN);

            m_Container.style.positionRight = StyleValue <float> .Create(m_Container.parent.layout.width - m_Container.layout.xMax);

            float newWidth  = Mathf.Max(0f, m_ResizeBeginLayout.width - relativeMousePosition.x);
            float newHeight = Mathf.Max(0f, m_ResizeBeginLayout.height - relativeMousePosition.y);

            if (maintainAspectRatio)
            {
                newWidth = newHeight = Mathf.Min(newWidth, newHeight);
            }

            m_ResizeTarget.style.width = StyleValue <float> .Create(newWidth);

            m_ResizeTarget.style.height = StyleValue <float> .Create(newHeight);

            mouseMoveEvent.StopPropagation();
        }
        protected void OnMouseMove(MouseMoveEvent e)
        {
            if (!m_Active)
            {
                return;
            }

            var graphView = target as GraphView;

            if (graphView == null)
            {
                return;
            }

            Vector2 diff = graphView.ChangeCoordinatesTo(graphView.ContentViewContainer, e.localMousePosition) - m_Start;

            // During the drag update only the view
            Vector3 s = graphView.ContentViewContainer.transform.scale;

            graphView.ViewTransform.position += Vector3.Scale(diff, s);

            graphView.ChangeMouseCursorTo((int)MouseCursor.Pan);

            e.StopPropagation();
        }
        /// <summary>
        /// Callback for the MouseMove event.
        /// </summary>
        /// <param name="e">The event.</param>
        protected void OnMouseMove(MouseMoveEvent e)
        {
            if (m_Active && !m_Dragging && m_SelectionContainer != null)
            {
                // Keep a copy of the selection
                var selection = m_SelectionContainer.GetSelection();

                if (selection.Count > 0)
                {
                    if (m_SelectedElement != null &&
                        m_SelectedElement.Model.IsDroppable() &&
                        Vector2.Distance(m_MouseDownPosition, e.localMousePosition) > k_StartDragTreshold)
                    {
                        DragAndDrop.PrepareStartDrag();
                        DragAndDrop.objectReferences = new Object[] { };     // this IS required for dragging to work
                        DragAndDrop.SetGenericData("DragSelection", selection);
                        m_Dragging = true;

                        DragAndDrop.StartDrag("");
                        DragAndDrop.visualMode = e.actionKey ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Move;
                        target.ReleaseMouse();
                    }

                    e.StopPropagation();
                }
            }
        }
        void HandleResizeFromBottomLeft(MouseMoveEvent mouseMoveEvent)
        {
            if (!m_Dragging)
            {
                return;
            }

            Vector2 relativeMousePosition = mouseMoveEvent.mousePosition - m_ResizeBeginMousePosition;

            // Set anchor points for positioning
            m_Container.style.top    = m_Container.layout.yMin;
            m_Container.style.bottom = float.NaN;
            m_Container.style.left   = float.NaN;
            m_Container.style.right  = m_Container.parent.layout.width - m_Container.layout.xMax;

            float newWidth  = Mathf.Max(0f, m_ResizeBeginLayout.width - relativeMousePosition.x);
            float newHeight = Mathf.Max(0f, m_ResizeBeginLayout.height + relativeMousePosition.y);

            if (maintainAspectRatio)
            {
                newWidth = newHeight = Mathf.Min(newWidth, newHeight);
            }

            m_ResizeTarget.style.width  = newWidth;
            m_ResizeTarget.style.height = newHeight;

            mouseMoveEvent.StopPropagation();
        }
        protected void OnMouseMove(MouseMoveEvent e)
        {
            if (m_Active && !m_Dragging && selectionContainer != null)
            {
                // Keep a copy of the selection
                var selection = selectionContainer.selection.ToList();

                if (selection.Count > 0)
                {
                    var  ce           = selection[0] as GraphElement;
                    bool canStartDrag = ce != null && ce.IsDroppable();

                    if (canStartDrag && m_DragAndDropDelay.CanStartDrag(e.localMousePosition))
                    {
                        DragAndDrop.PrepareStartDrag();
                        DragAndDrop.objectReferences = new UnityEngine.Object[] {};   // this IS required for dragging to work
                        DragAndDrop.SetGenericData("DragSelection", selection);
                        m_Dragging = true;

                        DragAndDrop.StartDrag("");
                        DragAndDrop.visualMode = e.actionKey ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Move;
                        target.ReleaseMouse();
                    }

                    e.StopPropagation();
                }
            }
        }
Example #10
0
 private void OnMouseMove(MouseMoveEvent e)
 {
     if (this.m_Active)
     {
         this.m_Rectangle.end = e.localMousePosition;
         e.StopPropagation();
     }
 }
Example #11
0
 protected void OnMouseMove(MouseMoveEvent evt)
 {
     if (base.target.HasMouseCapture())
     {
         this.lastMousePosition = evt.localMousePosition;
         evt.StopPropagation();
     }
 }
 protected void OnMouseMove(MouseMoveEvent evt)
 {
     if (m_Active)
     {
         lastMousePosition = evt.localMousePosition;
         evt.StopPropagation();
     }
 }
 void OnMouseMove(MouseMoveEvent e)
 {
     if (m_Active)
     {
         SetTimeSnappedToFrameFromPixel(e.mousePosition.x);
         e.StopPropagation();
     }
 }
Example #14
0
        protected void OnMouseMove(MouseMoveEvent evt)
        {
            evt.StopPropagation();

            Vector2 listRelativeMouse = m_Root.WorldToLocal(evt.mousePosition);

            m_Root.ItemDragging(m_Ctx, m_Line, listRelativeMouse.y - startPosition.y, evt.mousePosition);
        }
Example #15
0
        void OnMouseMove(MouseMoveEvent evt)
        {
            if (!m_Dragging)
            {
                return;
            }

            // We don't freeze immediately as it breaks focus when we refresh the list.
            if (!m_ListFrozen)
            {
                m_DragAreaBottom = FreezeScrollView();
                m_ListFrozen     = true;
            }

            var newPos = Mathf.Clamp(m_Item.style.top.value.value + evt.mouseDelta.y, m_DragAreaTop, m_DragAreaBottom - m_Item.layout.height);

            int   index  = 0;
            float y      = 0;
            float offset = 0;

            m_CurrentIndex = -1;
            foreach (ListItem child in m_Children)
            {
                if (child == m_Item)
                {
                    continue;
                }

                if (m_CurrentIndex == -1 && newPos < y + child.layout.height * 0.5f)
                {
                    offset        += m_Item.layout.height;
                    m_CurrentIndex = index;
                }

                if (child.Animator?.to.top != offset)
                {
                    child.Animator?.Stop();
                    child.Animator?.Recycle();
                    child.Animator = child.experimental.animation.Start(new StyleValues {
                        top = offset
                    }, 500);
                    child.Animator.KeepAlive();
                }

                y      += child.layout.height;
                offset += child.layout.height;
                index++;
            }

            if (m_CurrentIndex == -1)
            {
                m_CurrentIndex = m_Children.Count - 1;
            }

            m_Item.style.top = newPos;
            m_Item.BringToFront();
            evt.StopPropagation();
        }
Example #16
0
 private void OnMouseMove(MouseMoveEvent e)
 {
     if (this.m_Active)
     {
         this.m_FreehandElement.points.Add(e.localMousePosition);
         this.m_FreehandElement.deleteModifier = e.shiftKey;
         e.StopPropagation();
     }
 }
 protected void OnMouseMove(MouseMoveEvent e)
 {
     if (m_Active)
     {
         Pan(m_LastPosition, e.mousePosition);
         m_LastPosition = e.mousePosition;
         e.StopPropagation();
     }
 }
Example #18
0
 protected virtual void OnMouseMove(MouseMoveEvent e)
 {
     if (!m_Active)
     {
         return;
     }
     m_EdgeDragHelper.HandleMouseMove(e);
     e.StopPropagation();
 }
Example #19
0
 protected virtual void OnMouseMove(MouseMoveEvent e)
 {
     if (IsDragged)
     {
         UpdatePosition(e.mousePosition);
         OnMove?.Invoke();
         e.StopPropagation();
     }
 }
Example #20
0
        void OnMouseMove(MouseMoveEvent e)
        {
            VisualElement resizedTarget = resizedElement.parent;
            VisualElement resizedBase   = resizedTarget.parent;
            Vector2       mousePos      = resizedBase.WorldToLocal(e.mousePosition);

            if (!m_DragStarted)
            {
                if (resizedTarget is IResizable)
                {
                    (resizedTarget as IResizable).OnStartResize();
                }
                m_DragStarted = true;
            }

            if ((direction & ResizableElement.Resizer.Right) != 0)
            {
                resizedTarget.style.width = Mathf.Min(m_MaxSize.x, Mathf.Max(m_MinSize.x, m_StartSize.x + mousePos.x - m_StartMouse.x));
            }
            else if ((direction & ResizableElement.Resizer.Left) != 0)
            {
                float delta = mousePos.x - m_StartMouse.x;

                if (m_StartSize.x - delta < m_MinSize.x)
                {
                    delta = -m_MinSize.x + m_StartSize.x;
                }
                else if (m_StartSize.x - delta > m_MaxSize.x)
                {
                    delta = -m_MaxSize.x + m_StartSize.x;
                }

                resizedTarget.style.left  = delta + m_StartPosition.x;
                resizedTarget.style.width = -delta + m_StartSize.x;
            }
            if ((direction & ResizableElement.Resizer.Bottom) != 0)
            {
                var delta = mousePos.y - m_StartMouse.y;
                resizedTarget.style.height = Mathf.Clamp(m_StartSize.y + delta, m_MinSize.y, m_MaxSize.y);
            }
            else if ((direction & ResizableElement.Resizer.Top) != 0)
            {
                float delta = mousePos.y - m_StartMouse.y;

                if (m_StartSize.y - delta < m_MinSize.y)
                {
                    delta = -m_MinSize.y + m_StartSize.y;
                }
                else if (m_StartSize.y - delta > m_MaxSize.y)
                {
                    delta = -m_MaxSize.y + m_StartSize.y;
                }
                resizedTarget.style.top    = delta + m_StartPosition.y;
                resizedTarget.style.height = -delta + m_StartSize.y;
            }
            e.StopPropagation();
        }
        protected void OnMouseMove(MouseMoveEvent e)
        {
            if (!m_Active)
            {
                return;
            }

            m_Rectangle.end = e.localMousePosition;
            e.StopPropagation();
        }
Example #22
0
            private void OnMouseMove(MouseMoveEvent e)
            {
                if (!m_Active || !target.HasMouseCapture())
                {
                    return;
                }

                ApplyDelta((e.localMousePosition - m_Start).x);
                e.StopPropagation();
            }
        void OnMouseMove(MouseMoveEvent evt)
        {
            if (!m_Panning)
            {
                return;
            }

            m_Viewport.contentOffset += evt.mouseDelta;
            evt.StopPropagation();
        }
        protected void OnMouseMove(MouseMoveEvent e)
        {
            if (!m_active || !target.HasMouseCapture())
            {
                return;
            }

            target.CaptureMouse();
            e.StopPropagation();
        }
        void OnHover(MouseMoveEvent evt)
        {
            var pickedElement = PickElement(evt.mousePosition);

            if (pickedElement != null)
            {
                // Don't allow selection of elements inside template instances.
                pickedElement = pickedElement.GetClosestElementPartOfCurrentDocument();

                parentTracker.Activate(pickedElement);

                ClearMatchingExplorerItems();

                // Highlight corresponding element in Explorer (if visible).
                var explorerItem    = pickedElement.GetProperty(BuilderConstants.ElementLinkedExplorerItemVEPropertyName) as BuilderExplorerItem;
                var explorerItemRow = explorerItem?.row();
                if (explorerItemRow != null)
                {
                    m_MatchingExplorerItems.Add(explorerItemRow);
                }

                // Highlight matching selectors in the Explorer (if visible).
                var matchingSelectors = BuilderSharedStyles.GetMatchingSelectorsOnElement(pickedElement);
                if (matchingSelectors != null)
                {
                    foreach (var selectorStr in matchingSelectors)
                    {
                        var selectorElement = BuilderSharedStyles.FindSelectorElement(m_DocumentElement, selectorStr);
                        if (selectorElement == null)
                        {
                            continue;
                        }

                        var selectorItem    = selectorElement.GetProperty(BuilderConstants.ElementLinkedExplorerItemVEPropertyName) as BuilderExplorerItem;
                        var selectorItemRow = selectorItem?.row();
                        if (selectorItemRow == null)
                        {
                            continue;
                        }

                        m_MatchingExplorerItems.Add(selectorItemRow);
                    }
                }

                HighlightMatchingExplorerItems();
            }
            else
            {
                parentTracker.Deactivate();

                ClearMatchingExplorerItems();
            }

            evt.StopPropagation();
        }
Example #26
0
 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;
     }
 }
        void OnMouseMove(MouseMoveEvent evt)
        {
            if (!m_Active || !m_DragHandle.HasMouseCapture())
            {
                return;
            }

            m_DragBar.style.top = evt.localMousePosition.y + m_Offset;

            evt.StopPropagation();
        }
Example #28
0
        void OnMouseMove(MouseMoveEvent evt)
        {
            if (!m_Zooming || Mathf.Abs(evt.localMousePosition.x - m_LastZoomPos.x) < ZoomStepDistance)
            {
                return;
            }

            Zoom(evt.mouseDelta.x, m_PressPos);
            m_LastZoomPos = evt.localMousePosition;
            evt.StopPropagation();
        }
        protected void OnMouseMove(MouseMoveEvent e)
        {
            if (m_Active)
            {
                Vector2 diff      = e.localMousePosition - m_Last;
                float   zoomScale = 1f + (diff.x + diff.y) * k_ZoomStep;
                Zoom(m_ZoomCenter, zoomScale);
                e.StopPropagation();

                m_Last = e.localMousePosition;
            }
        }
        protected virtual void OnMouseMove(MouseMoveEvent e)
        {
            if (!active)
            {
                return;
            }

            edgeDragHelper.HandleMouseMove(e);
            edgeCandidate.candidatePosition = e.mousePosition;
            edgeCandidate.UpdateEdgeControl();
            e.StopPropagation();
        }