public static bool SelectDownTrack(bool shift = false)
        {
            if (TrackHeadActive())
            {
                var nextTrack = SelectionManager.SelectedTracks().Last().NextTrack();
                if (nextTrack != null)
                {
                    if (shift)
                    {
                        if (SelectionManager.Contains(nextTrack))
                        {
                            SelectionManager.Remove(SelectionManager.SelectedTracks().Last());
                        }
                        SelectionManager.Add(nextTrack);
                    }
                    else
                    {
                        SelectionManager.SelectOnly(nextTrack);
                    }

                    FrameTrackHeader(GetVisibleTracks().First(x => x.track == nextTrack));
                }
                return(true);
            }

            return(false);
        }
        void DrawTrackButtons(Rect headerRect, WindowState state)
        {
            const float buttonSize = WindowConstants.trackHeaderButtonSize;
            const float padding    = WindowConstants.trackHeaderButtonPadding;

            var buttonRect = new Rect(headerRect.xMax - buttonSize - padding, headerRect.y + ((headerRect.height - buttonSize) / 2f), buttonSize, buttonSize);

            if (GUI.Button(buttonRect, EditorGUIUtility.IconContent("CreateAddNew"), m_Styles.trackGroupAddButton))
            {
                // the drop down will apply to all selected tracks
                if (!SelectionManager.Contains(track))
                {
                    SelectionManager.Clear();
                    SelectionManager.Add(track);
                }
                SequencerContextMenu.ShowNewTracksContextMenu(SelectionManager.SelectedTracks().ToArray(), TimelineWindow.state, buttonRect);
            }
            buttonRect.x -= buttonSize;

            var suitePadding = DrawButtonSuite(2, ref buttonRect);

            DrawMuteButton(buttonRect, state);
            buttonRect.x -= buttonSize + padding;
            DrawLockButton(buttonRect, state);
            buttonRect.x -= suitePadding;
        }
 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());
         }
     }
 }
Exemple #4
0
        void DrawTrackBinding(Rect rect, Rect headerRect)
        {
            if (m_TrackDrawData.m_ShowTrackBindings)
            {
                DoTrackBindingGUI(rect, headerRect);
                return;
            }

            var textStyle = m_Styles.trackHeaderFont;

            textStyle.normal.textColor = SelectionManager.Contains(track) ? Color.white : m_Styles.customSkin.colorTrackFont;

            string trackName = track.name;

            EditorGUI.BeginChangeCheck();

            // by default the size is just the width of the string (for selection purposes)
            rect.width = m_Styles.trackHeaderFont.CalcSize(new GUIContent(trackName)).x;

            // if we are editing, supply the entire width of the header
            if (GUIUtility.keyboardControl == track.GetInstanceID())
            {
                rect.width = (headerRect.xMax - rect.xMin) - (5 * WindowConstants.trackHeaderButtonSize);
            }

            trackName = EditorGUI.DelayedTextField(rect, GUIContent.none, track.GetInstanceID(), track.name, textStyle);

            if (EditorGUI.EndChangeCheck())
            {
                TimelineUndo.PushUndo(track, "Rename Track");
                track.name = trackName;
            }
        }
