Browse Source

Allow SwitchQuantity first index to start at value other than 0.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
1f0e27749e
2 changed files with 5 additions and 4 deletions
  1. +3
    -2
      src/app/ParamWidget.cpp
  2. +2
    -2
      src/engine/ParamQuantity.cpp

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

@@ -274,7 +274,8 @@ void ParamWidget::createContextMenu() {
menu->addChild(paramLabel);

if (switchQuantity) {
int index = (int) std::floor(pq->getValue());
float minValue = pq->getMinValue();
int index = (int) std::floor(pq->getValue() - minValue);
int numStates = switchQuantity->labels.size();
for (int i = 0; i < numStates; i++) {
std::string label = switchQuantity->labels[i];
@@ -282,7 +283,7 @@ void ParamWidget::createContextMenu() {
paramValueItem->text = label;
paramValueItem->rightText = CHECKMARK(i == index);
paramValueItem->paramWidget = this;
paramValueItem->value = i;
paramValueItem->value = minValue + i;
menu->addChild(paramValueItem);
}
if (numStates > 0) {


+ 2
- 2
src/engine/ParamQuantity.cpp View File

@@ -177,7 +177,7 @@ void ParamQuantity::fromJson(json_t* rootJ) {


std::string SwitchQuantity::getDisplayValueString() {
int index = (int) std::floor(getValue());
int index = (int) std::floor(getValue() - getMinValue());
if (!(0 <= index && index < (int) labels.size()))
return "";
return labels[index];
@@ -191,7 +191,7 @@ void SwitchQuantity::setDisplayValueString(std::string s) {
if (it == labels.end())
return;
int index = std::distance(labels.begin(), it);
setValue(index);
setValue(getMinValue() + index);
}




Loading…
Cancel
Save