示例#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);
        }
 public override void Init(IControl parent)
 {
     parent.ContextClick += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         TimelineTrackGUI timelineTrackGUI = target as TimelineTrackGUI;
         bool             result;
         if (timelineTrackGUI == null)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             if (!timelineTrackGUI.headerBounds.Contains(evt.get_mousePosition()))
             {
                 bool flag = state.quadTree.GetItemsAtPosition(evt.get_mousePosition()).Any((IBounds x) => x is TimelineItemGUI);
                 if (flag)
                 {
                     result = base.IgnoreEvent();
                     return(result);
                 }
             }
             timelineTrackGUI.drawer.trackMenuContext.clipTimeCreation = TrackDrawer.TrackMenuContext.ClipTimeCreation.Mouse;
             timelineTrackGUI.drawer.trackMenuContext.mousePosition    = evt.get_mousePosition();
             timelineTrackGUI.DisplayTrackMenu(state);
             result = base.ConsumeEvent();
         }
         return(result);
     };
 }
示例#3
0
        private float DrawTrackIconKind(Rect rect, TimelineWindow.TimelineState state)
        {
            float result;

            if (base.track != null && base.track.isSubTrack)
            {
                result = 0f;
            }
            else
            {
                rect.set_yMin(rect.get_yMin() + (rect.get_height() - 16f) / 2f);
                rect.set_width(16f);
                rect.set_height(16f);
                if (this.m_HadProblems)
                {
                    this.GenerateIconForBindingValidationResult(this.m_Styles, this.GetTrackBindingValidationResult(state));
                    if (TimelineTrackGUI.CanDrawIcon(this.m_ProblemIcon))
                    {
                        this.DrawErrorIcon(rect, state);
                    }
                }
                else if (TimelineTrackGUI.CanDrawIcon(this.headerIcon))
                {
                    GUI.Box(rect, this.headerIcon, GUIStyle.get_none());
                }
                result = rect.get_width();
            }
            return(result);
        }
示例#4
0
 static void CommitExtension(TimelineTrackGUI trackGUI)
 {
     if (trackGUI != null)
     {
         TimelineWindowViewPrefs.SetTrackHeightExtension(trackGUI.track, trackGUI.heightExtension);
     }
 }
示例#5
0
        private void DoTrackBindingGUI(Rect rect, Rect headerRect, ITimelineState state)
        {
            float num = 130f;

            rect.set_y(rect.get_y() + (rect.get_height() - 16f) / 2f);
            rect.set_height(16f);
            rect.set_width(headerRect.get_xMax() - num - rect.get_xMin());
            Object genericBinding = state.currentDirector.GetGenericBinding(base.track);

            if (rect.Contains(Event.get_current().get_mousePosition()) && TimelineTrackGUI.IsDraggingEvent() && DragAndDrop.get_objectReferences().Length == 1)
            {
                this.HandleDragAndDrop(state, TimelineTrackGUI.GetRequiredBindingType(this.m_Bindings[0]));
            }
            else
            {
                TrackAsset track = base.track;
                switch (this.m_Bindings[0].get_streamType())
                {
                case 0:
                {
                    EditorGUI.BeginChangeCheck();
                    Animator animator = EditorGUI.ObjectField(rect, genericBinding, typeof(Animator), true) as Animator;
                    if (EditorGUI.EndChangeCheck())
                    {
                        TimelineTrackGUI.SetTrackBinding(state, track, (!(animator == null)) ? animator.get_gameObject() : null);
                    }
                    goto IL_1E8;
                }

                case 1:
                {
                    EditorGUI.BeginChangeCheck();
                    AudioSource objectToBind = EditorGUI.ObjectField(rect, genericBinding, typeof(AudioSource), true) as AudioSource;
                    if (EditorGUI.EndChangeCheck())
                    {
                        TimelineTrackGUI.SetTrackBinding(state, track, objectToBind);
                    }
                    goto IL_1E8;
                }

                case 3:
                    if (this.m_Bindings[0].get_sourceBindingType() != null && typeof(Object).IsAssignableFrom(this.m_Bindings[0].get_sourceBindingType()))
                    {
                        EditorGUI.BeginChangeCheck();
                        Object objectToBind2 = EditorGUI.ObjectField(rect, genericBinding, this.m_Bindings[0].get_sourceBindingType(), true);
                        if (EditorGUI.EndChangeCheck())
                        {
                            TimelineTrackGUI.SetTrackBinding(state, track, objectToBind2);
                        }
                    }
                    goto IL_1E8;
                }
                throw new NotImplementedException("");
                IL_1E8 :;
            }
        }
