Skip to content

Commit

Permalink
Fixes #9
Browse files Browse the repository at this point in the history
Lyqst committed Mar 10, 2022
1 parent 966ab98 commit 7e00f41
Showing 3 changed files with 21 additions and 22 deletions.
17 changes: 7 additions & 10 deletions src/bss.cpp
Original file line number Diff line number Diff line change
@@ -200,17 +200,16 @@ struct Bss : Module
struct BssNoteWidget : rack::TransparentWidget
{
Bss *module;
std::shared_ptr<rack::Font> 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> 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);
}
};

2 changes: 1 addition & 1 deletion src/ntrvlc.cpp
Original file line number Diff line number Diff line change
@@ -400,7 +400,7 @@ struct NtrvlcNoteWidget : rack::TransparentWidget
}
else
{
snprintf(str, sizeof(str), " =)");
snprintf(str, sizeof(str), "hi ");
}
}

24 changes: 13 additions & 11 deletions src/spc.cpp
Original file line number Diff line number Diff line change
@@ -161,17 +161,16 @@ struct Spc : Module
struct SpcNoteWidget : rack::TransparentWidget
{
Spc *module;
std::shared_ptr<rack::Font> 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> 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);
}
}
};

0 comments on commit 7e00f41

Please sign in to comment.