2008-07-26 04:04:41 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
|
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2008-07-16 01:21:25 +08:00
|
|
|
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
|
|
|
// $Id: ViewerEventHandlers 31 2008-04-01 19:36:41Z cubicool $
|
|
|
|
|
|
|
|
#ifndef OSGWIDGET_VIEWER_EVENT_HANDLERS
|
|
|
|
#define OSGWIDGET_VIEWER_EVENT_HANDLERS
|
|
|
|
|
|
|
|
#include <osgGA/GUIEventAdapter>
|
|
|
|
#include <osgGA/GUIEventHandler>
|
|
|
|
#include <osgWidget/WindowManager>
|
|
|
|
|
|
|
|
// NOTE! These are all just examples of some default event handlers--they are not
|
|
|
|
// required. You are more than welcome to provide your own even handlers that
|
|
|
|
// communicate with a WindowManager using it's public API.
|
|
|
|
|
|
|
|
namespace osgWidget {
|
|
|
|
|
|
|
|
// This handles the pressing/moving of mouse buttons, etc.
|
2008-07-26 03:57:17 +08:00
|
|
|
class OSGWIDGET_EXPORT MouseHandler: public osgGA::GUIEventHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MouseHandler(WindowManager*);
|
|
|
|
|
|
|
|
virtual bool handle(
|
|
|
|
const osgGA::GUIEventAdapter&,
|
|
|
|
osgGA::GUIActionAdapter&,
|
|
|
|
osg::Object*,
|
|
|
|
osg::NodeVisitor*
|
|
|
|
);
|
|
|
|
|
2008-09-17 22:21:47 +08:00
|
|
|
|
|
|
|
typedef bool (MouseHandler::*MouseAction)(float, float, int);
|
|
|
|
typedef bool (WindowManager::*MouseEvent)(float, float);
|
|
|
|
|
2008-07-26 03:57:17 +08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
osg::ref_ptr<WindowManager> _wm;
|
|
|
|
|
|
|
|
bool _handleMousePush (float, float, int);
|
|
|
|
bool _handleMouseRelease (float, float, int);
|
|
|
|
bool _handleMouseDoubleClick (float, float, int);
|
|
|
|
bool _handleMouseDrag (float, float, int);
|
|
|
|
bool _handleMouseMove (float, float, int);
|
|
|
|
bool _handleMouseScroll (float, float, int);
|
|
|
|
|
|
|
|
MouseAction _isMouseEvent (osgGA::GUIEventAdapter::EventType) const;
|
|
|
|
bool _doMouseEvent (float, float, MouseEvent);
|
|
|
|
|
2008-07-16 01:21:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// This handles the forwarding of keypress events.
|
2008-07-26 03:57:17 +08:00
|
|
|
class OSGWIDGET_EXPORT KeyboardHandler: public osgGA::GUIEventHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
KeyboardHandler(WindowManager*);
|
|
|
|
|
|
|
|
virtual bool handle(
|
|
|
|
const osgGA::GUIEventAdapter&,
|
|
|
|
osgGA::GUIActionAdapter&,
|
|
|
|
osg::Object*,
|
|
|
|
osg::NodeVisitor*
|
|
|
|
);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
osg::ref_ptr<WindowManager> _wm;
|
|
|
|
|
2008-07-16 01:21:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// This class offers a default kind of handling for resizing.
|
2008-07-26 03:57:17 +08:00
|
|
|
class OSGWIDGET_EXPORT ResizeHandler: public osgGA::GUIEventHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ResizeHandler(WindowManager*, osg::Camera*);
|
|
|
|
|
|
|
|
virtual bool handle(
|
|
|
|
const osgGA::GUIEventAdapter&,
|
|
|
|
osgGA::GUIActionAdapter&,
|
|
|
|
osg::Object*,
|
|
|
|
osg::NodeVisitor*
|
|
|
|
);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
osg::ref_ptr<WindowManager> _wm;
|
|
|
|
osg::ref_ptr<osg::Camera> _camera;
|
|
|
|
|
2008-07-16 01:21:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|