commit a97f75e16c5b27b4d1106d299220c639cfa55392
parent b4af126eb05aa5ea84ce49cb979c2e9b5968b413
Author: Adam M <aemalone@gmail.com>
Date: Sat, 2 May 2020 10:31:09 -0500
Puttons labels
Diffstat:
3 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/src/Computerscare.hpp b/src/Computerscare.hpp
@@ -456,6 +456,7 @@ struct SmallLetterDisplay : Widget {
std::string defaultFontPath = "res/Oswald-Regular.ttf";
NVGcolor baseColor = COLOR_COMPUTERSCARE_TRANSPARENT;
NVGcolor textColor = nvgRGB(0x10, 0x10, 0x00);
+ Vec textOffset = Vec(0,0);
float letterSpacing = 2.5;
int textAlign = 1;
@@ -501,7 +502,7 @@ struct SmallLetterDisplay : Widget {
nvgTextLineHeight(ctx.vg, 0.7);
nvgTextAlign(ctx.vg, textAlign);
- Vec textPos = Vec(6.0f, 12.0f);
+ Vec textPos = Vec(6.0f, 12.0f).plus(textOffset);
NVGcolor color = (!blink || doubleblink) ? textColor : COLOR_COMPUTERSCARE_YELLOW;
nvgFillColor(ctx.vg, color);
nvgTextBox(ctx.vg, textPos.x, textPos.y, breakRowWidth, value.c_str(), NULL);
diff --git a/src/ComputerscareBolyPuttons.cpp b/src/ComputerscareBolyPuttons.cpp
@@ -178,19 +178,40 @@ struct ComputerscareBolyPuttons : ComputerscarePolyModule {
struct DisableableParamWidget : SmallIsoButton {
ComputerscareBolyPuttons *module;
+ SmallLetterDisplay *smallLetterDisplay;
int channel;
+ Vec labelOffset = Vec(0,0);
DisableableParamWidget() {
+ smallLetterDisplay = new SmallLetterDisplay();
+ smallLetterDisplay->box.size = Vec(5, 10);
+ smallLetterDisplay->fontSize = 17;
+ smallLetterDisplay->value = "";
+ smallLetterDisplay->textAlign = 1;
+ smallLetterDisplay->box.pos = box.pos;//Vec(box.pos.x,box.pos.y);
+ //smallLetterDisplay->box.pos = Vec(x + labelDx, y - 12 + labelDy);
+
+ addChild(smallLetterDisplay);
SmallIsoButton();
}
void step() override {
if (module) {
disabled = channel > module->polyChannels - 1;
momentary = module->momentary;
+ bool pressed = module->params[channel].getValue() == 1.f;
+ labelOffset = Vec(pressed ? 3.f : -4.f, pressed ? 7.f : 2.f);
+ //smallLetterDisplay
+ //smallLetterDisplay->box.pos=box.pos;//.plus(Vec(0,0/*disabled ? 5 : 0,0*/));
}
+ smallLetterDisplay->value = std::to_string(channel+1);
SmallIsoButton::step();
}
+ void draw(const DrawArgs &ctx) override {
+ //addChild(smallLetterDisplay);
+ smallLetterDisplay->textOffset = labelOffset;//.plus(labelOffset);
+ SmallIsoButton::draw(ctx);
+ }
};
struct ComputerscareBolyPuttonsWidget : ModuleWidget {
@@ -239,13 +260,7 @@ struct ComputerscareBolyPuttonsWidget : ModuleWidget {
//addParam(createParam<DisableableParamWidget>(Vec(x, y), module, ComputerscareBolyPuttons::TOGGLE + index));
- smallLetterDisplay = new SmallLetterDisplay();
- smallLetterDisplay->box.size = Vec(5, 10);
- smallLetterDisplay->fontSize = 16;
- smallLetterDisplay->value = label;
- smallLetterDisplay->textAlign = 1;
- smallLetterDisplay->box.pos = Vec(x + labelDx, y - 12 + labelDy);
- addChild(smallLetterDisplay);
+
}
diff --git a/src/ComputerscareKnolyPobs.cpp b/src/ComputerscareKnolyPobs.cpp
@@ -132,13 +132,13 @@ struct ComputerscareKnolyPobsWidget : ModuleWidget {
float xx;
float yy;
- float yInitial=84;
+ float yInitial=86;
float ySpacing = 34;
float yRightColumnOffset=14.3/8;
for (int i = 0; i < numKnobs; i++) {
xx = 1.4f + 24.3 * (i - i % 8) / 8;
yy = yInitial + ySpacing* (i % 8) + yRightColumnOffset* (i - i % 8) ;
- addLabeledKnob(std::to_string(i + 1), xx, yy, module, i, (i - i % 8) * 1.2 - 2 +(i==8 ? 5 : 0), 2);
+ addLabeledKnob(std::to_string(i + 1), xx, yy, module, i, (i - i % 8) * 1.2 - 3 +(i==8 ? 5 : 0), 2);
}
}
@@ -146,7 +146,7 @@ struct ComputerscareKnolyPobsWidget : ModuleWidget {
smallLetterDisplay = new SmallLetterDisplay();
smallLetterDisplay->box.size = Vec(5, 10);
- smallLetterDisplay->fontSize = 14;
+ smallLetterDisplay->fontSize = 18;
smallLetterDisplay->value = label;
smallLetterDisplay->textAlign = 1;