computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit a534a875929c09c5cf9b32c9b9bcb0703f9a0bce
parent e17f6a1eacc9b15b2c78ed7f4360b297fe14bfce
Author: Adam M <[email protected]>
Date:   Tue, 25 Dec 2018 13:12:10 -0600

Make the active step display its own widget, and make it large

Diffstat:
Msrc/Computerscare.hpp | 15++++++++++++---
Msrc/ComputerscareILoveCookies.cpp | 23+++++++++++++++++------
Msrc/ComputerscareLaundrySoup.cpp | 5++---
Msrc/dtpulse.cpp | 2+-
4 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/src/Computerscare.hpp b/src/Computerscare.hpp @@ -149,12 +149,20 @@ struct SmallLetterDisplay : TransparentWidget { std::string value; std::shared_ptr<Font> font; + int fontSize = 19; + std::string defaultFontPath = "res/Oswald-Regular.ttf"; + + float letterSpacing = 2.5; + int textAlign = 1; bool active = false; bool blink = false; bool doubleblink = false; SmallLetterDisplay() { - font = Font::load(assetPlugin(plugin, "res/Oswald-Regular.ttf")); + font = Font::load(assetPlugin(plugin,defaultFontPath)); + }; + SmallLetterDisplay(std::string fontPath) { + font = Font::load(assetPlugin(plugin,fontPath)); }; void draw(NVGcontext *vg) override @@ -180,10 +188,11 @@ struct SmallLetterDisplay : TransparentWidget { } // text - nvgFontSize(vg, 19); + nvgFontSize(vg, fontSize); nvgFontFaceId(vg, font->handle); - nvgTextLetterSpacing(vg, 2.5); + nvgTextLetterSpacing(vg, letterSpacing); nvgTextLineHeight(vg, 0.7); + nvgTextAlign(vg,textAlign); Vec textPos = Vec(6.0f, 12.0f); NVGcolor textColor = (!blink || doubleblink) ? nvgRGB(0x10, 0x10, 0x00) : COLOR_COMPUTERSCARE_YELLOW; diff --git a/src/ComputerscareILoveCookies.cpp b/src/ComputerscareILoveCookies.cpp @@ -115,13 +115,13 @@ struct ComputerscareILoveCookies : Module { MyTextFieldCookie* textFields[numFields]; SmallLetterDisplay* smallLetterDisplays[numFields]; + SmallLetterDisplay* currentWorkingStepDisplays[numFields]; AbsoluteSequence newABS[numFields]; bool shouldChange[numFields] = {false}; bool changeImminent[numFields] = {false}; - std::string displayString[numFields]; int activeKnobIndex[numFields] = {0}; ComputerscareILoveCookies() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {} @@ -221,11 +221,11 @@ void onCreate () override void incrementInternalStep(int i) { newABS[i].incrementAndCheck(); - this->displayString[i] = this->getDisplayString(i); if(newABS[i].readHead == 0) { this->setChangeImminent(i,false); } - this->smallLetterDisplays[i]->value = this->displayString[i]; + this->smallLetterDisplays[i]->value = this->getDisplayString(i); + this->currentWorkingStepDisplays[i]->value = this->newABS[i].getWorkingStepDisplay(); } void resetOneOfThem(int i) { @@ -237,12 +237,12 @@ void onCreate () override std::string getDisplayString(int index) { std::string lhs = std::to_string(this->newABS[index].readHead + 1); std::string rhs = std::to_string(this->newABS[index].numTokens); - std::string thisVal = this->newABS[index].getWorkingStepDisplay(); padTo(lhs, 3,' '); padTo(rhs, 3,' '); - std::string val = lhs + "/" + rhs + "\n" + thisVal.substr(0,4); + std::string val = lhs + "\n" + rhs; + return val; } float mapKnobValue(float rawValue, int rowIndex) { @@ -479,16 +479,27 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget { smallLetterDisplay = new SmallLetterDisplay(); smallLetterDisplay->box.pos = mm2px(Vec(21+xStart,verticalStart - 9.2 +verticalSpacing*i)); smallLetterDisplay->box.size = Vec(60, 30); - smallLetterDisplay->value = "?/?"; + smallLetterDisplay->value = "?\n?"; addChild(smallLetterDisplay); module->smallLetterDisplays[i] = smallLetterDisplay; + //active/total steps display + currentWorkingStepDisplay = new SmallLetterDisplay(); + currentWorkingStepDisplay->box.pos = mm2px(Vec(11+xStart,verticalStart - 7.0 +verticalSpacing*i)); + currentWorkingStepDisplay->box.size = mm2px(Vec(2,10)); + currentWorkingStepDisplay->fontSize = 26; + currentWorkingStepDisplay->textAlign = 4; + currentWorkingStepDisplay->value = "?"; + addChild(currentWorkingStepDisplay); + module->currentWorkingStepDisplays[i] = currentWorkingStepDisplay; + addParam(ParamWidget::create<ComputerscareInvisibleButton>(mm2px(Vec(21+xStart,verticalStart - 9.9 +verticalSpacing*i)), module, ComputerscareILoveCookies::INDIVIDUAL_RESET_PARAM + i, 0.0, 1.0, 0.0)); } module->onCreate(); } MyTextFieldCookie* textField; SmallLetterDisplay* smallLetterDisplay; + SmallLetterDisplay* currentWorkingStepDisplay; }; diff --git a/src/ComputerscareLaundrySoup.cpp b/src/ComputerscareLaundrySoup.cpp @@ -204,15 +204,14 @@ void onCreate () override */ void incrementInternalStep(int i) { - this->absoluteStep[i] +=1; + this->absoluteStep[i] += 1; this->absoluteStep[i] %= this->numSteps[i]; this->smallLetterDisplays[i]->value = this->getDisplayString(i); } std::string getDisplayString(int i) { std::string out = std::to_string(this->absoluteStep[i]+1); - out += "/" + std::to_string(this->numSteps[i]); - out+= "\n"; + out += "\n" + std::to_string(this->numSteps[i]); return out; } void resetOneOfThem(int i) { diff --git a/src/dtpulse.cpp b/src/dtpulse.cpp @@ -441,7 +441,7 @@ std::string AbsoluteSequence::getWorkingStepDisplay() { return str; } else { - return std::to_string((long double) exactFloats[stepIndex - 52]); + return std::to_string((long double) exactFloats[stepIndex - 52]).substr(0,4);; } }