Пример #1
0
        private void Pan(TimerState ts)
        {
            m_GraphView.viewTransform.position -= m_PanDiff;
            m_ItemPanDiff += m_PanDiff;

            foreach (KeyValuePair <GraphElement, Rect> v in m_OriginalPos)
            {
                GraphElement ce = v.Key;

                Matrix4x4 g     = ce.worldTransform;
                var       scale = new Vector3(g.m00, g.m11, g.m22);

                Rect ceLayout = ce.GetPosition();

                ce.SetPosition(
                    new Rect(v.Value.x - (m_MouseDiff.x - m_ItemPanDiff.x) * panSpeed.x / scale.x,
                             v.Value.y - (m_MouseDiff.y - m_ItemPanDiff.y) * panSpeed.y / scale.y,
                             ceLayout.width, ceLayout.height));
            }
        }
Пример #2
0
        void MoveElements(float deltaX, float deltaY)
        {
            if (m_ContainedElements != null)
            {
                m_IsMovingElements = true;

                for (int i = 0; i < m_ContainedElements.Count; ++i)
                {
                    GraphElement subElement = m_ContainedElements[i];

                    if (m_IsUpdatingGeometryFromContent == false)
                    {
                        Rect currentPosition = subElement.GetPosition();

                        subElement.SetPosition(new Rect(currentPosition.x + deltaX, currentPosition.y + deltaY, currentPosition.width, currentPosition.height));
                    }
                }

                m_IsMovingElements = false;
            }
        }
Пример #3
0
        protected new void OnMouseMove(MouseMoveEvent e)
        {
            if (!target.HasMouseCapture())
            {
                // We lost the capture. Since we still receive mouse events,
                // the MouseDown target must have taken it in its ExecuteDefaultAction().
                // Stop processing the event sequence, then.
                // FIXME: replace this by a handler on the upcoming LostCaptureEvent.

                m_PrevDropTarget = null;
                m_Active         = false;
            }

            if (!m_Active)
            {
                return;
            }

            if (m_GraphView == null)
            {
                return;
            }

            var     ve         = (VisualElement)e.target;
            Vector2 gvMousePos = ve.ChangeCoordinatesTo(m_GraphView.contentContainer, e.localMousePosition);

            m_PanDiff = GetEffectivePanSpeed(gvMousePos);


            if (m_PanDiff != Vector3.zero)
            {
                m_PanSchedule.Resume();
            }
            else
            {
                m_PanSchedule.Pause();
            }

            // We need to monitor the mouse diff "by hand" because we stop positionning the graph elements once the
            // mouse has gone out.
            m_MouseDiff = m_originalMouse - e.mousePosition;

            foreach (KeyValuePair <GraphElement, Rect> v in m_OriginalPos)
            {
                GraphElement ce = v.Key;

                Matrix4x4 g     = ce.worldTransform;
                var       scale = new Vector3(g.m00, g.m11, g.m22);

                Rect ceLayout = ce.GetPosition();

                ce.SetPosition(
                    new Rect(v.Value.x - (m_MouseDiff.x - m_ItemPanDiff.x) * panSpeed.x / scale.x,
                             v.Value.y - (m_MouseDiff.y - m_ItemPanDiff.y) * panSpeed.y / scale.y,
                             ceLayout.width, ceLayout.height));
            }
            List <ISelectable> selection = m_GraphView.selection;

            // TODO: Replace with a temp drawing or something...maybe manipulator could fake position
            // all this to let operation know which element sits under cursor...or is there another way to draw stuff that is being dragged?

            IDropTarget dropTarget = GetDropTargetAt(e.localMousePosition);

            if (m_PrevDropTarget != dropTarget && m_PrevDropTarget != null)
            {
                using (IMGUIEvent eexit = IMGUIEvent.GetPooled(e.imguiEvent))
                {
                    eexit.imguiEvent.type = EventType.DragExited;
                    SendDragAndDropEvent(eexit, selection, m_PrevDropTarget);
                }
            }

            using (IMGUIEvent eupdated = IMGUIEvent.GetPooled(e.imguiEvent))
            {
                eupdated.imguiEvent.type = EventType.DragUpdated;
                SendDragAndDropEvent(eupdated, selection, dropTarget);
            }

            m_PrevDropTarget = dropTarget;

            selectedElement = null;
            e.StopPropagation();
        }