Ejemplo n.º 1
0
 public void Draw(Rect rect, TrackDrawer drawer, WindowState state)
 {
     foreach (var layer in m_Layers)
     {
         layer.Draw(rect, drawer, state);
     }
 }
        // Entry point to the Clip Drawing...
        public override void Draw(Rect trackRect, TrackDrawer drawer, WindowState state)
        {
            if (SelectionManager.Contains(clip))
            {
                clip.dirtyHash = 0;
            }

            // compute dirty hash, depends on the clip and the timeline
            int dirtyHash = HashUtility.CombineHash(ComputeClipHash(), state.timeAreaTranslation.GetHashCode(), state.timeAreaScale.GetHashCode(), trackRect.GetHashCode());

            // update the clip projected rectangle on the timeline
            CalculateClipRectangle(trackRect, state, dirtyHash);
            // update the blend rects (when clip overlaps with others)
            CalculateBlendRect();
            // update the loop rects (when clip loops)
            CalculateLoopRects(trackRect, state, dirtyHash);

            clip.dirtyHash = dirtyHash;

            if (drawer.canDrawExtrapolationIcon)
            {
                DrawExtrapolation(trackRect, treeViewRect);
            }

            DrawInto(treeViewRect, state);
        }
Ejemplo n.º 3
0
 private static void DrawClipSelected(TrackDrawer.ClipDrawData drawData)
 {
     if (SelectionManager.Contains(drawData.uiClip.clip))
     {
         Rect rect = drawData.clipCenterSection;
         TrackDrawer.DrawBorder(drawData, Color.get_white());
         if (drawData.uiClip.blendInKind == TimelineClipGUI.BlendKind.Ease)
         {
             rect = drawData.uiClip.mixInRect;
             rect.set_position(Vector2.get_zero());
             EditorGUI.DrawRect(new Rect(rect.get_xMin(), rect.get_yMax() - 2f, rect.get_width(), 2f), Color.get_white());
         }
         if (drawData.uiClip.blendInKind == TimelineClipGUI.BlendKind.Mix)
         {
             rect = drawData.uiClip.mixInRect;
             rect.set_position(Vector2.get_zero());
             EditorGUI.DrawRect(new Rect(rect.get_xMin(), rect.get_yMin(), rect.get_width(), 2f), Color.get_white());
             Graphics.DrawLineAA(4f, new Vector3(rect.get_xMin(), rect.get_yMin(), 0f), new Vector3(rect.get_xMax(), rect.get_yMax() - 1f, 0f), Color.get_white());
             if (drawData.uiClip.previousClip != null && SelectionManager.Contains(drawData.uiClip.previousClip.clip))
             {
                 EditorGUI.DrawRect(new Rect(rect.get_xMin(), rect.get_yMax() - 2f, rect.get_width(), 2f), Color.get_white());
                 EditorGUI.DrawRect(new Rect(rect.get_xMax() - 2f, rect.get_yMin(), 2f, rect.get_height()), Color.get_white());
                 EditorGUI.DrawRect(new Rect(rect.get_xMin(), rect.get_yMin(), 2f, rect.get_height()), Color.get_white());
             }
         }
         if (drawData.uiClip.blendOutKind == TimelineClipGUI.BlendKind.Ease || drawData.uiClip.blendOutKind == TimelineClipGUI.BlendKind.Mix)
         {
             rect = drawData.uiClip.mixOutRect;
             rect.set_x(drawData.targetRect.get_xMax() - rect.get_width());
             rect.set_y(0f);
             EditorGUI.DrawRect(new Rect(rect.get_xMin(), rect.get_yMax() - 2f, rect.get_width(), 2f), Color.get_white());
             Graphics.DrawLineAA(4f, new Vector3(rect.get_xMin(), rect.get_yMin(), 0f), new Vector3(rect.get_xMax(), rect.get_yMax() - 1f, 0f), Color.get_white());
         }
     }
 }
