Esempio n. 1
0
        static void DrawCurveEditor(IClipCurveEditorOwner clipCurveEditorOwner, WindowState state, Rect headerRect, Rect trackRect, Vector2 activeRange, bool locked)
        {
            ClipCurveEditor clipCurveEditor = clipCurveEditorOwner.clipCurveEditor;
            CurveDataSource dataSource      = clipCurveEditor.dataSource;
            Rect            curveRect       = dataSource.GetBackgroundRect(state);

            bool newlySelected = false;

            if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.ContextClick)
            {
                newlySelected = MouseOverTrackArea(curveRect, trackRect) || MouseOverHeaderArea(headerRect, trackRect);
            }

            // make sure to not use any event before drawing the curve.
            bool prevEnabledState = GUI.enabled;

            GUI.enabled = true;
            clipCurveEditorOwner.clipCurveEditor.DrawHeader(headerRect);
            GUI.enabled = prevEnabledState;

            bool displayAsSelected = !locked && (clipCurveEditorOwner.inlineCurvesSelected || newlySelected);

            using (new EditorGUI.DisabledScope(locked))
                clipCurveEditor.DrawCurveEditor(trackRect, state, activeRange, clipCurveEditorOwner.showLoops, displayAsSelected);

            if (newlySelected && !locked)
            {
                clipCurveEditorOwner.inlineCurvesSelected = true;
                HandleCurrentEvent();
            }
        }
        void CreateInlineCurveEditor(WindowState state)
        {
            if (clipCurveEditor != null)
            {
                return;
            }

            var animationClip = clip.animationClip;

            if (animationClip != null && animationClip.empty)
            {
                animationClip = null;
            }

            // prune out clips coming from FBX
            if (animationClip != null && !clip.recordable)
            {
                return; // don't show, even if there are curves
            }
            if (animationClip == null && !clip.HasAnyAnimatableParameters())
            {
                return; // nothing to show
            }
            state.AddEndFrameDelegate((istate, currentEvent) =>
            {
                clipCurveEditor = new ClipCurveEditor(CurveDataSource.Create(this), TimelineWindow.instance, clip.GetParentTrack());
                return(true);
            });
        }
 public BindingTreeViewDataSource(
     TreeViewController treeView, AnimationClip clip, CurveDataSource curveDataSource)
     : base(treeView)
 {
     m_Clip            = clip;
     showRootItem      = false;
     m_CurveDataSource = curveDataSource;
 }
Esempio n. 4
0
        void UpdateInfiniteClipEditor(TimelineWindow window)
        {
            if (clipCurveEditor != null || track == null || !track.ShouldShowInfiniteClipEditor())
            {
                return;
            }

            var dataSource = CurveDataSource.Create(this);

            clipCurveEditor = new ClipCurveEditor(dataSource, window, track);
        }
        public void InitIfNeeded(Rect rect, CurveDataSource dataSource, bool isNewSelection)
        {
            if (Event.current.type != EventType.Layout)
            {
                return;
            }

            m_CurveDataSource = dataSource;
            var clip = dataSource.animationClip;

            List <EditorCurveBinding> allBindings = new List <EditorCurveBinding>();

            allBindings.Add(new EditorCurveBinding {
                propertyName = "Summary"
            });
            if (clip != null)
            {
                allBindings.AddRange(AnimationUtility.GetCurveBindings(clip));
            }

            m_DopeLines.list = allBindings.ToArray();

            if (m_TreeViewState != null)
            {
                if (isNewSelection)
                {
                    RefreshAll();
                }

                return;
            }

            m_TreeViewState = m_TrackGlobalTreeViewState != null ? m_TrackGlobalTreeViewState : new TreeViewState();

            m_TreeView = new TreeViewController(m_Window, m_TreeViewState)
            {
                useExpansionAnimation        = false,
                deselectOnUnhandledMouseDown = true
            };

            m_TreeView.selectionChangedCallback += OnItemSelectionChanged;

            m_TreeViewDataSource = new BindingTreeViewDataSource(m_TreeView, clip, m_CurveDataSource);

            m_TreeViewGUI = new BindingTreeViewGUI(m_TreeView);
            m_TreeView.Init(rect, m_TreeViewDataSource, m_TreeViewGUI, null);

            m_TreeViewDataSource.UpdateData();

            RefreshSelection();
        }
Esempio n. 6
0
        static void DrawCurveEditor(IClipCurveEditorOwner clipCurveEditorOwner, WindowState state, Rect headerRect, Rect trackRect, Vector2 activeRange, bool locked)
        {
            ClipCurveEditor clipCurveEditor = clipCurveEditorOwner.clipCurveEditor;
            CurveDataSource dataSource      = clipCurveEditor.dataSource;
            Rect            curveRect       = dataSource.GetBackgroundRect(state);

            bool newlySelected = false;

            if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.ContextClick)
            {
                newlySelected = MouseOverTrackArea(curveRect, trackRect) || MouseOverHeaderArea(headerRect, trackRect);
            }

            // make sure to not use any event before drawing the curve.
            bool prevEnabledState = GUI.enabled;

            GUI.enabled = true;
            clipCurveEditorOwner.clipCurveEditor.DrawHeader(headerRect);
            GUI.enabled = prevEnabledState;

            bool displayAsSelected = !locked && (clipCurveEditorOwner.inlineCurvesSelected || newlySelected);

            using (new EditorGUI.DisabledScope(locked))
            {
                using (new GUIViewportScope(trackRect))
                {
                    Rect animEditorRect = curveRect;
                    animEditorRect.y      = trackRect.y;
                    animEditorRect.height = trackRect.height;

                    // clamp the curve editor to the track. this allows the menu to scroll properly
                    animEditorRect.xMin = Mathf.Max(animEditorRect.xMin, trackRect.xMin);
                    animEditorRect.xMax = trackRect.xMax;

                    if (activeRange == Vector2.zero)
                    {
                        activeRange = new Vector2(animEditorRect.xMin, animEditorRect.xMax);
                    }

                    clipCurveEditor.DrawCurveEditor(animEditorRect, state, activeRange, clipCurveEditorOwner.showLoops, displayAsSelected);
                }
            }

            if (newlySelected && !locked)
            {
                clipCurveEditorOwner.inlineCurvesSelected = true;
                HandleCurrentEvent();
            }
        }