Browse Source

Draw digital display on layer 1.

tags/v2.0.1
Andrew Belt 2 years ago
parent
commit
4640c20c42
1 changed files with 21 additions and 10 deletions
  1. +21
    -10
      src/plugin.hpp

+ 21
- 10
src/plugin.hpp View File

@@ -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);
}
};



Loading…
Cancel
Save