示例#1
0
        public static void ShowNewTracksContextMenu(TrackAsset parentTrack, TimelineGroupGUI parentGroup, WindowState state)
        {
            var menu = new GenericMenu();

            AddTrackMenuCommands(menu, parentTrack, parentGroup, state);
            menu.ShowAsContext();
        }
示例#2
0
        public static void ShowTrackContextMenu(TrackDrawer drawer, TrackAsset track, Vector2 mousePosition)
        {
            var menu = new GenericMenu();

            TimelineAction.AddToMenu(menu, TimelineWindow.instance.state, mousePosition);
            menu.AddSeparator("");

            TrackAction.AddToMenu(menu, TimelineWindow.instance.state);

            var groupTrack = track as GroupTrack;

            if (groupTrack == null)
            {
                if (drawer != null)
                {
                    drawer.OnBuildTrackContextMenu(menu, track, TimelineWindow.instance.state);
                }
            }
            else
            {
                // Add all the track types..
                menu.AddSeparator("");
                TimelineGroupGUI.AddMenuItems(menu, groupTrack);
            }

            menu.ShowAsContext();
        }
        public virtual Vector2 GetSizeOfRow(TreeViewItem item)
        {
            Vector2 result;

            if (item.get_displayName() == "root")
            {
                result = new Vector2(this.m_TreeView.GetTotalRect().get_width(), 0f);
            }
            else
            {
                TimelineGroupGUI timelineGroupGUI = item as TimelineGroupGUI;
                if (timelineGroupGUI != null)
                {
                    result = new Vector2(this.m_TreeView.GetTotalRect().get_width(), timelineGroupGUI.GetHeight(this.m_State));
                }
                else
                {
                    float num = this.m_State.trackHeight;
                    if (item.get_hasChildren() && this.m_TreeView.get_data().IsExpanded(item))
                    {
                        num = Mathf.Min(this.m_State.trackHeight, TimelineTreeView.kMinTrackHeight);
                    }
                    result = new Vector2(this.m_TreeView.GetTotalRect().get_width(), num);
                }
            }
            return(result);
        }
        static void AddNewTrackMenuCommand(GenericMenu menu, TrackAsset parentTrack, TimelineGroupGUI parentGroup, Type type, WindowState state)
        {
            GenericMenu.MenuFunction2 lastMethod = trackType =>
            {
                SelectionManager.Clear();
                TimelineHelpers.CreateTrack((Type)trackType, parentTrack);
            };

            var category = TimelineHelpers.GetTrackCategoryName(type);

            if (!string.IsNullOrEmpty(category))
            {
                category += "/";
            }

            var name     = category + TimelineHelpers.GetTrackMenuName(type);
            var disabled = (parentTrack != null && parentTrack.lockedInHierarchy) || state.editSequence.isReadOnly;

            bool addenu = true;
            var  attr   = Attribute.GetCustomAttribute(type, typeof(TrackAttribute)) as TrackAttribute;

            if (attr != null)
            {
                addenu = !attr.onlyInSub;
            }

            if (addenu)
            {
                AddCommandToMenu(menu, name, lastMethod, type, !disabled);
            }
        }
 static bool AllChildrenMuted(TimelineGroupGUI groupGui)
 {
     if (!groupGui.track.muted)
     {
         return(false);
     }
     if (groupGui.children == null)
     {
         return(true);
     }
     return(groupGui.children.OfType <TimelineGroupGUI>().All(AllChildrenMuted));
 }
        public void ExpandItems(TreeViewItem item)
        {
            if (this.treeroot == item)
            {
                this.SetExpanded(this.treeroot, true);
            }
            TimelineGroupGUI timelineGroupGUI = item as TimelineGroupGUI;

            if (timelineGroupGUI != null && timelineGroupGUI.track != null)
            {
                this.SetExpanded(item, !timelineGroupGUI.track.GetCollapsed());
            }
            if (item.get_children() != null)
            {
                for (int i = 0; i < item.get_children().Count; i++)
                {
                    this.ExpandItems(item.get_children()[i]);
                }
            }
        }
示例#7
0
        public sealed override void FetchData()
        {
            // create root item
            m_RootItem = new TimelineGroupGUI(m_TreeView, m_ParentGUI, 1, 0, null, "root", null, true);

            var tree = new Dictionary <TrackAsset, TimelineTrackBaseGUI>();

            var filteredView = m_TimelineWindow.state.editSequence.asset.trackObjects;

            allTrackGuis = new List <TimelineTrackBaseGUI>(filteredView.Count());

            foreach (var t in filteredView)
            {
                CreateItem(t, ref tree, filteredView.OfType <TrackAsset>(), m_RootItem);
            }

            m_NeedRefreshRows = true;

            SetExpanded(m_RootItem, true);
        }
示例#8
0
        public void ExpandItems(TreeViewItem item)
        {
            if (treeroot == item)
            {
                SetExpanded(treeroot, true);
            }

            TimelineGroupGUI gui = item as TimelineGroupGUI;

            if (gui != null && gui.track != null)
            {
                SetExpanded(item, !gui.track.GetCollapsed());
            }

            if (item.children != null)
            {
                for (int c = 0; c < item.children.Count; c++)
                {
                    ExpandItems(item.children[c]);
                }
            }
        }