Exemple #5
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);
            }
        }
        private static void HandleSingleSelection(Event evt, TimelineWindow.TimelineState state, List <IBounds> elements)
        {
            if (RectangleSelect.CanClearSelection(evt))
            {
                SelectionManager.Clear();
            }
            TimelineItemGUI timelineItemGUI = RectangleSelect.PickItemGUI(elements);

            if (evt.get_modifiers() == 1)
            {
                timelineItemGUI.parentTrackGUI.RangeSelectItems(timelineItemGUI, state);
            }
            else if (evt.get_modifiers() == 2 || evt.get_modifiers() == 8)
            {
                bool flag = SelectionManager.Contains(timelineItemGUI.item);
                if (flag)
                {
                    SelectionManager.Remove(timelineItemGUI.item);
                }
                else
                {
                    SelectionManager.Add(timelineItemGUI.item);
                }
            }
            else
            {
                SelectionManager.Add(timelineItemGUI.item);
            }
        }
        // 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);
        }
        private static bool CanStartRectableSelect(Event evt, List <IBounds> elements, out bool hasOneSelected)
        {
            hasOneSelected = false;
            bool result;

            foreach (IBounds current in elements)
            {
                if (current != null)
                {
                    if (current is InlineCurveEditor)
                    {
                        hasOneSelected = true;
                        result         = false;
                        return(result);
                    }
                    if (current is TimelineItemGUI)
                    {
                        SelectionManager.Contains((current as TimelineItemGUI).item);
                        if (SelectionManager.Contains((current as TimelineItemGUI).item) && evt.get_modifiers() == null)
                        {
                            SelectionManager.Add((current as TimelineItemGUI).item);
                            hasOneSelected = true;
                        }
                        result = false;
                        return(result);
                    }
                }
            }
            result = true;
            return(result);
        }
        public static bool SelectLeftItem(bool shift = false)
        {
            if (ClipAreaActive())
            {
                var items    = SelectionManager.SelectedItems().ToList();
                var clipOnly = FilterItems(ref items);

                var item = items.Last();
                var prev = item.PreviousItem(clipOnly);
                if (prev != null)
                {
                    if (shift)
                    {
                        if (SelectionManager.Contains(prev))
                        {
                            SelectionManager.Remove(item);
                        }
                        SelectionManager.Add(prev);
                    }
                    else
                    {
                        SelectionManager.SelectOnly(prev);
                    }
                    TimelineHelpers.FrameItems(new[] { prev });
                }
                else if (item != null && !shift && item.parentTrack != TimelineEditor.inspectedAsset.markerTrack)
                {
                    SelectionManager.SelectOnly(item.parentTrack);
                }
                return(true);
            }
            return(false);
        }
        public static bool SelectRightItem(bool shift = false)
        {
            if (ClipAreaActive())
            {
                var items    = SelectionManager.SelectedItems().ToList();
                var clipOnly = FilterItems(ref items);

                var item = items.Last();
                var next = item.NextItem(clipOnly);
                if (next != null)
                {
                    if (shift)
                    {
                        if (SelectionManager.Contains(next))
                        {
                            SelectionManager.Remove(item);
                        }
                        SelectionManager.Add(next);
                    }
                    else
                    {
                        SelectionManager.SelectOnly(next);
                    }
                    TimelineHelpers.FrameItems(new[] { next });
                    return(true);
                }
            }
            return(false);
        }
 public static bool SelectUpTrack(bool shift = false)
 {
     if (TrackHeadActive())
     {
         var prevTrack = PreviousTrack(SelectionManager.SelectedTracks().Last());
         if (prevTrack != null)
         {
             if (shift)
             {
                 if (SelectionManager.Contains(prevTrack))
                 {
                     SelectionManager.Remove(SelectionManager.SelectedTracks().Last());
                 }
                 SelectionManager.Add(prevTrack);
             }
             else
             {
                 SelectionManager.SelectOnly(prevTrack);
             }
             FrameTrackHeader(GetVisibleTracks().First(x => x.track == prevTrack));
         }
         return(true);
     }
     return(false);
 }
        public static void DrawBorder(Rect centerRect, ClipBorder border, ClipBlends blends, TimelineClip prevClip = null)
        {
            var thickness = border.thickness;
            var color     = border.color;

            // Draw top selected lines.
            EditorGUI.DrawRect(new Rect(centerRect.xMin, centerRect.yMin, centerRect.width, thickness), color);

            // Draw bottom selected lines.
            EditorGUI.DrawRect(new Rect(centerRect.xMin, centerRect.yMax - thickness, centerRect.width, thickness), color);

            // Draw Left Selected Lines
            if (blends.inKind == BlendKind.None)
            {
                EditorGUI.DrawRect(new Rect(centerRect.xMin, centerRect.yMin, thickness, centerRect.height), color);
            }
            else
            {
                var mixInRect = blends.inRect;

                if (blends.inKind == BlendKind.Ease)
                {
                    EditorGUI.DrawRect(new Rect(mixInRect.xMin, mixInRect.yMax - thickness, mixInRect.width, thickness), color);

                    EditorGUI.DrawRect(new Rect(mixInRect.xMin, mixInRect.yMin, thickness, mixInRect.height), color);

                    Graphics.DrawLineAA(2.0f * thickness, new Vector3(mixInRect.xMin, mixInRect.yMax - 1f, 0), new Vector3(mixInRect.xMax, mixInRect.yMin + 1f, 0), color);
                }
                else if (blends.inKind == BlendKind.Mix)
                {
                    EditorGUI.DrawRect(new Rect(mixInRect.xMin, mixInRect.yMin, mixInRect.width, thickness), color);

                    // If there's another clip in the left, draw the blend.
                    if (prevClip != null && SelectionManager.Contains(prevClip))
                    {
                        EditorGUI.DrawRect(new Rect(mixInRect.xMin, mixInRect.yMax - thickness, mixInRect.width, thickness), color); //  Bottom
                    }
                    Graphics.DrawLineAA(2.0f * thickness, new Vector3(mixInRect.xMin, mixInRect.yMin + 1f, 0), new Vector3(mixInRect.xMax, mixInRect.yMax - 1f, 0), color);
                }
            }

            // Draw Right Selected Lines
            if (blends.outKind == BlendKind.None)
            {
                EditorGUI.DrawRect(new Rect(centerRect.xMax - thickness, centerRect.yMin, thickness, centerRect.height), color);
            }
            else
            {
                var mixOutRect = blends.outRect;
                EditorGUI.DrawRect(new Rect(mixOutRect.xMin, mixOutRect.yMax - thickness, mixOutRect.width, thickness), color);

                if (blends.outKind == BlendKind.Ease)
                {
                    EditorGUI.DrawRect(new Rect(mixOutRect.xMax - thickness, mixOutRect.yMin, thickness, mixOutRect.height), color);
                }

                Graphics.DrawLineAA(2.0f * thickness, new Vector3(mixOutRect.xMin, mixOutRect.yMin + 1f, 0), new Vector3(mixOutRect.xMax, mixOutRect.yMax - 1f, 0), color);
            }
        }
