public override void Init(IControl parent)
 {
     parent.ContextClick += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (TimelineWindow.instance.sequenceHeaderBounds.Contains(evt.get_mousePosition()))
         {
             TimelineTrackBaseGUI[] visibleTrackGuis = TimelineWindow.instance.treeView.visibleTrackGuis;
             for (int i = 0; i < visibleTrackGuis.Length; i++)
             {
                 TimelineTrackBaseGUI timelineTrackBaseGUI = visibleTrackGuis[i];
                 Rect headerBounds = timelineTrackBaseGUI.headerBounds;
                 headerBounds.set_y(headerBounds.get_y() + TimelineWindow.instance.treeviewBounds.get_y());
                 if (headerBounds.Contains(evt.get_mousePosition()))
                 {
                     result = base.IgnoreEvent();
                     return(result);
                 }
             }
             TimelineWindow.instance.ShowNewTracksContextMenu(null, null);
             result = base.ConsumeEvent();
         }
         else
         {
             result = base.IgnoreEvent();
         }
         return(result);
     };
 }
Ejemplo n.º 2
0
 internal override void OnHeaderIconGUI(Rect iconRect)
 {
     if (this.hasMultipleSelection)
     {
         base.OnHeaderIconGUI(iconRect);
     }
     else
     {
         if (this.m_IconCache == null)
         {
             Texture2D texture2D = this.m_DefaultIcon;
             if (this.m_SelectionInfo.selectedAssetTypesAreHomogeneous)
             {
                 TimelineClip clip = this.m_SelectionCache.First <ClipInspector.EditorClipSelection>().clip;
                 texture2D = AssetPreview.GetMiniThumbnail(clip.underlyingAsset);
                 if (texture2D == this.m_DefaultIcon)
                 {
                     TimelineTrackBaseGUI timelineTrackBaseGUI = TimelineWindow.instance.allTracks.Find((TimelineTrackBaseGUI uiTrack) => uiTrack.track == clip.parentTrack);
                     if (timelineTrackBaseGUI != null && timelineTrackBaseGUI.drawer.GetIcon() != GUIContent.none)
                     {
                         this.m_IconCache = timelineTrackBaseGUI.drawer.GetIcon();
                     }
                 }
             }
             if (this.m_IconCache == null)
             {
                 this.m_IconCache = new GUIContent(texture2D);
             }
         }
         GUI.Label(iconRect, this.m_IconCache);
     }
 }
Ejemplo n.º 3
0
 internal virtual void ConfigureUITrack(TimelineTrackBaseGUI uiTrack)
 {
     uiTrack.ClearManipulators();
     uiTrack.AddManipulator(new SelectorTool());
     uiTrack.AddManipulator(new TrackContextMenuManipulator());
     uiTrack.AddManipulator(new TrackDoubleClick());
     uiTrack.AddManipulator(new TrackShortcutManipulator());
 }
        public virtual void OnRowGUI(Rect rowRect, TreeViewItem item, int row, bool selected, bool focused)
        {
            Rect headerRect = rowRect;
            Rect trackRect  = rowRect;

            headerRect.set_width(this.m_State.sequencerHeaderWidth);
            trackRect.set_xMin(trackRect.get_xMin() + this.m_State.sequencerHeaderWidth);
            trackRect.set_width(rowRect.get_width() - this.m_State.sequencerHeaderWidth - 1f);
            float foldoutIndent = this.GetFoldoutIndent(item);
            Rect  rect          = rowRect;
            TimelineTrackBaseGUI timelineTrackBaseGUI = (TimelineTrackBaseGUI)item;

            timelineTrackBaseGUI.isExpanded = this.m_TreeView.get_data().IsExpanded(item);
            timelineTrackBaseGUI.Draw(headerRect, trackRect, this.m_State, foldoutIndent);
            if (trackRect.Contains(Event.get_current().get_mousePosition()) || Event.get_current().get_isKey())
            {
                timelineTrackBaseGUI.OnEvent(Event.get_current(), this.m_State, false);
            }
            if (Event.get_current().get_type() == 7)
            {
                if (this.showInsertionMarker)
                {
                    if (this.m_TreeView.get_dragging() != null && this.m_TreeView.get_dragging().GetRowMarkerControlID() == TreeViewController.GetItemControlID(item))
                    {
                        this.m_DraggingInsertionMarkerRect = new Rect(rowRect.get_x() + foldoutIndent, rowRect.get_y(), rowRect.get_width() - foldoutIndent, rowRect.get_height());
                    }
                }
            }
            bool flag = this.m_TreeView.get_data().IsExpandable(item);

            if (flag)
            {
                rect.set_x(foldoutIndent - TimelineTreeView.kFoldOutOffset);
                rect.set_width(this.m_FoldoutWidth);
                EditorGUI.BeginChangeCheck();
                float num = (float)DirectorStyles.Instance.foldout.get_normal().get_background().get_height();
                rect.set_y(rect.get_y() + num / 2f);
                rect.set_height(num);
                bool flag2 = GUI.Toggle(rect, this.m_TreeView.get_data().IsExpanded(item), GUIContent.none, TimelineTreeView.m_Styles.foldout);
                if (EditorGUI.EndChangeCheck())
                {
                    if (Event.get_current().get_alt())
                    {
                        this.m_TreeView.get_data().SetExpandedWithChildren(item, flag2);
                    }
                    else
                    {
                        this.m_TreeView.get_data().SetExpanded(item, flag2);
                    }
                }
            }
            if (headerRect.Contains(Event.get_current().get_mousePosition()) || Event.get_current().get_isKey())
            {
                timelineTrackBaseGUI.OnEvent(Event.get_current(), this.m_State, false);
            }
        }
