diff --git a/include/engine/ParamHandle.hpp b/include/engine/ParamHandle.hpp index 518c07d9..ed4dfb95 100644 --- a/include/engine/ParamHandle.hpp +++ b/include/engine/ParamHandle.hpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace rack { @@ -16,6 +17,9 @@ struct ParamHandle { int moduleId = -1; int paramId = 0; Module *module = NULL; + + std::string text; + NVGcolor color; }; diff --git a/src/Core/MIDI_Map.cpp b/src/Core/MIDI_Map.cpp index e342afb2..9e141d36 100644 --- a/src/Core/MIDI_Map.cpp +++ b/src/Core/MIDI_Map.cpp @@ -42,6 +42,7 @@ struct MIDI_Map : Module { MIDI_Map() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); for (int id = 0; id < MAX_CHANNELS; id++) { + paramHandles[id].color = nvgRGB(0xff, 0x40, 0xff); APP->engine->addParamHandle(¶mHandles[id]); } onReset(); @@ -117,6 +118,7 @@ struct MIDI_Map : Module { learnedCc = true; commitLearn(); updateMapLen(); + refreshParamHandleText(learningId); } values[cc] = value; } @@ -127,6 +129,7 @@ struct MIDI_Map : Module { APP->engine->updateParamHandle(¶mHandles[id], -1, 0, true); valueFilters[id].reset(); updateMapLen(); + refreshParamHandleText(id); } void clearMaps() { @@ -135,6 +138,7 @@ struct MIDI_Map : Module { ccs[id] = -1; APP->engine->updateParamHandle(¶mHandles[id], -1, 0, true); valueFilters[id].reset(); + refreshParamHandleText(id); } mapLen = 0; } @@ -191,6 +195,15 @@ struct MIDI_Map : Module { updateMapLen(); } + void refreshParamHandleText(int id) { + std::string text; + if (ccs[id] >= 0) + text = string::f("CC%02d", ccs[id]); + else + text = "MIDI-Map"; + paramHandles[id].text = text; + } + json_t *dataToJson() override { json_t *rootJ = json_object(); @@ -225,6 +238,7 @@ struct MIDI_Map : Module { continue; ccs[mapIndex] = json_integer_value(ccJ); APP->engine->updateParamHandle(¶mHandles[mapIndex], json_integer_value(moduleIdJ), json_integer_value(paramIdJ), false); + refreshParamHandleText(mapIndex); } } @@ -313,7 +327,7 @@ struct MIDI_MapChoice : LedDisplayChoice { // Set text text = ""; if (module->ccs[id] >= 0) { - text += string::f("CC%d ", module->ccs[id]); + text += string::f("CC%02d ", module->ccs[id]); } if (module->paramHandles[id].moduleId >= 0) { text += getParamName(); diff --git a/src/app/ParamWidget.cpp b/src/app/ParamWidget.cpp index 437b317d..cbd10735 100644 --- a/src/app/ParamWidget.cpp +++ b/src/app/ParamWidget.cpp @@ -128,7 +128,7 @@ void ParamWidget::draw(const DrawArgs &args) { // Param map indicator engine::ParamHandle *paramHandle = paramQuantity ? APP->engine->getParamHandle(paramQuantity->module->id, paramQuantity->paramId) : NULL; if (paramHandle) { - NVGcolor color = nvgRGB(0xff, 0x40, 0xff); + NVGcolor color = paramHandle->color; nvgBeginPath(args.vg); nvgCircle(args.vg, box.size.x - 3, box.size.y - 3, 3.0); nvgFillColor(args.vg, color); @@ -214,6 +214,7 @@ void ParamWidget::createContextMenu() { if (paramHandle) { ParamUnmapItem *unmapItem = new ParamUnmapItem; unmapItem->text = "Unmap"; + unmapItem->rightText = paramHandle->text; unmapItem->paramWidget = this; menu->addChild(unmapItem); }