From dfa723119bce838cc43082ddcb1801d518892470 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 19 Nov 2017 08:32:52 -0500 Subject: [PATCH] Fix SVGSwitch value scaling, add confirmation for clearing the patch with File > New --- src/app/RackWidget.cpp | 6 ++++-- src/app/SVGSwitch.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index f8301de5..a7bf58be 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -41,8 +41,10 @@ void RackWidget::clear() { } void RackWidget::reset() { - clear(); - loadPatch(assetLocal("template.vcv")); + if (osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, "Clear your patch and start over?")) { + clear(); + loadPatch(assetLocal("template.vcv")); + } } void RackWidget::openDialog() { diff --git a/src/app/SVGSwitch.cpp b/src/app/SVGSwitch.cpp index 5b66518d..eda234cc 100644 --- a/src/app/SVGSwitch.cpp +++ b/src/app/SVGSwitch.cpp @@ -24,7 +24,8 @@ void SVGSwitch::step() { void SVGSwitch::onChange(EventChange &e) { assert(frames.size() > 0); - int index = clampi((int) roundf(value), 0, frames.size() - 1); + float valueScaled = rescalef(value, minValue, maxValue, 0, frames.size() - 1); + int index = clampi((int) roundf(valueScaled), 0, frames.size() - 1); sw->setSVG(frames[index]); dirty = true; Switch::onChange(e);