示例#9
0
        public static TrackAsset GetGroup(object o)
        {
            TrackAsset result;

            if (o == null)
            {
                result = null;
            }
            else
            {
                TrackAsset       trackAsset       = o as TrackAsset;
                TimelineGroupGUI timelineGroupGUI = o as TimelineGroupGUI;
                if (trackAsset == null)
                {
                    if (timelineGroupGUI != null)
                    {
                        if (timelineGroupGUI.track.GetType() == TimelineHelpers.GroupTrackType.trackType)
                        {
                            result = timelineGroupGUI.track;
                            return(result);
                        }
                        trackAsset = (timelineGroupGUI.track.parent as TrackAsset);
                    }
                }
                while (trackAsset != null)
                {
                    if (trackAsset.GetType() == TimelineHelpers.GroupTrackType.trackType)
                    {
                        result = trackAsset;
                        return(result);
                    }
                    trackAsset = (trackAsset.parent as TrackAsset);
                }
                result = null;
            }
            return(result);
        }
        public static void Show(TrackDrawer drawer, TrackAsset track, Vector2 mousePosition)
        {
            GenericMenu genericMenu = new GenericMenu();

            TimelineAction.AddToMenu(genericMenu, TimelineWindow.instance.state);
            genericMenu.AddSeparator("");
            TrackAction.AddToMenu(genericMenu, TimelineWindow.instance.state);
            GroupTrack groupTrack = track as GroupTrack;

            if (groupTrack == null)
            {
                if (drawer != null)
                {
                    genericMenu.AddSeparator("");
                    drawer.OnBuildTrackContextMenu(genericMenu, track, TimelineWindow.instance.state);
                }
            }
            else
            {
                genericMenu.AddSeparator("");
                TimelineGroupGUI.AddMenuItems(genericMenu, groupTrack);
            }
            genericMenu.ShowAsContext();
        }
示例#11
0
        static void AddNewTrackMenuCommand(GenericMenu menu, TrackAsset parentTrack, TimelineGroupGUI parentGroup, Type type, WindowState state)
        {
            GenericMenu.MenuFunction2 lastMethod = trackType =>
            {
                SelectionManager.Clear();

                if (parentTrack is GroupTrack)
                {
                    parentTrack.SetCollapsed(false);
                }
                var track = state.GetWindow().AddTrack((Type)trackType, parentGroup == null ? null : parentGroup.track);
                if (parentGroup != null)
                {
                    state.GetWindow().treeView.data.SetExpanded(parentGroup, true);
                }

                if (track.GetType() == typeof(ActivationTrack))
                {
                    var clip = track.CreateClip(0);
                    clip.displayName = ActivationTrackDrawer.Styles.ClipText.text;
                    state.Refresh();
                }
            };

            var category = TimelineHelpers.GetTrackCategoryName(type);

            if (!string.IsNullOrEmpty(category))
            {
                category += "/";
            }

            var name     = category + TimelineHelpers.GetTrackMenuName(type);
            var disabled = parentTrack != null && parentTrack.lockedInHierarchy;

            AddCommandToMenu(menu, name, lastMethod, type, !disabled);
        }
示例#12
0
        static void AddTrackMenuCommands(GenericMenu newTrackMenu, TrackAsset parentTrack, TimelineGroupGUI parentGroup, WindowState state)
        {
            // Add Group or SubGroup
            var title = parentTrack == null?L10n.Tr("Track Group") : L10n.Tr("Track Sub-Group");

            var disabled = parentTrack != null && parentTrack.lockedInHierarchy;

            GenericMenu.MenuFunction command = () =>
            {
                SelectionManager.Clear();
                TimelineGroupGUI.Create(parentTrack, title);
                state.Refresh();
            };

            AddCommandToMenu(newTrackMenu, title, command, !disabled);
            newTrackMenu.AddSeparator("");

            var allTypes    = TypeUtility.AllTrackTypes().Where(x => x != typeof(GroupTrack) && !TypeUtility.IsHiddenInMenu(x) && x.IsPublic).ToList();
            var builtIn     = allTypes.Where(x => x.Assembly.Equals(typeof(TimelineAsset).Assembly)).OrderBy(i => i.FullName).ToList();
            var customTypes = allTypes.Except(builtIn).ToList();

            foreach (var t in builtIn)
            {
                AddNewTrackMenuCommand(newTrackMenu, parentTrack, parentGroup, t, state);
            }

            if (builtIn.Any() && customTypes.Any())
            {
                newTrackMenu.AddSeparator("");
            }

            foreach (var t in customTypes)
            {
                AddNewTrackMenuCommand(newTrackMenu, parentTrack, parentGroup, t, state);
            }
        }
        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 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);
     };
 }
 private static bool CanClearSelection(Event evt, TimelineGroupGUI track)
 {
     return(!SelectionManager.Contains(track.track) && evt.get_modifiers() != 2 && evt.get_modifiers() != 1 && evt.get_modifiers() != 8);
 }
示例#16
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);
        }