| 241 | |
| 242 | |
| 243 | void ParamWidget::createContextMenu() { |
| 244 | ui::Menu* menu = createMenu(); |
| 245 | |
| 246 | engine::ParamQuantity* pq = getParamQuantity(); |
| 247 | engine::SwitchQuantity* switchQuantity = dynamic_cast<engine::SwitchQuantity*>(pq); |
| 248 | |
| 249 | ParamLabel* paramLabel = new ParamLabel; |
| 250 | paramLabel->paramWidget = this; |
| 251 | menu->addChild(paramLabel); |
| 252 | |
| 253 | if (switchQuantity) { |
| 254 | float minValue = pq->getMinValue(); |
| 255 | int index = (int) std::floor(pq->getValue() - minValue); |
| 256 | int numStates = switchQuantity->labels.size(); |
| 257 | for (int i = 0; i < numStates; i++) { |
| 258 | std::string label = switchQuantity->labels[i]; |
| 259 | ParamValueItem* paramValueItem = createMenuItem<ParamValueItem>(label, CHECKMARK(i == index)); |
| 260 | paramValueItem->paramWidget = this; |
| 261 | paramValueItem->value = minValue + i; |
| 262 | menu->addChild(paramValueItem); |
| 263 | } |
| 264 | if (numStates > 0) { |
| 265 | menu->addChild(new ui::MenuSeparator); |
| 266 | } |
| 267 | } |
| 268 | else { |
| 269 | ParamField* paramField = new ParamField; |
| 270 | paramField->box.size.x = 100; |
| 271 | paramField->setParamWidget(this); |
| 272 | menu->addChild(paramField); |
| 273 | } |
| 274 | |
| 275 | // Initialize |
| 276 | if (pq && pq->resetEnabled && pq->isBounded()) { |
| 277 | menu->addChild(createMenuItem(string::translate("ParamWidget.initialize"), switchQuantity ? "" : string::translate("key.doubleClick"), [=]() { |
| 278 | this->resetAction(); |
| 279 | })); |
| 280 | } |
| 281 | |
| 282 | // Fine |
| 283 | if (!switchQuantity) { |
| 284 | menu->addChild(createMenuItem(string::translate("ParamWidget.fine"), widget::getKeyCommandName(0, RACK_MOD_CTRL) + string::translate("key.drag"), NULL, true)); |
| 285 | } |
| 286 | |
| 287 | // Unmap |
| 288 | engine::ParamHandle* paramHandle = module ? APP->engine->getParamHandle(module->id, paramId) : NULL; |
| 289 | if (paramHandle) { |
| 290 | menu->addChild(createMenuItem(string::translate("ParamWidget.unmap"), paramHandle->text, [=]() { |
| 291 | APP->engine->updateParamHandle(paramHandle, -1, 0); |
| 292 | })); |
| 293 | } |
| 294 | |
| 295 | appendContextMenu(menu); |
| 296 | } |
| 297 | |
| 298 | |
| 299 | void ParamWidget::resetAction() { |
nothing calls this directly
no test coverage detected