Ejemplo n.º 4
0
 private static void DrawClipRecorded(TrackDrawer.ClipDrawData drawData)
 {
     if (drawData.state.recording && drawData.clip.recordable && drawData.clip.parentTrack.IsRecordingToClip(drawData.clip))
     {
         TrackDrawer.DrawBorder(drawData, DirectorStyles.Instance.customSkin.colorRecordingClipOutline);
     }
 }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
 private void DrawDefaultClip(TrackDrawer.ClipDrawData drawData)
 {
     if (drawData.targetRect.get_width() < TrackDrawer.k_MinClipWidth)
     {
         drawData.targetRect.set_width(TrackDrawer.k_MinClipWidth);
         drawData.clipCenterSection.set_width(TrackDrawer.k_MinClipWidth);
         this.DrawClipBody(drawData, false);
         TrackDrawer.DrawClipSelected(drawData);
         this.DrawClipText(drawData.title, drawData.targetRect, 1);
     }
     else
     {
         this.DrawClipBody(drawData, true);
         TrackDrawer.DrawClipSelected(drawData);
         TrackDrawer.DrawClipRecorded(drawData);
         TrackDrawer.DrawClipTimescale(drawData);
         TrackDrawer.DrawClipInOut(drawData);
         Rect clipCenterSection = drawData.clipCenterSection;
         if (clipCenterSection.get_width() < 20f)
         {
             if (drawData.targetRect.get_width() > 20f)
             {
                 this.DrawClipText(drawData.title, clipCenterSection, 1);
             }
         }
         else
         {
             TrackDrawer.DrawLoops(drawData, clipCenterSection);
             this.DrawClipText(drawData.title, clipCenterSection, 1);
         }
     }
 }
Ejemplo n.º 7
0
 protected void AddAddAssetMenuItem(GenericMenu menu, Type assetType, TrackAsset track, ITimelineState state)
 {
     if (!assetType.IsAbstract)
     {
         menu.AddItem(EditorGUIUtility.TextContent(TrackDrawer.k_AddClipContent.get_text() + " " + ObjectNames.NicifyVariableName(assetType.Name)), false, delegate(object typeOfClip)
         {
             TrackDrawer.AddAssetOnTrack(typeOfClip as Type, track, state);
         }, assetType);
     }
 }
Ejemplo n.º 8
0
        private void CreateExistingMarker(string key, ITimelineMarkerContainer container, ITimelineState state)
        {
            Vector3 mousePosition = (this.trackMenuContext.clipTimeCreation != TrackDrawer.TrackMenuContext.ClipTimeCreation.Mouse) ? TimelineHelpers.sInvalidMousePosition : this.trackMenuContext.mousePosition;
            double  time          = TrackDrawer.CalculateMarkerTimeForMousePosition(container as TrackAsset, state, mousePosition);

            TimelineUndo.PushUndo(container as Object, "Create Marker");
            TimelineMarker newEvent = container.CreateMarker(key, time);

            TrackDrawer.SelectMarkerInInspector(state, newEvent);
            state.Refresh();
        }
