public static bool SelectUpItem()
        {
            if (ClipAreaActive())
            {
                var refItem   = SelectionManager.SelectedItems().Last();
                var prevTrack = refItem.parentTrack.PreviousTrack();
                while (prevTrack != null)
                {
                    var selectionItem = GetClosestItem(prevTrack, refItem);
                    if (selectionItem == null)
                    {
                        prevTrack = prevTrack.PreviousTrack();
                        continue;
                    }

                    SelectionManager.SelectOnly(selectionItem);
                    TimelineHelpers.FrameItems(new[] { selectionItem });
                    FrameTrackHeader(GetVisibleTracks().First(x => x.track == selectionItem.parentTrack));
                    break;
                }
                return(true);
            }

            return(false);
        }
        internal bool Execute(WindowState state, Func <ITimelineItem, ITimelineItem, double> gapBetweenItems)
        {
            var selectedItems = SelectionManager.SelectedItems().ToItemsPerTrack().ToList();

            if (selectedItems.Any())
            {
                var requestedTime   = CalculateDuplicateTime(selectedItems, gapBetweenItems);
                var duplicatedItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(state, TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, selectedItems, requestedTime, "Duplicate Items");

                TimelineHelpers.FrameItems(state, duplicatedItems);
                SelectionManager.RemoveTimelineSelection();
                foreach (var item in duplicatedItems)
                {
                    SelectionManager.Add(item);
                }
            }

            var tracks = SelectionManager.SelectedTracks().ToArray();

            if (tracks.Length > 0)
            {
                TrackAction.Invoke <DuplicateTracks>(state, tracks);
            }

            state.Refresh();
            return(true);
        }
Ejemplo n.º 3
0
        void ItemDoubleClickedCallback(int id)
        {
            var trackGUI = m_TreeView.FindItem(id) as TimelineTrackGUI;

            if (trackGUI == null)
            {
                return;
            }

            if (trackGUI.track == null || trackGUI.track.lockedInHierarchy)
            {
                return;
            }

            var selection      = SelectionManager.SelectedItems().ToList();
            var items          = ItemsUtils.GetItems(trackGUI.track).ToList();
            var addToSelection = !selection.SequenceEqual(items);

            foreach (var i in items)
            {
                if (addToSelection)
                {
                    SelectionManager.Add(i);
                }
                else
                {
                    SelectionManager.Remove(i);
                }
            }
        }
Ejemplo n.º 4
0
        public override bool Execute(TimelineWindow.TimelineState state)
        {
            bool result;

            if (state.IsEditingASubItem())
            {
                result = false;
            }
            else if (SelectionManager.Count() == 0)
            {
                result = false;
            }
            else
            {
                bool flag = false;
                foreach (TimelineClip current in SelectionManager.SelectedItems <TimelineClip>())
                {
                    flag |= TimelineHelpers.NudgeClip(current, state, 1.0);
                }
                if (flag)
                {
                    state.Evaluate();
                }
                result = true;
            }
            return(result);
        }
        internal void ItemDoubleClickedCallback(int id)
        {
            var gui      = m_TreeView.FindItem(id);
            var trackGUI = gui as TimelineTrackGUI;

            if (trackGUI != null)
            {
                if (trackGUI.track == null || trackGUI.track.lockedInHierarchy)
                {
                    return;
                }
                var selection      = SelectionManager.SelectedItems().ToList();
                var items          = ItemsUtils.GetItems(trackGUI.track).ToList();
                var addToSelection = !selection.SequenceEqual(items);

                foreach (var i in items)
                {
                    if (addToSelection)
                    {
                        SelectionManager.Add(i);
                    }
                    else
                    {
                        SelectionManager.Remove(i);
                    }
                }

                return;
            }

            if (gui is TimelineGroupGUI groupGUI)
            {
                KeyboardNavigation.ToggleCollapseGroup(new[] { groupGUI.track });
            }
        }
        public override bool Execute(WindowState state)
        {
            if (SelectionManager.GetCurrentInlineEditorCurve() != null)
            {
                return(false);
            }

            if (!CanDelete(state))
            {
                return(false);
            }

            var selectedItems = SelectionManager.SelectedItems();

            DeleteItems(selectedItems);

            var tracks = SelectionManager.SelectedTracks().ToArray();

            if (tracks.Any())
            {
                TrackAction.Invoke <DeleteTracks>(state, tracks);
            }

            state.Refresh();
            return(selectedItems.Any() || tracks.Length > 0);
        }
