Exemplo n.º 1
0
        private void UpdateDragTarget(TimelineClipGUI uiClip, Vector2 point, TimelineWindow.TimelineState state)
        {
            List <IBounds>   elementsAtPosition = Manipulator.GetElementsAtPosition(state.quadTree, point);
            TimelineTrackGUI timelineTrackGUI   = elementsAtPosition.OfType <TimelineTrackGUI>().FirstOrDefault((TimelineTrackGUI t) => MoveClip.ValidateClipDrag(t.track, uiClip.clip));

            this.m_HasValidDropTarget = (timelineTrackGUI != null && timelineTrackGUI.track.IsCompatibleWithItem(uiClip.clip));
            if (this.m_HasValidDropTarget)
            {
                AnimationTrack animationTrack = timelineTrackGUI.track as AnimationTrack;
                float          start          = state.PixelToTime(this.m_PreviewRect.get_x());
                float          end            = state.PixelToTime(this.m_PreviewRect.get_xMax());
                bool           hasValidDropTarget;
                if (animationTrack != null && animationTrack.CanConvertToClipMode())
                {
                    hasValidDropTarget = ((animationTrack.animClip.get_startTime() < start || animationTrack.animClip.get_stopTime() > end) && (start <animationTrack.animClip.get_startTime() || end> animationTrack.animClip.get_stopTime()));
                }
                else
                {
                    float num = end - start;
                    start = Math.Max(start, 0f);
                    end   = start + num;
                    hasValidDropTarget = (!timelineTrackGUI.track.clips.Any((TimelineClip x) => x.start >= (double)start && x.end <= (double)end) && !timelineTrackGUI.track.clips.Any((TimelineClip x) => (double)start >= x.start && (double)end <= x.end));
                }
                this.m_HasValidDropTarget = hasValidDropTarget;
            }
            this.m_DropTarget = ((!this.m_HasValidDropTarget) ? null : timelineTrackGUI);
        }
Exemplo n.º 2
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>();
                }
            }
        }
Exemplo n.º 3
0
 internal virtual void ConfigureUIClip(TimelineClipGUI uiClip)
 {
     uiClip.AddManipulator(new MoveClip());
     uiClip.AddManipulator(new ClipContextMenu());
     uiClip.AddManipulator(new ClipActionsShortcutManipulator());
     uiClip.AddManipulator(new DrillIntoClip());
 }
Exemplo n.º 4
0
        public ClipsLayer(Layer layerOrder, IRowGUI parent) : base(layerOrder)
        {
            var track = parent.asset;

            track.SortClips();
            TimelineClipGUI previousClipGUI = null;

            foreach (var clip in track.clips)
            {
                var oldClipGUI = ItemToItemGui.GetGuiForClip(clip);
                var isInvalid  = oldClipGUI != null && oldClipGUI.isInvalid; // HACK Make sure to carry invalidy state when refereshing the cache.

                var currentClipGUI = new TimelineClipGUI(clip, parent, this)
                {
                    isInvalid = isInvalid
                };
                if (previousClipGUI != null)
                {
                    previousClipGUI.nextClip = currentClipGUI;
                }
                currentClipGUI.previousClip = previousClipGUI;
                AddItem(currentClipGUI);
                previousClipGUI = currentClipGUI;
            }
        }
Exemplo n.º 5
0
 public override void Init(IControl parent)
 {
     parent.DoubleClick += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         TimelineClipGUI timelineClipGUI = target as TimelineClipGUI;
         bool            result;
         if (timelineClipGUI == null || timelineClipGUI.clip == null)
         {
             result = base.IgnoreEvent();
         }
         else if (evt.get_button() != 0)
         {
             result = base.IgnoreEvent();
         }
         else if (!timelineClipGUI.rect.Contains(evt.get_mousePosition()))
         {
             result = base.IgnoreEvent();
         }
         else if (timelineClipGUI.clip.curves != null || timelineClipGUI.clip.animationClip != null)
         {
             ItemActionInvoker.InvokeByName <TimelineClip>("EditClipInAnimationWindow", state, timelineClipGUI.clip);
             result = base.ConsumeEvent();
         }
         else
         {
             result = base.IgnoreEvent();
         }
         return(result);
     };
 }
            public void OnAttractedEdge(IAttractable attractable, AttractedEdge edge, double time, double duration)
            {
                TimelineClipGUI timelineClipGUI = attractable as TimelineClipGUI;

                if (timelineClipGUI != null)
                {
                    TimelineClip clip = timelineClipGUI.clip;
                    if (edge == AttractedEdge.Right)
                    {
                        clip.duration = time - clip.start;
                        clip.duration = Math.Max(clip.duration, TimelineClip.kMinDuration);
                    }
                    else if (edge == AttractedEdge.Left)
                    {
                        double num      = time - clip.start;
                        double newValue = clip.clipIn + num * clip.timeScale;
                        if (DragClipHandle.SetClipIn(clip, newValue, num))
                        {
                            this.m_FrameSnap.Reset();
                        }
                    }
                    else
                    {
                        clip.start    = time;
                        clip.duration = duration;
                    }
                }
            }
