internal void OnGUI(Rect clientRect, CurvePresetLibrary presets)
 {
     if (this.InitStyles())
     {
         if (this.m_Curves != null && this.m_Curves.Length != 0)
         {
             Rect rect  = new Rect(clientRect.get_x(), clientRect.get_y(), clientRect.get_width(), 30f);
             Rect rect2 = new Rect(clientRect.get_x(), clientRect.get_y() + rect.get_height(), clientRect.get_width(), clientRect.get_height() - 30f - 30f);
             Rect rect3 = new Rect(clientRect.get_x() + 30f, clientRect.get_y() + rect2.get_height() + 30f, clientRect.get_width() - 30f, 30f);
             GUI.Box(rect, this.headerString, this.m_LabelStyle);
             this.m_CurveEditor.set_rect(rect2);
             this.m_CurveEditor.set_shownAreaInsideMargins(new Rect(0f, 0f, 1f, 1f));
             this.m_CurveEditor.set_animationCurves(this.m_CurveWrappers);
             this.UpdateSelectionColors();
             this.DrawTrackHead(rect2);
             EditorGUI.BeginChangeCheck();
             this.m_CurveEditor.OnGUI();
             this.DrawPresets(rect3, presets);
             bool flag = EditorGUI.EndChangeCheck();
             if (presets == null)
             {
                 this.DrawLegend(rect3);
             }
             if (flag)
             {
                 this.ProcessUpdates();
             }
         }
     }
 }
Esempio n. 2
0
        internal void OnGUI(Rect clientRect, CurvePresetLibrary presets)
        {
            const float presetPad = 30.0f;

            if (!InitStyles())
            {
                return;
            }

            if (m_Curves == null || m_Curves.Length == 0)
            {
                return;
            }

            // regions
            var headerRect = new Rect(clientRect.x, clientRect.y, clientRect.width, k_HeaderHeight);
            var curveRect  = new Rect(clientRect.x, clientRect.y + headerRect.height, clientRect.width, clientRect.height - k_HeaderHeight - k_PresetHeight);
            var presetRect = new Rect(clientRect.x + presetPad, clientRect.y + curveRect.height + k_HeaderHeight, clientRect.width - presetPad, k_PresetHeight);

            GUI.Box(headerRect, headerString, m_LabelStyle);

            //Case 1201474 : Force to update only when Repaint event is called as the new rect provided on other event create a wrong curve editor computation.
            if (Event.current.type == EventType.Repaint)
            {
                m_CurveEditor.rect = curveRect;
                m_CurveEditor.shownAreaInsideMargins = new Rect(0, 0, 1, 1);
            }
            m_CurveEditor.animationCurves = m_CurveWrappers;
            UpdateSelectionColors();

            DrawTrackHead(curveRect);

            EditorGUI.BeginChangeCheck();

            m_CurveEditor.OnGUI();
            DrawPresets(presetRect, presets);

            bool hasChanged = EditorGUI.EndChangeCheck();

            if (presets == null)
            {
                DrawLegend(presetRect);
            }

            if (hasChanged)
            {
                ProcessUpdates();
            }

            ConsumeMouseEvents(clientRect);
        }
