internal override void OnHeaderIconGUI(Rect iconRect)
        {
            using (new EditorGUI.DisabledScope(IsLocked()))
            {
                var bgColor = Color.white;
                if (!EditorGUIUtility.isProSkin)
                {
                    bgColor.a = 0.55f;
                }
                using (new GUIColorOverride(bgColor))
                {
                    GUI.Label(iconRect, Styles.TimelineClipBG);
                }

                var fgColor = Color.white;
                if (m_SelectionInfo != null && m_SelectionInfo.uniqueParentTracks.Count == 1)
                {
                    fgColor = TrackResourceCache.GetTrackColor(m_SelectionInfo.uniqueParentTracks.First());
                }

                using (new GUIColorOverride(fgColor))
                {
                    GUI.Label(iconRect, Styles.TimelineClipFG);
                }
            }
        }
        /// <summary>
        /// The color drawn under the clip. By default, the color is the same as the track color.
        /// </summary>
        /// <param name="clip">The clip being drawn.</param>
        /// <returns>Returns the highlight color of the clip being drawn.</returns>
        public Color GetDefaultHighlightColor(TimelineClip clip)
        {
            if (clip == null)
            {
                return(Color.white);
            }

            return(TrackResourceCache.GetTrackColor(clip.GetParentTrack()));
        }
        public static TrackDrawer CreateInstance(TrackAsset trackAsset)
        {
            if (trackAsset == null)
            {
                return(Activator.CreateInstance <TrackDrawer>());
            }

            TrackDrawer drawer;

            try
            {
                drawer = (TrackDrawer)Activator.CreateInstance(TimelineHelpers.GetCustomDrawer(trackAsset.GetType()));
            }
            catch (Exception)
            {
                drawer = Activator.CreateInstance <TrackDrawer>();
            }

            drawer.track      = trackAsset;
            drawer.trackColor = TrackResourceCache.GetTrackColor(trackAsset);
            drawer.icon       = TrackResourceCache.GetTrackIcon(trackAsset);
            return(drawer);
        }
        public override void Draw(Rect headerRect, Rect contentRect, WindowState state)
        {
            if (track == null || m_IsRoot)
            {
                return;
            }

            if (m_MustRecomputeUnions)
            {
                RecomputeRectUnions();
            }

            if (depth == 1)
            {
                Graphics.DrawBackgroundRect(state, headerRect);
            }

            var background = headerRect;

            background.height = expandedRect.height;

            var groupColor = TrackResourceCache.GetTrackColor(track);

            m_TreeViewRect = contentRect;

            var col = groupColor;

            var isSelected = SelectionManager.Contains(track);

            if (isSelected)
            {
                col = DirectorStyles.Instance.customSkin.colorSelection;
            }
            else if (isDropTarget)
            {
                col = DirectorStyles.Instance.customSkin.colorDropTarget;
            }
            else
            {
                if (m_GroupDepth % 2 == 1)
                {
                    float h, s, v;
                    Color.RGBToHSV(col, out h, out s, out v);
                    v  += 0.06f;
                    col = Color.HSVToRGB(h, s, v);
                }
            }

            if (background.width > 0)
            {
                using (new GUIColorOverride(col))
                    GUI.Box(background, GUIContent.none, m_Styles.groupBackground);
            }

            var trackRectBackground = headerRect;

            trackRectBackground.xMin  += background.width;
            trackRectBackground.width  = contentRect.width;
            trackRectBackground.height = background.height;

            if (isSelected)
            {
                col = state.IsEditingASubTimeline()
                    ? m_Styles.customSkin.colorTrackSubSequenceBackgroundSelected
                    : m_Styles.customSkin.colorTrackBackgroundSelected;
            }
            else
            {
                col = m_Styles.customSkin.colorGroupTrackBackground;
            }

            EditorGUI.DrawRect(trackRectBackground, col);
            if (!isExpanded && children != null && children.Count > 0)
            {
                var collapsedTrackRect = contentRect;

                foreach (var u in m_Unions)
                {
                    u.Draw(collapsedTrackRect, state);
                }
            }

            using (new GUIGroupScope(headerRect))
            {
                var groupRect = new Rect(0, 0, headerRect.width, headerRect.height);
                DrawName(groupRect, isSelected);
                DrawTrackButtons(groupRect, state);
            }

            if (IsTrackRecording(state))
            {
                using (new GUIColorOverride(DirectorStyles.Instance.customSkin.colorTrackBackgroundRecording))
                    GUI.Label(background, GUIContent.none, m_Styles.displayBackground);
            }

            // is this a referenced track?
            if (m_IsReferencedTrack)
            {
                var refRect = contentRect;
                refRect.x     = state.timeAreaRect.xMax - 20.0f;
                refRect.y    += 5.0f;
                refRect.width = 30.0f;
                GUI.Label(refRect, DirectorStyles.referenceTrackLabel, EditorStyles.label);
            }

            var bgRect = contentRect;

            if (track as GroupTrack != null || AllChildrenMuted(this))
            {
                bgRect.height = expandedRect.height;
            }
            DrawTrackState(contentRect, bgRect, track);
        }
