]> git.mxchange.org Git - flightgear.git/commitdiff
Handle scroll wheel events in osgViewer version
authortimoore <timoore>
Mon, 20 Aug 2007 21:38:25 +0000 (21:38 +0000)
committertimoore <timoore>
Mon, 20 Aug 2007 21:38:25 +0000 (21:38 +0000)
src/Main/FGManipulator.cxx
src/Main/FGManipulator.hxx

index 416ecf529a1991e27fbc90ed8fe8642a38ed186b..058641981b68b29451e18a58f7c3948b36f39a20 100644 (file)
@@ -6,6 +6,10 @@
 #include <plib/pu.h>
 #include "FGManipulator.hxx"
 
+#if !defined(X_DISPLAY_MISSING)
+#define X_DOUBLE_SCROLL_BUG 1
+#endif
+
 // The manipulator is responsible for updating a Viewer's camera. It's
 // event handling method is also a convenient place to run the the FG
 // idle and draw handlers.
@@ -13,7 +17,8 @@
 FGManipulator::FGManipulator() :
     idleHandler(0), drawHandler(0), windowResizeHandler(0), keyHandler(0),
     mouseClickHandler(0), mouseMotionHandler(0), currentModifiers(0),
-    osgModifiers(0), resizable(true), mouseWarped(false)
+    osgModifiers(0), resizable(true), mouseWarped(false),
+    scrollButtonPressed(false)
 {
     using namespace osgGA;
     
@@ -166,6 +171,25 @@ bool FGManipulator::handle(const osgGA::GUIEventAdapter& ea,
                                  == osgGA::GUIEventAdapter::RELEASE), x, y, mainWindow, &ea);
        return true;
     }
+    case osgGA::GUIEventAdapter::SCROLL:
+    {
+        bool mainWindow = eventToViewport(ea, us, x, y);
+#ifdef X_DOUBLE_SCROLL_BUG
+        scrollButtonPressed = !scrollButtonPressed;
+        if (!scrollButtonPressed) // Drop the button release event
+            return true;
+#endif
+        int button;
+        if (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_UP)
+            button = 3;
+        else
+            button = 4;
+        if (mouseClickHandler) {
+            (*mouseClickHandler)(button, 0, x, y, mainWindow, &ea);
+            (*mouseClickHandler)(button, 1, x, y, mainWindow, &ea);
+        }
+        return true;
+    }
     case osgGA::GUIEventAdapter::MOVE:
     case osgGA::GUIEventAdapter::DRAG:
         // If we warped the mouse, then disregard all pointer motion
index 5412ce6f36c88aea1465d9fe7396a85e49c6ebea..4ad190d19ae6f09345319032957acf283c9f5f1a 100644 (file)
@@ -137,5 +137,7 @@ protected:
     void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
     bool resizable;
     bool mouseWarped;
+    // workaround for osgViewer double scroll events
+    bool scrollButtonPressed;
 };
 #endif