Exemple #13
0
        private void DrawHeaderBackground(Rect headerRect)
        {
            Color color = (!SelectionManager.Contains(base.track)) ? DirectorStyles.Instance.customSkin.colorTrackHeaderBackground : DirectorStyles.Instance.customSkin.colorSelection;
            Rect  rect  = headerRect;

            rect.set_x(rect.get_x() + this.m_Styles.trackSwatchStyle.get_fixedWidth());
            rect.set_width(rect.get_width() - this.m_Styles.trackSwatchStyle.get_fixedWidth());
            EditorGUI.DrawRect(rect, color);
        }
        void DrawInto(Rect drawRect, WindowState state)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            // create the inline curve editor if not already created
            CreateInlineCurveEditor(state);

            // @todo optimization, most of the calculations (rect, offsets, colors, etc.) could be cached
            // and rebuilt when the hash of the clip changes.

            if (isInvalid)
            {
                drawer.DrawInvalidClip(this, treeViewRect);
                return;
            }

            GUI.BeginClip(drawRect);

            var    originRect = new Rect(0.0f, 0.0f, drawRect.width, drawRect.height);
            string clipLabel  = name;
            bool   selected   = SelectionManager.Contains(clip);

            if (selected && !Equals(1.0, clip.timeScale))
            {
                clipLabel += " " + clip.timeScale.ToString("F2") + "x";
            }

            DrawClipByDrawer(state, originRect, clipLabel, selected, drawRect.x);

            GUI.EndClip();

            if (clip.parentTrack != null && !clip.parentTrack.lockedInHierarchy)
            {
                if (selected && supportResize)
                {
                    var cursorRect = boundingRect;
                    cursorRect.xMin += m_LeftHandle.boundingRect.width;
                    cursorRect.xMax -= m_RightHandle.boundingRect.width;
                    EditorGUIUtility.AddCursorRect(cursorRect, MouseCursor.MoveArrow);
                }

                if (supportResize)
                {
                    var handleWidth = Mathf.Clamp(drawRect.width * 0.3f, k_MinHandleWidth, k_MaxHandleWidth);

                    m_LeftHandle.Draw(drawRect, handleWidth);
                    m_RightHandle.Draw(drawRect, handleWidth);

                    state.spacePartitioner.AddBounds(m_LeftHandle);
                    state.spacePartitioner.AddBounds(m_RightHandle);
                }
            }
        }
        void DrawInto(Rect drawRect, WindowState state)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            // create the inline curve editor if not already created
            CreateInlineCurveEditor(state);

            // @todo optimization, most of the calculations (rect, offsets, colors, etc.) could be cached
            // and rebuilt when the hash of the clip changes.

            if (isInvalid)
            {
                DrawInvalidClip(treeViewRect);
                return;
            }

            GUI.BeginClip(drawRect);

            var    originRect           = new Rect(0.0f, 0.0f, drawRect.width, drawRect.height);
            string clipLabel            = name;
            var    selected             = SelectionManager.Contains(clip);
            var    previousClipSelected = previousClip != null && SelectionManager.Contains(previousClip.clip);

            if (selected && 1.0 != clip.timeScale)
            {
                clipLabel += " " + clip.timeScale.ToString("F2") + "x";
            }

            UpdateDrawData(state, originRect, clipLabel, selected, previousClipSelected, drawRect.x);
            DrawClip(m_ClipDrawData);

            GUI.EndClip();

            if (clip.GetParentTrack() != null && !clip.GetParentTrack().lockedInHierarchy)
            {
                if (selected && supportResize)
                {
                    var cursorRect = rect;
                    cursorRect.xMin += leftHandle.boundingRect.width;
                    cursorRect.xMax -= rightHandle.boundingRect.width;
                    EditorGUIUtility.AddCursorRect(cursorRect, MouseCursor.MoveArrow);
                }

                if (supportResize)
                {
                    var handleWidth = Mathf.Clamp(drawRect.width * 0.3f, k_MinHandleWidth, k_MaxHandleWidth);

                    leftHandle.Draw(drawRect, handleWidth, state);
                    rightHandle.Draw(drawRect, handleWidth, state);
                }
            }
        }
