From 70bd833e97afd352aa73e6a21a1f33d0d8ff8720 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 2 Nov 2021 03:59:12 -0400 Subject: [PATCH] Use Switch behavior in SvgLatch. --- src/app/SvgLatch.cpp | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/app/SvgLatch.cpp b/src/app/SvgLatch.cpp index a2a2daf2..b69a9a76 100644 --- a/src/app/SvgLatch.cpp +++ b/src/app/SvgLatch.cpp @@ -5,36 +5,20 @@ namespace rack { namespace app { -struct SvgLatch::Internal { - bool unlatch = false; -}; - - SvgLatch::SvgLatch() { - internal = new Internal; } SvgLatch::~SvgLatch() { - delete internal; } void SvgLatch::onDragStart(const DragStartEvent& e) { - ParamWidget::onDragStart(e); + // Use Switch behavior + Switch::onDragStart(e); if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; - // Set value - engine::ParamQuantity* pq = getParamQuantity(); - if (pq) { - if (pq->isMax()) { - internal->unlatch = true; - } - else { - pq->setMax(); - } - } // Set down frame if (frames.size() >= 2) { sw->setSvg(frames[1]); @@ -44,18 +28,11 @@ void SvgLatch::onDragStart(const DragStartEvent& e) { void SvgLatch::onDragEnd(const DragEndEvent& e) { - ParamWidget::onDragEnd(e); + // Use Switch behavior + Switch::onDragEnd(e); if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; - // Set value - engine::ParamQuantity* pq = getParamQuantity(); - if (pq) { - if (internal->unlatch) { - internal->unlatch = false; - pq->setMin(); - } - } // Set up frame if (frames.size() >= 1) { sw->setSvg(frames[0]);