Browse Source

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

tags/v1.0.0
Andrew Belt 6 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() { void Knob::reset() {
if (paramQuantity && paramQuantity->isBounded()) { if (paramQuantity && paramQuantity->isBounded()) {
paramQuantity->reset(); paramQuantity->reset();
oldValue = snapValue = paramQuantity->getValue();
} }
} }


@@ -111,6 +112,7 @@ void Knob::randomize() {
if (snap) if (snap)
value = std::round(value); value = std::round(value);
paramQuantity->setValue(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)) if (!std::isfinite(value))
return; return;
// This setter clamps the value // This setter clamps the value
getParam()->setValue(value);
APP->engine->setParam(module, paramId, value);
} }


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


Loading…
Cancel
Save