Exemple #16
0
        protected override bool MouseDown(Event evt, WindowState state)
        {
            var handle = PickerUtils.PickedLayerableOfType <TimelineClipHandle>();

            if (handle == null)
            {
                return(false);
            }

            if (handle.clipGUI.clip.parentTrack != null && handle.clipGUI.clip.parentTrack.lockedInHierarchy)
            {
                return(false);
            }

            if (ItemSelection.CanClearSelection(evt))
            {
                SelectionManager.Clear();
            }

            if (!SelectionManager.Contains(handle.clipGUI.clip))
            {
                SelectionManager.Add(handle.clipGUI.clip);
            }

            m_TrimClipHandler = handle;

            m_IsCaptured = true;
            state.AddCaptured(this);

            m_UndoSaved = false;

            var clip = m_TrimClipHandler.clipGUI.clip;

            m_OriginalDuration        = clip.duration;
            m_OriginalTimeScale       = clip.timeScale;
            m_OriginalEaseInDuration  = clip.easeInDuration;
            m_OriginalEaseOutDuration = clip.easeOutDuration;

            RefreshOverlayStrings(m_TrimClipHandler, state);

            // in ripple trim, the right edge moves and needs to snap
            var edges = ManipulateEdges.Right;

            if (EditMode.editType != EditMode.EditType.Ripple && m_TrimClipHandler.trimDirection == TrimEdge.Start)
            {
                edges = ManipulateEdges.Left;
            }
            m_SnapEngine = new SnapEngine(m_TrimClipHandler.clipGUI, new TrimClipAttractionHandler(), edges, state,
                                          evt.mousePosition);

            EditMode.BeginTrim(ItemsUtils.ToItem(clip), m_TrimClipHandler.trimDirection);

            return(true);
        }
Exemple #17
0
        void DrawHeaderBackground(Rect headerRect)
        {
            Color backgroundColor = SelectionManager.Contains(track)
                ? DirectorStyles.Instance.customSkin.colorSelection
                : DirectorStyles.Instance.customSkin.colorTrackHeaderBackground;

            var bgRect = headerRect;

            bgRect.x     += m_Styles.trackSwatchStyle.fixedWidth;
            bgRect.width -= m_Styles.trackSwatchStyle.fixedWidth;

            EditorGUI.DrawRect(bgRect, backgroundColor);
        }
Exemple #18
0
        protected void DrawBackground(Rect trackRect, TimelineWindow.TimelineState state)
        {
            bool flag = this.IsRecording(state) && (this.m_InfiniteTrackDrawer == null || this.m_InfiniteTrackDrawer.CanDraw(base.track, state));

            if (flag)
            {
                this.DrawRecordingTrackBackground(trackRect);
            }
            else
            {
                Color color = (!SelectionManager.Contains(base.track)) ? DirectorStyles.Instance.customSkin.colorTrackBackground : DirectorStyles.Instance.customSkin.colorTrackBackgroundSelected;
                EditorGUI.DrawRect(trackRect, color);
            }
        }
Exemple #19
0
        public static bool Contains(ITimelineItem item)
        {
            TimelineClip timelineClip = item as TimelineClip;
            bool         result;

            if (timelineClip != null)
            {
                result = SelectionManager.Contains(timelineClip);
            }
            else
            {
                TimelineMarker timelineMarker = item as TimelineMarker;
                result = (timelineMarker != null && SelectionManager.Contains(timelineMarker));
            }
            return(result);
        }
Exemple #20
0
        public static TrackAsset Clone(PlayableAsset parent, TrackAsset trackAsset, PlayableDirector directorInstance)
        {
            TrackAsset result;

            if (trackAsset == null)
            {
                result = null;
            }
            else
            {
                TimelineAsset timelineAsset = trackAsset.timelineAsset;
                if (timelineAsset == null)
                {
                    result = null;
                }
                else
                {
                    TrackAsset trackAsset2 = Object.Instantiate <TrackAsset>(trackAsset);
                    trackAsset2.SetClips(new List <TimelineClip>());
                    trackAsset2.parent    = parent;
                    trackAsset2.subTracks = new List <TrackAsset>();
                    string[] array = (from x in timelineAsset.flattenedTracks
                                      select x.get_name()).ToArray <string>();
                    trackAsset2.set_name(ObjectNames.GetUniqueName(array, trackAsset.get_name()));
                    if (trackAsset.animClip != null)
                    {
                        trackAsset2.animClip = TimelineHelpers.CloneAnimationClipIfRequired(trackAsset.animClip, trackAsset);
                    }
                    TimelineClip[] clips = trackAsset.clips;
                    for (int i = 0; i < clips.Length; i++)
                    {
                        TimelineClip clip         = clips[i];
                        TimelineClip timelineClip = TimelineHelpers.Clone(clip, directorInstance);
                        timelineClip.parentTrack = trackAsset2;
                        trackAsset2.AddClip(timelineClip);
                    }
                    trackAsset2.SetCollapsed(trackAsset.GetCollapsed());
                    if (SelectionManager.Contains(trackAsset))
                    {
                        SelectionManager.Remove(trackAsset);
                        SelectionManager.Add(trackAsset2);
                    }
                    result = trackAsset2;
                }
            }
            return(result);
        }