Esempio n. 3
0
 // Callback when the mixin/mixout properties are clicked on
 void OnMixCurveSelected(string title, CurvePresetLibrary library, SerializedProperty curveSelected, bool easeIn)
 {
     m_CurvePresets  = library;
     m_PreviewCurves = new[] { curveSelected.animationCurveValue };
     m_ClipCurveEditor.headerString = title;
     m_ClipCurveEditor.SetCurves(m_PreviewCurves, null);
     m_ClipCurveEditor.SetSelected(curveSelected.animationCurveValue);
     if (easeIn)
     {
         m_ClipCurveEditor.SetUpdateCurveCallback(MixInCurveUpdated);
     }
     else
     {
         m_ClipCurveEditor.SetUpdateCurveCallback(MixOutCurveUpdated);
     }
     Repaint();
 }
        internal void OnGUI(Rect clientRect, CurvePresetLibrary presets)
        {
            const float presetPad = 30.0f;

            if (!InitStyles())
            {
                return;
            }

            if (m_Curves == null || m_Curves.Length == 0)
            {
                return;
            }

            // regions
            var headerRect = new Rect(clientRect.x, clientRect.y, clientRect.width, k_HeaderHeight);
            var curveRect  = new Rect(clientRect.x, clientRect.y + headerRect.height, clientRect.width, clientRect.height - k_HeaderHeight - k_PresetHeight);
            var presetRect = new Rect(clientRect.x + presetPad, clientRect.y + curveRect.height + k_HeaderHeight, clientRect.width - presetPad, k_PresetHeight);

            GUI.Box(headerRect, headerString, m_LabelStyle);

            m_CurveEditor.rect = curveRect;
            m_CurveEditor.shownAreaInsideMargins = new Rect(0, 0, 1, 1);
            m_CurveEditor.animationCurves        = m_CurveWrappers;
            UpdateSelectionColors();

            DrawTrackHead(curveRect);

            EditorGUI.BeginChangeCheck();

            m_CurveEditor.OnGUI();
            DrawPresets(presetRect, presets);

            bool hasChanged = EditorGUI.EndChangeCheck();

            if (presets == null)
            {
                DrawLegend(presetRect);
            }

            if (hasChanged)
            {
                ProcessUpdates();
            }
        }
        // Callback when the mixin/mixout properties are clicked on
        void OnMixCurveSelected(string title, CurvePresetLibrary library, SerializedProperty curveSelected, bool easeIn)
        {
            m_PreviewCurveState = easeIn ? PreviewCurveState.MixIn : PreviewCurveState.MixOut;

            m_CurvePresets = library;
            var animationCurve = curveSelected.animationCurveValue;

            m_ClipCurveEditor.headerString = title;
            m_ClipCurveEditor.SetCurve(animationCurve);
            m_ClipCurveEditor.SetSelected(animationCurve);
            if (easeIn)
            {
                m_ClipCurveEditor.SetUpdateCurveCallback(MixInCurveUpdated);
            }
            else
            {
                m_ClipCurveEditor.SetUpdateCurveCallback(MixOutCurveUpdated);
            }
            Repaint();
        }
 private void OnMixCurveSelected(string title, CurvePresetLibrary library, SerializedProperty curveSelected, bool easeIn)
 {
     this.m_CurvePresets  = library;
     this.m_PreviewCurves = new AnimationCurve[]
     {
         curveSelected.get_animationCurveValue()
     };
     this.m_ClipCurveEditor.headerString = title;
     this.m_ClipCurveEditor.SetCurves(this.m_PreviewCurves, null);
     this.m_ClipCurveEditor.SetSelected(curveSelected.get_animationCurveValue());
     if (easeIn)
     {
         this.m_ClipCurveEditor.SetUpdateCurveCallback(new Action <AnimationCurve, EditorCurveBinding>(this.MixInCurveUpdated));
     }
     else
     {
         this.m_ClipCurveEditor.SetUpdateCurveCallback(new Action <AnimationCurve, EditorCurveBinding>(this.MixOutCurveUpdated));
     }
     base.Repaint();
 }
        void OnGUI()
        {
            bool gotMouseUp = (Event.current.type == EventType.MouseUp);

            if (delegateView == null && m_OnCurveChanged == null)
            {
                m_Curve = null;
            }

            if (ms_Styles == null)
            {
                ms_Styles = new Styles();
            }

            // Curve Editor
            m_CurveEditor.rect         = GetCurveEditorRect();
            m_CurveEditor.hRangeLocked = Event.current.shift;
            m_CurveEditor.vRangeLocked = EditorGUI.actionKey;

            GUI.changed = false;

            GUI.Label(m_CurveEditor.drawRect, GUIContent.none, ms_Styles.curveEditorBackground);
            m_CurveEditor.OnGUI();

            // Preset swatch area
            GUI.Box(new Rect(0, position.height - kPresetsHeight, position.width, kPresetsHeight), "", ms_Styles.curveSwatchArea);
            Color curveColor = m_Color;

            curveColor.a *= 0.6f;
            const float margin = 45f;
            const float width  = 40f;
            const float height = 25f;
            float       yPos   = position.height - kPresetsHeight + (kPresetsHeight - height) * 0.5f;

            InitCurvePresets();
            CurvePresetLibrary curveLibrary = m_CurvePresets.GetPresetLibraryEditor().GetCurrentLib();

            if (curveLibrary != null)
            {
                for (int i = 0; i < curveLibrary.Count(); i++)
                {
                    Rect swatchRect = new Rect(margin + (width + 5f) * i, yPos, width, height);
                    m_GUIContent.tooltip = curveLibrary.GetName(i);
                    if (GUI.Button(swatchRect, m_GUIContent, ms_Styles.curveSwatch))
                    {
                        AnimationCurve animCurve = curveLibrary.GetPreset(i) as AnimationCurve;
                        m_Curve.keys         = GetDenormalizedKeys(animCurve.keys);
                        m_Curve.postWrapMode = animCurve.postWrapMode;
                        m_Curve.preWrapMode  = animCurve.preWrapMode;
                        m_CurveEditor.SelectNone();
                        SendEvent(CurveChangedCommand, true);
                    }
                    if (Event.current.type == EventType.Repaint)
                    {
                        curveLibrary.Draw(swatchRect, i);
                    }

                    if (swatchRect.xMax > position.width - 2 * margin)
                    {
                        break;
                    }
                }
            }

            Rect presetDropDownButtonRect = new Rect(margin - 20f, yPos + 5f, 20, 20);

            PresetDropDown(presetDropDownButtonRect);

            // For adding default preset curves
            //if (EditorGUI.DropdownButton(new Rect (position.width -26, yPos, 20, 20), GUIContent.none, FocusType.Passive, "OL Plus"))
            //  AddDefaultPresetsToCurrentLib ();

            if (Event.current.type == EventType.Used && gotMouseUp)
            {
                DoUpdateCurve(false);
                SendEvent(CurveChangeCompletedCommand, true);
            }
            else if (Event.current.type != EventType.Layout && Event.current.type != EventType.Repaint)
            {
                DoUpdateCurve(true);
            }
        }