Browse Source

Use Switch behavior in SvgLatch.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
70bd833e97
1 changed files with 4 additions and 27 deletions
  1. +4
    -27
      src/app/SvgLatch.cpp

+ 4
- 27
src/app/SvgLatch.cpp View File

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


Loading…
Cancel
Save