public static bool CanCycleMarkers()
        {
            if (!SelectionManager.SelectedMarkers().Any())
            {
                return(false);
            }

            var cluster = PickerUtils.TopmostPickedItemOfType <TimelineMarkerClusterGUI>();

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

            // Only cycle if the marker is selected and nothing else is selected
            return(cluster.topMarker.IsSelected() && SelectionManager.Count() == 1);
        }
        public override bool Execute(TimelineWindow.TimelineState state)
        {
            bool result;

            if (state.IsEditingASubItem())
            {
                result = false;
            }
            else if (SelectionManager.Count() == 0)
            {
                result = false;
            }
            else
            {
                float num  = 3.40282347E+38f;
                float num2 = -3.40282347E+38f;
                IEnumerable <TimelineClipGUI> enumerable = SelectionManager.SelectedClipGUI();
                if (!enumerable.Any <TimelineClipGUI>())
                {
                    result = false;
                }
                else
                {
                    foreach (TimelineClipGUI current in enumerable)
                    {
                        num  = Mathf.Min(num, (float)current.clip.start);
                        num2 = Mathf.Max(num2, (float)current.clip.start + (float)current.clip.duration);
                        if (current.clipCurveEditor != null)
                        {
                            current.clipCurveEditor.FrameClip();
                        }
                    }
                    float num3 = num2 - num;
                    if (Mathf.Abs(num3) < 1.401298E-45f)
                    {
                        num3 = 1f;
                    }
                    state.SetTimeAreaShownRange(Mathf.Max(num - num3 * 0.2f, -10f), num2 + num3 * 0.2f);
                    state.Evaluate();
                    result = true;
                }
            }
            return(result);
        }
예제 #3
0
        public override bool Execute(WindowState state)
        {
            if (state.IsEditingASubItem())
            {
                return(false);
            }

            if (SelectionManager.Count() == 0)
            {
                return(false);
            }

            var startTime = float.MaxValue;
            var endTime   = float.MinValue;

            var clips   = SelectionManager.SelectedClipGUI();
            var markers = SelectionManager.SelectedMarkers();

            if (!clips.Any() && !markers.Any())
            {
                return(false);
            }

            foreach (var c in clips)
            {
                startTime = Mathf.Min(startTime, (float)c.clip.start);
                endTime   = Mathf.Max(endTime, (float)c.clip.end);
                if (c.clipCurveEditor != null)
                {
                    c.clipCurveEditor.FrameClip();
                }
            }

            foreach (var marker in markers)
            {
                startTime = Mathf.Min(startTime, (float)marker.time);
                endTime   = Mathf.Max(endTime, (float)marker.time);
            }

            FrameRange(startTime, endTime, state);

            return(true);
        }
예제 #4
0
 public override ActionValidity Validate(ActionContext context)
 {
     return(SelectionManager.Count() > 0 ? ActionValidity.Valid : ActionValidity.NotApplicable);
 }
 public override MenuActionDisplayState GetDisplayState(WindowState state)
 {
     return(SelectionManager.Count() > 0 ? MenuActionDisplayState.Visible : MenuActionDisplayState.Disabled);
 }
예제 #6
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);
     };
 }
예제 #7
0
 public static bool IsMultiSelect()
 {
     return(SelectionManager.Count() > 1);
 }
예제 #8
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);
            };
        }