Пример #1
0
        void DrawBackground(Rect trackRect, TrackAsset trackAsset, Vector2 visibleTime, WindowState state)
        {
            bool canDrawRecordBackground = IsRecording(state);

            if (canDrawRecordBackground)
            {
                DrawRecordingTrackBackground(trackRect, trackAsset, visibleTime, state);
            }
            else
            {
                Color trackBackgroundColor;

                if (SelectionManager.Contains(track))
                {
                    trackBackgroundColor = state.IsEditingASubTimeline() ?
                                           DirectorStyles.Instance.customSkin.colorTrackSubSequenceBackgroundSelected :
                                           DirectorStyles.Instance.customSkin.colorTrackBackgroundSelected;
                }
                else
                {
                    trackBackgroundColor = state.IsEditingASubTimeline() ?
                                           DirectorStyles.Instance.customSkin.colorTrackSubSequenceBackground :
                                           DirectorStyles.Instance.customSkin.colorTrackBackground;
                }

                EditorGUI.DrawRect(trackRect, trackBackgroundColor);
            }
        }
Пример #2
0
        public SnapEngine(IAttractable attractable, IAttractionHandler attractionHandler, ManipulateEdges manipulateEdges, WindowState state,
                          Vector2 mousePosition, IEnumerable <ISnappable> snappables = null)
        {
            m_Attractable     = attractable;
            m_ManipulateEdges = manipulateEdges;

            m_AttractionHandler = attractionHandler;
            m_State             = state;

            m_CurrentTimes = m_GrabbedTimes = new TimeBoundaries(m_Attractable.start, m_Attractable.end);
            m_GrabbedTime  = m_State.PixelToTime(mousePosition.x);

            // Add Time zero as Magnet
            AddMagnet(0.0, true, state);

            // Add current Time as Magnet
            // case1157280 only add current time as magnet if visible
            if (TimelineWindow.instance.currentMode.ShouldShowTimeCursor(m_State))
            {
                AddMagnet(state.editSequence.time, true, state);
            }

            if (state.IsEditingASubTimeline())
            {
                // Add start and end of evaluable range as Magnets
                // This includes the case where the master timeline has a fixed length
                var range = state.editSequence.GetEvaluableRange();
                AddMagnet(range.start, true, state);
                AddMagnet(range.end, true, state);
            }
            else if (state.masterSequence.asset.durationMode == TimelineAsset.DurationMode.FixedLength)
            {
                // Add end sequence Time as Magnet
                AddMagnet(state.masterSequence.asset.duration, true, state);
            }


            if (snappables == null)
            {
                snappables = GetVisibleSnappables(m_State);
            }

            foreach (var snappable in snappables)
            {
                if (!attractable.ShouldSnapTo(snappable))
                {
                    continue;
                }

                var edges = snappable.SnappableEdgesFor(attractable, manipulateEdges);
                foreach (var edge in edges)
                {
                    AddMagnet(edge.time, edge.showSnapHint, state);
                }
            }
        }
Пример #3
0
        void TracksGUI(Rect clientRect, WindowState state, TimelineModeGUIState trackState)
        {
            if (Event.current.type == EventType.Repaint && treeView != null)
            {
                state.headerSpacePartitioner.Clear();
                state.spacePartitioner.Clear();
            }

            if (state.IsEditingASubTimeline() && !state.IsEditingAnEmptyTimeline())
            {
                var headerRect = clientRect;
                headerRect.width = state.sequencerHeaderWidth;
                Graphics.DrawBackgroundRect(state, headerRect);

                var clipRect = clientRect;
                clipRect.xMin = headerRect.xMax;
                Graphics.DrawBackgroundRect(state, clipRect, subSequenceMode: true);
            }
            else
            {
                Graphics.DrawBackgroundRect(state, clientRect);
            }

            if (!state.IsEditingAnEmptyTimeline())
            {
                m_TimeArea.DrawMajorTicks(sequenceContentRect, state.referenceSequence.frameRate);
            }

            GUILayout.BeginVertical();
            {
                GUILayout.Space(5.0f);
                GUILayout.BeginHorizontal();

                if (this.state.editSequence.asset == null)
                {
                    DrawNoSequenceGUI(state);
                }
                else
                {
                    DrawTracksGUI(clientRect, trackState);
                }

                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            Graphics.DrawShadow(clientRect);
        }
Пример #4
0
        internal static void AddTimeAreaMenuItems(GenericMenu menu, WindowState state)
        {
            foreach (var value in Enum.GetValues(typeof(TimelineAsset.DurationMode)))
            {
                var mode = (TimelineAsset.DurationMode)value;
                var item = EditorGUIUtility.TextContent(string.Format(TimelineWindow.Styles.DurationModeText, L10n.Tr(ObjectNames.NicifyVariableName(mode.ToString()))));

                if (state.recording || state.IsEditingASubTimeline() || state.editSequence.asset == null)
                {
                    menu.AddDisabledItem(item);
                }
                else
                {
                    menu.AddItem(item, state.editSequence.asset.durationMode == mode, () => SelectDurationCallback(state, mode));
                }

                menu.AddItem(DirectorStyles.showMarkersOnTimeline, state.showMarkerHeader, () => new ToggleShowMarkersOnTimeline().Execute(state));
            }
        }
        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);
        }
Пример #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);
        }