@@ -30,12 +30,13 @@ public enum NormalizationMode
30
30
}
31
31
32
32
//const int kToolbarHeight = 17;
33
- const int kPresetsHeight = 46 ;
33
+ const int kPresetsHeight = 50 ;
34
34
35
35
static CurveEditorWindow s_SharedCurveEditor ;
36
36
37
37
internal CurveEditor m_CurveEditor ;
38
38
39
+ Vector2 m_PresetScrollPosition ;
39
40
AnimationCurve m_Curve ;
40
41
Color m_Color ;
41
42
@@ -476,20 +477,38 @@ void OnGUI()
476
477
m_CurveEditor . OnGUI ( ) ;
477
478
478
479
// Preset swatch area
479
- GUI . Box ( new Rect ( 0 , position . height - kPresetsHeight , position . width , kPresetsHeight ) , "" , ms_Styles . curveSwatchArea ) ;
480
+ var presetRect = new Rect ( 0 , position . height - kPresetsHeight , position . width , kPresetsHeight ) ;
481
+ GUI . Box ( presetRect , "" , ms_Styles . curveSwatchArea ) ;
482
+
480
483
Color curveColor = m_Color ;
481
484
curveColor . a *= 0.6f ;
482
- const float margin = 45f ;
483
485
const float width = 40f ;
484
486
const float height = 25f ;
485
- float yPos = position . height - kPresetsHeight + ( kPresetsHeight - height ) * 0.5f ;
487
+ const float spaceBetweenSwatches = 5f ;
488
+ const float presetDropdownSize = 16f ;
489
+ const float horizontalScrollbarHeight = 15f ;
490
+ const float presetDropdownCenteringOffset = 2f ;
491
+ float yPos = ( kPresetsHeight - height ) * 0.5f ;
486
492
InitCurvePresets ( ) ;
487
493
CurvePresetLibrary curveLibrary = m_CurvePresets . GetPresetLibraryEditor ( ) . GetCurrentLib ( ) ;
488
494
if ( curveLibrary != null )
489
495
{
490
- for ( int i = 0 ; i < curveLibrary . Count ( ) ; i ++ )
496
+ var numPresets = curveLibrary . Count ( ) ;
497
+ var presetDropDownRect = new Rect ( spaceBetweenSwatches , yPos + presetDropdownCenteringOffset , presetDropdownSize , presetDropdownSize ) ;
498
+ Rect contentRect = new Rect ( 0 , 0 , numPresets * ( width + spaceBetweenSwatches ) + presetDropDownRect . xMax , presetRect . height - horizontalScrollbarHeight ) ;
499
+ m_PresetScrollPosition = GUI . BeginScrollView (
500
+ presetRect , // Rectangle of the visible area
501
+ m_PresetScrollPosition , // Current scroll position
502
+ contentRect , // Rectangle containing all content
503
+ false , // Always show horizontal scrollbar
504
+ false // Always show vertical scrollbar
505
+ ) ;
506
+
507
+ PresetDropDown ( presetDropDownRect ) ;
508
+
509
+ Rect swatchRect = new Rect ( presetDropDownRect . xMax + spaceBetweenSwatches , yPos , width , height ) ;
510
+ for ( int i = 0 ; i < numPresets ; i ++ )
491
511
{
492
- Rect swatchRect = new Rect ( margin + ( width + 5f ) * i , yPos , width , height ) ;
493
512
m_GUIContent . tooltip = curveLibrary . GetName ( i ) ;
494
513
if ( GUI . Button ( swatchRect , m_GUIContent , ms_Styles . curveSwatch ) )
495
514
{
@@ -503,14 +522,11 @@ void OnGUI()
503
522
if ( Event . current . type == EventType . Repaint )
504
523
curveLibrary . Draw ( swatchRect , i ) ;
505
524
506
- if ( swatchRect . xMax > position . width - 2 * margin )
507
- break ;
525
+ swatchRect . x += width + spaceBetweenSwatches ;
508
526
}
527
+ GUI . EndScrollView ( ) ;
509
528
}
510
529
511
- Rect presetDropDownButtonRect = new Rect ( margin - 20f , yPos + 5f , 20 , 20 ) ;
512
- PresetDropDown ( presetDropDownButtonRect ) ;
513
-
514
530
// For adding default preset curves
515
531
//if (EditorGUI.DropdownButton(new Rect (position.width -26, yPos, 20, 20), GUIContent.none, FocusType.Passive, "OL Plus"))
516
532
// AddDefaultPresetsToCurrentLib ();
0 commit comments