diff --git a/dgl/EventHandlers.hpp b/dgl/EventHandlers.hpp index 8d553b65..3545a2c5 100644 --- a/dgl/EventHandlers.hpp +++ b/dgl/EventHandlers.hpp @@ -94,7 +94,8 @@ class KnobEventHandler public: enum Orientation { Horizontal, - Vertical + Vertical, + Both }; // NOTE hover not implemented yet @@ -139,7 +140,7 @@ public: void setUsingLogScale(bool yesNo) noexcept; Orientation getOrientation() const noexcept; - void setOrientation(const Orientation orientation) noexcept; + void setOrientation(Orientation orientation) noexcept; void setCallback(Callback* callback) noexcept; diff --git a/dgl/src/EventHandlers.cpp b/dgl/src/EventHandlers.cpp index 64f81ca3..35666e42 100644 --- a/dgl/src/EventHandlers.cpp +++ b/dgl/src/EventHandlers.cpp @@ -402,23 +402,35 @@ struct KnobEventHandler::PrivateData { bool doVal = false; float d, value2 = 0.0f; - if (orientation == Horizontal) + switch (orientation) { + case Horizontal: if (const double movX = ev.pos.getX() - lastX) { d = (ev.mod & kModifierControl) ? 2000.0f : 200.0f; value2 = (usingLog ? invlogscale(valueTmp) : valueTmp) + (float(maximum - minimum) / d * float(movX)); doVal = true; } - } - else if (orientation == Vertical) - { + break; + case Vertical: if (const double movY = lastY - ev.pos.getY()) { d = (ev.mod & kModifierControl) ? 2000.0f : 200.0f; value2 = (usingLog ? invlogscale(valueTmp) : valueTmp) + (float(maximum - minimum) / d * float(movY)); doVal = true; } + break; + case Both: + const double movX = ev.pos.getX() - lastX; + const double movY = lastY - ev.pos.getY(); + + if (const double mov = movX + movY) + { + d = (ev.mod & kModifierControl) ? 2000.0f : 200.0f; + value2 = (usingLog ? invlogscale(valueTmp) : valueTmp) + (float(maximum - minimum) / d * float(mov)); + doVal = true; + } + break; } if (! doVal) @@ -596,9 +608,6 @@ KnobEventHandler::Orientation KnobEventHandler::getOrientation() const noexcept void KnobEventHandler::setOrientation(const Orientation orientation) noexcept { - if (pData->orientation == orientation) - return; - pData->orientation = orientation; }