Browse Source

Reset double-click state after DoubleClickEvent is fired. Fix Knob resetting.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
6d755381f9
3 changed files with 11 additions and 4 deletions
  1. +2
    -0
      src/app/Knob.cpp
  2. +1
    -1
      src/app/ParamQuantity.cpp
  3. +8
    -3
      src/widget/event.cpp

+ 2
- 0
src/app/Knob.cpp View File

@@ -102,6 +102,7 @@ void Knob::onDragMove(const widget::DragMoveEvent &e) {
void Knob::reset() {
if (paramQuantity && paramQuantity->isBounded()) {
paramQuantity->reset();
oldValue = snapValue = paramQuantity->getValue();
}
}

@@ -111,6 +112,7 @@ void Knob::randomize() {
if (snap)
value = std::round(value);
paramQuantity->setValue(value);
oldValue = snapValue = paramQuantity->getValue();
}
}



+ 1
- 1
src/app/ParamQuantity.cpp View File

@@ -29,7 +29,7 @@ void ParamQuantity::setValue(float value) {
if (!std::isfinite(value))
return;
// This setter clamps the value
getParam()->setValue(value);
APP->engine->setParam(module, paramId, value);
}

float ParamQuantity::getValue() {


+ 8
- 3
src/widget/event.cpp View File

@@ -135,7 +135,7 @@ void EventState::handleButton(math::Vec pos, int button, int action, int mods) {
}

if (action == GLFW_PRESS) {
const double doubleClickDuration = 0.5;
const double doubleClickDuration = 0.3;
double clickTime = glfwGetTime();
if (clickedWidget
&& clickTime - lastClickTime <= doubleClickDuration
@@ -143,9 +143,14 @@ void EventState::handleButton(math::Vec pos, int button, int action, int mods) {
// DoubleClickEvent
DoubleClickEvent eDoubleClick;
clickedWidget->onDoubleClick(eDoubleClick);
// Reset double click
lastClickTime = -INFINITY;
lastClickedWidget = NULL;
}
else {
lastClickTime = clickTime;
lastClickedWidget = clickedWidget;
}
lastClickTime = clickTime;
lastClickedWidget = clickedWidget;
}
}
}


Loading…
Cancel
Save