Clear();
}
+ FontResource boldFont { font.faceName, font.size, true, window = this };
+
bool OnLoadGraphics()
{
StatusField field;
}
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);
}
}
}
+ 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
{
char * text;
int width;
Color color;
+ ColorAlpha backColor;
StatusBar _statusBar;
bool colorSet;
+ bool bold;
};
}
*/
+ 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;
}
{
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;
}
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";