]> git.mxchange.org Git - flightgear.git/commitdiff
Fix calculating CanvasWidget mouse coordinates
authorThomas Geymayer <tomgey@gmail.com>
Sun, 2 Dec 2012 22:59:44 +0000 (23:59 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Sun, 2 Dec 2012 22:59:44 +0000 (23:59 +0100)
src/GUI/CanvasWidget.cxx
src/GUI/CanvasWidget.hxx

index 18bee716de61368a348ed6803d8f31b8183bdf2f..fe0119db5e1645780b6aabca598cbe91086a6d54 100644 (file)
@@ -113,11 +113,12 @@ void CanvasWidget::doHit(int button, int updown, int x, int y)
 
   namespace sc = simgear::canvas;
   sc::MouseEventPtr event(new sc::MouseEvent);
-  event->pos.set(x - abox.min[0], y - abox.min[1]);
-  event->delta.set(x - _last_x, y - _last_y);
+  event->pos.set(x - abox.min[0], abox.max[1] - y);
+  event->delta.set( event->pos.x() - _last_x,
+                    event->pos.y() - _last_y );
 
-  _last_x = x;
-  _last_y = y;
+  _last_x = event->pos.x();
+  _last_y = event->pos.y();
 
   switch( button )
   {
index 976b336ae07c64e62fc887080ea24dda9efb5bc0..f5fa0bf75a2056c0f134ba7478d8e65928120566 100644 (file)
@@ -45,8 +45,8 @@ class CanvasWidget:
                        *_mouse_down,
                        *_mouse_drag;
 
-    int _last_x,
-        _last_y;
+    float _last_x,
+          _last_y;
 };
 
 #endif /* CANVASWIDGET_HXX_ */