Exemplo n.º 7
0
        public static CurveDataSource Create(TimelineClipGUI clipGUI)
        {
            if (clipGUI.clip.animationClip != null)
            {
                return(new ClipAnimationCurveDataSource(clipGUI));
            }

            return(new ClipParametersCurveDataSource(clipGUI));
        }
 private static void HandleReselection(List <IBounds> elements)
 {
     foreach (IBounds current in elements)
     {
         if (current is TimelineClipGUI)
         {
             TimelineClipGUI timelineClipGUI = current as TimelineClipGUI;
             SelectionManager.Add(timelineClipGUI.item);
             break;
         }
     }
 }
Exemplo n.º 9
0
 void Add(TimelineClipGUI clip)
 {
     m_Members.Add(clip);
     if (m_Members.Count == 1)
     {
         m_BoundingRect = clip.clippedRect;
     }
     else
     {
         m_BoundingRect = Encompass(m_BoundingRect, clip.boundingRect);
     }
 }
Exemplo n.º 10
0
 private void RebuildClipsGUICache()
 {
     this.m_ClipGUICache = new List <TimelineClipGUI>();
     TimelineClip[] clips = base.track.clips;
     for (int i = 0; i < clips.Length; i++)
     {
         TimelineClip    clip = clips[i];
         TimelineClipGUI item = new TimelineClipGUI(clip, this);
         this.m_ClipGUICache.Add(item);
         this.m_ChildrenControls.Add(item);
     }
 }
Exemplo n.º 11
0
        public void OnAttractedEdge(IAttractable attractable, AttractedEdge edge, double time, double duration)
        {
            TimelineClipGUI timelineClipGUI = attractable as TimelineClipGUI;

            if (timelineClipGUI != null)
            {
                TimelineClip clip = timelineClipGUI.clip;
                if (edge == AttractedEdge.Left || edge == AttractedEdge.None)
                {
                    clip.start = time;
                }
                else
                {
                    clip.start = time - clip.duration;
                }
            }
        }
Exemplo n.º 12
0
        private static void SelectMenuCallback(Func <TimelineClip, bool> selector, TimelineWindow.TimelineState state)
        {
            List <TimelineClipGUI> allClipGuis = state.GetWindow().treeView.allClipGuis;

            if (allClipGuis != null)
            {
                SelectionManager.Clear();
                for (int num = 0; num != allClipGuis.Count; num++)
                {
                    TimelineClipGUI timelineClipGUI = allClipGuis[num];
                    if (timelineClipGUI != null && timelineClipGUI.clip != null && selector(timelineClipGUI.clip))
                    {
                        SelectionManager.Add(timelineClipGUI.clip);
                    }
                }
            }
        }
Exemplo n.º 13
0
        void DrawCurveEditorsForClipsOnTrack(Rect headerRect, Rect trackRect, WindowState state)
        {
            if (m_TrackGUI.clips.Count == 0)
            {
                return;
            }

            if (Event.current.type == EventType.Layout)
            {
                var selectedClip = SelectionManager.SelectedClipGUI().FirstOrDefault(x => x.parent == m_TrackGUI);
                if (selectedClip != null)
                {
                    m_LastSelectedClipGUI = selectedClip;
                    SelectFromCurveOwner(m_LastSelectedClipGUI);
                }
                else if (state.recording && state.IsArmedForRecord(m_TrackGUI.track))
                {
                    if (m_LastSelectedClipGUI == null || !m_TrackGUI.track.IsRecordingToClip(m_LastSelectedClipGUI.clip))
                    {
                        var clip = m_TrackGUI.clips.FirstOrDefault(x => m_TrackGUI.track.IsRecordingToClip(x.clip));
                        if (clip != null)
                        {
                            m_LastSelectedClipGUI = clip;
                        }
                    }
                }

                if (m_LastSelectedClipGUI == null)
                {
                    m_LastSelectedClipGUI = m_TrackGUI.clips[0];
                }
            }

            if (m_LastSelectedClipGUI == null || m_LastSelectedClipGUI.clipCurveEditor == null || m_LastSelectedClipGUI.isInvalid)
            {
                return;
            }

            var activeRange = new Vector2(state.TimeToPixel(m_LastSelectedClipGUI.clip.start), state.TimeToPixel(m_LastSelectedClipGUI.clip.end));

            DrawCurveEditor(m_LastSelectedClipGUI, state, headerRect, trackRect, activeRange, m_TrackGUI.locked);
            m_LastSelectionWasClip = true;
        }