示例#6
0
        public override bool CanBeParent(TreeViewItem item)
        {
            // will prevent track becoming subtracks via dragging
            TimelineTrackGUI track = item as TimelineTrackGUI;

            if (track != null)
            {
                return(false);
            }

            return(true);
        }
示例#7
0
        private void HandleDragAndDrop(ITimelineState state, Type requiredComponent)
        {
            DragAndDropVisualMode dragAndDropVisualMode = 32;

            if (requiredComponent != null && requiredComponent.IsInstanceOfType(DragAndDrop.get_objectReferences()[0]))
            {
                dragAndDropVisualMode = 2;
                if (Event.get_current().get_type() == 10)
                {
                    TimelineTrackGUI.SetTrackBinding(state, base.track, DragAndDrop.get_objectReferences()[0]);
                }
            }
            else if (typeof(Component).IsAssignableFrom(requiredComponent))
            {
                GameObject gameObjectBeingDragged = DragAndDrop.get_objectReferences()[0] as GameObject;
                if (gameObjectBeingDragged != null)
                {
                    dragAndDropVisualMode = 2;
                    if (Event.get_current().get_type() == 10)
                    {
                        Component component = gameObjectBeingDragged.GetComponent(requiredComponent);
                        if (component == null)
                        {
                            string      str         = requiredComponent.ToString().Split(".".ToCharArray()).Last <string>();
                            GenericMenu genericMenu = new GenericMenu();
                            genericMenu.AddItem(EditorGUIUtility.TextContent("Create " + str + " on " + gameObjectBeingDragged.get_name()), false, delegate(object nullParam)
                            {
                                Undo.AddComponent(gameObjectBeingDragged, requiredComponent);
                                TimelineTrackGUI.SetTrackBinding(state, this.track, gameObjectBeingDragged);
                            }, null);
                            genericMenu.AddSeparator("");
                            genericMenu.AddItem(EditorGUIUtility.TextContent("Cancel"), false, delegate(object userData)
                            {
                            }, null);
                            genericMenu.ShowAsContext();
                        }
                        else
                        {
                            TimelineTrackGUI.SetTrackBinding(state, base.track, gameObjectBeingDragged);
                        }
                    }
                }
            }
            DragAndDrop.set_visualMode(dragAndDropVisualMode);
            if (dragAndDropVisualMode == 2)
            {
                DragAndDrop.AcceptDrag();
            }
        }
示例#8
0
        private float GetExpandedHeight(TimelineWindow.TimelineState state)
        {
            float num = this.GetHeight(state);

            if (base.isExpanded && this.get_children() != null)
            {
                foreach (TreeViewItem current in this.get_children())
                {
                    TimelineTrackGUI timelineTrackGUI = current as TimelineTrackGUI;
                    if (timelineTrackGUI != null)
                    {
                        num += timelineTrackGUI.GetVerticalSpacingBetweenTracks();
                        num += timelineTrackGUI.GetHeight(state);
                    }
                }
            }
            return(num);
        }
        public virtual float GetFoldoutIndent(TreeViewItem item)
        {
            float result;

            if (item.get_depth() <= 1 || this.m_TreeView.get_isSearching())
            {
                result = DirectorStyles.kBaseIndent;
            }
            else
            {
                int num = item.get_depth();
                TimelineTrackGUI timelineTrackGUI = item as TimelineTrackGUI;
                if (timelineTrackGUI != null && timelineTrackGUI.track != null && timelineTrackGUI.track.isSubTrack)
                {
                    num--;
                }
                result = (float)num * DirectorStyles.kBaseIndent;
            }
            return(result);
        }
