Exemplo n.º 1
0
        protected override bool MouseDown(Event evt, WindowState state)
        {
            var handle = PickerUtils.PickedLayerableOfType <TimelineClipHandle>();

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

            if (handle.clipGUI.clip.parentTrack != null && handle.clipGUI.clip.parentTrack.lockedInHierarchy)
            {
                return(false);
            }

            if (ItemSelection.CanClearSelection(evt))
            {
                SelectionManager.Clear();
            }

            if (!SelectionManager.Contains(handle.clipGUI.clip))
            {
                SelectionManager.Add(handle.clipGUI.clip);
            }

            m_TrimClipHandler = handle;

            m_IsCaptured = true;
            state.AddCaptured(this);

            m_UndoSaved = false;

            var clip = m_TrimClipHandler.clipGUI.clip;

            m_OriginalDuration        = clip.duration;
            m_OriginalTimeScale       = clip.timeScale;
            m_OriginalEaseInDuration  = clip.easeInDuration;
            m_OriginalEaseOutDuration = clip.easeOutDuration;

            RefreshOverlayStrings(m_TrimClipHandler, state);

            // in ripple trim, the right edge moves and needs to snap
            var edges = ManipulateEdges.Right;

            if (EditMode.editType != EditMode.EditType.Ripple && m_TrimClipHandler.trimDirection == TrimEdge.Start)
            {
                edges = ManipulateEdges.Left;
            }
            m_SnapEngine = new SnapEngine(m_TrimClipHandler.clipGUI, new TrimClipAttractionHandler(), edges, state,
                                          evt.mousePosition);

            EditMode.BeginTrim(ItemsUtils.ToItem(clip), m_TrimClipHandler.trimDirection);

            return(true);
        }
Exemplo n.º 2
0
        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);
        }
        protected override bool MouseUp(Event evt, WindowState state)
        {
            if (!m_IsCaptured)
            {
                return(false);
            }

            m_IsCaptured      = false;
            m_TrimClipHandler = null;
            m_UndoSaved       = false;
            m_SnapEngine      = null;
            EditMode.FinishTrim();

            state.captured.Clear();

            return(true);
        }
Exemplo n.º 4
0
        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);
        }