Exemplo n.º 14
0
 public override void Init(IControl parent)
 {
     parent.ContextClick += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         IEnumerable <TimelineClipGUI> source = SelectionManager.SelectedClipGUI();
         bool result;
         if (!source.Any <TimelineClipGUI>())
         {
             result = base.IgnoreEvent();
         }
         else if (!source.Any((TimelineClipGUI c) => c.bounds.Contains(evt.get_mousePosition())))
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineClipGUI timelineClipGUI = target as TimelineClipGUI;
             SequencerContextMenu.Show(timelineClipGUI.parentTrackGUI.drawer, evt.get_mousePosition());
             result = base.ConsumeEvent();
         }
         return(result);
     };
 }
Exemplo n.º 15
0
        private void DrawClips(Rect trackRect, TimelineWindow.TimelineState state)
        {
            Vector2 timeAreaShownRange = state.timeAreaShownRange;

            for (int num = 0; num != this.m_ClipGUICache.Count; num++)
            {
                TimelineClipGUI timelineClipGUI = this.m_ClipGUICache[num];
                timelineClipGUI.visible = (timelineClipGUI.clip.end >= (double)timeAreaShownRange.x && timelineClipGUI.clip.start <= (double)timeAreaShownRange.y);
                if (timelineClipGUI.visible)
                {
                    if (num + 1 < this.m_ClipGUICache.Count)
                    {
                        timelineClipGUI.nextClip = this.m_ClipGUICache[num + 1];
                    }
                    if (num > 0)
                    {
                        timelineClipGUI.previousClip = this.m_ClipGUICache[num - 1];
                    }
                    timelineClipGUI.DrawBlendingCurves(state);
                    timelineClipGUI.Draw(trackRect, state, base.drawer);
                }
            }
        }
 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
         {
             TimelineClipGUI timelineClipGUI = target as TimelineClipGUI;
             if (!SelectionManager.Contains(timelineClipGUI.clip))
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 result = ItemAction <TimelineClip> .HandleShortcut(state, evt, timelineClipGUI.clip);
             }
         }
         return(result);
     };
 }
Exemplo n.º 17
0
 public TimelineClipHandle(TimelineClipGUI theClipGUI, TrimEdge trimDirection)
 {
     m_TrimDirection = trimDirection;
     m_ClipGUI       = theClipGUI;
     m_ZOrder        = theClipGUI.zOrder.ChangeLayer(Layer.ClipHandles);
 }
Exemplo n.º 18
0
 public void DrawGhostClip(TimelineClipGUI clipGUI, Rect targetRect)
 {
     DrawSimpleClip(clipGUI, targetRect, ClipBorder.kSelection, new Color(1.0f, 1.0f, 1.0f, 0.5f), GetClipDrawing(clipGUI.clip));
 }
Exemplo n.º 19
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);
     };
 }
Exemplo n.º 20
0
 public ClipParametersCurveDataSource(TimelineClipGUI clipGUI) : base(clipGUI.parent)
 {
     m_ClipGUI     = clipGUI;
     m_CurvesProxy = new CurvesProxy(clipGUI.clip);
 }
Exemplo n.º 21
0
 public TimelineClipCurveDataSource(TimelineClipGUI clipGUI) : base(clipGUI.parentTrackGUI)
 {
     this.m_ClipGUI = clipGUI;
 }
Exemplo n.º 22
0
 // TODO, move to clip data?
 public static ClipBlends BlendsFromGUI(TimelineClipGUI clipGUI)
 {
     return(new ClipBlends(clipGUI.blendInKind, clipGUI.mixInRect, clipGUI.blendOutKind, clipGUI.mixOutRect));
 }
Exemplo n.º 23
0
 public static void DrawSimpleClip(TimelineClipGUI clip, Rect targetRect, ClipBorder border, Color overlay, ClipDrawing drawing)
 {
     ClipDrawer.DrawSimpleClip(clip.clip, targetRect, border, overlay, drawing, BlendsFromGUI(clip));
 }
Exemplo n.º 24
0
 public TimelineClipHandle(TimelineClipGUI theClipGUI, TrimEdge trimDirection)
 {
     m_TrimDirection = trimDirection;
     m_ClipGUI       = theClipGUI;
 }
Exemplo n.º 25
0
 public ClipAnimationCurveDataSource(TimelineClipGUI clipGUI) : base(clipGUI.parent)
 {
     m_ClipGUI = clipGUI;
 }
 public TimelineClipCurveDataSource(TimelineClipGUI clipGUI) : base(clipGUI.parent)
 {
     m_ClipGUI = clipGUI;
 }
Exemplo n.º 27
0
 public void DrawInvalidClip(TimelineClipGUI clipGUI, Rect targetRect)
 {
     DrawSimpleClip(clipGUI, targetRect, ClipBorder.kSelection, DirectorStyles.Instance.customSkin.colorInvalidClipOverlay, GetClipDrawing(clipGUI.clip));
 }