Ejemplo n.º 5
0
        // Should return the row number of the first and last row thats fits in the pixel rect defined by top and height
        public void GetFirstAndLastRowVisible(out int firstRowVisible, out int lastRowVisible)
        {
            int rowCount = m_TreeView.data.rowCount;

            if (rowCount == 0)
            {
                firstRowVisible = lastRowVisible = -1;
                return;
            }

            if (rowCount != m_ExpandedRowRects.Count)
            {
                Debug.LogError("Mismatch in state: rows vs cached rects. Did you remember to hook up: dataSource.onVisibleRowsChanged += gui.CalculateRowRects ?");
                CalculateRowRects();
            }

            float topPixel       = m_TreeView.state.scrollPos.y;
            float heightInPixels = m_TreeView.GetTotalRect().height;

            int firstVisible = -1;
            int lastVisible  = -1;

            Rect visibleRect = new Rect(0, topPixel, m_ExpandedRowRects[0].width, heightInPixels);

            for (int i = 0; i < m_ExpandedRowRects.Count; ++i)
            {
                bool visible = visibleRect.Overlaps(m_ExpandedRowRects[i]);
                if (visible)
                {
                    if (firstVisible == -1)
                    {
                        firstVisible = i;
                    }
                    lastVisible = i;
                }

                TimelineTrackBaseGUI gui = m_TreeView.data.GetItem(i) as TimelineTrackBaseGUI;
                if (gui != null)
                {
                    gui.visibleExpanded = visible;
                    gui.visibleRow      = visibleRect.Overlaps(m_RowRects[i]);
                }
            }

            if (firstVisible != -1 && lastVisible != -1)
            {
                firstRowVisible = firstVisible;
                lastRowVisible  = lastVisible;
            }
            else
            {
                firstRowVisible = 0;
                lastRowVisible  = rowCount - 1;
            }
        }
        public override bool IsExpandable(TreeViewItem item)
        {
            bool flag = false;
            TimelineTrackBaseGUI timelineTrackBaseGUI = item as TimelineTrackBaseGUI;

            if (timelineTrackBaseGUI != null)
            {
                flag = timelineTrackBaseGUI.expandable;
            }
            return(flag && item.get_hasChildren());
        }
Ejemplo n.º 7
0
 internal override void OnHeaderIconGUI(Rect iconRect)
 {
     if (!(TimelineWindow.instance == null))
     {
         TimelineTrackBaseGUI timelineTrackBaseGUI = TimelineWindow.instance.allTracks.Find((TimelineTrackBaseGUI uiTrack) => uiTrack.track == base.get_target() as TrackAsset);
         if (timelineTrackBaseGUI != null)
         {
             GUI.Label(iconRect, timelineTrackBaseGUI.drawer.GetIcon());
         }
     }
 }
 public override bool Execute(TimelineWindow.TimelineState state, TrackAsset[] tracks)
 {
     for (int i = 0; i < tracks.Length; i++)
     {
         TrackAsset trackAsset = tracks[i];
         state.timeline.CreateTrack <GroupTrack>(trackAsset, "Track Sub-Group");
         TimelineTrackBaseGUI timelineTrackBaseGUI = TimelineTrackBaseGUI.FindGUITrack(trackAsset);
         if (timelineTrackBaseGUI != null)
         {
             TimelineWindow.instance.treeView.data.SetExpanded(timelineTrackBaseGUI, true);
         }
     }
     state.Refresh();
     return(true);
 }
        private static float GetSpacing(TreeViewItem item)
        {
            TimelineTrackBaseGUI timelineTrackBaseGUI = item as TimelineTrackBaseGUI;
            float result;

            if (timelineTrackBaseGUI != null)
            {
                result = timelineTrackBaseGUI.GetVerticalSpacingBetweenTracks();
            }
            else
            {
                result = 3f;
            }
            return(result);
        }
        internal override void OnHeaderIconGUI(Rect iconRect)
        {
            if (TimelineWindow.instance == null)
            {
                return;
            }

            //when selecting multiple track types, the default icon will appear by default
            //when selecting only one track type, this will display the track type icon
            TimelineTrackBaseGUI trackGui = TimelineWindow.instance.allTracks.Find((uiTrack => uiTrack.track == target as TrackAsset));

            if (trackGui != null)
            {
                GUI.Label(iconRect, trackGui.drawer.icon);
            }
        }