Ejemplo n.º 7
0
        public void Init(TimelineClipGUI gui, TimelineWindow.TimelineState state)
        {
            TrackAsset track  = gui.parentTrackGUI.track;
            var        source = SelectionManager.SelectedClipGUI().GroupBy((TimelineClipGUI p) => p.parentTrackGUI, (TimelineClipGUI p) => p.clip, (TimelineTrackGUI key, IEnumerable <TimelineClip> g) => new
            {
                track = key,
                clips = g.ToList <TimelineClip>()
            });

            if (!source.Any(r => r.track.track == track && r.clips[0] != gui.clip))
            {
                this.m_RippleTotal = 0f;
                List <TimelineClip> exclude = SelectionManager.SelectedItems <TimelineClip>().ToList <TimelineClip>();
                exclude.Add(gui.clip);
                if ((this.m_Direction & Ripple.RippleDirection.After) == Ripple.RippleDirection.After)
                {
                    this.m_RippleAfter = (from c in track.clips
                                          where !exclude.Contains(c) && c.start >= gui.clip.start
                                          select c).ToList <TimelineClip>();
                }
                if ((this.m_Direction & Ripple.RippleDirection.Before) == Ripple.RippleDirection.Before)
                {
                    this.m_RippleBefore = (from c in track.clips
                                           where !exclude.Contains(c) && c.start < gui.clip.start
                                           select c).ToList <TimelineClip>();
                }
            }
        }
        public static bool SelectLeftItem(bool shift = false)
        {
            if (ClipAreaActive())
            {
                var items    = SelectionManager.SelectedItems().ToList();
                var clipOnly = FilterItems(ref items);

                var item = items.Last();
                var prev = item.PreviousItem(clipOnly);
                if (prev != null)
                {
                    if (shift)
                    {
                        if (SelectionManager.Contains(prev))
                        {
                            SelectionManager.Remove(item);
                        }
                        SelectionManager.Add(prev);
                    }
                    else
                    {
                        SelectionManager.SelectOnly(prev);
                    }
                    TimelineHelpers.FrameItems(new[] { prev });
                }
                else if (item != null && !shift && item.parentTrack != TimelineEditor.inspectedAsset.markerTrack)
                {
                    SelectionManager.SelectOnly(item.parentTrack);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 9
0
        static void ProcessInputAction(IInputHandler handler, InputEvent action, double value, WindowState state)
        {
            var items = SelectionManager.SelectedItems();

            switch (action)
            {
            case InputEvent.None:
                return;

            case InputEvent.DragEnter:
                handler.OnEnterDrag(items, state);
                break;

            case InputEvent.Drag:
                handler.OnDrag(value, state);
                break;

            case InputEvent.DragExit:
                handler.OnExitDrag();
                break;

            case InputEvent.KeyboardInput:
                handler.OnSetValue(items, value, state);
                break;

            default:
                return;
            }
        }
        public static bool SelectRightItem(bool shift = false)
        {
            if (ClipAreaActive())
            {
                var items    = SelectionManager.SelectedItems().ToList();
                var clipOnly = FilterItems(ref items);

                var item = items.Last();
                var next = item.NextItem(clipOnly);
                if (next != null)
                {
                    if (shift)
                    {
                        if (SelectionManager.Contains(next))
                        {
                            SelectionManager.Remove(item);
                        }
                        SelectionManager.Add(next);
                    }
                    else
                    {
                        SelectionManager.SelectOnly(next);
                    }
                    TimelineHelpers.FrameItems(new[] { next });
                    return(true);
                }
            }
            return(false);
        }
 static bool CanDelete(WindowState state)
 {
     if (state.editSequence.isReadOnly)
     {
         return(false);
     }
     // All() returns true when empty
     return(SelectionManager.SelectedTracks().All(x => !x.lockedInHierarchy) &&
            SelectionManager.SelectedItems().All(x => x.parentTrack == null || !x.parentTrack.lockedInHierarchy));
 }
Ejemplo n.º 12
0
 private void SetUndo(TimelineWindow.TimelineState state)
 {
     if (!this.m_UndoSet)
     {
         IEnumerable <TrackAsset> enumerable = (from x in SelectionManager.SelectedItems <TimelineMarker>()
                                                select x.parentTrack).Distinct <TrackAsset>();
         foreach (TrackAsset current in enumerable)
         {
             TimelineUndo.PushUndo(current, "event.drag");
         }
         this.m_UndoSet = true;
     }
 }
Ejemplo n.º 13
0
 private void SetUndo()
 {
     if (!this.m_UndoSet)
     {
         IEnumerable <TrackAsset> enumerable = (from x in SelectionManager.SelectedItems <TimelineClip>()
                                                select x.parentTrack).Distinct <TrackAsset>();
         foreach (TrackAsset current in enumerable)
         {
             TimelineUndo.PushUndo(current, "Drag Clip");
         }
         this.m_UndoSet = true;
     }
 }
        public static void RangeSelectItems(ITimelineItem lastItemToSelect)
        {
            var selectSorted = SelectionManager.SelectedItems().ToList();
            var firstSelect  = selectSorted.FirstOrDefault();

            if (firstSelect == null)
            {
                SelectionManager.Add(lastItemToSelect);
                return;
            }

            var allItems = TimelineWindow.instance.allTracks.OfType <TimelineTrackGUI>().SelectMany(ttGui => ItemsUtils.GetItems(ttGui.track)).ToList();

            TimelineHelpers.RangeSelect(allItems, selectSorted, lastItemToSelect, SelectionManager.Add, SelectionManager.Remove);
        }
Ejemplo n.º 15
0
        public static void RangeSelectItems(ITimelineItem lastItemToSelect)
        {
            var selectSorted = SelectionManager.SelectedItems().ToList();
            var firstSelect  = selectSorted.FirstOrDefault();

            if (firstSelect == null)
            {
                SelectionManager.Add(lastItemToSelect);
                return;
            }

            var allTracks = TimelineEditor.inspectedAsset.flattenedTracks;
            var allItems  = allTracks.SelectMany(ItemsUtils.GetItems).ToList();

            TimelineHelpers.RangeSelect(allItems, selectSorted, lastItemToSelect, SelectionManager.Add, SelectionManager.Remove);
        }
Ejemplo n.º 16
0
 public override void Init(IControl parent)
 {
     parent.KeyDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (state.IsEditingASubItem())
         {
             result = base.IgnoreEvent();
         }
         else if ((evt.get_modifiers() & 15) != null)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             bool flag  = evt.get_keyCode() == 49 || evt.get_keyCode() == 257;
             bool flag2 = evt.get_keyCode() == 50 || evt.get_keyCode() == 258;
             if (!evt.get_isKey() || (!flag && !flag2))
             {
                 result = base.IgnoreEvent();
             }
             else if (SelectionManager.Count() == 0)
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 double offset = (!flag2) ? -1.0 : 1.0;
                 bool   flag3  = false;
                 foreach (TimelineClip current in SelectionManager.SelectedItems <TimelineClip>())
                 {
                     flag3 |= this.NudgeClip(current, state, offset);
                 }
                 if (flag3)
                 {
                     state.Evaluate();
                     result = base.ConsumeEvent();
                 }
                 else
                 {
                     result = base.IgnoreEvent();
                 }
             }
         }
         return(result);
     };
 }
