BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

commit 34eacdfdaf8349db5c5ec56877f931739cfe9717
parent 393d453808bde1ffe9c6a5de1d559504ecd2f4c3
Author: Matt Demanett <matt@demanett.net>
Date:   Tue, 23 Jun 2020 22:34:24 -0400

Fix randomize/initialize for StatefulButton widget; should be the last custom widget missing these.

Diffstat:
Msrc/widgets.cpp | 15+++++++++++++++
Msrc/widgets.hpp | 2++
2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/widgets.cpp b/src/widgets.cpp @@ -239,6 +239,21 @@ StatefulButton::StatefulButton(const char* offSvgPath, const char* onSvgPath) { shadow->box.pos = Vec(0.0, 1.0); } +void StatefulButton::reset() { + if (paramQuantity) { + paramQuantity->setValue(paramQuantity->getMinValue()); + } +} + +void StatefulButton::randomize() { + if (paramQuantity) { + float min = paramQuantity->getMinValue(); + float max = paramQuantity->getMaxValue(); + float value = roundf(min + (max - min) * random::uniform()); + paramQuantity->setValue(value); + } +} + void StatefulButton::onDragStart(const event::DragStart& e) { if (paramQuantity) { _svgWidget->setSvg(_frames[1]); diff --git a/src/widgets.hpp b/src/widgets.hpp @@ -95,6 +95,8 @@ struct StatefulButton : ParamWidget { CircularShadow* shadow = NULL; StatefulButton(const char* offSvgPath, const char* onSvgPath); + void reset() override; + void randomize() override; void onDragStart(const event::DragStart& e) override; void onDragEnd(const event::DragEnd& e) override; };