Ejemplo n.º 9
0
        public virtual void OnBuildTrackContextMenu(GenericMenu menu, TrackAsset trackAsset, ITimelineState state)
        {
            bool flag = trackAsset is AnimationTrack || trackAsset is AudioTrack;

            if (flag)
            {
                List <Type> list = TimelineHelpers.GetTypesHandledByTrackType(TimelineHelpers.TrackTypeFromType(trackAsset.GetType())).ToList <Type>();
                for (int i = 0; i < list.Count; i++)
                {
                    Type assetType = list[i];
                    this.AddAddAssetMenuItem(menu, assetType, trackAsset, state);
                }
            }
            else if (TimelineHelpers.GetMediaTypeFromType(trackAsset.GetType()) == TimelineAsset.MediaType.Script)
            {
                Type customPlayableType = trackAsset.GetCustomPlayableType();
                if (customPlayableType != null)
                {
                    string     displayName = TrackDrawer.GetDisplayName(customPlayableType);
                    GUIContent gUIContent  = new GUIContent("Add " + displayName + " Clip");
                    menu.AddItem(new GUIContent(gUIContent), false, delegate(object userData)
                    {
                        TimelineHelpers.CreateClipOnTrack(userData as Type, trackAsset, state);
                    }, customPlayableType);
                }
            }
            ITimelineMarkerContainer markerContainer = trackAsset as ITimelineMarkerContainer;

            if (markerContainer != null)
            {
                menu.AddItem(TrackDrawer.Styles.newMarker, false, delegate
                {
                    this.CreateNewMarker(markerContainer, state);
                });
                IEnumerable <string> enumerable = (from x in markerContainer.GetMarkers()
                                                   select x.key).Distinct <string>();
                if (enumerable.Any <string>())
                {
                    using (IEnumerator <string> enumerator = enumerable.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            string key = enumerator.Current;
                            menu.AddItem(new GUIContent(TrackDrawer.Styles.addMarker.get_text() + key), false, delegate
                            {
                                this.CreateExistingMarker(key, markerContainer, state);
                            });
                        }
                    }
                }
            }
        }
        public abstract void OnGraphRebuilt(); // callback when the corresponding graph is rebuilt. This can happen, but not have the GUI rebuilt.

        protected TimelineTrackBaseGUI(int id, int depth, TreeViewItem parent, string displayName, TrackAsset trackAsset, TreeViewController tv, TimelineTreeViewGUI tvgui)
            : base(id, depth, parent, displayName)
        {
            m_Drawer = TrackDrawer.CreateInstance(trackAsset);
            m_Drawer.sequencerState = tvgui.TimelineWindow.state;

            isExpanded   = false;
            isDropTarget = false;
            track        = trackAsset;
            treeView     = tv;

            m_TreeViewGUI = tvgui;
        }
        public override void Draw(Rect trackRect, TrackDrawer drawer, WindowState state)
        {
            RegisterRect(state);

            topMarker.Draw(trackRect, drawer, state);

            if (m_MarkerGUIs.Count > 1)
            {
                GUI.Box(treeViewRect, String.Empty, DirectorStyles.Instance.markerMultiOverlay);
            }

            if (m_ManipulatedMarker != null)
            {
                m_ManipulatedMarker.Draw(trackRect, drawer, state);
            }
        }
Ejemplo n.º 12
0
 public override void OnBuildTrackContextMenu(GenericMenu menu, TrackAsset trackAsset, ITimelineState state)
 {
     Type[] allStandalonePlayableAssets = TimelineHelpers.GetAllStandalonePlayableAssets();
     Type[] array = allStandalonePlayableAssets;
     for (int i = 0; i < array.Length; i++)
     {
         Type type = array[i];
         if (!type.IsDefined(typeof(HideInMenuAttribute), true) && !type.IsDefined(typeof(IgnoreOnPlayableTrackAttribute), true))
         {
             string     displayName = TrackDrawer.GetDisplayName(type);
             GUIContent gUIContent  = new GUIContent("Add Clip/" + displayName);
             menu.AddItem(gUIContent, false, delegate(object userData)
             {
                 TimelineHelpers.CreateClipOnTrack(userData as Type, trackAsset, state);
             }, type);
         }
     }
 }
        public static void Show(TrackDrawer drawer, Vector2 mousePosition)
        {
            GenericMenu genericMenu = new GenericMenu();

            TimelineAction.AddToMenu(genericMenu, TimelineWindow.instance.state);
            ItemAction <TimelineClip> .AddToMenu(genericMenu, TimelineWindow.instance.state);

            ItemAction <TimelineMarker> .AddToMenu(genericMenu, TimelineWindow.instance.state);

            if (drawer != null)
            {
                TimelineClip[] array = SelectionManager.SelectedItems <TimelineClip>().ToArray <TimelineClip>();
                if (array.Length > 0)
                {
                    genericMenu.AddSeparator("");
                    drawer.OnBuildClipContextMenu(genericMenu, array, TimelineWindow.instance.state);
                }
            }
            genericMenu.ShowAsContext();
        }
Ejemplo n.º 14
0
        public override void Draw(Rect trackRect, TrackDrawer drawer, WindowState state)
        {
            // compute marker hash
            var currentMarkerHash = ComputeDirtyHash();

            // compute timeline hash
            var currentTimelineHash = state.timeAreaTranslation.GetHashCode() ^ state.timeAreaScale.GetHashCode() ^ trackRect.GetHashCode();

            // update the clip projected rectangle on the timeline
            CalculateClipRectangle(trackRect, state, currentMarkerHash ^ currentTimelineHash);

            var isSelected  = selectable && SelectionManager.Contains(marker);
            var showMarkers = parent.showMarkers;

            DrawMarker(treeViewRect, marker.GetType(), isSelected, !showMarkers);

            if (Event.current.type == EventType.Repaint && showMarkers && !parent.locked)
            {
                state.spacePartitioner.AddBounds(this);
            }
        }
