| @@ -45,13 +45,7 @@ struct DigitalDisplay : Widget { | |||||
| NVGcolor fgColor = SCHEME_YELLOW; | NVGcolor fgColor = SCHEME_YELLOW; | ||||
| Vec textPos; | 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 | // Get font | ||||
| std::shared_ptr<Font> font = APP->window->loadFont(fontPath); | std::shared_ptr<Font> font = APP->window->loadFont(fontPath); | ||||
| if (!font) | if (!font) | ||||
| @@ -60,14 +54,31 @@ struct DigitalDisplay : Widget { | |||||
| nvgFontSize(args.vg, fontSize); | nvgFontSize(args.vg, fontSize); | ||||
| nvgTextLetterSpacing(args.vg, 0.0); | nvgTextLetterSpacing(args.vg, 0.0); | ||||
| nvgTextAlign(args.vg, NVG_ALIGN_RIGHT); | 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 | // Background text | ||||
| nvgFillColor(args.vg, bgColor); | nvgFillColor(args.vg, bgColor); | ||||
| nvgText(args.vg, textPos.x, textPos.y, bgText.c_str(), NULL); | 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); | |||||
| } | } | ||||
| }; | }; | ||||