| @@ -168,6 +168,10 @@ struct Light : TransparentWidget { | |||||
| struct ParamWidget : OpaqueWidget, QuantityWidget { | struct ParamWidget : OpaqueWidget, QuantityWidget { | ||||
| Module *module = NULL; | Module *module = NULL; | ||||
| int paramId; | int paramId; | ||||
| /** Used to momentarily disable value randomization | |||||
| To permanently disable or change randomization behavior, override the randomize() method instead of changing this. | |||||
| */ | |||||
| bool randomizable = true; | |||||
| json_t *toJson(); | json_t *toJson(); | ||||
| void fromJson(json_t *rootJ); | void fromJson(json_t *rootJ); | ||||
| @@ -12,6 +12,7 @@ namespace rack { | |||||
| void Knob::onDragStart() { | void Knob::onDragStart() { | ||||
| guiCursorLock(); | guiCursorLock(); | ||||
| randomizable = false; | |||||
| } | } | ||||
| void Knob::onDragMove(Vec mouseRel) { | void Knob::onDragMove(Vec mouseRel) { | ||||
| @@ -23,6 +24,7 @@ void Knob::onDragMove(Vec mouseRel) { | |||||
| void Knob::onDragEnd() { | void Knob::onDragEnd() { | ||||
| guiCursorUnlock(); | guiCursorUnlock(); | ||||
| randomizable = true; | |||||
| } | } | ||||
| void Knob::onChange() { | void Knob::onChange() { | ||||
| @@ -15,7 +15,8 @@ void ParamWidget::fromJson(json_t *rootJ) { | |||||
| } | } | ||||
| void ParamWidget::randomize() { | void ParamWidget::randomize() { | ||||
| setValue(rescalef(randomf(), 0.0, 1.0, minValue, maxValue)); | |||||
| if (randomizable) | |||||
| setValue(rescalef(randomf(), 0.0, 1.0, minValue, maxValue)); | |||||
| } | } | ||||
| void ParamWidget::onMouseDownOpaque(int button) { | void ParamWidget::onMouseDownOpaque(int button) { | ||||