computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit 66ec16f9692fee2fd38256196e4324350f811293
parent b10fb507eeecc5a3ae1c5bb0888f06ffa2855026
Author: Adam M <aemalone@gmail.com>
Date:   Tue, 12 Feb 2019 17:15:46 -0600

v1 integrate other computerscare components

Diffstat:
Msrc/Computerscare.hpp | 48++++++++++++++++++++++++------------------------
Msrc/ComputerscareIso.cpp | 49+++++++++++++++++++++++++------------------------
2 files changed, 49 insertions(+), 48 deletions(-)

diff --git a/src/Computerscare.hpp b/src/Computerscare.hpp @@ -55,25 +55,24 @@ struct IsoButton : SvgSwitch { } }; -struct ComputerscareResetButton : SvgSwitch,MomentarySwitch { +struct ComputerscareResetButton : SvgSwitch { ComputerscareResetButton() { addFrame(APP->window->loadSvg(asset::plugin(pluginInstance,"res/computerscare-rst-text.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance,"res/computerscare-rst-text-red.svg"))); //APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-pentagon-jack-1-outline-flipped.svg")); } }; -/* -struct ComputerscareClockButton : SVGSwitch,MomentarySwitch { + +struct ComputerscareClockButton : SvgSwitch { ComputerscareClockButton() { addFrame(APP->window->loadSvg(asset::plugin(pluginInstance,"res/computerscare-clk-text.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance,"res/computerscare-clk-text-red.svg"))); } }; -struct ComputerscareInvisibleButton : SVGSwitch,MomentarySwitch { +struct ComputerscareInvisibleButton : SvgSwitch { ComputerscareInvisibleButton() { addFrame(APP->window->loadSvg(asset::plugin(pluginInstance,"res/computerscare-invisible-button.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance,"res/computerscare-invisible-button-frame2.svg"))); - //APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-pentagon-jack-1-outline-flipped.svg")); } }; @@ -82,7 +81,7 @@ struct ComputerscareGreenLight : GrayModuleLightWidget { addBaseColor(COLOR_COMPUTERSCARE_GREEN); } }; - +/* struct ComputerscareRedLight : ModuleLightWidget { ComputerscareRedLight() { bgColor = nvgRGBA(0x5a, 0x5a, 0x5a, 0x00); @@ -192,7 +191,7 @@ struct ComputerscareDotKnob : SmallKnob { } }; -/* + //////////////////////////////////// struct SmallLetterDisplay : TransparentWidget { @@ -209,44 +208,45 @@ struct SmallLetterDisplay : TransparentWidget { bool doubleblink = false; SmallLetterDisplay() { - font = Font::load(asset::plugin(pluginInstance,defaultFontPath)); + //APP->window->loadFont() + font = APP->window->loadFont(asset::plugin(pluginInstance,defaultFontPath)); }; SmallLetterDisplay(std::string fontPath) { - font = Font::load(asset::plugin(pluginInstance,fontPath)); + font = APP->window->loadFont(asset::plugin(pluginInstance,fontPath)); }; - void draw(NVGcontext *vg) override + void draw(const DrawContext &ctx) override { // Background NVGcolor backgroundColor = COLOR_COMPUTERSCARE_RED; NVGcolor doubleblinkColor = COLOR_COMPUTERSCARE_YELLOW; - nvgBeginPath(vg); - nvgRoundedRect(vg, 1.0, -1.0, box.size.x-3, box.size.y-3, 4.0); + nvgBeginPath(ctx.vg); + nvgRoundedRect(ctx.vg, 1.0, -1.0, box.size.x-3, box.size.y-3, 4.0); if(doubleblink) { - nvgFillColor(vg, doubleblinkColor); + nvgFillColor(ctx.vg, doubleblinkColor); } else { if(blink) { - nvgFillColor(vg, backgroundColor); + nvgFillColor(ctx.vg, backgroundColor); } else { - nvgFillColor(vg, baseColor); + nvgFillColor(ctx.vg, baseColor); } } - nvgFill(vg); + nvgFill(ctx.vg); // text - nvgFontSize(vg, fontSize); - nvgFontFaceId(vg, font->handle); - nvgTextLetterSpacing(vg, letterSpacing); - nvgTextLineHeight(vg, 0.7); - nvgTextAlign(vg,textAlign); + nvgFontSize(ctx.vg, fontSize); + nvgFontFaceId(ctx.vg, font->handle); + nvgTextLetterSpacing(ctx.vg, letterSpacing); + nvgTextLineHeight(ctx.vg, 0.7); + nvgTextAlign(ctx.vg,textAlign); Vec textPos = Vec(6.0f, 12.0f); NVGcolor textColor = (!blink || doubleblink) ? nvgRGB(0x10, 0x10, 0x00) : COLOR_COMPUTERSCARE_YELLOW; - nvgFillColor(vg, textColor); - nvgTextBox(vg, textPos.x, textPos.y,80,value.c_str(), NULL); + nvgFillColor(ctx.vg, textColor); + nvgTextBox(ctx.vg, textPos.x, textPos.y,80,value.c_str(), NULL); } -};*/ +}; diff --git a/src/ComputerscareIso.cpp b/src/ComputerscareIso.cpp @@ -5,6 +5,7 @@ struct ComputerscareIso; const int numKnobs = 16; const int numToggles = 16; +const int numOutputs = 16; struct ComputerscareIso : Module { enum ParamIds { @@ -19,7 +20,7 @@ struct ComputerscareIso : Module { }; enum OutputIds { POLY_OUTPUT, - NUM_OUTPUTS + NUM_OUTPUTS=POLY_OUTPUT + numOutputs }; enum LightIds { NUM_LIGHTS @@ -55,7 +56,7 @@ struct ComputerscareIsoWidget : ModuleWidget { setModule(module); //setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/ComputerscareIsoPanel.svg"))); - + float outputY = 334; box.size = Vec(15*9, 380); { ComputerscareSVGPanel *panel = new ComputerscareSVGPanel(); @@ -66,36 +67,36 @@ struct ComputerscareIsoWidget : ModuleWidget { addChild(panel); } + + addParam(createParam<IsoButton>(Vec(10, 5), module, ComputerscareIso::TOGGLES)); + addParam(createParam<ComputerscareClockButton>(Vec(10,40),module,ComputerscareIso::TOGGLES+2)); + addParam(createParam<ComputerscareResetButton>(Vec(55,40),module,ComputerscareIso::TOGGLES+1)); + + + smallLetterDisplay = new SmallLetterDisplay(); + smallLetterDisplay->box.pos = Vec(20,77); + smallLetterDisplay->box.size = Vec(60, 30); + smallLetterDisplay->value = "1"; + smallLetterDisplay->baseColor = COLOR_COMPUTERSCARE_TRANSPARENT; + addChild(smallLetterDisplay); + + addParam(createParam<Davies1900hBlackKnob>(Vec(28, 87), module, ComputerscareIso::KNOB)); addParam(createParam<MediumSnapKnob>(Vec(68, 97), module, ComputerscareIso::KNOB+1)); - addParam(createParam<SmoothKnob>(Vec(68, 127), module, ComputerscareIso::KNOB+2)); - addParam(createParam<SmallKnob>(Vec(68, 157), module, ComputerscareIso::KNOB+3)); + + + addParam(createParam<SmoothKnob>(Vec(30, 147), module, ComputerscareIso::KNOB+2)); + addParam(createParam<SmallKnob>(Vec(62, 147), module, ComputerscareIso::KNOB+3)); addParam(createParam<BigSmoothKnob>(Vec(68, 187), module, ComputerscareIso::KNOB+4)); addParam(createParam<MediumSnapKnob>(Vec(68, 267), module, ComputerscareIso::KNOB+5)); - addParam(createParam<IsoButton>(Vec(20, 44), module, ComputerscareIso::TOGGLES)); - - //addInput(createInput<PJ301MPort>(Vec(33, 186), module, MyModule::PITCH_INPUT)); - addOutput(createOutput<OutPort>(Vec(33, 275), module, ComputerscareIso::POLY_OUTPUT)); - - //addChild(createLight<MediumLight<RedLight>>(Vec(41, 59), module, MyModule::BLINK_LIGHT)); - + addOutput(createOutput<OutPort>(Vec(33, outputY), module, ComputerscareIso::POLY_OUTPUT)); + addOutput(createOutput<PointingUpPentagonPort>(Vec(63, outputY), module, ComputerscareIso::POLY_OUTPUT+1)); + addOutput(createOutput<InPort>(Vec(93, outputY), module, ComputerscareIso::POLY_OUTPUT+2)); } - - /*void drawShadow(NVGcontext *vg) { - nvgBeginPath(vg); - float r = 20; // Blur radius - float c = 20; // Corner radius - Vec b = Vec(-10, 30); // Offset from each corner - nvgRect(vg, b.x - r, b.y - r, box.size.x - 2*b.x + 2*r, box.size.y - 2*b.y + 2*r); - NVGcolor shadowColor = nvgRGBAf(0, 220, 0, 0.2); - NVGcolor transparentColor = nvgRGBAf(0, 0, 0, 0); - nvgFillPaint(vg, nvgBoxGradient(vg, b.x, b.y, box.size.x - 2*b.x, box.size.y - 2*b.y, c, r, shadowColor, transparentColor)); - nvgFill(vg); -}*/ - +SmallLetterDisplay* smallLetterDisplay; };