diff --git a/include/osgGA/EventQueue b/include/osgGA/EventQueue index d045f92a0..ad0a3f4be 100644 --- a/include/osgGA/EventQueue +++ b/include/osgGA/EventQueue @@ -84,43 +84,43 @@ class OSGGA_EXPORT EventQueue : public osg::Referenced /** Method for adapting window resize event, placing this event on the back of the event queue. */ - void windowResize(int x, int y, int width, int height) { windowResize(x,y,width,height,getTime()); } + osgGA::GUIEventAdapter* windowResize(int x, int y, int width, int height) { return windowResize(x,y,width,height,getTime()); } /** Method for adapting window resize event, placing this event on the back of the event queue, with specified time. */ - void windowResize(int x, int y, int width, int height, double time); + osgGA::GUIEventAdapter* windowResize(int x, int y, int width, int height, double time); /** Method for adapting mouse scroll wheel events, placing this event on the back of the event queue. */ - void mouseScroll(GUIEventAdapter::ScrollingMotion sm) { mouseScroll(sm,getTime()); } + osgGA::GUIEventAdapter* mouseScroll(GUIEventAdapter::ScrollingMotion sm) { return mouseScroll(sm,getTime()); } /** Method for adapting mouse scroll wheel events, placing this event on the back of the event queue, with specified time. */ - void mouseScroll(GUIEventAdapter::ScrollingMotion sm, double time); + osgGA::GUIEventAdapter* mouseScroll(GUIEventAdapter::ScrollingMotion sm, double time); /** Method for adapting mouse scroll wheel events, placing this event on the back of the event queue. */ - void mouseScroll2D(float x, float y) { mouseScroll2D(x, y, getTime()); } + osgGA::GUIEventAdapter* mouseScroll2D(float x, float y) { return mouseScroll2D(x, y, getTime()); } /** Method for adapting mouse scroll wheel events, placing this event on the back of the event queue. */ - void mouseScroll2D(float x, float y, double time); + osgGA::GUIEventAdapter* mouseScroll2D(float x, float y, double time); /** Method for adapting pen pressure events, placing this event on the back of the event queue.*/ - void penPressure(float pressure) { penPressure(pressure, getTime()); } + osgGA::GUIEventAdapter* penPressure(float pressure) { return penPressure(pressure, getTime()); } /** Method for adapting pen pressure events, placing this event on the back of the event queue, with specified time.*/ - void penPressure(float pressure, double time); + osgGA::GUIEventAdapter* penPressure(float pressure, double time); /** Method for adapting pen orientation events, placing this event on the back of the event queue.*/ - void penOrientation(float tiltX, float tiltY, float rotation) { penOrientation(tiltX, tiltY, rotation, getTime()); } + osgGA::GUIEventAdapter* penOrientation(float tiltX, float tiltY, float rotation) { return penOrientation(tiltX, tiltY, rotation, getTime()); } /** Method for adapting pen orientation events, placing this event on the back of the event queue, with specified time.*/ - void penOrientation(float tiltX, float tiltY, float rotation, double time); + osgGA::GUIEventAdapter* penOrientation(float tiltX, float tiltY, float rotation, double time); /** Method for adapting pen proximity events, placing this event on the back of the event queue.*/ - void penProximity(GUIEventAdapter::TabletPointerType pt, bool isEntering) { penProximity(pt, isEntering, getTime()); } + osgGA::GUIEventAdapter* penProximity(GUIEventAdapter::TabletPointerType pt, bool isEntering) { return penProximity(pt, isEntering, getTime()); } /** Method for adapting pen proximity events, placing this event on the back of the event queue, with specified time.*/ - void penProximity(GUIEventAdapter::TabletPointerType pt, bool isEntering, double time); + osgGA::GUIEventAdapter* penProximity(GUIEventAdapter::TabletPointerType pt, bool isEntering, double time); /** Method for updating in response to a mouse warp. Note, just moves the mouse position without creating a new event for it.*/ @@ -128,51 +128,51 @@ class OSGGA_EXPORT EventQueue : public osg::Referenced /** Method for adapting mouse motion events, placing this event on the back of the event queue.*/ - void mouseMotion(float x, float y) { mouseMotion(x,y, getTime()); } + osgGA::GUIEventAdapter* mouseMotion(float x, float y) { return mouseMotion(x,y, getTime()); } /** Method for adapting mouse motion events, placing this event on the back of the event queue, with specified time.*/ - void mouseMotion(float x, float y, double time); + osgGA::GUIEventAdapter* mouseMotion(float x, float y, double time); /** Method for adapting mouse button pressed events, placing this event on the back of the event queue. * Button numbering is 1 for left mouse button, 2 for middle, 3 for right. */ - void mouseButtonPress(float x, float y, unsigned int button) { mouseButtonPress(x, y, button, getTime()); } + osgGA::GUIEventAdapter* mouseButtonPress(float x, float y, unsigned int button) { return mouseButtonPress(x, y, button, getTime()); } /** Method for adapting mouse button pressed events, placing this event on the back of the event queue, with specified time. * Button numbering is 1 for left mouse button, 2 for middle, 3 for right. */ - void mouseButtonPress(float x, float y, unsigned int button, double time); + osgGA::GUIEventAdapter* mouseButtonPress(float x, float y, unsigned int button, double time); /** Method for adapting mouse button pressed events, placing this event on the back of the event queue. * Button numbering is 1 for left mouse button, 2 for middle, 3 for right. */ - void mouseDoubleButtonPress(float x, float y, unsigned int button) { mouseDoubleButtonPress(x, y, button, getTime()); } + osgGA::GUIEventAdapter* mouseDoubleButtonPress(float x, float y, unsigned int button) { return mouseDoubleButtonPress(x, y, button, getTime()); } /** Method for adapting mouse button pressed events, placing this event on the back of the event queue, with specified time. * Button numbering is 1 for left mouse button, 2 for middle, 3 for right. */ - void mouseDoubleButtonPress(float x, float y, unsigned int button, double time); + osgGA::GUIEventAdapter* mouseDoubleButtonPress(float x, float y, unsigned int button, double time); /** Method for adapting mouse button release events, placing this event on the back of the event queue. * Button numbering is 1 for left mouse button, 2 for middle, 3 for right. */ - void mouseButtonRelease(float x, float y, unsigned int button) { mouseButtonRelease(x, y, button, getTime()); } + osgGA::GUIEventAdapter* mouseButtonRelease(float x, float y, unsigned int button) { return mouseButtonRelease(x, y, button, getTime()); } /** Method for adapting mouse button release events, placing this event on the back of the event queue, with specified time. * Button numbering is 1 for left mouse button, 2 for middle, 3 for right. */ - void mouseButtonRelease(float x, float y, unsigned int button, double time); + osgGA::GUIEventAdapter* mouseButtonRelease(float x, float y, unsigned int button, double time); /** Method for adapting keyboard press events. Note, special keys such as Ctrl/Function keys should be adapted to GUIEventAdapter::KeySymbol mappings.*/ - void keyPress(int key, int unmodifiedKey = 0) { keyPress(key, getTime(), unmodifiedKey); } + osgGA::GUIEventAdapter* keyPress(int key, int unmodifiedKey = 0) { return keyPress(key, getTime(), unmodifiedKey); } /** Method for adapting keyboard press events. Note, special keys such as Ctrl/Function keys should be adapted to GUIEventAdapter::KeySymbol mappings, with specified time.*/ - void keyPress(int key, double time, int unmodifiedKey = 0); + osgGA::GUIEventAdapter* keyPress(int key, double time, int unmodifiedKey = 0); /** Method for adapting keyboard press events. Note, special keys such as Ctrl/Function keys should be adapted to GUIEventAdapter::KeySymbol mappings.*/ - void keyRelease(int key, int unmodifiedKey = 0) { keyRelease(key, getTime(), unmodifiedKey); } + osgGA::GUIEventAdapter* keyRelease(int key, int unmodifiedKey = 0) { return keyRelease(key, getTime(), unmodifiedKey); } /** Method for adapting keyboard press events. Note, special keys such as Ctrl/Function keys should be adapted to GUIEventAdapter::KeySymbol mappings, with specified time.*/ - void keyRelease(int key, double time, int unmodifiedKey = 0); + osgGA::GUIEventAdapter* keyRelease(int key, double time, int unmodifiedKey = 0); GUIEventAdapter* touchBegan(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, double time); GUIEventAdapter* touchBegan(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y) { @@ -192,21 +192,21 @@ class OSGGA_EXPORT EventQueue : public osg::Referenced /** Method for adapting close window events.*/ - void closeWindow() { closeWindow(getTime()); } + osgGA::GUIEventAdapter* closeWindow() { return closeWindow(getTime()); } /** Method for adapting close window event with specified event time.*/ - void closeWindow(double time); + osgGA::GUIEventAdapter* closeWindow(double time); /** Method for adapting application quit events.*/ - void quitApplication() { quitApplication(getTime()); } + osgGA::GUIEventAdapter* quitApplication() { return quitApplication(getTime()); } /** Method for adapting application quit events with specified event time.*/ - void quitApplication(double time); + osgGA::GUIEventAdapter* quitApplication(double time); /** Method for adapting frame events.*/ - void frame(double time); + osgGA::GUIEventAdapter* frame(double time); void setStartTick(osg::Timer_t tick) { _startTick = tick; clear(); } @@ -226,10 +226,10 @@ class OSGGA_EXPORT EventQueue : public osg::Referenced const GUIEventAdapter* getCurrentEventState() const { return _accumulateEventState.get(); } /** Method for adapting user defined events */ - void userEvent(osg::Referenced* userEventData) { userEvent(userEventData, getTime()); } + GUIEventAdapter* userEvent(osg::Referenced* userEventData) { return userEvent(userEventData, getTime()); } /** Method for adapting user defined events with specified event time */ - void userEvent(osg::Referenced* userEventData, double time); + GUIEventAdapter* userEvent(osg::Referenced* userEventData, double time); void setFirstTouchEmulatesMouse(bool b) { _firstTouchEmulatesMouse = b; } bool getFirstTouchEmulatesMouse() const { return _firstTouchEmulatesMouse; } diff --git a/src/osgGA/EventQueue.cpp b/src/osgGA/EventQueue.cpp index c5cdf8469..dab810290 100644 --- a/src/osgGA/EventQueue.cpp +++ b/src/osgGA/EventQueue.cpp @@ -138,7 +138,7 @@ void EventQueue::syncWindowRectangleWithGraphicsContext() if (traits) _accumulateEventState->setWindowRectangle(traits->x, traits->y, traits->width, traits->height, !_useFixedMouseInputRange); } -void EventQueue::windowResize(int x, int y, int width, int height, double time) +osgGA::GUIEventAdapter* EventQueue::windowResize(int x, int y, int width, int height, double time) { _accumulateEventState->setWindowRectangle(x, y, width, height, !_useFixedMouseInputRange); @@ -147,9 +147,11 @@ void EventQueue::windowResize(int x, int y, int width, int height, double time) event->setTime(time); addEvent(event); + + return event; } -void EventQueue::penPressure(float pressure, double time) +osgGA::GUIEventAdapter* EventQueue::penPressure(float pressure, double time) { GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); event->setEventType(GUIEventAdapter::PEN_PRESSURE); @@ -157,9 +159,11 @@ void EventQueue::penPressure(float pressure, double time) event->setTime(time); addEvent(event); + + return event; } -void EventQueue::penOrientation(float tiltX, float tiltY, float rotation, double time) +osgGA::GUIEventAdapter* EventQueue::penOrientation(float tiltX, float tiltY, float rotation, double time) { GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); event->setEventType(GUIEventAdapter::PEN_ORIENTATION); @@ -169,9 +173,11 @@ void EventQueue::penOrientation(float tiltX, float tiltY, float rotation, double event->setTime(time); addEvent(event); + + return event; } -void EventQueue::penProximity(GUIEventAdapter::TabletPointerType pt, bool isEntering, double time) +osgGA::GUIEventAdapter* EventQueue::penProximity(GUIEventAdapter::TabletPointerType pt, bool isEntering, double time) { GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); event->setEventType( (isEntering) ? GUIEventAdapter::PEN_PROXIMITY_ENTER : GUIEventAdapter::PEN_PROXIMITY_LEAVE); @@ -179,9 +185,11 @@ void EventQueue::penProximity(GUIEventAdapter::TabletPointerType pt, bool isEnte event->setTime(time); addEvent(event); + + return event; } -void EventQueue::mouseScroll(GUIEventAdapter::ScrollingMotion sm, double time) +osgGA::GUIEventAdapter* EventQueue::mouseScroll(GUIEventAdapter::ScrollingMotion sm, double time) { GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); event->setEventType(GUIEventAdapter::SCROLL); @@ -189,9 +197,11 @@ void EventQueue::mouseScroll(GUIEventAdapter::ScrollingMotion sm, double time) event->setTime(time); addEvent(event); + + return event; } -void EventQueue::mouseScroll2D(float x, float y, double time) +osgGA::GUIEventAdapter* EventQueue::mouseScroll2D(float x, float y, double time) { GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); event->setEventType(GUIEventAdapter::SCROLL); @@ -199,6 +209,8 @@ void EventQueue::mouseScroll2D(float x, float y, double time) event->setTime(time); addEvent(event); + + return event; } @@ -209,7 +221,7 @@ void EventQueue::mouseWarped(float x, float y) } -void EventQueue::mouseMotion(float x, float y, double time) +osgGA::GUIEventAdapter* EventQueue::mouseMotion(float x, float y, double time) { _accumulateEventState->setX(x); _accumulateEventState->setY(y); @@ -219,9 +231,11 @@ void EventQueue::mouseMotion(float x, float y, double time) event->setTime(time); addEvent(event); + + return event; } -void EventQueue::mouseButtonPress(float x, float y, unsigned int button, double time) +osgGA::GUIEventAdapter* EventQueue::mouseButtonPress(float x, float y, unsigned int button, double time) { _accumulateEventState->setX(x); _accumulateEventState->setY(y); @@ -257,9 +271,11 @@ void EventQueue::mouseButtonPress(float x, float y, unsigned int button, double } addEvent(event); + + return event; } -void EventQueue::mouseDoubleButtonPress(float x, float y, unsigned int button, double time) +osgGA::GUIEventAdapter* EventQueue::mouseDoubleButtonPress(float x, float y, unsigned int button, double time) { _accumulateEventState->setX(x); _accumulateEventState->setY(y); @@ -295,9 +311,11 @@ void EventQueue::mouseDoubleButtonPress(float x, float y, unsigned int button, d } addEvent(event); + + return event; } -void EventQueue::mouseButtonRelease(float x, float y, unsigned int button, double time) +osgGA::GUIEventAdapter* EventQueue::mouseButtonRelease(float x, float y, unsigned int button, double time) { _accumulateEventState->setX(x); _accumulateEventState->setY(y); @@ -333,9 +351,11 @@ void EventQueue::mouseButtonRelease(float x, float y, unsigned int button, doubl } addEvent(event); + + return event; } -void EventQueue::keyPress(int key, double time, int unmodifiedKey) +osgGA::GUIEventAdapter* EventQueue::keyPress(int key, double time, int unmodifiedKey) { switch(key) { @@ -377,9 +397,11 @@ void EventQueue::keyPress(int key, double time, int unmodifiedKey) event->setTime(time); addEvent(event); + + return event; } -void EventQueue::keyRelease(int key, double time, int unmodifiedKey) +osgGA::GUIEventAdapter* EventQueue::keyRelease(int key, double time, int unmodifiedKey) { switch(key) { @@ -405,10 +427,12 @@ void EventQueue::keyRelease(int key, double time, int unmodifiedKey) event->setTime(time); addEvent(event); + + return event; } -GUIEventAdapter* EventQueue::touchBegan(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, double time) +GUIEventAdapter* EventQueue::touchBegan(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, double time) { if(_firstTouchEmulatesMouse) { @@ -432,7 +456,7 @@ GUIEventAdapter* EventQueue::touchBegan(unsigned int id, GUIEventAdapter::Touch } -GUIEventAdapter* EventQueue::touchMoved(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, double time) +GUIEventAdapter* EventQueue::touchMoved(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, double time) { if(_firstTouchEmulatesMouse) { @@ -449,7 +473,7 @@ GUIEventAdapter* EventQueue::touchMoved(unsigned int id, GUIEventAdapter::Touch return event; } -GUIEventAdapter* EventQueue::touchEnded(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, unsigned int tap_count, double time) +GUIEventAdapter* EventQueue::touchEnded(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, unsigned int tap_count, double time) { if (_firstTouchEmulatesMouse) { @@ -471,34 +495,38 @@ GUIEventAdapter* EventQueue::touchEnded(unsigned int id, GUIEventAdapter::Touch } -void EventQueue::closeWindow(double time) +osgGA::GUIEventAdapter* EventQueue::closeWindow(double time) { GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); event->setEventType(GUIEventAdapter::CLOSE_WINDOW); event->setTime(time); addEvent(event); + + return event; } -void EventQueue::quitApplication(double time) +osgGA::GUIEventAdapter* EventQueue::quitApplication(double time) { GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); event->setEventType(GUIEventAdapter::QUIT_APPLICATION); event->setTime(time); addEvent(event); + + return event; } -void EventQueue::frame(double time) +osgGA::GUIEventAdapter* EventQueue::frame(double time) { GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState); event->setEventType(GUIEventAdapter::FRAME); event->setTime(time); - // OSG_NOTICE<<"frame("<getX()="<getX()<<", event->getY()="<getY()<<", event->getXmin()="<getXmin()<<", event->getYmin()="<getYmin()<<", event->getXmax()="<getXmax()<<", event->getYmax()="<getYmax()<setEventType(GUIEventAdapter::USER); @@ -515,6 +543,8 @@ void EventQueue::userEvent(osg::Referenced* userEventData, double time) event->setTime(time); addEvent(event); + + return event; }