From 0e3ea2b7ff43126d10979e8f1b7e8be28bd5bb2c Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 6 Aug 2023 21:15:12 -0400 Subject: [PATCH] Make SvgKnob::onChange() reset knob angle if ParamQuantity is null. --- src/app/SvgKnob.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/app/SvgKnob.cpp b/src/app/SvgKnob.cpp index 6a2a467c..eb0fce12 100644 --- a/src/app/SvgKnob.cpp +++ b/src/app/SvgKnob.cpp @@ -38,11 +38,12 @@ void SvgKnob::setSvg(std::shared_ptr svg) { } void SvgKnob::onChange(const ChangeEvent& e) { - // Re-transform the widget::TransformWidget + float angle = 0.f; + + // Calculate angle from value engine::ParamQuantity* pq = getParamQuantity(); if (pq) { float value = pq->getValue(); - float angle; if (!pq->isBounded()) { // Number of rotations equals value for unbounded range angle = value * (2 * M_PI); @@ -56,14 +57,16 @@ void SvgKnob::onChange(const ChangeEvent& e) { angle = math::rescale(value, pq->getMinValue(), pq->getMaxValue(), minAngle, maxAngle); } angle = std::fmod(angle, 2 * M_PI); - tw->identity(); - // Rotate SVG - math::Vec center = sw->box.getCenter(); - tw->translate(center); - tw->rotate(angle); - tw->translate(center.neg()); - fb->setDirty(); } + + tw->identity(); + // Rotate SVG + math::Vec center = sw->box.getCenter(); + tw->translate(center); + tw->rotate(angle); + tw->translate(center.neg()); + fb->setDirty(); + Knob::onChange(e); }