示例#10
0
        private void DrawTrackBinding(Rect rect, Rect headerRect, TimelineWindow.TimelineState state)
        {
            if (this.showSceneReference)
            {
                if (state.currentDirector != null)
                {
                    this.DoTrackBindingGUI(rect, headerRect, state);
                    return;
                }
            }
            GUIStyle trackHeaderFont = this.m_Styles.trackHeaderFont;

            trackHeaderFont.get_normal().set_textColor((!SelectionManager.Contains(base.track)) ? this.m_Styles.customSkin.colorTrackFont : Color.get_white());
            bool   flag = false;
            string text = base.drawer.GetCustomTitle(base.track);

            if (string.IsNullOrEmpty(text))
            {
                flag = true;
                text = TimelineTrackGUI.GetTrackDisplayName(base.track, state);
            }
            rect.set_width(this.m_Styles.trackHeaderFont.CalcSize(new GUIContent(text)).x);
            if (flag)
            {
                if (GUIUtility.get_keyboardControl() == base.track.GetInstanceID())
                {
                    Rect rect2 = rect;
                    rect2.set_width(headerRect.get_xMax() - rect.get_xMin() - 80f);
                    base.track.set_name(EditorGUI.DelayedTextField(rect2, GUIContent.none, base.track.GetInstanceID(), base.track.get_name(), trackHeaderFont));
                }
                else
                {
                    EditorGUI.DelayedTextField(rect, GUIContent.none, base.track.GetInstanceID(), text, trackHeaderFont);
                }
            }
            else
            {
                EditorGUI.LabelField(rect, text, trackHeaderFont);
            }
        }
示例#11
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);
     };
 }
示例#12
0
 protected CurveDataSource(TimelineTrackGUI trackGUI)
 {
     this.m_TrackGUI = trackGUI;
 }
 public InlineCurveResizeHandle(TimelineTrackGUI trackGUI)
 {
     this.trackGUI = trackGUI;
 }
 public override void Init(IControl parent)
 {
     parent.DoubleClick += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         this.m_DoubleClicked = true;
         bool result;
         if (state.IsEditingASubItem())
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineTrackGUI timelineTrackGUI = target as TimelineTrackGUI;
             if (timelineTrackGUI == null)
             {
                 result = base.IgnoreEvent();
             }
             else if (evt.get_button() != 0)
             {
                 result = base.IgnoreEvent();
             }
             else if (!timelineTrackGUI.indentedHeaderBounds.Contains(evt.get_mousePosition()))
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 bool flag = SelectionManager.SelectedTracks().Contains(timelineTrackGUI.track);
                 foreach (TimelineItemGUI current in timelineTrackGUI.items)
                 {
                     if (flag)
                     {
                         SelectionManager.Add(current.item);
                     }
                     else
                     {
                         SelectionManager.Remove(current.item);
                     }
                 }
                 result = base.ConsumeEvent();
             }
         }
         return(result);
     };
     parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         this.m_DoubleClicked = false;
         bool result;
         if (state.IsCurrentEditingASequencerTextField())
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineGroupGUI timelineGroupGUI = target as TimelineGroupGUI;
             if (timelineGroupGUI == null)
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 if (target is TimelineTrackGUI)
                 {
                     TimelineTrackGUI timelineTrackGUI = target as TimelineTrackGUI;
                     if (timelineTrackGUI.locked)
                     {
                         if (SelectorTool.CanClearSelection(evt, timelineGroupGUI))
                         {
                             SelectionManager.Clear();
                         }
                         SelectionManager.Add(timelineTrackGUI.track);
                     }
                     bool flag = timelineTrackGUI.items.Any((TimelineItemGUI x) => x.bounds.Contains(evt.get_mousePosition()));
                     if (flag && !TimelineWindow.instance.sequenceHeaderBounds.Contains(evt.get_mousePosition()))
                     {
                         result = base.IgnoreEvent();
                         return(result);
                     }
                 }
                 if (SelectorTool.CanClearSelection(evt, timelineGroupGUI))
                 {
                     SelectionManager.Clear();
                 }
                 IEnumerable <TrackAsset> source = SelectionManager.SelectedTracks();
                 if (evt.get_modifiers() == 2 || evt.get_modifiers() == 8)
                 {
                     if (SelectionManager.Contains(timelineGroupGUI.track))
                     {
                         SelectionManager.Remove(timelineGroupGUI.track);
                     }
                     else
                     {
                         SelectionManager.Add(timelineGroupGUI.track);
                     }
                 }
                 else if (evt.get_modifiers() == 1)
                 {
                     if (!source.Any <TrackAsset>() && !SelectionManager.Contains(timelineGroupGUI.track))
                     {
                         SelectionManager.Add(timelineGroupGUI.track);
                     }
                     else
                     {
                         bool flag2 = false;
                         foreach (TimelineTrackBaseGUI current in TimelineWindow.instance.allTracks)
                         {
                             if (!flag2)
                             {
                                 if (current == timelineGroupGUI || SelectionManager.Contains(current.track))
                                 {
                                     SelectionManager.Add(current.track);
                                     flag2 = true;
                                     continue;
                                 }
                             }
                             if (flag2)
                             {
                                 if (current == timelineGroupGUI || SelectionManager.Contains(current.track))
                                 {
                                     SelectionManager.Add(current.track);
                                     flag2 = false;
                                     continue;
                                 }
                             }
                             if (flag2)
                             {
                                 SelectionManager.Add(current.track);
                             }
                         }
                     }
                 }
                 else
                 {
                     SelectionManager.Add(timelineGroupGUI.track);
                 }
                 result = base.IgnoreEvent();
             }
         }
         return(result);
     };
     parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (this.m_DoubleClicked || evt.get_modifiers() != null || evt.get_button() != 0 || !SelectionManager.IsMultiSelect())
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineGroupGUI timelineGroupGUI = target as TimelineGroupGUI;
             if (timelineGroupGUI == null)
             {
                 result = base.IgnoreEvent();
             }
             else if (!SelectionManager.Contains(timelineGroupGUI.track))
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 SelectionManager.Clear();
                 SelectionManager.Add(timelineGroupGUI.track);
                 result = base.ConsumeEvent();
             }
         }
         return(result);
     };
 }
