computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit ccf630341d19e77f1f3313ce7ce2bc9c96e1e916
parent 23c3a5c3f44faaf62714a896a007a4dd2afeed5b
Author: Adam M <aemalone@gmail.com>
Date:   Mon, 29 Jun 2020 17:55:45 -0500

Disabled knobs on moly patrix

Diffstat:
Ares/computerscare-small-knob-effed-dark.svg | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ares/computerscare-small-knob-effed-disabled.svg | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/ComputerscareMolyPatrix.cpp | 53++++++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 192 insertions(+), 9 deletions(-)

diff --git a/res/computerscare-small-knob-effed-dark.svg b/res/computerscare-small-knob-effed-dark.svg @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="Layer_1" + data-name="Layer 1" + viewBox="0 0 18 18" + version="1.1" + sodipodi:docname="computerscare-small-knob-effed-dark.svg" + inkscape:version="0.92.2 5c3e80d, 2017-08-06" + width="18" + height="18"> + <metadata + id="metadata1289"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>01 Big Knob</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1398" + inkscape:window-height="834" + id="namedview1287" + showgrid="false" + inkscape:zoom="22.378007" + inkscape:cx="-0.98240185" + inkscape:cy="9.9790231" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="Big_Knob" /> + <defs + id="defs1279"> + <style + id="style1277">.cls-1{fill:#245559;}.cls-2{fill:none;stroke:#24c9a6;stroke-miterlimit:10;stroke-width:3px;}</style> + </defs> + <title + id="title1281">01 Big Knob</title> + <g + id="Big_Knob" + data-name="Big Knob" + transform="translate(0,-42)"> + <path + style="fill:#0d8691;fill-opacity:1;stroke:#000000;stroke-width:0.794;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" + d="m 17.306156,50.928799 c 0.547144,6.492783 -3.674677,9.295802 -8.5188736,8.849665 -4.4544548,-0.410243 -9.25218903,-4.158274 -8.1261913,-8.808316 1.8128765,-7.48665 4.5399117,-8.489838 8.8083151,-8.808316 0.2710372,-0.02022 0.4944121,-0.0716 0.6174528,0.01303 0.851296,0.585106 -1.6051492,2.237455 4.408529,3.087358 0,0 2.658576,3.860647 2.810768,5.666637 z" + id="Big_Button_Circle" + inkscape:connector-curvature="0" + sodipodi:nodetypes="sssssss" /> + <path + style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#5ce8e8;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.23041919;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 9.6493062,42.217346 c 0.6901338,1.262844 -0.548965,3.216837 -0.548965,3.216837 l -0.3231724,0.861123 -0.3698409,0.875245 -0.02896,1.076248 0.4536482,0.994808 0.2552772,1.369224 -0.8293436,2.367331 c 1.5767568,0.128967 1.6355518,0.105956 2.9791143,-0.697449 l -0.654823,-1.713233 -0.338963,-1.404356 -0.0276,-1.376181 0.21628,-0.595809 -0.415667,-1.10013 1.174804,-3.480722 -0.910737,-0.425652 c -0.6312958,0.192164 -0.6394358,-0.0063 -0.6437358,0.09061 -0.00293,0.06413 0.04844,-0.230324 0.0124,-0.05784 0,0 -0.071022,0.01167 -0.06892,0.03779 0.0016,0.01993 0.05652,0.02005 0.05652,0.02005 z" + id="Button_Pointer" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccccccccccccscacc" /> + </g> +</svg> diff --git a/res/computerscare-small-knob-effed-disabled.svg b/res/computerscare-small-knob-effed-disabled.svg @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="Layer_1" + data-name="Layer 1" + viewBox="0 0 18 18" + version="1.1" + sodipodi:docname="computerscare-small-knob-effed-disabled.svg" + inkscape:version="0.92.2 5c3e80d, 2017-08-06" + width="18" + height="18"> + <metadata + id="metadata1289"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>01 Big Knob</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1398" + inkscape:window-height="834" + id="namedview1287" + showgrid="false" + inkscape:zoom="22.378007" + inkscape:cx="-0.98240185" + inkscape:cy="9.9790231" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="Big_Knob" /> + <defs + id="defs1279"> + <style + id="style1277">.cls-1{fill:#245559;}.cls-2{fill:none;stroke:#24c9a6;stroke-miterlimit:10;stroke-width:3px;}</style> + </defs> + <title + id="title1281">01 Big Knob</title> + <g + id="Big_Knob" + data-name="Big Knob" + transform="translate(0,-42)"> + <path + style="fill:#aab8ba;fill-opacity:1;stroke:#000000;stroke-width:0.794;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" + d="m 17.306156,50.928799 c 0.547144,6.492783 -3.674677,9.295802 -8.5188736,8.849665 -4.4544548,-0.410243 -9.25218903,-4.158274 -8.1261913,-8.808316 1.8128765,-7.48665 4.5399117,-8.489838 8.8083151,-8.808316 0.2710372,-0.02022 0.4944121,-0.0716 0.6174528,0.01303 0.851296,0.585106 -1.6051492,2.237455 4.408529,3.087358 0,0 2.658576,3.860647 2.810768,5.666637 z" + id="Big_Button_Circle" + inkscape:connector-curvature="0" + sodipodi:nodetypes="sssssss" /> + <path + style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#6b7a77;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.23041919;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 9.6493062,42.217346 c 0.6901338,1.262844 -0.548965,3.216837 -0.548965,3.216837 l -0.3231724,0.861123 -0.3698409,0.875245 -0.02896,1.076248 0.4536482,0.994808 0.2552772,1.369224 -0.8293436,2.367331 c 1.5767568,0.128967 1.6355518,0.105956 2.9791143,-0.697449 l -0.654823,-1.713233 -0.338963,-1.404356 -0.0276,-1.376181 0.21628,-0.595809 -0.415667,-1.10013 1.174804,-3.480722 -0.910737,-0.425652 c -0.6312958,0.192164 -0.6394358,-0.0063 -0.6437358,0.09061 -0.00293,0.06413 0.04844,-0.230324 0.0124,-0.05784 0,0 -0.071022,0.01167 -0.06892,0.03779 0.0016,0.01993 0.05652,0.02005 0.05652,0.02005 z" + id="Button_Pointer" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccccccccccccscacc" /> + </g> +</svg> diff --git a/src/ComputerscareMolyPatrix.cpp b/src/ComputerscareMolyPatrix.cpp @@ -46,7 +46,7 @@ struct ComputerscareMolyPatrix : ComputerscarePolyModule { configParam(INPUT_ROW_TRIM + i, -2.f, 2.f, 1.f, "Input Channel " + std::to_string(i + 1) + " Attenuation"); configParam(OUTPUT_COLUMN_TRIM + i, -2.f, 2.f, 1.f, "Output Channel " + std::to_string(i + 1) + " Attenuation"); for (int j = 0; j < numColumns; j++) { - configParam(KNOB + i * 16 + j, -2.f, 2.f, i == j ? 1.f : 0.f, "Input ch." + std::to_string(i+1) + " → Output ch." + std::to_string(j+1)); + configParam(KNOB + i * 16 + j, -2.f, 2.f, i == j ? 1.f : 0.f, "Input ch." + std::to_string(i + 1) + " → Output ch." + std::to_string(j + 1)); } configParam(OUTPUT_TRIM, -2.f, 2.f, 1.f, "Output Attenuation"); configParam(OUTPUT_OFFSET, -10.f, 10.f, 0.f, "Output Offset"); @@ -77,13 +77,45 @@ struct ComputerscareMolyPatrix : ComputerscarePolyModule { for (int j = 0; j < numRows; j++) { float out = 0.f; for (int i = 0; i < numColumns; i++) { - out += params[KNOB + i * 16 + j].getValue() * inputs[POLY_INPUT].getVoltage(i)*params[INPUT_ROW_TRIM+i].getValue()*params[INPUT_TRIM].getValue(); + out += params[KNOB + i * 16 + j].getValue() * inputs[POLY_INPUT].getVoltage(i) * params[INPUT_ROW_TRIM + i].getValue() * params[INPUT_TRIM].getValue(); } outputs[POLY_OUTPUT].setVoltage(out, j); } } }; +struct DisableableSmallKnob : RoundKnob { + + std::vector<std::shared_ptr<Svg>> enabledThemes = {APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-small-knob-effed.svg")),APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-small-knob-dark.svg"))}; + + std::shared_ptr<Svg> enabledSvg = APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-small-knob-effed.svg")); + std::shared_ptr<Svg> disabledSvg = APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-small-knob-effed-disabled.svg")); + + int inputChannel = 0; + int outputChannel = 0; + bool disabled = false; + ComputerscareMolyPatrix *module; + + DisableableSmallKnob() { + setSvg(enabledSvg); + shadow->box.size = math::Vec(0, 0); + shadow->opacity = 0.f; + } + + void draw(const DrawArgs& args) override { + if (module) { + bool candidateDisabled = (module->numInputChannels !=0 && inputChannel > module->numInputChannels-1 || outputChannel > module->polyChannels-1) ; + if (disabled != candidateDisabled) { + setSvg(candidateDisabled ? disabledSvg : enabledSvg); + dirtyValue = -20.f; + disabled = candidateDisabled; + } + } + else { + } + RoundKnob::draw(args); + } +}; struct ComputerscareMolyPatrixWidget : ModuleWidget { ComputerscareMolyPatrixWidget(ComputerscareMolyPatrix *module) { @@ -109,25 +141,23 @@ struct ComputerscareMolyPatrixWidget : ModuleWidget { float dy = 21; addInput(createInput<PointingUpPentagonPort>(Vec(9, 12), module, ComputerscareMolyPatrix::POLY_INPUT)); - addLabeledKnob("",36,16,module,ComputerscareMolyPatrix::INPUT_TRIM,0,0); + addKnob(36, 16, module, ComputerscareMolyPatrix::INPUT_TRIM, 0, 0); for (int i = 0; i < numRows; i++) { for (int j = 0; j < numColumns; j++) { xx = x0 + j * dx; yy = y0 + i * dy; - addLabeledKnob(std::to_string(i + 1), xx, yy, module, i * 16 + j, 0, 0); + addKnob( xx, yy, module, i * 16 + j, i,j); } - addLabeledKnob("",x0-25,y0+i*dy,module,ComputerscareMolyPatrix::INPUT_ROW_TRIM+i,0,0); + addKnob( x0 - 25, y0 + i * dy, module, ComputerscareMolyPatrix::INPUT_ROW_TRIM + i,i,0); } - - channelWidget = new PolyOutputChannelsWidget(Vec(290, 1), module, ComputerscareMolyPatrix::POLY_CHANNELS); addChild(channelWidget); addOutput(createOutput<InPort>(Vec(318, 1), module, ComputerscareMolyPatrix::POLY_OUTPUT)); } - void addLabeledKnob(std::string label, int x, int y, ComputerscareMolyPatrix *module, int index, float labelDx, float labelDy) { + void addKnob(int x, int y, ComputerscareMolyPatrix *module, int index, int row,int column) { /* smallLetterDisplay = new SmallLetterDisplay(); smallLetterDisplay->box.size = Vec(5, 10); @@ -135,13 +165,18 @@ struct ComputerscareMolyPatrixWidget : ModuleWidget { smallLetterDisplay->value = label; smallLetterDisplay->textAlign = 1;*/ - addParam(createParam<ComputerscareDotKnob>(Vec(x, y), module, ComputerscareMolyPatrix::KNOB + index)); + knob = createParam<DisableableSmallKnob>(Vec(x, y), module, ComputerscareMolyPatrix::KNOB + index); + knob->module = module; + knob->inputChannel = row; + knob->outputChannel = column; + addParam(knob); //smallLetterDisplay->box.pos = Vec(x + labelDx, y - 12 + labelDy); // addChild(smallLetterDisplay); } + DisableableSmallKnob* knob; PolyOutputChannelsWidget* channelWidget; SmallLetterDisplay* smallLetterDisplay; };