Make the knob mouse-wheel direction configurable.

Add a global setting to control the mouse-wheel direction of the knob; a future commit will expose this in the FG GUI.
This commit is contained in:
James Turner 2013-02-03 17:21:50 +00:00
parent 0870407f65
commit 235c29913a
2 changed files with 18 additions and 2 deletions

View File

@ -361,6 +361,8 @@ static void readOptionalBindingList(const SGPropertyNode* aNode, SGPropertyNode*
}
static bool static_knobMouseWheelAlternateDirection = false;
class SGKnobAnimation::KnobPickCallback : public SGPickCallback {
public:
KnobPickCallback(const SGPropertyNode* configNode,
@ -400,11 +402,14 @@ public:
if ((button == 0) && (ea->getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_ALT)) {
button = 1;
}
int increaseMouseWheel = static_knobMouseWheelAlternateDirection ? 3 : 4;
int decreaseMouseWheel = static_knobMouseWheelAlternateDirection ? 4 : 3;
_direction = DIRECTION_NONE;
if ((button == 0) || (button == 4)) {
if ((button == 0) || (button == increaseMouseWheel)) {
_direction = DIRECTION_CLOCKWISE;
} else if ((button == 1) || (button == 3)) {
} else if ((button == 1) || (button == decreaseMouseWheel)) {
_direction = DIRECTION_ANTICLOCKWISE;
} else {
return false;
@ -518,3 +523,8 @@ SGKnobAnimation::createAnimationGroup(osg::Group& parent)
return transform;
}
void SGKnobAnimation::setAlternateMouseWheelDirection(bool aToggle)
{
static_knobMouseWheelAlternateDirection = aToggle;
}

View File

@ -54,6 +54,12 @@ public:
SGPropertyNode* modelRoot);
virtual osg::Group* createAnimationGroup(osg::Group& parent);
/**
* by default mouse wheel up corresponds to increment (CW)
* and mouse-wheel down corresponds to decrement (CCW).
* Since no one can agree on that, make it a global toggle.
*/
static void setAlternateMouseWheelDirection(bool aToggle);
private:
class KnobPickCallback;
class UpdateCallback;