Ejemplo n.º 11
0
 public override void Init(IControl parent)
 {
     parent.DoubleClick += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (evt.get_button() != 0)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineTrackBaseGUI timelineTrackBaseGUI = target as TimelineTrackBaseGUI;
             result = EditTrackInAnimationWindow.Do(state, timelineTrackBaseGUI.track);
         }
         return(result);
     };
 }
Ejemplo n.º 12
0
        public override bool Execute(WindowState state, TrackAsset[] tracks)
        {
            foreach (var track in tracks)
            {
                state.editSequence.asset.CreateTrack <GroupTrack>(track, "Track Sub-Group");

                var uiTrack = TimelineTrackBaseGUI.FindGUITrack(track);

                if (uiTrack != null)
                {
                    TimelineWindow.instance.treeView.data.SetExpanded(uiTrack, true);
                }
            }

            state.Refresh();

            return(true);
        }
Ejemplo n.º 13
0
 public override void Init(IControl parent)
 {
     parent.KeyDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (state.IsEditingASubItem())
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineTrackBaseGUI trackGUI = target as TimelineTrackBaseGUI;
             if (trackGUI == null || trackGUI.track == null)
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 bool arg_AC_0;
                 if (!SelectionManager.SelectedTracks().Contains(trackGUI.track))
                 {
                     arg_AC_0 = (from x in SelectionManager.SelectedItemGUI()
                                 select x).Any((TimelineItemGUI x) => x.parentTrackGUI == trackGUI);
                 }
                 else
                 {
                     arg_AC_0 = true;
                 }
                 bool flag = arg_AC_0;
                 if (flag)
                 {
                     result = TrackAction.HandleShortcut(state, evt, trackGUI.track);
                 }
                 else
                 {
                     result = base.IgnoreEvent();
                 }
             }
         }
         return(result);
     };
 }
Ejemplo n.º 14
0
        static void AddVisibleTrackRecursive(ref List <TimelineTrackBaseGUI> list, TimelineTrackBaseGUI track)
        {
            if (track == null)
            {
                return;
            }

            list.Add(track);

            if (!track.isExpanded)
            {
                return;
            }

            if (track.children != null)
            {
                foreach (var c in track.children)
                {
                    AddVisibleTrackRecursive(ref list, c as TimelineTrackBaseGUI);
                }
            }
        }
Ejemplo n.º 15
0
 public TrackHeaderBounds(TimelineTrackBaseGUI track, Rect localRect)
 {
     m_LocalRect = localRect;
     this.track  = track;
 }
Ejemplo n.º 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);
        }
        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);
        }
Ejemplo n.º 18
0
        public void CalculateRowRects()
        {
            if (m_TreeView.isSearching)
            {
                return;
            }

            const float          startY = 6.0f;
            IList <TreeViewItem> rows   = m_TreeView.data.GetRows();

            m_RowRects         = new List <Rect>(rows.Count);
            m_ExpandedRowRects = new List <Rect>(rows.Count);

            float curY = startY;

            m_MaxWidthOfRows = 1f;

            // first pass compute the row rects
            for (int i = 0; i < rows.Count; ++i)
            {
                var item = rows[i];

                if (i != 0)
                {
                    curY += GetSpacing(item);
                }

                Vector2 rowSize = GetSizeOfRow(item);
                m_RowRects.Add(new Rect(0, curY, rowSize.x, rowSize.y));
                m_ExpandedRowRects.Add(m_RowRects[i]);

                curY += rowSize.y;

                if (rowSize.x > m_MaxWidthOfRows)
                {
                    m_MaxWidthOfRows = rowSize.x;
                }

                // updated the expanded state
                var groupGUI = item as TimelineGroupGUI;
                if (groupGUI != null)
                {
                    groupGUI.SetExpanded(m_TreeView.data.IsExpanded(item));
                }
            }

            float       halfHeight   = halfDropBetweenHeight;
            const float kGroupPad    = 1.0f;
            const float kSkinPadding = 5.0f * 0.6f;

            // work bottom up and compute visible regions for groups
            for (int i = rows.Count - 1; i > 0; i--)
            {
                float height = 0;
                TimelineTrackBaseGUI item = (TimelineTrackBaseGUI)rows[i];
                if (item.isExpanded && item.children != null && item.children.Count > 0)
                {
                    for (var j = 0; j < item.children.Count; j++)
                    {
                        var child = item.children[j];
                        int index = rows.IndexOf(child);
                        if (index > i)
                        {
                            height += m_ExpandedRowRects[index].height + kSkinPadding;
                        }
                    }

                    height += kGroupPad;
                }
                m_ExpandedRowRects[i] = new Rect(m_RowRects[i].x, m_RowRects[i].y, m_RowRects[i].width, m_RowRects[i].height + height);

                var groupGUI = item as TimelineGroupGUI;
                if (groupGUI != null)
                {
                    var spacing = GetSpacing(item) + 1;
                    groupGUI.expandedRect = m_ExpandedRowRects[i];
                    groupGUI.rowRect      = m_RowRects[i];
                    groupGUI.dropRect     = new Rect(m_RowRects[i].x, m_RowRects[i].y - spacing, m_RowRects[i].width, m_RowRects[i].height + Mathf.Max(halfHeight, spacing));
                }
            }
        }