ide/Global Settings: More room for color scheme drop box
[sdk] / ide / src / dialogs / GlobalSettingsDialog.ec
index 1644ebc..370a770 100644 (file)
@@ -74,11 +74,31 @@ class GlobalSettingsDialog : Window
             {
                if(editorTab.useFreeCaret.checked != ideSettings.useFreeCaret ||
                      editorTab.showLineNumbers.checked != ideSettings.showLineNumbers ||
-                     editorTab.caretFollowsScrolling.checked != ideSettings.caretFollowsScrolling)
+                     editorTab.caretFollowsScrolling.checked != ideSettings.caretFollowsScrolling ||
+                     editorTab.fontPicker.fontSize != ideSettings.codeEditorFontSize ||
+                     editorTab.fontPicker.faceName.OnCompare(ideSettings.codeEditorFont) ||
+                     editorTab.dbColorSchemes.currentRow.string.OnCompare(ideSettings.activeColorScheme)
+                     )
                {
+                  DataRow csRow = editorTab.dbColorSchemes.currentRow;
                   ideSettings.useFreeCaret = editorTab.useFreeCaret.checked;
                   ideSettings.showLineNumbers = editorTab.showLineNumbers.checked;
                   ideSettings.caretFollowsScrolling = editorTab.caretFollowsScrolling.checked;
+                  ideSettings.codeEditorFont = editorTab.fontPicker.faceName;
+                  ideSettings.codeEditorFontSize = editorTab.fontPicker.fontSize;
+                  if(csRow && csRow.string)
+                  {
+                     ideSettings.activeColorScheme = csRow.string;
+                     for(cs : ideSettings.colorSchemes; cs.name && !strcmp(cs.name, csRow.string))
+                     {
+                        colorScheme = cs;
+                        ide.ApplyColorScheme(colorScheme);
+                        break;
+                     }
+                  }
+
+                  ide.ApplyFont(ideSettings.codeEditorFont, ideSettings.codeEditorFontSize);
+
                   editorSettingsChanged = true;
                }
             }
@@ -226,26 +246,63 @@ class GlobalSettingsDialog : Window
    virtual void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange);
 }
 
+import "FontPicker"
+
 class EditorTab : GlobalSettingsSubTab
 {
    background = formColor;
    text = $"Editor";
 
+   bool OnCreate()
+   {
+      dbColorSchemes.Clear();
+
+      for(s : ideSettings.colorSchemes)
+      {
+         DataRow row = dbColorSchemes.AddString(s.name);
+         if(!strcmp(s.name, ideSettings.activeColorScheme))
+            dbColorSchemes.currentRow = row;
+      }
+      return true;
+   }
+
+   Label lblColorSchemes { this, anchor = { top = 70, right = 16 }, labeledWindow = dbColorSchemes };
+   DropBox dbColorSchemes
+   {
+      this, text = $"Color Scheme: ", anchor = { top = 92, right = 16 }, size = { 200, 22 };
+
+      bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
+      {
+         if(row)
+         {
+            IDEColorScheme colorScheme = null;
+            for(cs : ideSettings.colorSchemes; cs.name && !strcmp(cs.name, row.string))
+            {
+               colorScheme = cs;
+               break;
+            }
+            fontPicker.SelectColorScheme(colorScheme);
+            modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
    Button useFreeCaret
    {
-      this, text = $"Move code editor caret freely past end of line", position = { 16, 68 }, isCheckbox = true;
+      this, text = $"Move code editor caret freely past end of line", position = { 16, 58 }, isCheckbox = true;
       NotifyClicked = NotifyClickedModifiedDocument;
    };
 
    Button caretFollowsScrolling
    {
-      this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 88 }, isCheckbox = true;
+      this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 78 }, isCheckbox = true;
       NotifyClicked = NotifyClickedModifiedDocument;
    };
 
    Button showLineNumbers
    {
-      this, text = $"Show line numbers in code editor", position = { 16, 108 }, isCheckbox = true;
+      this, text = $"Show line numbers in code editor", position = { 16, 98 }, isCheckbox = true;
       NotifyClicked = NotifyClickedModifiedDocument;
    };
 
@@ -254,6 +311,17 @@ class EditorTab : GlobalSettingsSubTab
       modifiedDocument = true;
       return true;
    }
+
+   FontPicker fontPicker
+   {
+      this, anchor = { left = 8, right = 8, top = 120, bottom = 8 };
+
+      bool NotifyChanged()
+      {
+         modifiedDocument = true;
+         return true;
+      }
+   };
 }
 
 static void DrawStipple(Surface surface, Size clientSize)