|
|
@@ -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]); |
|
|
|