Module() constructortags/v0.4.0
@@ -38,7 +38,7 @@ struct Module { | |||||
float cpuTime = 0.0; | float cpuTime = 0.0; | ||||
/** Deprecated, use constructor below this one */ | /** Deprecated, use constructor below this one */ | ||||
Module() {} | |||||
// Module() {} | |||||
/** Constructs Module with a fixed number of params, inputs, and outputs */ | /** Constructs Module with a fixed number of params, inputs, and outputs */ | ||||
Module(int numParams, int numInputs, int numOutputs) { | Module(int numParams, int numInputs, int numOutputs) { | ||||
params.resize(numParams); | params.resize(numParams); | ||||
@@ -58,6 +58,7 @@ struct Widget { | |||||
Vec getAbsolutePos(); | Vec getAbsolutePos(); | ||||
Rect getChildrenBoundingBox(); | Rect getChildrenBoundingBox(); | ||||
template <class T> | template <class T> | ||||
T *getAncestorOfType() { | T *getAncestorOfType() { | ||||
if (!parent) return NULL; | if (!parent) return NULL; | ||||
@@ -66,6 +67,17 @@ struct Widget { | |||||
return parent->getAncestorOfType<T>(); | return parent->getAncestorOfType<T>(); | ||||
} | } | ||||
template <class T> | |||||
T *getFirstDescendantOfType() { | |||||
for (Widget *child : children) { | |||||
T *c = dynamic_cast<T*>(child); | |||||
if (c) return c; | |||||
c = child->getFirstDescendantOfType<T>(); | |||||
if (c) return c; | |||||
} | |||||
return NULL; | |||||
} | |||||
/** Adds widget to list of children. | /** Adds widget to list of children. | ||||
Gives ownership of widget to this widget instance. | Gives ownership of widget to this widget instance. | ||||
*/ | */ | ||||
@@ -17,7 +17,7 @@ void Knob::onDragStart() { | |||||
void Knob::onDragMove(Vec mouseRel) { | void Knob::onDragMove(Vec mouseRel) { | ||||
// Drag slower if Mod | // Drag slower if Mod | ||||
if (guiIsModPressed()) | if (guiIsModPressed()) | ||||
mouseRel = mouseRel.mult(0.1); | |||||
mouseRel = mouseRel.mult(1/16.0); | |||||
setValue(value - KNOB_SENSITIVITY * (maxValue - minValue) * mouseRel.y); | setValue(value - KNOB_SENSITIVITY * (maxValue - minValue) * mouseRel.y); | ||||
} | } | ||||