From 2cefc5f71a79fa31e509423f46036d943c0ae77e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 14 May 2009 15:45:54 +0000 Subject: [PATCH] From Ulrich Hertlein, "please find attached a patch for TrackballManipulator to fix zooming using the MBP touchpad. The old code would always zoom-in even when using the gesture to zoom-out. Also attached are some code and documentation cleanups for GUIEventAdapter that collect related values (e.g. scrolling, tablet pen) in a struct. " --- src/osgGA/TrackballManipulator.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/osgGA/TrackballManipulator.cpp b/src/osgGA/TrackballManipulator.cpp index 8ca46ad00..566481bc6 100644 --- a/src/osgGA/TrackballManipulator.cpp +++ b/src/osgGA/TrackballManipulator.cpp @@ -256,7 +256,28 @@ bool TrackballManipulator::calcMovement() if (_ga_t0->getEventType()==GUIEventAdapter::SCROLL) { - dy = _ga_t0->getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_UP ? _zoomDelta : -_zoomDelta; + switch (_ga_t0->getScrollingMotion()) { + case osgGA::GUIEventAdapter::SCROLL_UP: + dy = _zoomDelta; + break; + case osgGA::GUIEventAdapter::SCROLL_DOWN: + dy = -_zoomDelta; + break; + case osgGA::GUIEventAdapter::SCROLL_LEFT: + case osgGA::GUIEventAdapter::SCROLL_RIGHT: + // pass + break; + case osgGA::GUIEventAdapter::SCROLL_2D: + // normalize scrolling delta + dx = _ga_t0->getScrollingDeltaX() / ((_ga_t0->getXmax()-_ga_t0->getXmin()) * 0.5f); + dy = _ga_t0->getScrollingDeltaY() / ((_ga_t0->getYmax()-_ga_t0->getYmin()) * 0.5f); + + dx *= _zoomDelta; + dy *= _zoomDelta; + break; + default: + break; + } buttonMask=GUIEventAdapter::SCROLL; } else