computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit afb03691eb8cd407a34d17afe6fb6691c9ad6cbc
parent 329860e15e8d2d758593d7d64996db13eeedbc90
Author: Adam M <aemalone@gmail.com>
Date:   Fri,  4 Jan 2019 22:44:34 -0600

check inError for text field redness on laundry

Diffstat:
Msrc/Computerscare.hpp | 1+
Msrc/ComputerscareILoveCookies.cpp | 1+
Msrc/ComputerscareLaundrySoup.cpp | 37++++++++++++++++++++++++++++++++-----
3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/src/Computerscare.hpp b/src/Computerscare.hpp @@ -22,6 +22,7 @@ static const NVGcolor COLOR_COMPUTERSCARE_GREEN = nvgRGB(0x24, 0xc9, 0xa6); static const NVGcolor COLOR_COMPUTERSCARE_RED = nvgRGB(0xC4, 0x34, 0x21); static const NVGcolor COLOR_COMPUTERSCARE_YELLOW = nvgRGB(0xE4, 0xC4, 0x21); static const NVGcolor COLOR_COMPUTERSCARE_BLUE = nvgRGB(0x24, 0x44, 0xC1); +static const NVGcolor COLOR_COMPUTERSCARE_PINK = nvgRGB(0xAA, 0x18, 0x31); static const NVGcolor COLOR_COMPUTERSCARE_TRANSPARENT = nvgRGBA(0x00, 0x00,0x00,0x00); diff --git a/src/ComputerscareILoveCookies.cpp b/src/ComputerscareILoveCookies.cpp @@ -30,6 +30,7 @@ class MyTextFieldCookie : public LedDisplayTextField { public: int fontSize = LG_FONT_SIZE; int rowIndex=0; + MyTextFieldCookie() : LedDisplayTextField() {} void setModule(ComputerscareILoveCookies* _module) { module = _module; diff --git a/src/ComputerscareLaundrySoup.cpp b/src/ComputerscareLaundrySoup.cpp @@ -17,6 +17,7 @@ class MyTextField : public LedDisplayTextField { public: int fontSize = 16; int rowIndex=0; + bool inError = false; MyTextField() : LedDisplayTextField() {} void setModule(ComputerscareLaundrySoup* _module) { module = _module; @@ -36,9 +37,17 @@ public: // Background nvgFontSize(vg, fontSize); nvgBeginPath(vg); - nvgRoundedRect(vg, 0, 0, box.size.x, box.size.y, 5.0); - nvgFillColor(vg, nvgRGB(0x00, 0x00, 0x00)); - nvgFill(vg); + nvgRoundedRect(vg, 0, 0, box.size.x, box.size.y, 10.0); + + if(inError) { + nvgFillColor(vg, COLOR_COMPUTERSCARE_PINK); + } + else { + nvgFillColor(vg, nvgRGB(0x00, 0x00, 0x00)); + //nvgFillColor(vg, nvgRGB(0x00, 0x00, 0x00)); + + } + nvgFill(vg); // Text if (font->handle >= 0) { @@ -174,8 +183,19 @@ void setAbsoluteSequenceFromQueue(int index) { absoluteSequences[index].resize(0); absoluteSequences[index] = nextAbsoluteSequences[index]; numSteps[index] = nextAbsoluteSequences[index].size() > 0 ? nextAbsoluteSequences[index].size() : 1; - laundrySequences[index] = LaundrySoupSequence(textFields[index]->text); - laundrySequences[index].print(); + + LaundrySoupSequence lss = LaundrySoupSequence(textFields[index]->text); + laundrySequences[index] = lss; + if(!lss.inError) { + laundrySequences[index] = lss; + laundrySequences[index].print(); + textFields[index]->inError=false; + } + else { + printf("ERROR\n"); + lss.print(); + textFields[index]->inError=true; + } } void checkIfShouldChange(int index) { if(shouldChange[index]) { @@ -305,6 +325,13 @@ void ComputerscareLaundrySoup::step() { void MyTextField::onTextChange() { std::string value = module->textFields[this->rowIndex]->text; + LaundrySoupSequence lss = LaundrySoupSequence(value); + if(!lss.inError) { + module->textFields[this->rowIndex]->inError=false; + } + else { + module->textFields[this->rowIndex]->inError=true; + } if(matchParens(value)) { module->setNextAbsoluteSequence(this->rowIndex); whoKnowsLaundry(value);