From b818a060ed7b3a46052e703665033fdc1f6c3faa Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Thu, 28 Sep 2017 09:46:23 -0400 Subject: [PATCH] Fix typo in Widget method, reduce precise mouse speed for Knobs, remove Module() constructor --- include/engine.hpp | 2 +- include/widgets.hpp | 12 ++++++++++++ src/app/Knob.cpp | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/engine.hpp b/include/engine.hpp index 6df8b664..c5124c2b 100644 --- a/include/engine.hpp +++ b/include/engine.hpp @@ -38,7 +38,7 @@ struct Module { float cpuTime = 0.0; /** Deprecated, use constructor below this one */ - Module() {} + // Module() {} /** Constructs Module with a fixed number of params, inputs, and outputs */ Module(int numParams, int numInputs, int numOutputs) { params.resize(numParams); diff --git a/include/widgets.hpp b/include/widgets.hpp index 742f3e10..3d5fc5fe 100644 --- a/include/widgets.hpp +++ b/include/widgets.hpp @@ -58,6 +58,7 @@ struct Widget { Vec getAbsolutePos(); Rect getChildrenBoundingBox(); + template T *getAncestorOfType() { if (!parent) return NULL; @@ -66,6 +67,17 @@ struct Widget { return parent->getAncestorOfType(); } + template + T *getFirstDescendantOfType() { + for (Widget *child : children) { + T *c = dynamic_cast(child); + if (c) return c; + c = child->getFirstDescendantOfType(); + if (c) return c; + } + return NULL; + } + /** Adds widget to list of children. Gives ownership of widget to this widget instance. */ diff --git a/src/app/Knob.cpp b/src/app/Knob.cpp index 8497937b..52b45cb3 100644 --- a/src/app/Knob.cpp +++ b/src/app/Knob.cpp @@ -17,7 +17,7 @@ void Knob::onDragStart() { void Knob::onDragMove(Vec mouseRel) { // Drag slower if Mod if (guiIsModPressed()) - mouseRel = mouseRel.mult(0.1); + mouseRel = mouseRel.mult(1/16.0); setValue(value - KNOB_SENSITIVITY * (maxValue - minValue) * mouseRel.y); }