Пример #5
0
 /// <summary>
 /// Gets the color information of a track.
 /// </summary>
 /// <param name="track"></param>
 /// <returns>Returns the color for the specified track.</returns>
 public Color GetTrackColor(TrackAsset track)
 {
     return(TrackResourceCache.GetTrackColor(track));
 }
Пример #6
0
        public override void Draw(Rect headerRect, Rect contentRect, WindowState state)
        {
            if (track == null)
            {
                return;
            }

            if (m_IsRoot)
            {
                return;
            }

            if (m_MustRecomputeUnions)
            {
                RecomputeRectUnions();
            }

            if (depth == 1)
            {
                Graphics.DrawBackgroundRect(state, headerRect);
            }

            var background = headerRect;

            background.height = expandedRect.height;

            var groupColor = TrackResourceCache.GetTrackColor(track);

            m_TreeViewRect = contentRect;

            var col = groupColor;

            var isSelected = SelectionManager.Contains(track);

            if (isSelected)
            {
                col = DirectorStyles.Instance.customSkin.colorSelection;
            }
            else if (isDropTarget)
            {
                col = DirectorStyles.Instance.customSkin.colorDropTarget;
            }
            else
            {
                if (m_GroupDepth % 2 == 1)
                {
                    float h, s, v;
                    Color.RGBToHSV(col, out h, out s, out v);
                    v  += 0.06f;
                    col = Color.HSVToRGB(h, s, v);
                }
            }

            // Draw Rounded Rectangle of the group...
            using (new GUIColorOverride(col))
                GUI.Box(background, GUIContent.none, m_Styles.groupBackground);

            var trackRectBackground = headerRect;

            trackRectBackground.xMin  += background.width;
            trackRectBackground.width  = contentRect.width;
            trackRectBackground.height = background.height;

            if (isSelected)
            {
                col = state.IsEditingASubTimeline()
                    ? m_Styles.customSkin.colorTrackSubSequenceBackgroundSelected
                    : m_Styles.customSkin.colorTrackBackgroundSelected;
            }
            else
            {
                col = m_Styles.customSkin.colorGroupTrackBackground;
            }

            EditorGUI.DrawRect(trackRectBackground, col);
            if (!isExpanded && children != null && children.Count > 0)
            {
                var collapsedTrackRect = contentRect;

                foreach (var u in m_Unions)
                {
                    u.Draw(collapsedTrackRect, state);
                }
            }

            // Draw the name of the Group...
            var labelRect = headerRect;

            labelRect.xMin += 20;
            var actorName = track != null ? track.name : "missing";

            labelRect.width = m_Styles.groupFont.CalcSize(new GUIContent(actorName)).x;
            labelRect.width = Math.Max(labelRect.width, 50.0f);

            // if we aren't bound to anything, we show a text field that allows to rename the actor
            // otherwise we show a ObjectField to allow binding to a go
            if (track != null && track is GroupTrack)
            {
                var textColor = m_Styles.groupFont.normal.textColor;

                if (isSelected)
                {
                    textColor = Color.white;
                }

                string newName;

                EditorGUI.BeginChangeCheck();
                using (new StyleNormalColorOverride(m_Styles.groupFont, textColor))
                {
                    newName = EditorGUI.DelayedTextField(labelRect, GUIContent.none, track.GetInstanceID(), track.name, m_Styles.groupFont);
                }

                if (EditorGUI.EndChangeCheck() && !string.IsNullOrEmpty(newName))
                {
                    track.name  = newName;
                    displayName = track.name;
                }
            }

            DrawTrackButtons(headerRect, state);

            if (IsTrackRecording(state))
            {
                using (new GUIColorOverride(DirectorStyles.Instance.customSkin.colorTrackBackgroundRecording))
                    GUI.Label(background, GUIContent.none, m_Styles.displayBackground);
            }

            // is this a referenced track?
            if (m_IsReferencedTrack)
            {
                var refRect = contentRect;
                refRect.x     = state.timeAreaRect.xMax - 20.0f;
                refRect.y    += 5.0f;
                refRect.width = 30.0f;
                GUI.Label(refRect, DirectorStyles.referenceTrackLabel, EditorStyles.label);
            }

            Rect bgRect = contentRect;

            if (track as GroupTrack != null || AllChildrenMuted(this))
            {
                bgRect.height = expandedRect.height;
            }
            DrawTrackState(contentRect, bgRect, track);
        }