]> git.mxchange.org Git - simgear.git/commitdiff
Make the knob mouse-wheel direction configurable.
authorJames Turner <zakalawe@mac.com>
Sun, 3 Feb 2013 17:21:50 +0000 (17:21 +0000)
committerJames Turner <zakalawe@mac.com>
Sun, 3 Feb 2013 17:21:50 +0000 (17:21 +0000)
Add a global setting to control the mouse-wheel direction of the knob; a future commit will expose this in the FG GUI.

simgear/scene/model/SGPickAnimation.cxx
simgear/scene/model/SGPickAnimation.hxx

index a02a207d1d53e9b6489ee4dc24efc3775ba082da..839d881d6c035c559befb8158fb6fd312d20ed76 100644 (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;
+}
+
index 615fef046e024979298e0f0e2b24194d3f31d9eb..bf52078da96df8625bbdad5b3bd9389c2c3e1974 100644 (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;