示例#15
0
        TimelineTrackBaseGUI CreateItem(ScriptableObject scriptableObject, ref Dictionary <TrackAsset, TimelineTrackBaseGUI> tree, IEnumerable <TrackAsset> selectedRows, TreeViewItem parentTreeViewItem)
        {
            // if a script doesn't load correctly, the trackAsset will be NULL, but the scriptableObject __should_ be intact (but == null will be true)
            var trackAsset = scriptableObject as TrackAsset;

            if (tree == null)
            {
                throw new ArgumentNullException("tree");
            }

            if (selectedRows == null)
            {
                throw new ArgumentNullException("selectedRows");
            }

            if (trackAsset != null && tree.ContainsKey(trackAsset))
            {
                return(tree[trackAsset]);
            }

            TimelineTrackBaseGUI parentItem = parentTreeViewItem as TimelineTrackBaseGUI;

            // should we create the parent?
            TrackAsset parentTrack = trackAsset != null ? (trackAsset.parent as TrackAsset) : null;

            if (trackAsset != null && parentTrack != null && selectedRows.Contains(parentTrack))
            {
                parentItem = CreateItem(parentTrack, ref tree, selectedRows, parentTreeViewItem);
            }

            int theDepth = -1;

            if (parentItem != null)
            {
                theDepth = parentItem.depth;
            }
            theDepth++;

            TimelineTrackBaseGUI newItem;

            if (trackAsset == null)
            {
                PlayableAsset parent = m_TimelineWindow.state.editSequence.asset;
                if (parentItem != null && parentItem.track != null)
                {
                    parent = parentItem.track;
                }

                newItem = new TimelineTrackErrorGUI(m_TreeView, m_ParentGUI, 0, theDepth, parentItem, "ERROR", scriptableObject, parent);
            }
            else if (trackAsset.GetType() != typeof(GroupTrack))
            {
                newItem = new TimelineTrackGUI(m_TreeView, m_ParentGUI, trackAsset.GetInstanceID(), theDepth, parentItem, trackAsset.name, trackAsset);
            }
            else
            {
                newItem = new TimelineGroupGUI(m_TreeView, m_ParentGUI, trackAsset.GetInstanceID(), theDepth, parentItem, trackAsset.name, trackAsset, false);
            }

            allTrackGuis.Add(newItem);

            if (parentItem != null)
            {
                if (parentItem.children == null)
                {
                    parentItem.children = new List <TreeViewItem>();
                }
                parentItem.children.Add(newItem);
                SetExpanded(newItem, trackAsset.GetCollapsed());
            }
            else
            {
                m_RootItem = newItem;
                SetExpanded(m_RootItem, true);
            }

            if (trackAsset != null)
            {
                tree[trackAsset] = newItem;
            }

            var  actorAsAnimTrack       = newItem.track as AnimationTrack;
            bool isEditableInfiniteClip = actorAsAnimTrack != null && actorAsAnimTrack.ShouldShowInfiniteClipEditor();

            if (isEditableInfiniteClip)
            {
                if (newItem.children == null)
                {
                    newItem.children = new List <TreeViewItem>();
                }
            }
            else if (trackAsset != null)
            {
                // check if clips on this track have animation, if so we inline a animationEditorTrack
                bool clipHasAnimatableAnimationCurves = false;

                for (var i = 0; i != newItem.track.clips.Length; ++i)
                {
                    var curveClip     = newItem.track.clips[i].curves;
                    var animationClip = newItem.track.clips[i].animationClip;

                    // prune out clip with zero curves
                    if (curveClip != null && curveClip.empty)
                    {
                        curveClip = null;
                    }

                    if (animationClip != null && animationClip.empty)
                    {
                        animationClip = null;
                    }

                    // prune out clips coming from FBX
                    if (animationClip != null && ((animationClip.hideFlags & HideFlags.NotEditable) != 0))
                    {
                        animationClip = null;
                    }

                    if (!newItem.track.clips[i].recordable)
                    {
                        animationClip = null;
                    }

                    clipHasAnimatableAnimationCurves = (curveClip != null) || (animationClip != null);
                    if (clipHasAnimatableAnimationCurves)
                    {
                        break;
                    }
                }

                if (clipHasAnimatableAnimationCurves)
                {
                    if (newItem.children == null)
                    {
                        newItem.children = new List <TreeViewItem>();
                    }
                }
            }

            if (trackAsset != null)
            {
                // Here we are using the internal subTrackObject so we can properly handle tracks whose script
                //  can't load (via ScriptableObject)
                foreach (var subTrack in trackAsset.subTracksObjects)
                {
                    CreateItem(subTrack, ref tree, selectedRows, newItem);
                }
            }
            return(newItem);
        }
 public InfiniteClipCurveDataSource(TimelineTrackGUI trackGui) : base(trackGui)
 {
     m_AnimationTrack = trackGui.track as AnimationTrack;
 }
        public override bool CanBeParent(TreeViewItem item)
        {
            TimelineTrackGUI timelineTrackGUI = item as TimelineTrackGUI;

            return(timelineTrackGUI == null);
        }
 public TrackResizeHandle(TimelineTrackGUI trackGUI)
 {
     this.trackGUI = trackGUI;
 }
        private TimelineGroupGUI CreateItem(TrackAsset a, ref Dictionary <TrackAsset, TimelineGroupGUI> tree, List <TrackAsset> selectedRows, TreeViewItem parentTreeViewItem)
        {
            TimelineGroupGUI result;

            if (a == null)
            {
                result = null;
            }
            else
            {
                if (tree == null)
                {
                    throw new ArgumentNullException("tree");
                }
                if (selectedRows == null)
                {
                    throw new ArgumentNullException("selectedRows");
                }
                if (tree.ContainsKey(a))
                {
                    result = tree[a];
                }
                else
                {
                    TimelineTrackBaseGUI timelineTrackBaseGUI = parentTreeViewItem as TimelineTrackBaseGUI;
                    if (selectedRows.Contains(a.parent as TrackAsset))
                    {
                        timelineTrackBaseGUI = this.CreateItem(a.parent as TrackAsset, ref tree, selectedRows, parentTreeViewItem);
                    }
                    int num = -1;
                    if (timelineTrackBaseGUI != null)
                    {
                        num = timelineTrackBaseGUI.get_depth();
                    }
                    num++;
                    TimelineGroupGUI timelineGroupGUI;
                    if (a.GetType() != TimelineHelpers.GroupTrackType.trackType)
                    {
                        timelineGroupGUI = new TimelineTrackGUI(this.m_TreeView, this.m_ParentGUI, a.GetInstanceID(), num, timelineTrackBaseGUI, a.get_name(), a);
                    }
                    else
                    {
                        timelineGroupGUI = new TimelineGroupGUI(this.m_TreeView, this.m_ParentGUI, a.GetInstanceID(), num, timelineTrackBaseGUI, a.get_name(), a, false);
                    }
                    this.allTrackGuis.Add(timelineGroupGUI);
                    if (timelineTrackBaseGUI != null)
                    {
                        if (timelineTrackBaseGUI.get_children() == null)
                        {
                            timelineTrackBaseGUI.set_children(new List <TreeViewItem>());
                        }
                        timelineTrackBaseGUI.get_children().Add(timelineGroupGUI);
                    }
                    else
                    {
                        this.m_RootItem = timelineGroupGUI;
                        this.SetExpanded(this.m_RootItem, true);
                    }
                    tree[a] = timelineGroupGUI;
                    AnimationTrack animationTrack = timelineGroupGUI.track as AnimationTrack;
                    bool           flag           = animationTrack != null && animationTrack.ShouldShowInfiniteClipEditor();
                    if (flag)
                    {
                        if (timelineGroupGUI.get_children() == null)
                        {
                            timelineGroupGUI.set_children(new List <TreeViewItem>());
                        }
                    }
                    else
                    {
                        bool flag2 = false;
                        for (int num2 = 0; num2 != timelineGroupGUI.track.clips.Length; num2++)
                        {
                            AnimationClip animationClip  = timelineGroupGUI.track.clips[num2].curves;
                            AnimationClip animationClip2 = timelineGroupGUI.track.clips[num2].animationClip;
                            if (animationClip != null && animationClip.get_empty())
                            {
                                animationClip = null;
                            }
                            if (animationClip2 != null && animationClip2.get_empty())
                            {
                                animationClip2 = null;
                            }
                            if (animationClip2 != null && (animationClip2.get_hideFlags() & 8) != null)
                            {
                                animationClip2 = null;
                            }
                            if (!timelineGroupGUI.track.clips[num2].recordable)
                            {
                                animationClip2 = null;
                            }
                            flag2 = (animationClip != null || animationClip2 != null);
                            if (flag2)
                            {
                                break;
                            }
                        }
                        if (flag2)
                        {
                            if (timelineGroupGUI.get_children() == null)
                            {
                                timelineGroupGUI.set_children(new List <TreeViewItem>());
                            }
                        }
                    }
                    if (a.subTracks != null)
                    {
                        for (int i = 0; i < a.subTracks.Count; i++)
                        {
                            this.CreateItem(a.subTracks[i], ref tree, selectedRows, timelineGroupGUI);
                        }
                    }
                    result = timelineGroupGUI;
                }
            }
            return(result);
        }
 public InlineCurveEditor(TimelineTrackGUI trackGUI)
 {
     m_TrackGUI     = trackGUI;
     m_ResizeHandle = new InlineCurveResizeHandle(trackGUI);
 }
