Browse Source

Add MIDI-Map panel and boilerplate. Various fixes for SVGButton.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
9ab5244002
9 changed files with 422 additions and 35 deletions
  1. +6
    -8
      include/app/SVGButton.hpp
  2. +0
    -1
      include/app/SVGSwitch.hpp
  3. +1
    -13
      include/componentlibrary.hpp
  4. +252
    -0
      res/Core/MIDI-Map.svg
  5. +5
    -0
      src/Core/Core.cpp
  6. +1
    -0
      src/Core/Core.hpp
  7. +129
    -0
      src/Core/MIDI_Map.cpp
  8. +1
    -1
      src/app/ParamWidget.cpp
  9. +27
    -12
      src/app/SVGButton.cpp

+ 6
- 8
include/app/SVGButton.hpp View File

@@ -1,5 +1,6 @@
#pragma once
#include "app/common.hpp"
#include "widgets/OpaqueWidget.hpp"
#include "widgets/FramebufferWidget.hpp"
#include "widgets/SVGWidget.hpp"

@@ -7,19 +8,16 @@
namespace rack {


/** A Component with a default (up) and active (down) state when clicked.
Does not modify a Param, simply calls onAction() of a subclass.
*/
struct SVGButton : FramebufferWidget {
std::shared_ptr<SVG> defaultSVG;
std::shared_ptr<SVG> activeSVG;
struct SVGButton : OpaqueWidget {
FramebufferWidget *fb;
SVGWidget *sw;
std::vector<std::shared_ptr<SVG>> frames;

SVGButton();
/** If `activeSVG` is NULL, `defaultSVG` is used as the active state instead. */
void setSVGs(std::shared_ptr<SVG> defaultSVG, std::shared_ptr<SVG> activeSVG);
void addFrame(std::shared_ptr<SVG> svg);
void onDragStart(const event::DragStart &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDragDrop(const event::DragDrop &e) override;
};




+ 0
- 1
include/app/SVGSwitch.hpp View File

@@ -1,6 +1,5 @@
#pragma once
#include "app/common.hpp"
#include "widgets/Widget.hpp"
#include "widgets/FramebufferWidget.hpp"
#include "widgets/SVGWidget.hpp"
#include "app/Switch.hpp"


+ 1
- 13
include/componentlibrary.hpp View File

@@ -506,7 +506,7 @@ struct PB61303Light : BASE {


////////////////////
// Switches and Buttons
// Switches
////////////////////

struct NKK : SVGSwitch {
@@ -585,18 +585,6 @@ struct PB61303 : SVGSwitch {
}
};

struct PB61303Button : SVGButton {
PB61303Button() {
setSVGs(SVG::load(asset::system("res/ComponentLibrary/PB61303.svg")), NULL);
}
};

struct LEDBezelButton : SVGButton {
LEDBezelButton() {
setSVGs(SVG::load(asset::system("res/ComponentLibrary/LEDBezel.svg")), NULL);
}
};

////////////////////
// Misc
////////////////////


+ 252
- 0
res/Core/MIDI-Map.svg View File

@@ -0,0 +1,252 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<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"
width="50.799999mm"
height="128.50069mm"
viewBox="0 0 50.799999 128.50069"
version="1.1"
id="svg25656"
inkscape:version="0.92.2 2405546, 2018-03-11"
sodipodi:docname="MIDI-Map.svg">
<defs
id="defs25650" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="246.19451"
inkscape:cy="233.38434"
inkscape:document-units="mm"
inkscape:current-layer="layer2"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:snap-bbox="true"
inkscape:snap-bbox-midpoints="true"
inkscape:snap-nodes="false"
inkscape:window-width="1600"
inkscape:window-height="882"
inkscape:window-x="0"
inkscape:window-y="18"
inkscape:window-maximized="0" />
<metadata
id="metadata25653">
<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></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-575.58863,33.900484)">
<path
inkscape:connector-curvature="0"
style="fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775"
d="m 575.68099,-33.806776 h 50.61394 V 94.506487 h -50.61394 z m 0,0"
id="path9556" />
<path
inkscape:connector-curvature="0"
style="fill:#ababab;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775"
d="m 626.38863,-33.900484 h -50.8 V 94.600197 h 50.8 z M 626.20124,94.412787 H 575.77469 V -33.713071 h 50.42655 z m 0,0"
id="path9558" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775"
d="m 598.23534,90.456437 c -0.11715,0 -0.22465,-0.0661 -0.27562,-0.1695 l -1.0032,-2.00505 c -0.0758,-0.15296 -0.0138,-0.33761 0.1378,-0.41479 0.15296,-0.0758 0.33761,-0.0138 0.41342,0.13919 l 0.7276,1.45245 0.72623,-1.45245 c 0.0758,-0.15297 0.2618,-0.21498 0.41339,-0.13919 0.15296,0.0772 0.21498,0.26183 0.13783,0.41479 l -1.00186,2.00505 c -0.0524,0.10336 -0.15984,0.1695 -0.27559,0.1695"
id="path16908" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775"
d="m 603.74058,90.456437 c -0.11712,0 -0.22324,-0.0661 -0.27559,-0.1695 l -1.00185,-2.00505 c -0.0771,-0.15296 -0.0152,-0.33761 0.13783,-0.41479 0.15155,-0.0758 0.33761,-0.0138 0.41338,0.13919 l 0.72623,1.45245 0.72623,-1.45245 c 0.0758,-0.15297 0.26183,-0.21498 0.41342,-0.13919 0.15296,0.0772 0.21498,0.26183 0.13917,0.41479 l -1.00319,2.00505 c -0.051,0.10336 -0.15847,0.1695 -0.27563,0.1695"
id="path16910" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775"
d="m 601.13747,90.456437 c -0.72348,0 -1.3105,-0.58705 -1.3105,-1.31051 0,-0.72209 0.58702,-1.31052 1.3105,-1.31052 0.28663,0 0.55813,0.091 0.78687,0.26183 0.13642,0.10197 0.16397,0.29628 0.0606,0.4327 -0.10199,0.13505 -0.29492,0.16261 -0.43134,0.0606 -0.11987,-0.091 -0.26458,-0.13919 -0.41617,-0.13919 -0.38308,0 -0.69452,0.31144 -0.69452,0.69454 0,0.38309 0.31144,0.69452 0.69452,0.69452 0.15159,0 0.2963,-0.0482 0.41617,-0.13918 0.13642,-0.10197 0.32935,-0.0744 0.43134,0.062 0.10333,0.13504 0.0758,0.32935 -0.0606,0.43132 -0.22874,0.17088 -0.50024,0.26183 -0.78687,0.26183"
id="path16912" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775"
d="m 601.55914,89.130757 c 0,0.22187 -0.18051,0.40102 -0.40237,0.40102 -0.22049,0 -0.39963,-0.17915 -0.39963,-0.40102 0,-0.22186 0.17914,-0.401 0.39963,-0.401 0.22186,0 0.40237,0.17914 0.40237,0.401"
id="path16914" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d="m 590.61407,-24.627051 c 0,0.176389 0.13783,0.319705 0.31422,0.319705 0.17639,0 0.31969,-0.143316 0.31969,-0.319705 v -1.471743 l 0.56776,0.865407 c 0.0661,0.104732 0.14884,0.165364 0.27009,0.165364 0.11574,0 0.20394,-0.06063 0.27008,-0.165364 l 0.57327,-0.881945 v 1.477257 c 0,0.181903 0.14333,0.330729 0.31972,0.330729 0.18189,0 0.32523,-0.148826 0.32523,-0.330729 v -2.353687 c 0,-0.181903 -0.14334,-0.325219 -0.32523,-0.325219 h -0.0717 c -0.13229,0 -0.22603,0.05512 -0.29217,0.165365 l -0.79375,1.289843 -0.78821,-1.284329 c -0.0551,-0.09922 -0.15434,-0.170879 -0.29217,-0.170879 h -0.0716 c -0.18189,0 -0.32523,0.143316 -0.32523,0.325219 z m 0,0"
id="path25184" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d="m 594.3598,-24.638075 c 0,0.181903 0.1433,0.330729 0.32519,0.330729 0.18193,0 0.32522,-0.148826 0.32522,-0.330729 v -2.359201 c 0,-0.181899 -0.14329,-0.325215 -0.32522,-0.325215 -0.18189,0 -0.32519,0.143316 -0.32519,0.325215 z m 0,0"
id="path25180" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d="m 595.7889,-24.660124 c 0,0.181903 0.14333,0.325219 0.32523,0.325219 h 0.82684 c 0.93154,0 1.57645,-0.650434 1.57645,-1.48277 v -0.0055 c 0,-0.837848 -0.64491,-1.477257 -1.57645,-1.477257 h -0.82684 c -0.1819,0 -0.32523,0.148826 -0.32523,0.330729 z m 0.65045,-0.264583 v -1.785937 h 0.50162 c 0.53467,0 0.89295,0.369316 0.89295,0.892969 v 0.01101 c 0,0.523656 -0.35828,0.881944 -0.89295,0.881944 z m 0,0"
id="path25176" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d="m 599.13457,-24.638075 c 0,0.181903 0.1433,0.330729 0.32519,0.330729 0.18193,0 0.32523,-0.148826 0.32523,-0.330729 v -2.359201 c 0,-0.181899 -0.1433,-0.325215 -0.32523,-0.325215 -0.18189,0 -0.32519,0.143316 -0.32519,0.325215 z m 0,0"
id="path25172" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d="m 600.74634,-25.338116 h 0.73315 c 0.17085,0 0.31418,-0.137806 0.31418,-0.308681 0,-0.170878 -0.14333,-0.30868 -0.31418,-0.30868 h -0.73315 c -0.17085,0 -0.30868,0.137802 -0.30868,0.30868 0,0.170875 0.13783,0.308681 0.30868,0.308681 z m 0,0"
id="path25168" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d="m 602.43185,-24.627051 c 0,0.176389 0.13783,0.319705 0.31422,0.319705 0.17638,0 0.31968,-0.143316 0.31968,-0.319705 v -1.471743 l 0.56776,0.865407 c 0.0661,0.104732 0.14884,0.165364 0.27009,0.165364 0.11575,0 0.20394,-0.06063 0.27009,-0.165364 l 0.57326,-0.881945 v 1.477257 c 0,0.181903 0.14333,0.330729 0.31972,0.330729 0.18189,0 0.32523,-0.148826 0.32523,-0.330729 v -2.353687 c 0,-0.181903 -0.14334,-0.325219 -0.32523,-0.325219 h -0.0717 c -0.13229,0 -0.22602,0.05512 -0.29217,0.165365 l -0.79375,1.289843 -0.78821,-1.284329 c -0.0551,-0.09922 -0.15434,-0.170879 -0.29217,-0.170879 h -0.0716 c -0.18189,0 -0.32522,0.143316 -0.32522,0.325219 z m 0,0"
id="path25160" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d="m 605.87281,-24.616026 c 0,0.170878 0.12678,0.30868 0.29767,0.30868 0.13779,0 0.24804,-0.07717 0.30314,-0.203948 l 0.20398,-0.490583 h 1.30637 l 0.19843,0.468535 c 0.0606,0.132292 0.15985,0.225996 0.31419,0.225996 0.17089,0 0.30868,-0.143316 0.30868,-0.314191 0,-0.0441 -0.0109,-0.08819 -0.0332,-0.132291 l -1.03628,-2.331643 c -0.0717,-0.15985 -0.19844,-0.259069 -0.37483,-0.259069 h -0.0386 c -0.17639,0 -0.30868,0.09922 -0.38033,0.259069 l -1.03079,2.331643 c -0.0219,0.0441 -0.0386,0.0937 -0.0386,0.137802 z m 1.04732,-0.959115 0.41339,-0.975649 0.40791,0.975649 z m 0,0"
id="path25164" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d="m 609.28773,-24.638075 c 0,0.181903 0.14333,0.330729 0.32522,0.330729 0.1819,0 0.32523,-0.148826 0.32523,-0.330729 v -0.584288 h 0.49608 c 0.66146,0 1.19616,-0.358288 1.19616,-1.041795 v -0.01101 c 0,-0.606337 -0.42997,-1.025261 -1.13552,-1.025261 h -0.88195 c -0.18189,0 -0.32522,0.148827 -0.32522,0.33073 z m 0.65045,-1.163062 v -0.909507 h 0.50162 c 0.32519,0 0.52916,0.159854 0.52916,0.451996 v 0.0055 c 0,0.253559 -0.18743,0.451997 -0.51816,0.451997 z m 0,0"
id="path25156" />
<path
inkscape:connector-curvature="0"
style="fill:#ffd714;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d=""
id="path24932" />
<path
inkscape:connector-curvature="0"
style="fill:#ffd714;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d=""
id="path24884" />
<path
inkscape:connector-curvature="0"
style="fill:#ffd714;fill-opacity:1;stroke:none;stroke-width:0.35277775"
d=""
id="path24840" />
</g>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="widgets"
sodipodi:insensitive="true"
style="display:none">
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="path26233"
cx="7.9988499"
cy="77.451256"
r="2" />
<circle
r="2"
cy="77.451256"
cx="19.599171"
id="circle27040"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle27042"
cx="31.198805"
cy="77.451256"
r="2" />
<circle
r="2"
cy="77.451256"
cx="42.799126"
id="circle27044"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
r="2"
cy="89.051582"
cx="7.9988499"
id="circle27046"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle27048"
cx="19.599171"
cy="89.051582"
r="2" />
<circle
r="2"
cy="89.051582"
cx="31.198805"
id="circle27050"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle27052"
cx="42.799126"
cy="89.051582"
r="2" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle27054"
cx="7.9988499"
cy="100.65191"
r="2" />
<circle
r="2"
cy="100.65191"
cx="19.599171"
id="circle27056"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle27058"
cx="31.198805"
cy="100.65191"
r="2" />
<circle
r="2"
cy="100.65191"
cx="42.799126"
id="circle27060"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
r="2"
cy="112.25155"
cx="7.9988499"
id="circle27062"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle27064"
cx="19.599171"
cy="112.25155"
r="2" />
<circle
r="2"
cy="112.25155"
cx="31.198805"
id="circle27066"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.69999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="circle27068"
cx="42.799126"
cy="112.25155"
r="2" />
</g>
</svg>

+ 5
- 0
src/Core/Core.cpp View File

@@ -33,6 +33,11 @@ void init(rack::Plugin *p) {
modelMIDI_Gate->tags = {"External", "MIDI"};
p->addModel(modelMIDI_Gate);

modelMIDI_Map->name = "MIDI-Map";
modelMIDI_Map->description = "";
modelMIDI_Map->tags = {"External", "MIDI"};
p->addModel(modelMIDI_Map);

modelCV_MIDI->name = "CV-MIDI";
modelCV_MIDI->description = "";
modelCV_MIDI->tags = {"External", "MIDI"};


+ 1
- 0
src/Core/Core.hpp View File

@@ -9,6 +9,7 @@ extern Model *modelAudioInterface;
extern Model *modelMIDI_CV;
extern Model *modelMIDI_CC;
extern Model *modelMIDI_Gate;
extern Model *modelMIDI_Map;
extern Model *modelCV_MIDI;
extern Model *modelCV_CC;
extern Model *modelCV_Gate;


+ 129
- 0
src/Core/MIDI_Map.cpp View File

@@ -0,0 +1,129 @@
#include "Core.hpp"


struct MIDI_Map : Module {
enum ParamIds {
NUM_PARAMS
};
enum InputIds {
NUM_INPUTS
};
enum OutputIds {
NUM_OUTPUTS
};
enum LightIds {
ENUMS(MAP_LIGHTS, 16),
NUM_LIGHTS
};

midi::InputQueue midiInput;
int8_t values[128];
int learningId = -1;
int learnedCcs[16] = {};
bool mapped[16] = {};

MIDI_Map() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
onReset();
}

void onReset() override {
for (int i = 0; i < 128; i++) {
values[i] = 0;
}
for (int i = 0; i < 16; i++) {
learnedCcs[i] = i;
}
learningId = -1;
midiInput.reset();
}

void step() override {
for (int i = 0; i < 16; i++) {
lights[MAP_LIGHTS + i].setBrightness(mapped[i]);
}
}
};


struct CKD6Button : SVGButton {
MIDI_Map *module;
int id;

CKD6Button() {
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_0.svg")));
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_1.svg")));
}

void onAction(const event::Action &e) override {
module->mapped[id] ^= true;
}
};

template <class TWidget>
TWidget *createMapButtonCentered(math::Vec pos, MIDI_Map *module, int id) {
TWidget *o = new TWidget;
o->box.pos = pos.minus(o->box.size.div(2));;
o->module = module;
o->id = id;
return o;
}


struct MIDI_MapWidget : ModuleWidget {
MIDI_MapWidget(MIDI_Map *module) {
setModule(module);
setPanel(SVG::load(asset::system("res/Core/MIDI-Map.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));

addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(8, 77)), module, 0));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(20, 77)), module, 1));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(31, 77)), module, 2));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(43, 77)), module, 3));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(8, 89)), module, 4));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(20, 89)), module, 5));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(31, 89)), module, 6));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(43, 89)), module, 7));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(8, 101)), module, 8));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(20, 101)), module, 9));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(31, 101)), module, 10));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(43, 101)), module, 11));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(8, 112)), module, 12));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(20, 112)), module, 13));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(31, 112)), module, 14));
addChild(createMapButtonCentered<CKD6Button>(mm2px(Vec(43, 112)), module, 15));

addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(8, 77)), module, MIDI_Map::MAP_LIGHTS + 0));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(20, 77)), module, MIDI_Map::MAP_LIGHTS + 1));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(31, 77)), module, MIDI_Map::MAP_LIGHTS + 2));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(43, 77)), module, MIDI_Map::MAP_LIGHTS + 3));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(8, 89)), module, MIDI_Map::MAP_LIGHTS + 4));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(20, 89)), module, MIDI_Map::MAP_LIGHTS + 5));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(31, 89)), module, MIDI_Map::MAP_LIGHTS + 6));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(43, 89)), module, MIDI_Map::MAP_LIGHTS + 7));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(8, 101)), module, MIDI_Map::MAP_LIGHTS + 8));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(20, 101)), module, MIDI_Map::MAP_LIGHTS + 9));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(31, 101)), module, MIDI_Map::MAP_LIGHTS + 10));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(43, 101)), module, MIDI_Map::MAP_LIGHTS + 11));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(8, 112)), module, MIDI_Map::MAP_LIGHTS + 12));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(20, 112)), module, MIDI_Map::MAP_LIGHTS + 13));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(31, 112)), module, MIDI_Map::MAP_LIGHTS + 14));
addChild(createLightCentered<MediumLight<YellowLight>>(mm2px(Vec(43, 112)), module, MIDI_Map::MAP_LIGHTS + 15));

