@@ -288,7 +288,6 @@ void SetMacroButton(ButtonName name, (int Row, int Col) pos)
288288 }
289289 }
290290
291-
292291 Widget BuildThemes ( )
293292 {
294293 Grid grid = new ( )
@@ -440,11 +439,11 @@ Widget BuildThemes()
440439 {
441440 var newTheme = ( string ) btnCombo . SelectedItem . Tag ;
442441
443-
444442 config . CurrentTheme = config . CurrentTheme with
445443 {
446444 Buttons = newTheme ,
447445 } ;
446+
448447 SaveConfig ( ) ;
449448 RebuildMacroButtons ( ) ;
450449 } ;
@@ -456,7 +455,7 @@ Widget BuildSettings()
456455 {
457456 Grid grid = new ( )
458457 {
459- Margin = new ( 20 ) ,
458+ Margin = new ( 20 , 10 , 20 , 15 ) ,
460459 VerticalAlignment = VerticalAlignment . Center ,
461460 ColumnSpacing = 8 ,
462461 RowSpacing = 4 ,
@@ -490,19 +489,12 @@ Widget BuildSettings()
490489 AddCheck ( 1 , 3 , "Use Shortcuts" , config . ShortcutsEnabled , check => config . ShortcutsEnabled = check ) ;
491490 CreateDirectionsSourceBox ( 1 , 4 , "Dir.Sources" ) ;
492491
493- AddNumeric ( 2 , 0 , "Input space" , config . SpaceBetweenInputs , v => config . SpaceBetweenInputs = v ) ;
494- AddNumeric ( 2 , 1 , "Command space" , config . SpaceBetweenCommands , v => config . SpaceBetweenCommands = v ) ;
495- AddNumeric ( 2 , 2 , "Direction space" , config . DirectionSpace , v => config . DirectionSpace = v ) ;
496- AddNumeric ( 2 , 3 , "Icon size" , config . IconSize , v => config . IconSize = v ) ;
497-
498- var backgroundColor = ColorPicker ( "Background color" , config . ClearColor , c =>
499- {
500- config . ClearColor = c ;
501- SaveConfig ( ) ;
502- } ) ;
503- Grid . SetColumn ( backgroundColor , 2 ) ;
504- Grid . SetRow ( backgroundColor , 4 ) ;
505- grid . Widgets . Add ( backgroundColor ) ;
492+ AddEnumCombo ( 2 , 0 , "SOCD" , config . SOCD , item => config . SOCD = item ) ;
493+ AddNumeric ( 2 , 1 , "Input space" , config . SpaceBetweenInputs , v => config . SpaceBetweenInputs = v ) ;
494+ AddNumeric ( 2 , 2 , "Command space" , config . SpaceBetweenCommands , v => config . SpaceBetweenCommands = v ) ;
495+ AddNumeric ( 2 , 3 , "Direction space" , config . DirectionSpace , v => config . DirectionSpace = v ) ;
496+ AddNumeric ( 2 , 4 , "Icon size" , config . IconSize , v => config . IconSize = v ) ;
497+ AddColorPicker ( 2 , 5 , "Background color" , config . ClearColor , c => config . ClearColor = c ) ;
506498
507499 return grid ;
508500
@@ -563,6 +555,80 @@ void AddNumeric(int col, int row, string labelText, int value, Action<int> onCha
563555 Grid . SetRow ( chk , row ) ;
564556 grid . Widgets . Add ( chk ) ;
565557 }
558+
559+ void AddEnumCombo < T > ( int col , int row , string labelText , T value , Action < T > onChange ) where T : struct , Enum
560+ {
561+ var panel = EnumComboView ( value , labelText , onChange ) ;
562+ Grid . SetColumn ( panel , col ) ;
563+ Grid . SetRow ( panel , row ) ;
564+ grid . Widgets . Add ( panel ) ;
565+ }
566+
567+ void AddColorPicker ( int col , int row , string labelText , Color value , Action < Color > onChange )
568+ {
569+ var backgroundColor = ColorPicker ( labelText . ToFieldLabel ( ) , value , newColor =>
570+ {
571+ onChange ( newColor ) ;
572+ SaveConfig ( ) ;
573+ } ) ;
574+ Grid . SetColumn ( backgroundColor , col ) ;
575+ Grid . SetRow ( backgroundColor , row ) ;
576+
577+ grid . Widgets . Add ( backgroundColor ) ;
578+ }
579+ }
580+
581+ HorizontalStackPanel EnumComboView < T > ( T value , string labelText , Action < T > onChange ) where T : struct , Enum
582+ {
583+ ComboView enumCombo = new ( )
584+ {
585+ VerticalAlignment = VerticalAlignment . Center ,
586+ } ;
587+
588+ var enums = Enum . GetValues < T > ( ) ;
589+ for ( var index = 0 ; index < enums . Length ; index ++ )
590+ {
591+ var enumValue = enums [ index ] ;
592+
593+ enumCombo . Widgets . Add (
594+ new Label
595+ {
596+ Text = enumValue . ToString ( ) ,
597+ Tag = enumValue ,
598+ VerticalAlignment = VerticalAlignment . Center ,
599+ Margin = new ( 5 , 0 ) ,
600+ }
601+ ) ;
602+
603+ if ( enumValue . Equals ( value ) )
604+ enumCombo . SelectedIndex = index ;
605+ }
606+
607+ HorizontalStackPanel panel = new ( )
608+ {
609+ Padding = new ( 4 ) ,
610+ } ;
611+
612+ Label label = new ( )
613+ {
614+ Text = labelText . ToFieldLabel ( ) ,
615+ VerticalAlignment = VerticalAlignment . Center ,
616+ Margin = new ( 0 , 0 , 5 , 0 ) ,
617+ } ;
618+
619+ panel . Widgets . Add ( label ) ;
620+
621+ enumCombo . SelectedIndexChanged += ( _ , _ ) =>
622+ {
623+ if ( enumCombo is not { SelectedItem . Tag : T newValue } )
624+ return ;
625+
626+ onChange ( newValue ) ;
627+ SaveConfig ( ) ;
628+ } ;
629+
630+ panel . Widgets . Add ( enumCombo ) ;
631+ return panel ;
566632 }
567633
568634 CheckButton InputCheck ( string labelText , bool isChecked , Action < bool > onClick )
@@ -672,7 +738,7 @@ HorizontalStackPanel ColorPicker(string labelText, Color color, Action<Color> on
672738 Color = current ,
673739 } ;
674740
675- dialog . Closed += ( s , a ) =>
741+ dialog . Closed += ( _ , _ ) =>
676742 {
677743 if ( ! dialog . Result ) return ;
678744 image . Tag = dialog . Color ;
0 commit comments