diff --git a/include/helpers.hpp b/include/helpers.hpp index 8b15fd82..9b44c169 100644 --- a/include/helpers.hpp +++ b/include/helpers.hpp @@ -1,3 +1,4 @@ +#pragma once #include "plugin/Model.hpp" #include "ui/MenuLabel.hpp" #include "ui/MenuItem.hpp" diff --git a/src/app/ParamWidget.cpp b/src/app/ParamWidget.cpp index c3ec3b75..50d7008e 100644 --- a/src/app/ParamWidget.cpp +++ b/src/app/ParamWidget.cpp @@ -108,6 +108,20 @@ struct ParamFineItem : ui::MenuItem { }; +struct ParamUnmapItem : ui::MenuItem { + ParamWidget *paramWidget; + ParamUnmapItem() { + text = "Unmap"; + } + void onAction(const event::Action &e) override { + engine::ParamHandle *paramHandle = APP->engine->getParamHandle(paramWidget->paramQuantity->module, paramWidget->paramQuantity->paramId); + if (paramHandle) { + APP->engine->updateParamHandle(paramHandle, -1, 0); + } + } +}; + + ParamWidget::~ParamWidget() { if (paramQuantity) delete paramQuantity; @@ -141,6 +155,18 @@ void ParamWidget::draw(const widget::DrawContext &ctx) { // std::string mapText = string::f("%d", paramQuantity->paramId); // bndLabel(ctx.vg, box.size.x - 17.0, box.size.y - 16.0, INFINITY, INFINITY, -1, mapText.c_str()); // } + + // Param map indicator + engine::ParamHandle *paramHandle = paramQuantity ? APP->engine->getParamHandle(paramQuantity->module, paramQuantity->paramId) : NULL; + if (paramHandle) { + NVGcolor color = nvgRGB(0xff, 0x40, 0xff); + nvgBeginPath(ctx.vg); + nvgCircle(ctx.vg, box.size.x - 3, box.size.y - 3, 3.0); + nvgFillColor(ctx.vg, color); + nvgFill(ctx.vg); + nvgStrokeColor(ctx.vg, color::mult(color, 0.5)); + nvgStroke(ctx.vg); + } } void ParamWidget::onButton(const event::Button &e) { @@ -209,6 +235,13 @@ void ParamWidget::createContextMenu() { // ParamFineItem *fineItem = new ParamFineItem; // menu->addChild(fineItem); + + engine::ParamHandle *paramHandle = paramQuantity ? APP->engine->getParamHandle(paramQuantity->module, paramQuantity->paramId) : NULL; + if (paramHandle) { + ParamUnmapItem *unmapItem = new ParamUnmapItem; + unmapItem->paramWidget = this; + menu->addChild(unmapItem); + } } void ParamWidget::resetAction() { diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 3873094b..e682976e 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -605,8 +605,8 @@ void Engine::removeParamHandle(ParamHandle *paramHandle) { } ParamHandle *Engine::getParamHandle(Module *module, int paramId) { - VIPLock vipLock(internal->vipMutex); - std::lock_guard lock(internal->mutex); + // VIPLock vipLock(internal->vipMutex); + // std::lock_guard lock(internal->mutex); for (ParamHandle *paramHandle : internal->paramHandles) { if (paramHandle->module == module && paramHandle->paramId == paramId) @@ -640,7 +640,6 @@ void Engine::updateParamHandle(ParamHandle *paramHandle, int moduleId, int param } } } - DEBUG("%d %p %d %d", it != internal->paramHandles.end(), paramHandle->module, paramHandle->moduleId, paramHandle->paramId); }