@@ -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
@@ -469,20 +470,38 @@ void OnGUI()
469
470
m_CurveEditor . OnGUI ( ) ;
470
471
471
472
// Preset swatch area
472
- GUI . Box ( new Rect ( 0 , position . height - kPresetsHeight , position . width , kPresetsHeight ) , "" , ms_Styles . curveSwatchArea ) ;
473
+ var presetRect = new Rect ( 0 , position . height - kPresetsHeight , position . width , kPresetsHeight ) ;
474
+ GUI . Box ( presetRect , "" , ms_Styles . curveSwatchArea ) ;
475
+
473
476
Color curveColor = m_Color ;
474
477
curveColor . a *= 0.6f ;
475
- const float margin = 45f ;
476
478
const float width = 40f ;
477
479
const float height = 25f ;
478
- float yPos = position . height - kPresetsHeight + ( kPresetsHeight - height ) * 0.5f ;
480
+ const float spaceBetweenSwatches = 5f ;
481
+ const float presetDropdownSize = 16f ;
482
+ const float horizontalScrollbarHeight = 15f ;
483
+ const float presetDropdownCenteringOffset = 2f ;
484
+ float yPos = ( kPresetsHeight - height ) * 0.5f ;
479
485
InitCurvePresets ( ) ;
480
486
CurvePresetLibrary curveLibrary = m_CurvePresets . GetPresetLibraryEditor ( ) . GetCurrentLib ( ) ;
481
487
if ( curveLibrary != null )
482
488
{
483
- for ( int i = 0 ; i < curveLibrary . Count ( ) ; i ++ )
489
+ var numPresets = curveLibrary . Count ( ) ;
490
+ var presetDropDownRect = new Rect ( spaceBetweenSwatches , yPos + presetDropdownCenteringOffset , presetDropdownSize , presetDropdownSize ) ;
491
+ Rect contentRect = new Rect ( 0 , 0 , numPresets * ( width + spaceBetweenSwatches ) + presetDropDownRect . xMax , presetRect . height - horizontalScrollbarHeight ) ;
492
+ m_PresetScrollPosition = GUI . BeginScrollView (
493
+ presetRect , // Rectangle of the visible area
494
+ m_PresetScrollPosition , // Current scroll position
495
+ contentRect , // Rectangle containing all content
496
+ false , // Always show horizontal scrollbar
497
+ false // Always show vertical scrollbar
498
+ ) ;
499
+
500
+ PresetDropDown ( presetDropDownRect ) ;
501
+
502
+ Rect swatchRect = new Rect ( presetDropDownRect . xMax + spaceBetweenSwatches , yPos , width , height ) ;
503
+ for ( int i = 0 ; i < numPresets ; i ++ )
484
504
{
485
- Rect swatchRect = new Rect ( margin + ( width + 5f ) * i , yPos , width , height ) ;
486
505
m_GUIContent . tooltip = curveLibrary . GetName ( i ) ;
487
506
if ( GUI . Button ( swatchRect , m_GUIContent , ms_Styles . curveSwatch ) )
488
507
{
@@ -496,14 +515,11 @@ void OnGUI()
496
515
if ( Event . current . type == EventType . Repaint )
497
516
curveLibrary . Draw ( swatchRect , i ) ;
498
517
499
- if ( swatchRect . xMax > position . width - 2 * margin )
500
- break ;
518
+ swatchRect . x += width + spaceBetweenSwatches ;
501
519
}
520
+ GUI . EndScrollView ( ) ;
502
521
}
503
522
504
- Rect presetDropDownButtonRect = new Rect ( margin - 20f , yPos + 5f , 20 , 20 ) ;
505
- PresetDropDown ( presetDropDownButtonRect ) ;
506
-
507
523
// For adding default preset curves
508
524
//if (EditorGUI.DropdownButton(new Rect (position.width -26, yPos, 20, 20), GUIContent.none, FocusType.Passive, "OL Plus"))
509
525
// AddDefaultPresetsToCurrentLib ();
0 commit comments