Ejemplo n.º 15
0
        public virtual void Draw(Rect rect, TrackDrawer drawer, WindowState state)
        {
            if (!m_Items.Any())
            {
                return;
            }

            Sort();
            var visibleTime = state.timeAreaShownRange;

            foreach (var item in m_Items)
            {
                item.visible = item.end > visibleTime.x && item.start < visibleTime.y;

                if (!item.visible)
                {
                    continue;
                }

                item.Draw(rect, drawer, state);
            }
        }
Ejemplo n.º 16
0
        public virtual GUIContent GetIcon()
        {
            if (!this.m_HasCheckForIconInGizmosFolder)
            {
                Texture2D texture2D = TrackDrawer.LoadIconInGizmosFolder(this.track.GetType().Name);
                if (texture2D != null)
                {
                    this.m_IconGizmosContent = new GUIContent(texture2D);
                }
                this.m_HasCheckForIconInGizmosFolder = true;
            }
            GUIContent result;

            if (this.m_IconGizmosContent != null)
            {
                result = this.m_IconGizmosContent;
            }
            else
            {
                result = EditorGUIUtility.IconContent("ScriptableObject Icon");
            }
            return(result);
        }
Ejemplo n.º 17
0
        public static TrackDrawer CreateInstance(TrackAsset trackAsset)
        {
            TrackDrawer result;

            if (trackAsset == null)
            {
                result = Activator.CreateInstance <TrackDrawer>();
            }
            else
            {
                TrackDrawer trackDrawer = null;
                try
                {
                    trackDrawer = (TrackDrawer)Activator.CreateInstance(TimelineHelpers.GetCustomDrawer(trackAsset.GetType()));
                }
                catch (Exception)
                {
                    trackDrawer = Activator.CreateInstance <TrackDrawer>();
                }
                result = trackDrawer;
            }
            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();
        }
Ejemplo n.º 19
0
 public virtual void DrawEvent(TrackDrawer.MarkerDrawData drawData)
 {
     TrackDrawer.DrawDefaultEvent(drawData);
 }
Ejemplo n.º 20
0
 public override void Draw(Rect rect, TrackDrawer drawer, WindowState state)
 {
     base.Draw(rect, drawer, state); //draw clips
     DrawConnector(items.OfType <TimelineClipGUI>());
 }
 public abstract void Draw(Rect rect, TrackDrawer drawer, WindowState state);
Ejemplo n.º 22
0
 private static void DrawLoops(TrackDrawer.ClipDrawData drawData, Rect containerRect)
 {
     if (drawData.selected || drawData.inlineCurvesSelected)
     {
         Color color = GUI.get_color();
         GUI.set_color(Color.get_white());
         int num = drawData.uiClip.minLoopIndex;
         for (int i = 0; i < drawData.uiClip.loopRects.Count; i++)
         {
             Rect rect = drawData.uiClip.loopRects[i];
             rect.set_x(rect.get_x() - drawData.unclippedRect.get_x());
             rect.set_x(rect.get_x() + 1f);
             rect.set_width(rect.get_width() - 2f);
             rect.set_y(5f);
             rect.set_height(rect.get_height() - 4f);
             rect.set_xMin(rect.get_xMin() - 4f);
             if (rect.get_width() >= 10f)
             {
                 GUI.set_color(new Color(0f, 0f, 0f, 0.2f));
                 GUI.Box(rect, GUIContent.none, DirectorStyles.Instance.displayBackground);
             }
             if (rect.get_width() > 30f)
             {
                 GUI.set_color(Color.get_white());
                 Graphics.ShadowLabel(rect, (!drawData.uiClip.supportsLooping) ? TrackDrawer.k_HoldText : TrackDrawer.GetLoopString(num), DirectorStyles.Instance.fontClip, Color.get_white(), Color.get_black());
             }
             num++;
             if (!drawData.uiClip.supportsLooping)
             {
                 break;
             }
         }
         GUI.set_color(color);
     }
 }