示例#21
0
 public override void Init(IControl parent)
 {
     this.m_Captured         = false;
     this.m_UndoAdded        = false;
     this.m_CapturedHeight   = 0f;
     this.m_CaptureMouseYPos = 0f;
     parent.MouseDown       += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         TimelineTrackGUI timelineTrackGUI = target as TimelineTrackGUI;
         bool             result;
         if (timelineTrackGUI == null)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             Rect rect = RectUtils.Encompass(timelineTrackGUI.headerBounds, timelineTrackGUI.boundingRect);
             rect.set_y(rect.get_yMax() - 5f);
             if (rect.Contains(evt.get_mousePosition()))
             {
                 this.m_Captured         = true;
                 this.m_CapturedHeight   = TimelineWindowViewPrefs.GetInlineCurveHeight(timelineTrackGUI.track);
                 this.m_CaptureMouseYPos = GUIUtility.GUIToScreenPoint(Event.get_current().get_mousePosition()).y;
                 state.captured.Add((IControl)target);
                 this.m_UndoAdded = false;
                 result           = base.ConsumeEvent();
             }
             else
             {
                 result = base.IgnoreEvent();
             }
         }
         return(result);
     };
     parent.MouseDrag += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (!this.m_Captured)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineTrackGUI timelineTrackGUI = target as TimelineTrackGUI;
             if (timelineTrackGUI == null)
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 if (!this.m_UndoAdded)
                 {
                     TimelineUndo.PushUndo(timelineTrackGUI.track, "Set Track Height");
                     this.m_UndoAdded = true;
                 }
                 float num = this.m_CapturedHeight + (GUIUtility.GUIToScreenPoint(Event.get_current().get_mousePosition()).y - this.m_CaptureMouseYPos);
                 TimelineWindowViewPrefs.SetInlineCurveHeight(timelineTrackGUI.track, Mathf.Max(num, 60f));
                 state.GetWindow().treeView.CalculateRowRects();
                 result = base.ConsumeEvent();
             }
         }
         return(result);
     };
     parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (!this.m_Captured)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             state.captured.Remove(target as IControl);
             this.m_Captured = false;
             result          = base.ConsumeEvent();
         }
         return(result);
     };
 }