From 182bf15fbe03b2d9741f0fb29a8b857f50216564 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 8 Dec 2017 07:52:15 -0500 Subject: [PATCH] Added ZoomWidget::onPathDrop --- include/math.hpp | 11 +---------- include/widgets.hpp | 1 + src/widgets/ZoomWidget.cpp | 7 +++++++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/math.hpp b/include/math.hpp index 0b94c9c1..815f3746 100644 --- a/include/math.hpp +++ b/include/math.hpp @@ -120,15 +120,6 @@ inline float sincf(float x) { return sinf(x) / x; } -inline float getf(const float *p, float v = 0.0) { - return p ? *p : v; -} - -inline void setf(float *p, float v) { - if (p) - *p = v; -} - /** Linearly interpolate an array `p` with index `x` Assumes that the array at `p` is of length at least floor(x)+1. */ @@ -139,7 +130,7 @@ inline float interpf(const float *p, float x) { } /** Complex multiply c = a * b -It is of course acceptable to reuse arguments +Arguments may be the same pointers i.e. cmultf(&ar, &ai, ar, ai, br, bi) */ inline void cmultf(float *cr, float *ci, float ar, float ai, float br, float bi) { diff --git a/include/widgets.hpp b/include/widgets.hpp index 454c9c43..6c8fa9f3 100644 --- a/include/widgets.hpp +++ b/include/widgets.hpp @@ -178,6 +178,7 @@ struct ZoomWidget : Widget { void onMouseMove(EventMouseMove &e) override; void onHoverKey(EventHoverKey &e) override; void onScroll(EventScroll &e) override; + void onPathDrop(EventPathDrop &e) override; }; //////////////////// diff --git a/src/widgets/ZoomWidget.cpp b/src/widgets/ZoomWidget.cpp index c6d6cb5d..5ef4d335 100644 --- a/src/widgets/ZoomWidget.cpp +++ b/src/widgets/ZoomWidget.cpp @@ -65,5 +65,12 @@ void ZoomWidget::onScroll(EventScroll &e) { e.pos = pos; } +void ZoomWidget::onPathDrop(EventPathDrop &e) { + Vec pos = e.pos; + e.pos = e.pos.div(zoom); + Widget::onPathDrop(e); + e.pos = pos; +} + } // namespace rack