Exemple #21
0
        float DrawTrackDropDownMenu(Rect rect)
        {
            rect.y += WindowConstants.trackOptionButtonVerticalPadding;

            if (GUI.Button(rect, GUIContent.none, m_Styles.trackOptions))
            {
                // the drop down will apply to all selected tracks
                if (!SelectionManager.Contains(track))
                {
                    SelectionManager.Clear();
                    SelectionManager.Add(track);
                }

                SequencerContextMenu.ShowTrackContextMenu(SelectionManager.SelectedTracks().ToArray(), null);
            }

            return(WindowConstants.trackHeaderButtonSize);
        }
Exemple #22
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);
            }
        }
Exemple #23
0
        public override void Draw(Rect trackRect, bool trackRectChanged, WindowState state)
        {
            UpdateDrawData();

            // compute marker hash
            var currentMarkerHash = ComputeDirtyHash();

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

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

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

            if (Event.current.type == EventType.Repaint && showMarkers && !parent.locked)
            {
                state.spacePartitioner.AddBounds(this, rect);
            }
        }
Exemple #24
0
        private void DrawTrackBinding(Rect rect, Rect headerRect, TimelineWindow.TimelineState state)
        {
            if (this.showSceneReference)
            {
                if (state.currentDirector != null)
                {
                    this.DoTrackBindingGUI(rect, headerRect, state);
                    return;
                }
            }
            GUIStyle trackHeaderFont = this.m_Styles.trackHeaderFont;

            trackHeaderFont.get_normal().set_textColor((!SelectionManager.Contains(base.track)) ? this.m_Styles.customSkin.colorTrackFont : Color.get_white());
            bool   flag = false;
            string text = base.drawer.GetCustomTitle(base.track);

            if (string.IsNullOrEmpty(text))
            {
                flag = true;
                text = TimelineTrackGUI.GetTrackDisplayName(base.track, state);
            }
            rect.set_width(this.m_Styles.trackHeaderFont.CalcSize(new GUIContent(text)).x);
            if (flag)
            {
                if (GUIUtility.get_keyboardControl() == base.track.GetInstanceID())
                {
                    Rect rect2 = rect;
                    rect2.set_width(headerRect.get_xMax() - rect.get_xMin() - 80f);
                    base.track.set_name(EditorGUI.DelayedTextField(rect2, GUIContent.none, base.track.GetInstanceID(), base.track.get_name(), trackHeaderFont));
                }
                else
                {
                    EditorGUI.DelayedTextField(rect, GUIContent.none, base.track.GetInstanceID(), text, trackHeaderFont);
                }
            }
            else
            {
                EditorGUI.LabelField(rect, text, trackHeaderFont);
            }
        }
 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
         {
             TimelineClipGUI timelineClipGUI = target as TimelineClipGUI;
             if (!SelectionManager.Contains(timelineClipGUI.clip))
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 result = ItemAction <TimelineClip> .HandleShortcut(state, evt, timelineClipGUI.clip);
             }
         }
         return(result);
     };
 }
 public override void Init(IControl parent)
 {
     parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         this.m_UndoSet    = false;
         this.m_IsCaptured = (this.m_CaptureOnNextMouseDrag = false);
         bool result;
         if (evt.get_modifiers() == 4 || evt.get_button() == 2 || evt.get_button() == 1)
         {
             result = base.IgnoreEvent();
         }
         else if (!SelectionManager.IsMouseHoveringOnItem())
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target;
             if (!SelectionManager.Contains(timelineClipGUI.clip))
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 this.m_FrameSnap.Reset();
                 this.m_CaptureOnNextMouseDrag = true;
                 this.m_MouseDownPosition      = evt.get_mousePosition();
                 this.m_HasValidDropTarget     = false;
                 result = base.ConsumeEvent();
             }
         }
         return(result);
     };
     parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (!this.m_IsCaptured)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             this.m_MagnetEngine = null;
             if (this.m_IsVerticalDrag)
             {
                 state.captured.Clear();
                 this.m_IsVerticalDrag = false;
                 state.isDragging      = false;
                 if (this.m_HasValidDropTarget && this.m_DropTarget != null)
                 {
                     TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target;
                     if (TrackExtensions.MoveClipToTrack(timelineClipGUI.clip, this.m_DropTarget.track))
                     {
                         timelineClipGUI.clip.start = (double)state.PixelToTime(this.m_PreviewRect.get_x());
                         timelineClipGUI.parentTrackGUI.SortClipsByStartTime();
                         this.m_DropTarget.SortClipsByStartTime();
                         state.Refresh();
                     }
                 }
             }
             state.Evaluate();
             state.captured.Remove(target as IControl);
             this.m_IsCaptured   = false;
             this.m_IsDragDriver = false;
             result = base.ConsumeEvent();
         }
         return(result);
     };
     parent.DragExited += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         this.m_IsVerticalDrag = false;
         return(base.IgnoreEvent());
     };
     parent.MouseDrag += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         if (!this.m_IsCaptured && this.m_CaptureOnNextMouseDrag)
         {
             state.captured.Add(target as IControl);
             this.m_IsCaptured             = true;
             this.m_CaptureOnNextMouseDrag = false;
             TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target;
             this.m_IsDragDriver = MoveItemUtilities.IsDriver(timelineClipGUI, evt, state);
             if (this.m_IsDragDriver)
             {
                 this.m_DragPixelOffset    = Vector2.get_zero();
                 this.m_IsDragDriverActive = false;
                 if (!SelectionManager.IsMultiSelect() && state.edgeSnaps)
                 {
                     this.m_MagnetEngine = new MagnetEngine(timelineClipGUI, new MoveClipAttractionHandler(), state);
                 }
             }
         }
         bool result;
         if (!this.m_IsCaptured)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             TimelineClipGUI timelineClipGUI2 = (TimelineClipGUI)target;
             if (SelectionManager.Count() == 1)
             {
                 TimelineClipGUI timelineClipGUI3 = SelectionManager.SelectedClipGUI().FirstOrDefault <TimelineClipGUI>();
                 if (timelineClipGUI3 != null)
                 {
                     TimelineTrackGUI dropTargetAt = MoveClip.GetDropTargetAt(state, evt.get_mousePosition());
                     if (dropTargetAt != null)
                     {
                         bool flag = dropTargetAt != timelineClipGUI3.parentTrackGUI;
                         if (flag && !this.m_IsVerticalDrag)
                         {
                             state.isDragging           = true;
                             this.m_HasValidDropTarget  = false;
                             this.m_DropTarget          = null;
                             this.m_MouseDownPosition.x = evt.get_mousePosition().x;
                             this.m_PreviewOffset       = this.m_MouseDownPosition - timelineClipGUI2.bounds.get_position();
                         }
                         else if (this.m_IsVerticalDrag && !flag)
                         {
                             state.isDragging          = false;
                             this.m_HasValidDropTarget = false;
                             this.m_DropTarget         = null;
                             this.m_DragPixelOffset    = evt.get_mousePosition() - this.m_MouseDownPosition - evt.get_delta();
                         }
                         this.m_IsVerticalDrag = flag;
                     }
                 }
             }
             if (this.m_IsVerticalDrag)
             {
                 this.m_PreviewRect = new Rect(evt.get_mousePosition().x, evt.get_mousePosition().y, timelineClipGUI2.bounds.get_width(), timelineClipGUI2.bounds.get_height());
                 this.m_PreviewRect.set_position(this.m_PreviewRect.get_position() - this.m_PreviewOffset);
                 this.UpdateDragTarget(timelineClipGUI2, evt.get_mousePosition(), state);
                 result = base.ConsumeEvent();
             }
             else
             {
                 if (this.m_IsDragDriver)
                 {
                     this.m_DragPixelOffset    += evt.get_delta();
                     this.m_IsDragDriverActive |= (Math.Abs(this.m_DragPixelOffset.x) > MoveClip.kDragBufferInPixels);
                     if (this.m_IsDragDriverActive)
                     {
                         float delta = this.m_DragPixelOffset.x / state.timeAreaScale.x;
                         this.m_DragPixelOffset = Vector3.get_zero();
                         this.SetUndo();
                         if (SelectionManager.IsMultiSelect())
                         {
                             double currentValue = (from x in SelectionManager.SelectedItems <TimelineClip>()
                                                    select x.start).DefaultIfEmpty(timelineClipGUI2.clip.start).Min();
                             this.m_FrameSnap.ApplyOffset(currentValue, delta, state);
                             foreach (TimelineClip current in from x in SelectionManager.SelectedItems <TimelineClip>()
                                      orderby x.start
                                      select x)
                             {
                                 if (current.start + this.m_FrameSnap.lastOffsetApplied < 0.0)
                                 {
                                     break;
                                 }
                                 current.start += this.m_FrameSnap.lastOffsetApplied;
                             }
                         }
                         else
                         {
                             timelineClipGUI2.clip.start = this.m_FrameSnap.ApplyOffset(timelineClipGUI2.clip.start, delta, state);
                         }
                         if (this.m_MagnetEngine != null)
                         {
                             this.m_MagnetEngine.Snap(evt.get_delta().x);
                         }
                         timelineClipGUI2.InvalidateEditor();
                         timelineClipGUI2.parentTrackGUI.SortClipsByStartTime();
                         state.Evaluate();
                     }
                 }
                 result = base.ConsumeEvent();
             }
         }
         return(result);
     };
     parent.Overlay += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         if (this.m_MagnetEngine != null)
         {
             this.m_MagnetEngine.OnGUI();
         }
         bool result;
         if (this.m_IsVerticalDrag)
         {
             TimelineClipGUI timelineClipGUI = (TimelineClipGUI)target;
             Color           color           = (!this.m_HasValidDropTarget) ? DirectorStyles.Instance.customSkin.colorInvalidDropTarget : DirectorStyles.Instance.customSkin.colorValidDropTarget;
             timelineClipGUI.DrawDragPreview(this.m_PreviewRect, color);
             result = base.ConsumeEvent();
         }
         else if (this.m_IsDragDriver)
         {
             IEnumerable <TimelineClip> enumerable = SelectionManager.SelectedItems <TimelineClip>();
             double num  = 1.7976931348623157E+308;
             double num2 = -1.7976931348623157E+308;
             foreach (TimelineClip current in enumerable)
             {
                 if (current.start < num)
                 {
                     num = current.start;
                 }
                 if (current.end > num2)
                 {
                     num2 = current.end;
                 }
             }
             this.m_SelectionIndicator.Draw(num, num2, this.m_MagnetEngine);
             result = base.ConsumeEvent();
         }
         else
         {
             result = base.IgnoreEvent();
         }
         return(result);
     };
 }
        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);
        }
 public override void Init(IControl parent)
 {
     parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (state.IsCurrentEditingASequencerTextField())
         {
             result = base.IgnoreEvent();
         }
         else if (evt.get_button() != 0 && evt.get_button() != 1)
         {
             result = base.IgnoreEvent();
         }
         else if (evt.get_modifiers() == 4)
         {
             result = base.IgnoreEvent();
         }
         else if (TimelineWindow.instance.sequenceHeaderBounds.Contains(evt.get_mousePosition()))
         {
             foreach (TimelineTrackBaseGUI current in TimelineWindow.instance.allTracks)
             {
                 Rect headerBounds = current.headerBounds;
                 headerBounds.set_y(headerBounds.get_y() + TimelineWindow.instance.treeviewBounds.get_y());
                 if (headerBounds.Contains(evt.get_mousePosition()))
                 {
                     result = base.IgnoreEvent();
                     return(result);
                 }
             }
             if (evt.get_modifiers() == null)
             {
                 SelectionManager.Clear();
             }
             result = base.IgnoreEvent();
         }
         else
         {
             this.m_ActiveRect = TimelineWindow.instance.clipArea;
             if (!this.m_ActiveRect.Contains(evt.get_mousePosition()))
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 List <IBounds> elementsAtPosition = Manipulator.GetElementsAtPosition(state.quadTree, evt.get_mousePosition());
                 bool           flag;
                 if (!RectangleSelect.CanStartRectableSelect(evt, elementsAtPosition, out flag))
                 {
                     if (flag)
                     {
                         RectangleSelect.HandleReselection(elementsAtPosition);
                     }
                     else
                     {
                         RectangleSelect.HandleSingleSelection(evt, state, elementsAtPosition);
                     }
                     result = base.IgnoreEvent();
                 }
                 else
                 {
                     state.captured.Add(target as IControl);
                     this.m_IsCaptured = true;
                     this.m_Start      = evt.get_mousePosition();
                     this.m_End        = evt.get_mousePosition();
                     if (RectangleSelect.CanClearSelection(evt))
                     {
                         SelectionManager.Clear();
                     }
                     result = base.IgnoreEvent();
                 }
             }
         }
         return(result);
     };
     parent.KeyDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (this.m_IsCaptured && evt.get_keyCode() == 27)
         {
             state.captured.Remove(target as IControl);
             this.m_IsCaptured = false;
             result            = base.ConsumeEvent();
         }
         else
         {
             result = base.IgnoreEvent();
         }
         return(result);
     };
     parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (!this.m_IsCaptured)
         {
             if (evt.get_modifiers() == null && evt.get_button() == 0 && SelectionManager.IsMultiSelect())
             {
                 List <IBounds>  elementsAtPosition = Manipulator.GetElementsAtPosition(state.quadTree, evt.get_mousePosition());
                 TimelineItemGUI timelineItemGUI    = RectangleSelect.PickItemGUI(elementsAtPosition);
                 if (timelineItemGUI != null && SelectionManager.Contains(timelineItemGUI.item))
                 {
                     SelectionManager.Clear();
                     SelectionManager.Add(timelineItemGUI.item);
                 }
             }
             result = base.IgnoreEvent();
         }
         else
         {
             state.captured.Remove(target as IControl);
             this.m_IsCaptured = false;
             Rect r = this.CurrentSelectionRect();
             if (r.get_width() < 1f || r.get_height() < 1f)
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 List <IBounds> elementsInRectangle = Manipulator.GetElementsInRectangle(state.quadTree, r);
                 if (elementsInRectangle.Count == 0)
                 {
                     result = base.IgnoreEvent();
                 }
                 else
                 {
                     if (RectangleSelect.CanClearSelection(evt))
                     {
                         SelectionManager.Clear();
                     }
                     foreach (IBounds current in elementsInRectangle)
                     {
                         if (!(current is TimelineGroupGUI))
                         {
                             if (current is TimelineItemGUI)
                             {
                                 SelectionManager.Add(((TimelineItemGUI)current).item);
                             }
                         }
                     }
                     result = base.ConsumeEvent();
                 }
             }
         }
         return(result);
     };
     parent.MouseDrag += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (!this.m_IsCaptured)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             this.m_End = evt.get_mousePosition();
             result     = base.ConsumeEvent();
         }
         return(result);
     };
     parent.Overlay += new TimelineUIEvent(this.DrawSelection);
 }
 public override bool IsSelected()
 {
     return(SelectionManager.Contains(clip));
 }