Ejemplo n.º 17
0
        static void TimeFieldWithEditMode(Rect rect, SerializedProperty property, GUIContent label)
        {
            double minStartTime;

            if (property.hasMultipleDifferentValues)
            {
                minStartTime = SelectionManager.SelectedItems().Min(i => i.start);
            }
            else
            {
                minStartTime = property.doubleValue;
            }

            var evt      = InputEvent.None;
            var newValue = TimelineInspectorUtility.TimeField(
                rect, label, minStartTime, false, property.hasMultipleDifferentValues, currentFrameRate, 0.0, float.MaxValue, ref evt);

            EditMode.inputHandler.ProcessMove(evt, newValue);
        }
Ejemplo n.º 18
0
 public override bool Execute(TimelineWindow.TimelineState state)
 {
     Clipboard.Clear();
     TimelineClip[] array = SelectionManager.SelectedItems <TimelineClip>().ToArray <TimelineClip>();
     if (array.Length > 0)
     {
         CopyClipsToClipboard.Do(state, array);
     }
     TimelineMarker[] array2 = SelectionManager.SelectedItems <TimelineMarker>().ToArray <TimelineMarker>();
     if (array2.Length > 0)
     {
         CopyMarkersToClipboard.Do(state, array2);
     }
     TrackAsset[] array3 = SelectionManager.SelectedTracks().ToArray <TrackAsset>();
     if (array3.Length > 0)
     {
         CopyTracksToClipboard.Do(state, array3);
     }
     return(true);
 }
        public static void Show(TrackDrawer drawer, Vector2 mousePosition)
        {
            GenericMenu genericMenu = new GenericMenu();

            TimelineAction.AddToMenu(genericMenu, TimelineWindow.instance.state);
            ItemAction <TimelineClip> .AddToMenu(genericMenu, TimelineWindow.instance.state);

            ItemAction <TimelineMarker> .AddToMenu(genericMenu, TimelineWindow.instance.state);

            if (drawer != null)
            {
                TimelineClip[] array = SelectionManager.SelectedItems <TimelineClip>().ToArray <TimelineClip>();
                if (array.Length > 0)
                {
                    genericMenu.AddSeparator("");
                    drawer.OnBuildClipContextMenu(genericMenu, array, TimelineWindow.instance.state);
                }
            }
            genericMenu.ShowAsContext();
        }
        public static bool SelectDownItem()
        {
            if (ClipAreaActive())
            {
                var refItem   = SelectionManager.SelectedItems().Last();
                var nextTrack = refItem.parentTrack.NextTrack();
                while (nextTrack != null)
                {
                    var selectionItem = GetClosestItem(nextTrack, refItem);
                    if (selectionItem == null || nextTrack.lockedInHierarchy)
                    {
                        nextTrack = nextTrack.NextTrack();
                        continue;
                    }

                    SelectionManager.SelectOnly(selectionItem);
                    TimelineHelpers.FrameItems(new[] { selectionItem });
                    FrameTrackHeader(GetVisibleTracks().First(x => x.track == selectionItem.parentTrack));
                    break;
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 21
0
        public override void Init(IControl parent)
        {
            bool         isCaptured   = false;
            MagnetEngine magnetEngine = null;

            parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
            {
                this.m_UndoSet = false;
                bool result;
                if (evt.get_modifiers() == 4 || evt.get_button() == 2 || evt.get_button() == 1)
                {
                    result = this.IgnoreEvent();
                }
                else if (!SelectionManager.IsMouseHoveringOnItem())
                {
                    result = this.IgnoreEvent();
                }
                else
                {
                    TimelineMarkerGUI timelineMarkerGUI = target as TimelineMarkerGUI;
                    if (!SelectionManager.Contains(timelineMarkerGUI.timelineMarker))
                    {
                        result = this.IgnoreEvent();
                    }
                    else
                    {
                        this.m_IsDragDriver = MoveItemUtilities.IsDriver(timelineMarkerGUI, evt, state);
                        this.m_FrameSnap.Reset();
                        state.captured.Add(target as IControl);
                        isCaptured = true;
                        if (this.m_IsDragDriver)
                        {
                            this.m_DragPixelOffset    = Vector2.get_zero();
                            this.m_IsDragDriverActive = false;
                            if (SelectionManager.Count() <= 1 && state.edgeSnaps)
                            {
                                magnetEngine = new MagnetEngine(timelineMarkerGUI, new MoveEventAttractionHandler(), state);
                            }
                        }
                        result = this.ConsumeEvent();
                    }
                }
                return(result);
            };
            parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state)
            {
                bool result;
                if (!isCaptured)
                {
                    result = this.IgnoreEvent();
                }
                else
                {
                    magnetEngine = null;
                    if (this.m_HasMoved)
                    {
                        state.rebuildGraph = true;
                        this.m_HasMoved    = false;
                    }
                    state.Evaluate();
                    state.captured.Remove(target as IControl);
                    isCaptured          = false;
                    this.m_IsDragDriver = false;
                    result = this.ConsumeEvent();
                }
                return(result);
            };
            parent.DragExited += ((object target, Event evt, TimelineWindow.TimelineState state) => this.IgnoreEvent());
            parent.MouseDrag  += delegate(object target, Event evt, TimelineWindow.TimelineState state)
            {
                bool result;
                if (!isCaptured)
                {
                    result = this.IgnoreEvent();
                }
                else
                {
                    TimelineMarkerGUI timelineMarkerGUI = (TimelineMarkerGUI)target;
                    if (this.m_IsDragDriver)
                    {
                        this.m_DragPixelOffset    += evt.get_delta();
                        this.m_IsDragDriverActive |= (Math.Abs(this.m_DragPixelOffset.x) > MoveEvent.kDragBufferInPixels);
                        if (this.m_IsDragDriverActive)
                        {
                            float delta = this.m_DragPixelOffset.x / state.timeAreaScale.x;
                            this.m_DragPixelOffset = Vector3.get_zero();
                            this.SetUndo(state);
                            if (SelectionManager.Count() > 1)
                            {
                                double currentValue = (from x in SelectionManager.SelectedItems <TimelineMarker>()
                                                       select x.time).DefaultIfEmpty(timelineMarkerGUI.timelineMarker.time).Min();
                                this.m_FrameSnap.ApplyOffset(currentValue, delta, state);
                                foreach (TimelineMarker current in from x in SelectionManager.SelectedItems <TimelineMarker>()
                                         orderby x.time
                                         select x)
                                {
                                    if (current.time + this.m_FrameSnap.lastOffsetApplied < 0.0)
                                    {
                                        break;
                                    }
                                    current.time += this.m_FrameSnap.lastOffsetApplied;
                                }
                            }
                            else
                            {
                                double num = this.m_FrameSnap.ApplyOffset(timelineMarkerGUI.timelineMarker.time, delta, state);
                                if (num < 0.0)
                                {
                                    num = 0.0;
                                }
                                timelineMarkerGUI.timelineMarker.time = num;
                            }
                            if (magnetEngine != null)
                            {
                                magnetEngine.Snap(evt.get_delta().x);
                            }
                            this.m_HasMoved = true;
                            state.Evaluate();
                        }
                    }
                    result = this.ConsumeEvent();
                }
                return(result);
            };
            parent.Overlay += delegate(object target, Event evt, TimelineWindow.TimelineState state)
            {
                if (magnetEngine != null)
                {
                    magnetEngine.OnGUI();
                }
                bool result;
                if (this.m_IsDragDriver)
                {
                    IEnumerable <TimelineMarker> enumerable = SelectionManager.SelectedItems <TimelineMarker>();
                    double num  = 1.7976931348623157E+308;
                    double num2 = -1.7976931348623157E+308;
                    foreach (TimelineMarker current in enumerable)
                    {
                        if (current.time < num)
                        {
                            num = current.time;
                        }
                        if (current.time > num2)
                        {
                            num2 = current.time;
                        }
                    }
                    this.m_SelectionIndicator.Draw(num, num2, magnetEngine);
                    result = this.ConsumeEvent();
                }
                else
                {
                    result = this.IgnoreEvent();
                }
                return(result);
            };
        }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
0
 public override void Init(IControl parent)
 {
     parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         this.m_UndoSet    = false;
         this.m_IsCaptured = (this.m_CaptureOnNextMouseDrag = false);
         bool result;
         if (evt.get_modifiers() == 4 || evt.get_button() == 2 || evt.get_button() == 1)
         {
             result = base.IgnoreEvent();
         }
         else if (!SelectionManager.IsMouseHoveringOnItem())
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target;
             if (!SelectionManager.Contains(timelineClipGUI.clip))
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 this.m_FrameSnap.Reset();
                 this.m_CaptureOnNextMouseDrag = true;
                 this.m_MouseDownPosition      = evt.get_mousePosition();
                 this.m_HasValidDropTarget     = false;
                 result = base.ConsumeEvent();
             }
         }
         return(result);
     };
     parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (!this.m_IsCaptured)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             this.m_MagnetEngine = null;
             if (this.m_IsVerticalDrag)
             {
                 state.captured.Clear();
                 this.m_IsVerticalDrag = false;
                 state.isDragging      = false;
                 if (this.m_HasValidDropTarget && this.m_DropTarget != null)
                 {
                     TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target;
                     if (TrackExtensions.MoveClipToTrack(timelineClipGUI.clip, this.m_DropTarget.track))
                     {
                         timelineClipGUI.clip.start = (double)state.PixelToTime(this.m_PreviewRect.get_x());
                         timelineClipGUI.parentTrackGUI.SortClipsByStartTime();
                         this.m_DropTarget.SortClipsByStartTime();
                         state.Refresh();
                     }
                 }
             }
             state.Evaluate();
             state.captured.Remove(target as IControl);
             this.m_IsCaptured   = false;
             this.m_IsDragDriver = false;
             result = base.ConsumeEvent();
         }
         return(result);
     };
     parent.DragExited += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         this.m_IsVerticalDrag = false;
         return(base.IgnoreEvent());
     };
     parent.MouseDrag += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         if (!this.m_IsCaptured && this.m_CaptureOnNextMouseDrag)
         {
             state.captured.Add(target as IControl);
             this.m_IsCaptured             = true;
             this.m_CaptureOnNextMouseDrag = false;
             TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target;
             this.m_IsDragDriver = MoveItemUtilities.IsDriver(timelineClipGUI, evt, state);
             if (this.m_IsDragDriver)
             {
                 this.m_DragPixelOffset    = Vector2.get_zero();
                 this.m_IsDragDriverActive = false;
                 if (!SelectionManager.IsMultiSelect() && state.edgeSnaps)
                 {
                     this.m_MagnetEngine = new MagnetEngine(timelineClipGUI, new MoveClipAttractionHandler(), state);
                 }
             }
         }
         bool result;
         if (!this.m_IsCaptured)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineClipGUI timelineClipGUI2 = (TimelineClipGUI)target;
             if (SelectionManager.Count() == 1)
             {
                 TimelineClipGUI timelineClipGUI3 = SelectionManager.SelectedClipGUI().FirstOrDefault <TimelineClipGUI>();
                 if (timelineClipGUI3 != null)
                 {
                     TimelineTrackGUI dropTargetAt = MoveClip.GetDropTargetAt(state, evt.get_mousePosition());
                     if (dropTargetAt != null)
                     {
                         bool flag = dropTargetAt != timelineClipGUI3.parentTrackGUI;
                         if (flag && !this.m_IsVerticalDrag)
                         {
                             state.isDragging           = true;
                             this.m_HasValidDropTarget  = false;
                             this.m_DropTarget          = null;
                             this.m_MouseDownPosition.x = evt.get_mousePosition().x;
                             this.m_PreviewOffset       = this.m_MouseDownPosition - timelineClipGUI2.bounds.get_position();
                         }
                         else if (this.m_IsVerticalDrag && !flag)
                         {
                             state.isDragging          = false;
                             this.m_HasValidDropTarget = false;
                             this.m_DropTarget         = null;
                             this.m_DragPixelOffset    = evt.get_mousePosition() - this.m_MouseDownPosition - evt.get_delta();
                         }
                         this.m_IsVerticalDrag = flag;
                     }
                 }
             }
             if (this.m_IsVerticalDrag)
             {
                 this.m_PreviewRect = new Rect(evt.get_mousePosition().x, evt.get_mousePosition().y, timelineClipGUI2.bounds.get_width(), timelineClipGUI2.bounds.get_height());
                 this.m_PreviewRect.set_position(this.m_PreviewRect.get_position() - this.m_PreviewOffset);
                 this.UpdateDragTarget(timelineClipGUI2, evt.get_mousePosition(), state);
                 result = base.ConsumeEvent();
             }
             else
             {
                 if (this.m_IsDragDriver)
                 {
                     this.m_DragPixelOffset    += evt.get_delta();
                     this.m_IsDragDriverActive |= (Math.Abs(this.m_DragPixelOffset.x) > MoveClip.kDragBufferInPixels);
                     if (this.m_IsDragDriverActive)
                     {
                         float delta = this.m_DragPixelOffset.x / state.timeAreaScale.x;
                         this.m_DragPixelOffset = Vector3.get_zero();
                         this.SetUndo();
                         if (SelectionManager.IsMultiSelect())
                         {
                             double currentValue = (from x in SelectionManager.SelectedItems <TimelineClip>()
                                                    select x.start).DefaultIfEmpty(timelineClipGUI2.clip.start).Min();
                             this.m_FrameSnap.ApplyOffset(currentValue, delta, state);
                             foreach (TimelineClip current in from x in SelectionManager.SelectedItems <TimelineClip>()
                                      orderby x.start
                                      select x)
                             {
                                 if (current.start + this.m_FrameSnap.lastOffsetApplied < 0.0)
                                 {
                                     break;
                                 }
                                 current.start += this.m_FrameSnap.lastOffsetApplied;
                             }
                         }
                         else
                         {
                             timelineClipGUI2.clip.start = this.m_FrameSnap.ApplyOffset(timelineClipGUI2.clip.start, delta, state);
                         }
                         if (this.m_MagnetEngine != null)
                         {
                             this.m_MagnetEngine.Snap(evt.get_delta().x);
                         }
                         timelineClipGUI2.InvalidateEditor();
                         timelineClipGUI2.parentTrackGUI.SortClipsByStartTime();
                         state.Evaluate();
                     }
                 }
                 result = base.ConsumeEvent();
             }
         }
         return(result);
     };
     parent.Overlay += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         if (this.m_MagnetEngine != null)
         {
             this.m_MagnetEngine.OnGUI();
         }
         bool result;
         if (this.m_IsVerticalDrag)
         {
             TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target;
             Color           color           = (!this.m_HasValidDropTarget) ? DirectorStyles.Instance.customSkin.colorInvalidDropTarget : DirectorStyles.Instance.customSkin.colorValidDropTarget;
             timelineClipGUI.DrawDragPreview(this.m_PreviewRect, color);
             result = base.ConsumeEvent();
         }
         else if (this.m_IsDragDriver)
         {
             IEnumerable <TimelineClip> enumerable = SelectionManager.SelectedItems <TimelineClip>();
             double num  = 1.7976931348623157E+308;
             double num2 = -1.7976931348623157E+308;
             foreach (TimelineClip current in enumerable)
             {
                 if (current.start < num)
                 {
                     num = current.start;
                 }
                 if (current.end > num2)
                 {
                     num2 = current.end;
                 }
             }
             this.m_SelectionIndicator.Draw(num, num2, this.m_MagnetEngine);
             result = base.ConsumeEvent();
         }
         else
         {
             result = base.IgnoreEvent();
         }
         return(result);
     };
 }
 public static IEnumerable <ITimelineItem> GetVisibleSelectedItems()
 {
     return(SelectionManager.SelectedItems().Where(x => x.parentTrack.IsVisibleRecursive()));
 }
Ejemplo n.º 25
0
 static bool CanDelete()
 {
     // All() returns true when empty
     return(SelectionManager.SelectedTracks().All(x => !x.lockedInHierarchy) &&
            SelectionManager.SelectedItems().All(x => x.parentTrack == null || !x.parentTrack.lockedInHierarchy));
 }