|
|
@@ -38,11 +38,12 @@ void SvgKnob::setSvg(std::shared_ptr<window::Svg> svg) { |
|
|
|
} |
|
|
|
|
|
|
|
void SvgKnob::onChange(const ChangeEvent& e) { |
|
|
|
// Re-transform the widget::TransformWidget |
|
|
|
float angle = 0.f; |
|
|
|
|
|
|
|
// Calculate angle from value |
|
|
|
engine::ParamQuantity* pq = getParamQuantity(); |
|
|
|
if (pq) { |
|
|
|
float value = pq->getValue(); |
|
|
|
float angle; |
|
|
|
if (!pq->isBounded()) { |
|
|
|
// Number of rotations equals value for unbounded range |
|
|
|
angle = value * (2 * M_PI); |
|
|
@@ -56,14 +57,16 @@ void SvgKnob::onChange(const ChangeEvent& e) { |
|
|
|
angle = math::rescale(value, pq->getMinValue(), pq->getMaxValue(), minAngle, maxAngle); |
|
|
|
} |
|
|
|
angle = std::fmod(angle, 2 * M_PI); |
|
|
|
tw->identity(); |
|
|
|
// Rotate SVG |
|
|
|
math::Vec center = sw->box.getCenter(); |
|
|
|
tw->translate(center); |
|
|
|
tw->rotate(angle); |
|
|
|
tw->translate(center.neg()); |
|
|
|
fb->setDirty(); |
|
|
|
} |
|
|
|
|
|
|
|
tw->identity(); |
|
|
|
// Rotate SVG |
|
|
|
math::Vec center = sw->box.getCenter(); |
|
|
|
tw->translate(center); |
|
|
|
tw->rotate(angle); |
|
|
|
tw->translate(center.neg()); |
|
|
|
fb->setDirty(); |
|
|
|
|
|
|
|
Knob::onChange(e); |
|
|
|
} |
|
|
|
|
|
|
|