computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit 1b00862fafbbe5ef13920c7b750d37244a493726
parent d1505daf9520860b24c8032c9627f43bb45f14ef
Author: Adam M <aemalone@gmail.com>
Date:   Wed,  3 Nov 2021 15:14:13 -0500

show father and son display steps as lights

Diffstat:
Msrc/ComputerscarePatchSequencer.cpp | 47++++++++++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/src/ComputerscarePatchSequencer.cpp b/src/ComputerscarePatchSequencer.cpp @@ -406,16 +406,15 @@ struct NumberDisplayWidget3 : TransparentWidget { int *value; ComputerscarePatchSequencer *module; - std::shared_ptr<Font> font; + std::string fontPath = "res/digital-7.ttf"; NumberDisplayWidget3() { - font = APP->window->loadFont(asset::plugin(pluginInstance, "res/digital-7.ttf")); + }; void draw(const DrawArgs &args) override { // Background - //if (module) { NVGcolor backgroundColor = nvgRGB(0x00, 0x00, 0x00); nvgBeginPath(args.vg); @@ -423,24 +422,34 @@ struct NumberDisplayWidget3 : TransparentWidget { nvgFillColor(args.vg, backgroundColor); nvgFill(args.vg); - // text - nvgFontSize(args.vg, 13); - nvgFontFaceId(args.vg, font->handle); - nvgTextLetterSpacing(args.vg, 2.5); - - std::stringstream to_display; - if (module) { - to_display << std::setw(3) << *value; - } - else { - to_display << std::setw(3) << "16"; + } + void drawLayer(const BGPanel::DrawArgs& args, int layer) override { + if (layer == 1) { + drawText(args); } + Widget::drawLayer(args, layer); + } + void drawText(const BGPanel::DrawArgs& args) { + std::shared_ptr<Font> font = APP->window->loadFont(asset::plugin(pluginInstance, fontPath)); + if (font) { + // text + nvgFontSize(args.vg, 13); + nvgFontFaceId(args.vg, font->handle); + nvgTextLetterSpacing(args.vg, 2.5); + + std::stringstream to_display; + if (module) { + to_display << std::setw(3) << *value; + } + else { + to_display << std::setw(3) << "16"; + } - Vec textPos = Vec(6.0f, 17.0f); - NVGcolor textColor = nvgRGB(0xC0, 0xE7, 0xDE); - nvgFillColor(args.vg, textColor); - nvgText(args.vg, textPos.x, textPos.y, to_display.str().c_str(), NULL); - // } + Vec textPos = Vec(6.0f, 17.0f); + NVGcolor textColor = nvgRGB(0xC0, 0xE7, 0xDE); + nvgFillColor(args.vg, textColor); + nvgText(args.vg, textPos.x, textPos.y, to_display.str().c_str(), NULL); + } } };