From e6ea20b81f9dfa1ca3a2245e13f268fac686db6f Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 5 Nov 2021 15:25:55 -0400 Subject: [PATCH] Update Quantizer note positions. --- res/Quantizer.svg | 319 +++++++++++++++++++++++----------------------- src/Quantizer.cpp | 54 +++++--- 2 files changed, 198 insertions(+), 175 deletions(-) diff --git a/res/Quantizer.svg b/res/Quantizer.svg index 5953177..a427e8e 100644 --- a/res/Quantizer.svg +++ b/res/Quantizer.svg @@ -1,21 +1,21 @@ + id="svg91" + sodipodi:docname="Quantizer.svg" + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"> + id="metadata95"> @@ -34,21 +34,22 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" - inkscape:window-height="1017" - id="namedview95" + inkscape:window-width="1600" + inkscape:window-height="882" + id="namedview93" showgrid="false" - inkscape:zoom="1.7566021" - inkscape:cx="-194.12266" - inkscape:cy="194.26707" - inkscape:window-x="-8" - inkscape:window-y="-8" + inkscape:zoom="2.9110525" + inkscape:cx="53.245346" + inkscape:cy="134.31568" + inkscape:window-x="0" + inkscape:window-y="18" inkscape:window-maximized="1" - inkscape:current-layer="ae78a0be-9002-435a-8d16-aab01d8766c8" /> + inkscape:current-layer="a25efd1d-a885-4bac-a53e-4d8304a6454b" + inkscape:pagecheckerboard="0" /> + fill="url(#a5fe35b8-2a0b-471b-b722-4d58f9c99033)" + id="rect9" /> @@ -148,108 +149,109 @@ + fill="#1f1f1f" + id="path35" /> + fill="#1f1f1f" + id="path37" /> + fill="#1f1f1f" + id="path39" /> + fill="#1f1f1f" + id="path41" /> + fill="#1f1f1f" + id="path45" /> + fill="#1f1f1f" + id="path47" /> + fill="#1f1f1f" + id="path49" /> + fill="#1f1f1f" + id="path53" /> + fill="#1f1f1f" + id="path55" /> + fill="#1f1f1f" + id="path57" /> + fill="#1f1f1f" + id="path59" /> + fill="#1f1f1f" + id="path61" /> + fill="#f0f0f0" + id="path65" /> + fill="#f0f0f0" + id="path67" /> + fill="#f0f0f0" + id="path69" /> diff --git a/src/Quantizer.cpp b/src/Quantizer.cpp index cf33f9a..0600117 100644 --- a/src/Quantizer.cpp +++ b/src/Quantizer.cpp @@ -132,14 +132,15 @@ struct QuantizerButton : OpaqueWidget { if (layer != 1) return; - const float margin = mm2px(1.5); Rect r = box.zeroPos(); + const float margin = mm2px(1.0); + Rect rMargin = r.grow(Vec(margin, margin)); + nvgBeginPath(args.vg); - nvgRect(args.vg, RECT_ARGS(r)); + nvgRect(args.vg, RECT_ARGS(rMargin)); nvgFillColor(args.vg, nvgRGB(0x12, 0x12, 0x12)); nvgFill(args.vg); - r = r.shrink(Vec(margin, margin / 2)); nvgBeginPath(args.vg); nvgRect(args.vg, RECT_ARGS(r)); if (module ? module->playingNotes[note] : (note == 0)) { @@ -177,28 +178,51 @@ struct QuantizerButton : OpaqueWidget { struct QuantizerDisplay : LedDisplay { void setModule(Quantizer* module) { + std::vector noteAbsPositions = { + mm2px(Vec(2.242, 60.54)), + mm2px(Vec(2.242, 58.416)), + mm2px(Vec(2.242, 52.043)), + mm2px(Vec(2.242, 49.919)), + mm2px(Vec(2.242, 45.67)), + mm2px(Vec(2.242, 39.298)), + mm2px(Vec(2.242, 37.173)), + mm2px(Vec(2.242, 30.801)), + mm2px(Vec(2.242, 28.677)), + mm2px(Vec(2.242, 22.304)), + mm2px(Vec(2.242, 20.18)), + mm2px(Vec(2.242, 15.931)), + }; + std::vector noteSizes = { + mm2px(Vec(10.734, 5.644)), + mm2px(Vec(8.231, 3.52)), + mm2px(Vec(10.734, 7.769)), + mm2px(Vec(8.231, 3.52)), + mm2px(Vec(10.734, 5.644)), + mm2px(Vec(10.734, 5.644)), + mm2px(Vec(8.231, 3.52)), + mm2px(Vec(10.734, 7.769)), + mm2px(Vec(8.231, 3.52)), + mm2px(Vec(10.734, 7.768)), + mm2px(Vec(8.231, 3.52)), + mm2px(Vec(10.734, 5.644)), + }; + // White notes static const std::vector whiteNotes = {0, 2, 4, 5, 7, 9, 11}; - for (size_t i = 0; i < whiteNotes.size(); i++) { - int note = whiteNotes[i]; + for (int note : whiteNotes) { QuantizerButton* quantizerButton = new QuantizerButton(); - quantizerButton->box.pos = Vec(0, i * box.size.y / 7); - quantizerButton->box.size = Vec(box.size.x, box.size.y / 7); + quantizerButton->box.pos = noteAbsPositions[note] - box.pos; + quantizerButton->box.size = noteSizes[note]; quantizerButton->module = module; quantizerButton->note = note; addChild(quantizerButton); } // Black notes static const std::vector blackNotes = {1, 3, 6, 8, 10}; - static const std::vector blackPos = {1, 2, 4, 5, 6}; - for (size_t i = 0; i < blackNotes.size(); i++) { - int note = blackNotes[i]; - float height = box.size.y * 0.1f; - float width = box.size.x * 0.6f; - float pos = blackPos[i] / 7.f * box.size.y - height / 2; + for (int note : blackNotes) { QuantizerButton* quantizerButton = new QuantizerButton(); - quantizerButton->box.pos = Vec(0, pos); - quantizerButton->box.size = Vec(width, height); + quantizerButton->box.pos = noteAbsPositions[note] - box.pos; + quantizerButton->box.size = noteSizes[note]; quantizerButton->module = module; quantizerButton->note = note; addChild(quantizerButton);