Browse Source

Add text and color to ParamHandle.

tags/v1.0.0
Andrew Belt 6 years ago
parent
commit
08a4d73457
3 changed files with 21 additions and 2 deletions
  1. +4
    -0
      include/engine/ParamHandle.hpp
  2. +15
    -1
      src/Core/MIDI_Map.cpp
  3. +2
    -1
      src/app/ParamWidget.cpp

+ 4
- 0
include/engine/ParamHandle.hpp View File

@@ -2,6 +2,7 @@
#include <common.hpp>
#include <engine/Module.hpp>
#include <engine/Param.hpp>
#include <color.hpp>


namespace rack {
@@ -16,6 +17,9 @@ struct ParamHandle {
int moduleId = -1;
int paramId = 0;
Module *module = NULL;

std::string text;
NVGcolor color;
};




+ 15
- 1
src/Core/MIDI_Map.cpp View File

@@ -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(&paramHandles[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(&paramHandles[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(&paramHandles[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(&paramHandles[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();


+ 2
- 1
src/app/ParamWidget.cpp View File

@@ -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);
}


Loading…
Cancel
Save