From 7e00f41ef5ac906d7e0ba44f281a4b8e98e763f7 Mon Sep 17 00:00:00 2001 From: Lyqst Date: Thu, 10 Mar 2022 09:59:12 -0300 Subject: [PATCH] Fixes #9 --- src/bss.cpp | 17 +++++++---------- src/ntrvlc.cpp | 2 +- src/spc.cpp | 24 +++++++++++++----------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/bss.cpp b/src/bss.cpp index 76adf88..33be3e5 100644 --- a/src/bss.cpp +++ b/src/bss.cpp @@ -200,17 +200,16 @@ struct Bss : Module struct BssNoteWidget : rack::TransparentWidget { Bss *module; - std::shared_ptr font; char str[4]; static constexpr const char *notes = "CCDDEFFGGAAB"; static constexpr const char *sharps = " # # # # # "; + const std::string fontPath = "res/fonts/ninepin.regular.ttf"; BssNoteWidget(rack::Vec pos, rack::Vec size, Bss *module) { box.size = size; box.pos = pos.minus(size.div(2)); this->module = module; - this->font = APP->window->loadFont(asset::plugin(pluginInstance, "res/fonts/ninepin.regular.ttf")); } void getString() @@ -227,24 +226,22 @@ struct BssNoteWidget : rack::TransparentWidget } } - void drawLayer(const DrawArgs &args, int layer) override + void draw(const DrawArgs &args) override { - if (layer == 1) + std::shared_ptr font = APP->window->loadFont(asset::plugin(pluginInstance, fontPath)); + if (font) { - NVGcolor textColor = nvgRGB(0x78, 0xD8, 0xC8); + nvgFontFaceId(args.vg, font->handle); nvgFontSize(args.vg, 12); - nvgFontFaceId(args.vg, this->font->handle); nvgTextLetterSpacing(args.vg, 1); nvgTextAlign(args.vg, NVG_ALIGN_CENTER); - Vec textPos = Vec(box.size.x - 6, 18); - nvgFillColor(args.vg, textColor); + nvgFillColor(args.vg, nvgRGB(100, 246, 237)); getString(); + Vec textPos = Vec(box.size.x - 6, 18); nvgText(args.vg, textPos.x, textPos.y, str, NULL); } - - Widget::drawLayer(args, layer); } }; diff --git a/src/ntrvlc.cpp b/src/ntrvlc.cpp index 716952d..1592e1f 100644 --- a/src/ntrvlc.cpp +++ b/src/ntrvlc.cpp @@ -400,7 +400,7 @@ struct NtrvlcNoteWidget : rack::TransparentWidget } else { - snprintf(str, sizeof(str), " =)"); + snprintf(str, sizeof(str), "hi "); } } diff --git a/src/spc.cpp b/src/spc.cpp index 1ac787a..0795d72 100644 --- a/src/spc.cpp +++ b/src/spc.cpp @@ -161,17 +161,16 @@ struct Spc : Module struct SpcNoteWidget : rack::TransparentWidget { Spc *module; - std::shared_ptr font; char str[4]; static constexpr const char *notes = "CCDDEFFGGAAB"; static constexpr const char *sharps = " # # # # # "; + const std::string fontPath = "res/fonts/ninepin.regular.ttf"; SpcNoteWidget(rack::Vec pos, rack::Vec size, Spc *module) { box.size = size; box.pos = pos.minus(size.div(2)); this->module = module; - this->font = APP->window->loadFont(asset::plugin(pluginInstance, "res/fonts/ninepin.regular.ttf")); } void getString() @@ -190,17 +189,20 @@ struct SpcNoteWidget : rack::TransparentWidget void draw(const DrawArgs &args) override { - NVGcolor textColor = nvgRGB(0x78, 0xD8, 0xC8); + std::shared_ptr font = APP->window->loadFont(asset::plugin(pluginInstance, fontPath)); + if (font) + { + nvgFontFaceId(args.vg, font->handle); - nvgFontSize(args.vg, 12); - nvgFontFaceId(args.vg, this->font->handle); - nvgTextLetterSpacing(args.vg, 1); - nvgTextAlign(args.vg, NVG_ALIGN_CENTER); + nvgFontSize(args.vg, 12); + nvgTextLetterSpacing(args.vg, 1); + nvgTextAlign(args.vg, NVG_ALIGN_CENTER); - Vec textPos = Vec(box.size.x - 6, 18); - nvgFillColor(args.vg, textColor); - getString(); - nvgText(args.vg, textPos.x, textPos.y, str, NULL); + nvgFillColor(args.vg, nvgRGB(100, 246, 237)); + getString(); + Vec textPos = Vec(box.size.x - 6, 18); + nvgText(args.vg, textPos.x, textPos.y, str, NULL); + } } };