| @@ -130,6 +130,9 @@ struct MenuItem : MenuEntry { | |||
| } | |||
| }; | |||
| struct TooltipOverlay : TransparentWidget { | |||
| }; | |||
| struct WindowOverlay : OpaqueWidget { | |||
| }; | |||
| @@ -246,12 +249,14 @@ struct ProgressBar : QuantityWidget { | |||
| }; | |||
| struct Tooltip : VirtualWidget { | |||
| void step() override; | |||
| std::string text; | |||
| Tooltip(); | |||
| void draw(NVGcontext *vg) override; | |||
| }; | |||
| struct Scene : OpaqueWidget { | |||
| Widget *overlay = NULL; | |||
| /** Takes ownership of `w` */ | |||
| void setOverlay(Widget *w); | |||
| Menu *createMenu(); | |||
| void step() override; | |||
| @@ -0,0 +1,58 @@ | |||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
| <!-- Generated by IcoMoon.io --> | |||
| <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" | |||
| version="1.1" | |||
| width="16" | |||
| height="16" | |||
| viewBox="0 0 16 16" | |||
| id="svg846" | |||
| sodipodi:docname="030-feed.svg" | |||
| inkscape:version="0.92.2 2405546, 2018-03-11"> | |||
| <metadata | |||
| id="metadata852"> | |||
| <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> | |||
| <defs | |||
| id="defs850" /> | |||
| <sodipodi:namedview | |||
| pagecolor="#ffffff" | |||
| bordercolor="#666666" | |||
| borderopacity="1" | |||
| objecttolerance="10" | |||
| gridtolerance="10" | |||
| guidetolerance="10" | |||
| inkscape:pageopacity="0" | |||
| inkscape:pageshadow="2" | |||
| inkscape:window-width="1600" | |||
| inkscape:window-height="900" | |||
| id="namedview848" | |||
| showgrid="false" | |||
| inkscape:zoom="43.5" | |||
| inkscape:cx="8.7586207" | |||
| inkscape:cy="8.045977" | |||
| inkscape:window-x="0" | |||
| inkscape:window-y="0" | |||
| inkscape:window-maximized="0" | |||
| inkscape:current-layer="svg846" /> | |||
| <path | |||
| d="M 6.5,8 C 6.5,7.17125 7.17125,6.5 8,6.5 8.82875,6.5 9.5,7.17125 9.5,8 9.5,8.82875 8.82875,9.5 8,9.5 7.17125,9.5 6.5,8.82875 6.5,8 Z M 9.785,4.7015 C 10.955,5.336 11.75,6.575 11.75,8 c 0,1.425 -0.79425,2.664 -1.965,3.2985 0.51675,-0.822 0.84,-1.995 0.84,-3.2985 0,-1.3035 -0.32325,-2.4765 -0.84,-3.2985 z M 5.375,8 c 0,1.3035 0.32325,2.4765 0.84,3.2985 C 5.045,10.664 4.25,9.425 4.25,8 4.25,6.575 5.04425,5.336 6.215,4.7015 5.69825,5.5235 5.375,6.6965 5.375,8 Z m -2.25,0 c 0,2.0145 0.6375,3.82275 1.6485,5.0595 C 3.10625,11.99375 2,10.12625 2,8 2,5.87375 3.1055,4.00625 4.7735,2.9405 3.7625,4.17725 3.125,5.9855 3.125,8 Z M 11.2265,2.9405 C 12.89375,4.00625 14,5.87375 14,8 c 0,2.12625 -1.1055,3.99375 -2.7735,5.0595 1.011,-1.23675 1.6485,-3.045 1.6485,-5.0595 0,-2.0145 -0.6375,-3.82275 -1.6485,-5.0595 z" | |||
| id="path844" | |||
| style="fill:#b4b4b4;fill-opacity:1;stroke-width:0.75" | |||
| inkscape:connector-curvature="0" /> | |||
| </svg> | |||
| @@ -0,0 +1,58 @@ | |||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
| <!-- Generated by IcoMoon.io --> | |||
| <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" | |||
| version="1.1" | |||
| width="16" | |||
| height="16" | |||
| viewBox="0 0 16 16" | |||
| id="svg4" | |||
| sodipodi:docname="037-file-empty.svg" | |||
| inkscape:version="0.92.2 2405546, 2018-03-11"> | |||
| <metadata | |||
| id="metadata10"> | |||
| <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> | |||
| <defs | |||
| id="defs8" /> | |||
| <sodipodi:namedview | |||
| pagecolor="#ffffff" | |||
| bordercolor="#666666" | |||
| borderopacity="1" | |||
| objecttolerance="10" | |||
| gridtolerance="10" | |||
| guidetolerance="10" | |||
| inkscape:pageopacity="0" | |||
| inkscape:pageshadow="2" | |||
| inkscape:window-width="1600" | |||
| inkscape:window-height="900" | |||
| id="namedview6" | |||
| showgrid="false" | |||
| inkscape:zoom="14.75" | |||
| inkscape:cx="4.5423729" | |||
| inkscape:cy="8.4745763" | |||
| inkscape:window-x="0" | |||
| inkscape:window-y="0" | |||
| inkscape:window-maximized="0" | |||
| inkscape:current-layer="svg4" /> | |||
| <path | |||
| d="M 12.75575,4.68425 C 12.4955,4.3295 12.1325,3.914 11.73425,3.51575 11.336,3.1175 10.9205,2.7545 10.56575,2.49425 9.96125,2.051 9.668,2 9.5,2 H 3.6875 C 3.17075,2 2.75,2.42075 2.75,2.9375 v 10.125 C 2.75,13.57925 3.17075,14 3.6875,14 h 8.625 C 12.82925,14 13.25,13.57925 13.25,13.0625 V 5.75 c 0,-0.168 -0.051,-0.46125 -0.49425,-1.06575 z m -1.5525,-0.6375 c 0.36,0.36 0.642,0.684 0.8505,0.95325 h -1.8045 V 3.19625 c 0.26925,0.2085 0.594,0.4905 0.95325,0.8505 z M 12.5,13.0625 c 0,0.102 -0.0855,0.1875 -0.1875,0.1875 H 3.6875 C 3.58625,13.25 3.5,13.1645 3.5,13.0625 V 2.9375 C 3.5,2.83625 3.58625,2.75 3.6875,2.75 c 0,0 5.81175,0 5.8125,0 V 5.375 C 9.5,5.582 9.668,5.75 9.875,5.75 H 12.5 Z" | |||
| id="path2" | |||
| style="fill:#b4b4b4;fill-opacity:1;stroke-width:0.75" | |||
| inkscape:connector-curvature="0" /> | |||
| </svg> | |||
| @@ -0,0 +1,57 @@ | |||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
| <!-- Generated by IcoMoon.io --> | |||
| <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" | |||
| version="1.1" | |||
| width="16" | |||
| height="16" | |||
| viewBox="0 0 16 16" | |||
| id="svg14" | |||
| sodipodi:docname="049-folder-open.svg" | |||
| inkscape:version="0.92.2 2405546, 2018-03-11"> | |||
| <metadata | |||
| id="metadata20"> | |||
| <rdf:RDF> | |||
| <cc:Work | |||
| rdf:about=""> | |||
| <dc:format>image/svg+xml</dc:format> | |||
| <dc:type | |||
| rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |||
| </cc:Work> | |||
| </rdf:RDF> | |||
| </metadata> | |||
| <defs | |||
| id="defs18" /> | |||
| <sodipodi:namedview | |||
| pagecolor="#ffffff" | |||
| bordercolor="#666666" | |||
| borderopacity="1" | |||
| objecttolerance="10" | |||
| gridtolerance="10" | |||
| guidetolerance="10" | |||
| inkscape:pageopacity="0" | |||
| inkscape:pageshadow="2" | |||
| inkscape:window-width="1600" | |||
| inkscape:window-height="882" | |||
| id="namedview16" | |||
| showgrid="false" | |||
| inkscape:zoom="14.75" | |||
| inkscape:cx="-1.6271186" | |||
| inkscape:cy="6.8474576" | |||
| inkscape:window-x="0" | |||
| inkscape:window-y="18" | |||
| inkscape:window-maximized="0" | |||
| inkscape:current-layer="svg14" /> | |||
| <path | |||
| d="m 11.75,12.875 2.25,-6 H 4.25 l -2.25,6 z M 3.5,6.125 2,12.875 v -9.75 h 3.375 l 1.5,1.5 h 4.875 v 1.5 z" | |||
| id="path12" | |||
| style="fill:#b4b4b4;fill-opacity:1;stroke-width:0.75" | |||
| inkscape:connector-curvature="0" /> | |||
| </svg> | |||
| @@ -1,4 +1,6 @@ | |||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
| <!-- Generated by IcoMoon.io --> | |||
| <svg | |||
| xmlns:dc="http://purl.org/dc/elements/1.1/" | |||
| xmlns:cc="http://creativecommons.org/ns#" | |||
| @@ -7,15 +9,15 @@ | |||
| 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" | |||
| viewBox="0 0 16 16" | |||
| version="1.1" | |||
| id="svg4" | |||
| sodipodi:docname="file.svg" | |||
| width="16" | |||
| height="16" | |||
| viewBox="0 0 16 16" | |||
| id="svg24" | |||
| sodipodi:docname="099-floppy-disk.svg" | |||
| inkscape:version="0.92.2 2405546, 2018-03-11"> | |||
| <metadata | |||
| id="metadata10"> | |||
| id="metadata30"> | |||
| <rdf:RDF> | |||
| <cc:Work | |||
| rdf:about=""> | |||
| @@ -27,7 +29,7 @@ | |||
| </rdf:RDF> | |||
| </metadata> | |||
| <defs | |||
| id="defs8" /> | |||
| id="defs28" /> | |||
| <sodipodi:namedview | |||
| pagecolor="#ffffff" | |||
| bordercolor="#666666" | |||
| @@ -39,18 +41,18 @@ | |||
| inkscape:pageshadow="2" | |||
| inkscape:window-width="1600" | |||
| inkscape:window-height="882" | |||
| id="namedview6" | |||
| id="namedview26" | |||
| showgrid="false" | |||
| inkscape:zoom="10.429825" | |||
| inkscape:cx="15.764779" | |||
| inkscape:cy="22.936865" | |||
| inkscape:zoom="14.75" | |||
| inkscape:cx="-3.5932203" | |||
| inkscape:cy="8" | |||
| inkscape:window-x="0" | |||
| inkscape:window-y="18" | |||
| inkscape:window-maximized="0" | |||
| inkscape:current-layer="svg4" /> | |||
| inkscape:current-layer="svg24" /> | |||
| <path | |||
| d="M 12.168717,4.2964265 10.202695,2.3304042 C 9.9917985,2.1195079 9.7059169,2 9.4083187,2 H 4.6256591 C 4.0046866,2.0023433 3.5008788,2.5061511 3.5008788,3.1271236 V 12.87522 C 3.5008788,13.496192 4.0046866,14 4.6256591,14 h 6.7486819 c 0.620972,0 1.12478,-0.503808 1.12478,-1.12478 V 5.0931459 c 0,-0.2975982 -0.119508,-0.5858231 -0.330404,-0.7967194 z m -0.885764,0.705331 H 9.4997071 V 3.218512 Z M 4.6256591,12.87522 V 3.1271236 h 3.7492677 v 2.437024 c 0,0.3116579 0.2507323,0.5623902 0.5623902,0.5623902 h 2.437024 V 12.87522 Z" | |||
| id="path2" | |||
| style="fill:#808080;fill-opacity:1;stroke-width:0.02343292" | |||
| d="M 12.5,2 H 2 V 14 H 14 V 3.5 Z M 8,3.5 h 1.5 v 3 H 8 Z m 4.5,9 h -9 v -9 H 4.25 V 7.25 H 11 V 3.5 h 0.879 L 12.5,4.121 Z" | |||
| id="path22" | |||
| style="fill:#b4b4b4;fill-opacity:1;stroke-width:0.75" | |||
| inkscape:connector-curvature="0" /> | |||
| </svg> | |||
| @@ -0,0 +1,58 @@ | |||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||
| <!-- Generated by IcoMoon.io --> | |||
| <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" | |||
| version="1.1" | |||
| width="16" | |||
| height="16" | |||
| viewBox="0 0 16 16" | |||
| id="svg34" | |||
| sodipodi:docname="167-meter.svg" | |||
| inkscape:version="0.92.2 2405546, 2018-03-11"> | |||
| <metadata | |||
| id="metadata40"> | |||
| <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> | |||
| <defs | |||
| id="defs38" /> | |||
| <sodipodi:namedview | |||
| pagecolor="#ffffff" | |||
| bordercolor="#666666" | |||
| borderopacity="1" | |||
| objecttolerance="10" | |||
| gridtolerance="10" | |||
| guidetolerance="10" | |||
| inkscape:pageopacity="0" | |||
| inkscape:pageshadow="2" | |||
| inkscape:window-width="1600" | |||
| inkscape:window-height="882" | |||
| id="namedview36" | |||
| showgrid="false" | |||
| inkscape:zoom="14.75" | |||
| inkscape:cx="-0.27118644" | |||
| inkscape:cy="5.6949153" | |||
| inkscape:window-x="0" | |||
| inkscape:window-y="18" | |||
| inkscape:window-maximized="0" | |||
| inkscape:current-layer="svg34" /> | |||
| <path | |||
| d="m 8,2.375 c 3.3135,0 6,2.6865 6,6 0,2.259 -1.24875,4.22625 -3.09375,5.25 H 5.09375 C 3.24875,12.60125 2,10.634 2,8.375 c 0,-3.3135 2.6865,-6 6,-6 z m 3.3975,9.3975 C 12.305,10.865 12.8045,9.65825 12.8045,8.375 H 11.75 v -0.75 h 0.99675 C 12.66425,7.09775 12.49625,6.59225 12.248,6.125 H 11 v -0.75 h 0.753 C 11.64275,5.237 11.5235,5.10425 11.39675,4.9775 10.85525,4.436 10.2065,4.03925 9.49925,3.80825 V 4.625 h -0.75 V 3.62825 c -0.246,-0.03825 -0.4965,-0.0585 -0.75,-0.0585 -0.2535,0 -0.504,0.0195 -0.75,0.0585 V 4.625 h -0.75 V 3.80825 C 5.792,4.04 5.14325,4.436 4.60175,4.9775 4.475,5.10425 4.3565,5.237 4.2455,5.375 h 0.753 v 0.75 H 3.7505 C 3.50225,6.59225 3.33425,7.09775 3.25175,7.625 H 4.2485 v 0.75 H 3.194 c 0,1.28325 0.4995,2.49 1.407,3.3975 0.12525,0.12525 0.25725,0.243 0.393,0.3525 h 2.2545 l 0.42825,-6 H 8.3195 l 0.42825,6 h 2.2545 c 0.1365,-0.1095 0.26775,-0.22725 0.393,-0.3525 z" | |||
| id="path32" | |||
| style="fill:#b4b4b4;fill-opacity:1;stroke-width:0.75" | |||
| inkscape:connector-curvature="0" /> | |||
| </svg> | |||
| @@ -1,2 +1,2 @@ | |||
| SVG icons in this directory are licensed under the CC BY 4.0 License by Font Awesome. | |||
| https://fontawesome.com/license | |||
| SVG icons in this directory are licensed under the CC BY 4.0 License by IcoMoon.io. | |||
| https://icomoon.io/ | |||
| @@ -7,116 +7,134 @@ | |||
| namespace rack { | |||
| struct NewButton : IconButton { | |||
| NewButton() { | |||
| setSVG(SVG::load(assetGlobal("res/icons/file.svg"))); | |||
| struct TooltipIconButton : IconButton { | |||
| std::string tooltipText; | |||
| void onMouseEnter(EventMouseEnter &e) override { | |||
| TooltipOverlay *overlay = new TooltipOverlay(); | |||
| Tooltip *tooltip = new Tooltip(); | |||
| tooltip->box.pos = getAbsoluteOffset(Vec(0, BND_WIDGET_HEIGHT)); | |||
| tooltip->text = tooltipText; | |||
| overlay->addChild(tooltip); | |||
| gScene->setOverlay(overlay); | |||
| } | |||
| void onAction(EventAction &e) override { | |||
| gRackWidget->reset(); | |||
| void onMouseLeave(EventMouseLeave &e) override { | |||
| gScene->setOverlay(NULL); | |||
| } | |||
| }; | |||
| struct NewItem : MenuItem { | |||
| struct NewButton : TooltipIconButton { | |||
| NewButton() { | |||
| setSVG(SVG::load(assetGlobal("res/icons/037-file-empty.svg"))); | |||
| tooltipText = "New patch (" WINDOW_MOD_KEY_NAME "+N)"; | |||
| } | |||
| void onAction(EventAction &e) override { | |||
| gRackWidget->reset(); | |||
| } | |||
| }; | |||
| struct DisconnectItem : MenuItem { | |||
| void onAction(EventAction &e) override { | |||
| gRackWidget->disconnect(); | |||
| struct OpenButton : TooltipIconButton { | |||
| OpenButton() { | |||
| setSVG(SVG::load(assetGlobal("res/icons/049-folder-open.svg"))); | |||
| tooltipText = "Open patch (" WINDOW_MOD_KEY_NAME "+O)"; | |||
| } | |||
| }; | |||
| struct OpenItem : MenuItem { | |||
| void onAction(EventAction &e) override { | |||
| gRackWidget->openDialog(); | |||
| } | |||
| }; | |||
| struct SaveItem : MenuItem { | |||
| struct SaveButton : TooltipIconButton { | |||
| SaveButton() { | |||
| setSVG(SVG::load(assetGlobal("res/icons/099-floppy-disk.svg"))); | |||
| tooltipText = "Save patch (" WINDOW_MOD_KEY_NAME "+S)"; | |||
| } | |||
| void onAction(EventAction &e) override { | |||
| gRackWidget->saveDialog(); | |||
| } | |||
| }; | |||
| struct SaveAsItem : MenuItem { | |||
| struct MeterButton : TooltipIconButton { | |||
| MeterButton() { | |||
| setSVG(SVG::load(assetGlobal("res/icons/167-meter.svg"))); | |||
| tooltipText = "Toggle CPU meter\nSee manual for mV definition"; | |||
| } | |||
| void onAction(EventAction &e) override { | |||
| gRackWidget->saveAsDialog(); | |||
| gCpuMeters ^= true; | |||
| } | |||
| }; | |||
| struct RevertItem : MenuItem { | |||
| struct EnginePauseItem : MenuItem { | |||
| void onAction(EventAction &e) override { | |||
| gRackWidget->revert(); | |||
| gPaused ^= true; | |||
| } | |||
| }; | |||
| struct QuitItem : MenuItem { | |||
| struct SampleRateItem : MenuItem { | |||
| float sampleRate; | |||
| void onAction(EventAction &e) override { | |||
| windowClose(); | |||
| engineSetSampleRate(sampleRate); | |||
| gPaused = false; | |||
| } | |||
| }; | |||
| struct FileChoice : ChoiceButton { | |||
| struct SampleRateButton : TooltipIconButton { | |||
| SampleRateButton() { | |||
| setSVG(SVG::load(assetGlobal("res/icons/030-feed.svg"))); | |||
| tooltipText = "Internal sample rate"; | |||
| } | |||
| void onAction(EventAction &e) override { | |||
| Menu *menu = gScene->createMenu(); | |||
| menu->box.pos = getAbsoluteOffset(Vec(0, box.size.y)); | |||
| menu->box.size.x = box.size.x; | |||
| menu->addChild(MenuItem::create<NewItem>("New", WINDOW_MOD_KEY_NAME "+N")); | |||
| menu->addChild(MenuItem::create<DisconnectItem>("Disconnect cables")); | |||
| menu->addChild(MenuItem::create<OpenItem>("Open", WINDOW_MOD_KEY_NAME "+O")); | |||
| menu->addChild(MenuItem::create<SaveItem>("Save", WINDOW_MOD_KEY_NAME "+S")); | |||
| menu->addChild(MenuItem::create<SaveAsItem>("Save as", WINDOW_MOD_KEY_NAME "+Shift+S")); | |||
| menu->addChild(MenuItem::create<RevertItem>("Revert")); | |||
| menu->addChild(MenuItem::create<QuitItem>("Quit", WINDOW_MOD_KEY_NAME "+Q")); | |||
| EnginePauseItem *pauseItem = new EnginePauseItem(); | |||
| pauseItem->text = gPaused ? "Resume engine" : "Pause engine"; | |||
| menu->addChild(pauseItem); | |||
| std::vector<float> sampleRates = {44100, 48000, 88200, 96000, 176400, 192000}; | |||
| for (float sampleRate : sampleRates) { | |||
| SampleRateItem *item = new SampleRateItem(); | |||
| item->text = stringf("%.0f Hz", sampleRate); | |||
| item->rightText = CHECKMARK(engineGetSampleRate() == sampleRate); | |||
| item->sampleRate = sampleRate; | |||
| menu->addChild(item); | |||
| } | |||
| } | |||
| }; | |||
| struct EnginePauseItem : MenuItem { | |||
| struct DisconnectItem : MenuItem { | |||
| void onAction(EventAction &e) override { | |||
| gPaused = !gPaused; | |||
| gRackWidget->disconnect(); | |||
| } | |||
| }; | |||
| struct EngineSampleRateItem : MenuItem { | |||
| float sampleRate; | |||
| struct SaveAsItem : MenuItem { | |||
| void onAction(EventAction &e) override { | |||
| engineSetSampleRate(sampleRate); | |||
| gPaused = false; | |||
| gRackWidget->saveAsDialog(); | |||
| } | |||
| }; | |||
| struct RevertItem : MenuItem { | |||
| void onAction(EventAction &e) override { | |||
| gRackWidget->revert(); | |||
| } | |||
| }; | |||
| struct EngineSampleRateChoice : ChoiceButton { | |||
| struct FileChoice : ChoiceButton { | |||
| void onAction(EventAction &e) override { | |||
| Menu *menu = gScene->createMenu(); | |||
| menu->box.pos = getAbsoluteOffset(Vec(0, box.size.y)); | |||
| menu->box.size.x = box.size.x; | |||
| EnginePauseItem *pauseItem = new EnginePauseItem(); | |||
| pauseItem->text = gPaused ? "Resume engine" : "Pause engine"; | |||
| menu->addChild(pauseItem); | |||
| std::vector<float> sampleRates = {44100, 48000, 88200, 96000, 176400, 192000}; | |||
| for (float sampleRate : sampleRates) { | |||
| EngineSampleRateItem *item = new EngineSampleRateItem(); | |||
| item->text = stringf("%.0f Hz", sampleRate); | |||
| item->sampleRate = sampleRate; | |||
| menu->addChild(item); | |||
| } | |||
| } | |||
| void step() override { | |||
| if (gPaused) | |||
| text = "Paused"; | |||
| else | |||
| text = stringf("%.0f Hz", engineGetSampleRate()); | |||
| menu->addChild(MenuItem::create<DisconnectItem>("Disconnect cables")); | |||
| menu->addChild(MenuItem::create<SaveAsItem>("Save as", WINDOW_MOD_KEY_NAME "+Shift+S")); | |||
| menu->addChild(MenuItem::create<RevertItem>("Revert")); | |||
| } | |||
| }; | |||
| Toolbar::Toolbar() { | |||
| box.size.y = BND_WIDGET_HEIGHT + 2*5; | |||
| @@ -125,18 +143,17 @@ Toolbar::Toolbar() { | |||
| layout->spacing = 5; | |||
| addChild(layout); | |||
| NewButton *newButton = new NewButton(); | |||
| layout->addChild(newButton); | |||
| layout->addChild(new NewButton()); | |||
| layout->addChild(new OpenButton()); | |||
| layout->addChild(new SaveButton()); | |||
| layout->addChild(new SampleRateButton()); | |||
| layout->addChild(new MeterButton()); | |||
| ChoiceButton *fileChoice = new FileChoice(); | |||
| fileChoice->box.size.x = 100; | |||
| fileChoice->text = "File"; | |||
| layout->addChild(fileChoice); | |||
| EngineSampleRateChoice *srChoice = new EngineSampleRateChoice(); | |||
| srChoice->box.size.x = 100; | |||
| layout->addChild(srChoice); | |||
| wireOpacitySlider = new Slider(); | |||
| wireOpacitySlider->box.size.x = 150; | |||
| wireOpacitySlider->label = "Cable opacity"; | |||
| @@ -5,9 +5,9 @@ namespace rack { | |||
| IconButton::IconButton() { | |||
| box.size.x = BND_WIDGET_HEIGHT; | |||
| box.size.x = BND_TOOL_WIDTH; | |||
| sw = new SVGWidget(); | |||
| sw->box.pos = Vec(2.75, 1.75); | |||
| sw->box.pos = Vec(2, 2); | |||
| addChild(sw); | |||
| } | |||
| @@ -4,19 +4,18 @@ | |||
| namespace rack { | |||
| void Tooltip::step() { | |||
| // Follow the mouse | |||
| box.pos = gMousePos; | |||
| // Wrap size to contents | |||
| // box.size = getChildrenBoundingBox().getBottomRight(); | |||
| Widget::step(); | |||
| Tooltip::Tooltip() { | |||
| } | |||
| void Tooltip::draw(NVGcontext *vg) { | |||
| // Wrap size to contents | |||
| float bounds[4]; | |||
| nvgTextBounds(gVg, 0.0, 0.0, text.c_str(), NULL, bounds); | |||
| box.size = Vec(bounds[2], BND_WIDGET_HEIGHT); | |||
| bndTooltipBackground(vg, 0.0, 0.0, box.size.x, box.size.y); | |||
| bndMenuLabel(vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str()); | |||
| Widget::draw(vg); | |||
| } | |||