Exemple #30
0
        public override void Draw(Rect headerRect, Rect trackRect, TimelineWindow.TimelineState state, float identWidth)
        {
            if (base.track.GetShowInlineCurves() && this.inlineCurveEditor == null)
            {
                this.inlineCurveEditor = new InlineCurveEditor(this);
            }
            this.UpdateInfiniteClipEditor(base.track as AnimationTrack, state.GetWindow());
            Rect  trackRect2 = trackRect;
            float num        = this.InlineAnimationCurveHeight();

            trackRect.set_height(trackRect.get_height() - num);
            if (Event.get_current().get_type() == 7)
            {
                this.m_TrackRect = trackRect;
                state.quadTree.Insert(this);
                int num2 = this.BlendHash();
                if (this.m_BlendHash != num2)
                {
                    this.UpdateClipOverlaps();
                    this.m_BlendHash = num2;
                }
                base.isDropTarget = false;
            }
            if (TimelineTrackGUI.s_ArmForRecordContentOn == null)
            {
                TimelineTrackGUI.s_ArmForRecordContentOn = new GUIContent(TimelineWindow.styles.autoKey.get_active().get_background());
            }
            if (TimelineTrackGUI.s_ArmForRecordContentOff == null)
            {
                TimelineTrackGUI.s_ArmForRecordContentOff = new GUIContent(TimelineWindow.styles.autoKey.get_normal().get_background());
            }
            base.track.SetCollapsed(!base.isExpanded);
            headerRect.set_width(headerRect.get_width() - 2f);
            if (this.m_TrackHash != base.track.Hash())
            {
                this.RebuildGUICache(state);
            }
            bool    flag = false;
            Vector2 timeAreaShownRange = state.timeAreaShownRange;

            if (base.drawer != null)
            {
                flag = base.drawer.DrawTrack(trackRect, base.track, timeAreaShownRange, state);
            }
            if (!flag)
            {
                using (new GUIViewportScope(trackRect))
                {
                    this.DrawBackground(trackRect, state);
                    if (this.resortClips)
                    {
                        int num3 = 0;
                        this.SortClipsByStartTime();
                        this.ResetClipParityID();
                        foreach (TimelineClipGUI current in this.m_ClipGUICache)
                        {
                            current.parityID = this.GetNextClipParityID();
                            current.zOrder   = num3++;
                            if (SelectionManager.Contains(current.clip))
                            {
                                current.zOrder += 1000;
                            }
                        }
                        IEnumerable <TimelineClipGUI> selectedClips = SelectionManager.SelectedClipGUI();
                        this.m_ClipGUICache = (from x in this.m_ClipGUICache
                                               orderby selectedClips.Contains(x), x.clip.start
                                               select x).ToList <TimelineClipGUI>();
                        this.resortClips = false;
                    }
                    if (this.resortEvents)
                    {
                        int num4 = 0;
                        this.SortEventsByStartTime();
                        foreach (TimelineMarkerGUI current2 in this.m_MarkerGuiCache)
                        {
                            current2.zOrder = num4++;
                            if (SelectionManager.Contains(current2.timelineMarker))
                            {
                                current2.zOrder += 1000;
                            }
                        }
                        IEnumerable <TimelineMarkerGUI> selectedMarkers = SelectionManager.SelectedMarkerGUI();
                        this.m_MarkerGuiCache = (from x in this.m_MarkerGuiCache
                                                 orderby selectedMarkers.Contains(x), x.timelineMarker.time
                                                 select x).ToList <TimelineMarkerGUI>();
                        this.resortEvents = false;
                    }
                    this.DrawClips(trackRect, state);
                    this.DrawEvents(trackRect, state);
                    this.DrawClipConnectors();
                }
                if (this.m_InfiniteTrackDrawer != null)
                {
                    this.m_InfiniteTrackDrawer.DrawTrack(trackRect, base.track, timeAreaShownRange, state);
                }
            }
            this.DrawTrackHeader(headerRect, state, identWidth, num);
            this.DrawInlineCurves(headerRect, trackRect2, state, identWidth, num);
            this.DrawMuteState(trackRect, state);
            this.DrawLockState(trackRect, state);
        }