Browse Source

Added momentary randomize() disable on ParamWidget

tags/v0.4.0
Andrew Belt 7 years ago
parent
commit
03795e3d91
3 changed files with 8 additions and 1 deletions
  1. +4
    -0
      include/app.hpp
  2. +2
    -0
      src/app/Knob.cpp
  3. +2
    -1
      src/app/ParamWidget.cpp

+ 4
- 0
include/app.hpp View File

@@ -168,6 +168,10 @@ struct Light : TransparentWidget {
struct ParamWidget : OpaqueWidget, QuantityWidget {
Module *module = NULL;
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();
void fromJson(json_t *rootJ);


+ 2
- 0
src/app/Knob.cpp View File

@@ -12,6 +12,7 @@ namespace rack {

void Knob::onDragStart() {
guiCursorLock();
randomizable = false;
}

void Knob::onDragMove(Vec mouseRel) {
@@ -23,6 +24,7 @@ void Knob::onDragMove(Vec mouseRel) {

void Knob::onDragEnd() {
guiCursorUnlock();
randomizable = true;
}

void Knob::onChange() {


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

@@ -15,7 +15,8 @@ void ParamWidget::fromJson(json_t *rootJ) {
}

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) {


Loading…
Cancel
Save