void OnGUI()
{
bool gotMouseUp = (Event.current.type == EventType.MouseUp);
if (m_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);
}
}