Browse Source

Add unmap context menu item to ParamWidget. Add indicator on mapped ParamWidgets.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
83ad8523c2
3 changed files with 36 additions and 3 deletions
  1. +1
    -0
      include/helpers.hpp
  2. +33
    -0
      src/app/ParamWidget.cpp
  3. +2
    -3
      src/engine/Engine.cpp

+ 1
- 0
include/helpers.hpp View File

@@ -1,3 +1,4 @@
#pragma once
#include "plugin/Model.hpp"
#include "ui/MenuLabel.hpp"
#include "ui/MenuItem.hpp"


+ 33
- 0
src/app/ParamWidget.cpp View File

@@ -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() {


+ 2
- 3
src/engine/Engine.cpp View File

@@ -605,8 +605,8 @@ void Engine::removeParamHandle(ParamHandle *paramHandle) {
}

ParamHandle *Engine::getParamHandle(Module *module, int paramId) {
VIPLock vipLock(internal->vipMutex);
std::lock_guard<std::recursive_mutex> lock(internal->mutex);
// VIPLock vipLock(internal->vipMutex);
// std::lock_guard<std::recursive_mutex> 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);
}




Loading…
Cancel
Save