Beispiel #1
0
            public static void SetValueForEdge(IEnumerable <ITimelineItem> items, AttractedEdge edge, double value, WindowState state)
            {
                var handler = new MoveItemHandler(state);

                foreach (var item in items)
                {
                    handler.Grab(new[] { item }, item.parentTrack);
                    handler.OnAttractedEdge(null, ManipulateEdges.Both, edge, value);
                    handler.Drop();
                }
            }
Beispiel #2
0
            public void OnExitDrag()
            {
                if (m_MoveItemHandler == null)
                {
                    return;
                }

                m_MoveItemHandler.Drop();
                m_MoveItemHandler = null;
                GUIUtility.ExitGUI();
            }
Beispiel #3
0
            public void OnSetValue(IEnumerable <ITimelineItem> items, double value, WindowState state)
            {
                if (!items.Any())
                {
                    return;
                }

                m_MoveItemHandler = new MoveItemHandler(state);
                m_MoveItemHandler.Grab(items, items.First().parentTrack);
                m_MoveItemHandler.OnAttractedEdge(null, ManipulateEdges.Both, AttractedEdge.None, value);
                m_MoveItemHandler.Drop();
                m_MoveItemHandler = null;
            }
        protected override bool MouseUp(Event evt, WindowState state)
        {
            if (!m_Dragged)
            {
                var item = PickerUtils.TopmostPickedItem() as ISelectable;

                if (item == null)
                {
                    return(false);
                }

                if (!item.IsSelected())
                {
                    return(false);
                }

                // Re-selecting an item part of a multi-selection should only keep this item selected.
                if (SelectionManager.Count() > 1 && ItemSelection.CanClearSelection(evt))
                {
                    SelectionManager.Clear();
                    item.Select();
                    return(true);
                }

                if (m_CycleMarkersPending)
                {
                    m_CycleMarkersPending = false;
                    TimelineMarkerClusterGUI.CycleMarkers();
                    return(true);
                }

                return(false);
            }

            m_TimeAreaAutoPanner = null;

            DropItems();

            m_SnapEngine      = null;
            m_MoveItemHandler = null;

            state.Evaluate();
            state.RemoveCaptured(this);
            m_Dragged = false;
            TimelineCursors.ClearCursor();

            return(true);
        }
Beispiel #5
0
        public static void FinishMove()
        {
            var manipulatedItemsList = s_CurrentMoveItemHandler.movingItems;

            moveMode.FinishMove(manipulatedItemsList);

            foreach (var itemsGroup in manipulatedItemsList)
            {
                foreach (var item in itemsGroup.items)
                {
                    item.parentTrack = itemsGroup.targetTrack;
                }
            }

            s_CurrentMoveItemHandler = null;

            TimelineCursors.ClearCursor();
            ClearEditMode();
        }
        protected override bool MouseDrag(Event evt, WindowState state)
        {
            if (state.editSequence.isReadOnly)
            {
                return(false);
            }

            // case 1099285 - ctrl-click can cause no clips to be selected
            var selectedItemsGUI = SelectionManager.SelectedItems();

            if (!selectedItemsGUI.Any())
            {
                m_Dragged = false;
                return(false);
            }

            const float hDeadZone = 5.0f;
            const float vDeadZone = 5.0f;

            bool vDone = m_VerticalMovementDone || Math.Abs(evt.mousePosition.y - m_MouseDownPosition.y) > vDeadZone;
            bool hDone = m_HorizontalMovementDone || Math.Abs(evt.mousePosition.x - m_MouseDownPosition.x) > hDeadZone;

            m_CycleMarkersPending = false;

            if (!m_Dragged)
            {
                var canStartMove = vDone || hDone;

                if (canStartMove)
                {
                    state.AddCaptured(this);
                    m_Dragged = true;

                    var referenceTrack = GetTrackDropTargetAt(state, m_MouseDownPosition);

                    foreach (var item in selectedItemsGUI)
                    {
                        item.gui.StartDrag();
                    }

                    m_MoveItemHandler = new MoveItemHandler(state);

                    m_MoveItemHandler.Grab(selectedItemsGUI, referenceTrack, m_MouseDownPosition);

                    m_SnapEngine = new SnapEngine(m_MoveItemHandler, m_MoveItemHandler, ManipulateEdges.Both,
                                                  state, m_MouseDownPosition);

                    m_TimeAreaAutoPanner = new TimeAreaAutoPanner(state);
                }
            }

            if (!m_VerticalMovementDone)
            {
                m_VerticalMovementDone = vDone;

                if (m_VerticalMovementDone)
                {
                    m_MoveItemHandler.OnTrackDetach();
                }
            }

            if (!m_HorizontalMovementDone)
            {
                m_HorizontalMovementDone = hDone;
            }

            if (m_Dragged)
            {
                if (m_HorizontalMovementDone)
                {
                    m_SnapEngine.Snap(evt.mousePosition, evt.modifiers);
                }

                if (m_VerticalMovementDone)
                {
                    var track = GetTrackDropTargetAt(state, evt.mousePosition);
                    m_MoveItemHandler.UpdateTrackTarget(track);
                }

                state.Evaluate();
            }

            return(true);
        }
        public static void HandleModeClutch()
        {
            if (Event.current.type == EventType.KeyDown && EditorGUI.IsEditingTextField())
            {
                return;
            }

            var prevType = editType;

            if (Event.current.type == EventType.KeyDown)
            {
                var clutchEditType = GetSubEditType(Event.current.keyCode);
                if (clutchEditType != EditType.None)
                {
                    s_OverrideEditType = clutchEditType;
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.KeyUp)
            {
                var clutchEditType = GetSubEditType(Event.current.keyCode);
                if (clutchEditType == s_OverrideEditType)
                {
                    s_OverrideEditType = EditType.None;
                    Event.current.Use();
                }
            }

            if (prevType != editType)
            {
                if (s_CurrentTrimItem != null)
                {
                    trimMode.OnBeforeTrim(s_CurrentTrimItem, s_CurrentTrimDirection);
                }
                else if (s_CurrentMoveItemHandler != null)
                {
                    if (s_CurrentMoveItemHandler.movingItems == null)
                    {
                        s_CurrentMoveItemHandler = null;
                        return;
                    }

                    foreach (var movingItems in s_CurrentMoveItemHandler.movingItems)
                    {
                        if (movingItems != null && movingItems.HasAnyDetachedParents())
                        {
                            foreach (var items in movingItems.items)
                            {
                                items.parentTrack = movingItems.originalTrack;
                            }
                        }
                    }

                    var movingSelection = s_CurrentMoveItemHandler.movingItems;

                    // Handle clutch key transition if needed
                    GetSubEditMode(prevType).moveItemMode.OnModeClutchExit(movingSelection);
                    moveMode.OnModeClutchEnter(movingSelection);

                    moveMode.BeginMove(movingSelection);
                    moveMode.HandleTrackSwitch(movingSelection);

                    UpdateMove();
                    s_CurrentMoveItemHandler.RefreshPreviewItems();

                    TimelineWindow.instance.state.rebuildGraph = true; // TODO Rebuild only if parent changed
                }

                TimelineWindow.instance.Repaint(); // TODO Refresh the toolbar without doing a full repaint?
            }
        }
 public static void BeginMove(MoveItemHandler moveItemHandler)
 {
     s_CurrentMoveItemHandler = moveItemHandler;
     moveMode.BeginMove(s_CurrentMoveItemHandler.movingItems);
 }