ide; ecere/StatusBar: Nicer key states lights
authorJerome St-Louis <jerome@ecere.com>
Sat, 15 Feb 2014 22:09:07 +0000 (14:09 -0800)
committerJerome St-Louis <jerome@ecere.com>
Sat, 15 Feb 2014 22:09:07 +0000 (14:09 -0800)
ecere/src/gui/controls/StatusBar.ec
ide/src/designer/CodeEditor.ec
ide/src/ide.ec

index b3e355d..df1e651 100644 (file)
@@ -61,6 +61,8 @@ private:
       Clear();
    }
 
+   FontResource boldFont { font.faceName, font.size, true, window = this };
+
    bool OnLoadGraphics()
    {
       StatusField field;
@@ -106,9 +108,15 @@ private:
          }
          if(field.text)
          {
-            Box clip { x, 2, x + field.width - 1, statusBarHeight-1 };
+            Box clip { x, 2, x + field.width - 1, statusBarHeight-3 };
             int tw;
             surface.Clip(clip);
+            if(field.backColor)
+            {
+               surface.SetBackground(field.backColor);
+               surface.Clear(colorBuffer);
+            }
+            surface.font = field.bold ? boldFont.font : fontObject;
             surface.TextExtent(field.text, strlen(field.text), &tw, null);
             surface.WriteTextf(x + (field.width - tw) / 2, 2, field.text);
             surface.Clip(null);
@@ -170,6 +178,26 @@ public:
          }
       }
    }
+   property ColorAlpha backColor
+   {
+      set
+      {
+         if(this)
+         {
+            backColor = value;
+            colorSet = true;
+            if(_statusBar)
+               _statusBar.Update(null);
+         }
+      }
+   }
+   property bool bold
+   {
+      set
+      {
+         if(this) this.bold = value;
+      }
+   }
 
    property char * text
    {
@@ -237,6 +265,8 @@ private:
    char * text;
    int width;
    Color color;
+   ColorAlpha backColor;
    StatusBar _statusBar;
    bool colorSet;
+   bool bold;
 };
index 98d96c6..ba971cd 100644 (file)
@@ -856,7 +856,7 @@ class CodeEditor : Window
 
       void NotifyOvrToggle(EditBox editBox, bool overwrite)
       {
-         ide.ovr.color = overwrite ? black : Color { 128, 128, 128 };
+         ide.UpdateStateLight(ide.ovr, overwrite);
       }
 
       void NotifyUpdate(EditBox editBox)
index ff94368..70b3205 100644 (file)
@@ -2549,10 +2549,17 @@ class IDEWorkSpace : Window
    }
    */
 
+   void UpdateStateLight(StatusField fld, bool on)
+   {
+      fld.color = on ? lime : Color { 128,128,128 };
+      fld.backColor = on ? dimGray : 0;
+      fld.bold = on;
+   }
+
    bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
    {
-      caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
-      num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
+      UpdateStateLight(caps, app.GetKeyState(capsState));
+      UpdateStateLight(num, app.GetKeyState(numState));
       return true;
    }
 
@@ -2560,15 +2567,19 @@ class IDEWorkSpace : Window
    {
       switch(key)
       {
-         case b:
-            projectView.Update(null);
-            break;
-         case capsLock:
-            caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
-            break;
-         case numLock:
-            num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
-            break;
+         case b: projectView.Update(null); break;
+         case capsLock: UpdateStateLight(caps, app.GetKeyState(capsState)); break;
+         case numLock:  UpdateStateLight(num, app.GetKeyState(numState)); break;
+      }
+      return true;
+   }
+
+   bool OnKeyUp(Key key, unichar ch)
+   {
+      switch(key)
+      {
+         case capsLock: UpdateStateLight(caps, app.GetKeyState(capsState)); break;
+         case numLock:  UpdateStateLight(num, app.GetKeyState(numState)); break;
       }
       return true;
    }
@@ -2906,14 +2917,17 @@ class IDEWorkSpace : Window
 
             statusBar.AddField(pos);
 
-            caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
+            caps = { width = 40, text = $"CAPS" };
             statusBar.AddField(caps);
+            UpdateStateLight(caps, app.GetKeyState(capsState));
 
-            ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
+            ovr = { width = 36, text = $"OVR" };
             statusBar.AddField(ovr);
+            UpdateStateLight(ovr, (editBox && editBox.overwrite));
 
-            num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
+            num = { width = 36, text = $"NUM" };
             statusBar.AddField(num);
+            UpdateStateLight(num, app.GetKeyState(numState));
 
             //statusBar.text = "Ready";