|
|
@@ -45,13 +45,7 @@ struct DigitalDisplay : Widget { |
|
|
|
NVGcolor fgColor = SCHEME_YELLOW; |
|
|
|
Vec textPos; |
|
|
|
|
|
|
|
void draw(const DrawArgs &args) override { |
|
|
|
// Background |
|
|
|
nvgBeginPath(args.vg); |
|
|
|
nvgRoundedRect(args.vg, 0, 0, box.size.x, box.size.y, 2); |
|
|
|
nvgFillColor(args.vg, nvgRGB(0x19, 0x19, 0x19)); |
|
|
|
nvgFill(args.vg); |
|
|
|
|
|
|
|
void prepareFont(const DrawArgs& args) { |
|
|
|
// Get font |
|
|
|
std::shared_ptr<Font> font = APP->window->loadFont(fontPath); |
|
|
|
if (!font) |
|
|
@@ -60,14 +54,31 @@ struct DigitalDisplay : Widget { |
|
|
|
nvgFontSize(args.vg, fontSize); |
|
|
|
nvgTextLetterSpacing(args.vg, 0.0); |
|
|
|
nvgTextAlign(args.vg, NVG_ALIGN_RIGHT); |
|
|
|
} |
|
|
|
|
|
|
|
void draw(const DrawArgs& args) override { |
|
|
|
// Background |
|
|
|
nvgBeginPath(args.vg); |
|
|
|
nvgRoundedRect(args.vg, 0, 0, box.size.x, box.size.y, 2); |
|
|
|
nvgFillColor(args.vg, nvgRGB(0x19, 0x19, 0x19)); |
|
|
|
nvgFill(args.vg); |
|
|
|
|
|
|
|
prepareFont(args); |
|
|
|
|
|
|
|
// Background text |
|
|
|
nvgFillColor(args.vg, bgColor); |
|
|
|
nvgText(args.vg, textPos.x, textPos.y, bgText.c_str(), NULL); |
|
|
|
} |
|
|
|
|
|
|
|
void drawLayer(const DrawArgs& args, int layer) override { |
|
|
|
if (layer == 1) { |
|
|
|
prepareFont(args); |
|
|
|
|
|
|
|
// Foreground text |
|
|
|
nvgFillColor(args.vg, fgColor); |
|
|
|
nvgText(args.vg, textPos.x, textPos.y, text.c_str(), NULL); |
|
|
|
// Foreground text |
|
|
|
nvgFillColor(args.vg, fgColor); |
|
|
|
nvgText(args.vg, textPos.x, textPos.y, text.c_str(), NULL); |
|
|
|
} |
|
|
|
Widget::drawLayer(args, layer); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|