typedef Grid16MidiWidget<CcChoice<MIDI_Map>> TMidiWidget;
TMidiWidget *midiWidget = createWidget<TMidiWidget>(mm2px(Vec(3.399621, 14.837339)));
midiWidget->box.size = mm2px(Vec(44, 54.667));
if (module)
midiWidget->midiIO = &module->midiInput;
midiWidget->setModule(module);
addChild(midiWidget);
}
};


Model *modelMIDI_Map = createModel<MIDI_Map, MIDI_MapWidget>("MIDI-Map");


+ 1
- 1
src/app/ParamWidget.cpp View File

@@ -161,7 +161,7 @@ void ParamWidget::onButton(const event::Button &e) {
}

void ParamWidget::onEnter(const event::Enter &e) {
if (settings::paramTooltip && !tooltip) {
if (settings::paramTooltip && !tooltip && paramQuantity) {
ParamTooltip *paramTooltip = new ParamTooltip;
paramTooltip->paramWidget = this;
app()->scene->addChild(paramTooltip);


+ 27
- 12
src/app/SVGButton.cpp View File

@@ -5,27 +5,42 @@ namespace rack {


SVGButton::SVGButton() {
fb = new FramebufferWidget;
addChild(fb);

sw = new SVGWidget;
addChild(sw);
fb->addChild(sw);
}

void SVGButton::setSVGs(std::shared_ptr<SVG> defaultSVG, std::shared_ptr<SVG> activeSVG) {
sw->setSVG(defaultSVG);
box.size = sw->box.size;
this->defaultSVG = defaultSVG;
this->activeSVG = activeSVG ? activeSVG : defaultSVG;
void SVGButton::addFrame(std::shared_ptr<SVG> svg) {
frames.push_back(svg);
// If this is our first frame, automatically set SVG and size
if (!sw->svg) {
sw->setSVG(svg);
box.size = sw->box.size;
fb->box.size = sw->box.size;
}
}

void SVGButton::onDragStart(const event::DragStart &e) {
event::Action eAction;
onAction(eAction);
sw->setSVG(activeSVG);
dirty = true;
if (frames.size() >= 2) {
sw->setSVG(frames[1]);
fb->dirty = true;
}
}

void SVGButton::onDragEnd(const event::DragEnd &e) {
sw->setSVG(defaultSVG);
dirty = true;
if (frames.size() >= 1) {
sw->setSVG(frames[0]);
fb->dirty = true;
}
}

void SVGButton::onDragDrop(const event::DragDrop &e) {
if (e.origin == this) {
event::Action eAction;
onAction(eAction);
}
}




Loading…
Cancel
Save