OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Callbacks.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSGUI_CALLBACKS
15 #define OSGUI_CALLBACKS
16 
17 #include <osg/Callback>
18 #include <osgGA/EventVisitor>
19 
20 #include <osgUI/Export>
21 #include <osgUI/Widget>
22 
23 namespace osgUI
24 {
25 
26 
28 {
29 public:
30  CloseCallback(const std::string& callbackName=std::string("close"), osgUI::Widget* closeWidget=0);
33 
34  void setCloseWidget(osgUI::Widget* widget) { _closeWidget = widget; }
35  osgUI::Widget* getCloseWidget() { return _closeWidget.get(); }
36  const osgUI::Widget* getCloseWidget() const { return _closeWidget.get(); }
37 
38  virtual bool run(osg::Object* object, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const;
39 
40 protected:
41  virtual ~CloseCallback() {}
43 };
44 
46 {
47 public:
51 
52  virtual bool run(osg::Object* object, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const;
53  virtual bool handle(osgGA::EventVisitor* ev, osgGA::Event* event) const;
54 
55 protected:
56  virtual ~HandleCallback() {}
57 };
58 
60 {
61 public:
62  DragCallback();
65 
66  void setDragging(bool v) { _dragging = v; }
67  bool getDragging() const { return _dragging; }
68 
69  void setPreviousPosition(const osg::Vec3d& position) { _previousPosition = position; }
70  const osg::Vec3d& getPreviousPosition() const { return _previousPosition; }
71 
72  virtual bool handle(osgGA::EventVisitor* ev, osgGA::Event* event) const;
73 
74 protected:
75  virtual ~DragCallback() {}
76 
77  bool _dragging;
79 
80 };
81 
82 }
83 
84 #endif
osg::Vec3d _previousPosition
Definition: Callbacks.h:78
virtual ~HandleCallback()
Definition: Callbacks.h:56
void setCloseWidget(osgUI::Widget *widget)
Definition: Callbacks.h:34
osg::observer_ptr< osgUI::Widget > _closeWidget
Definition: Callbacks.h:42
virtual ~DragCallback()
Definition: Callbacks.h:75
osgUI::Widget * getCloseWidget()
Definition: Callbacks.h:35
const osgUI::Widget * getCloseWidget() const
Definition: Callbacks.h:36
std::vector< osg::ref_ptr< osg::Object > > Parameters
Definition: Callback.h:92
void setDragging(bool v)
Definition: Callbacks.h:66
#define META_Object(library, name)
Definition: Object.h:42
virtual ~CloseCallback()
Definition: Callbacks.h:41
void setPreviousPosition(const osg::Vec3d &position)
Definition: Callbacks.h:69
bool getDragging() const
Definition: Callbacks.h:67
const osg::Vec3d & getPreviousPosition() const
Definition: Callbacks.h:70
#define OSGUI_EXPORT
Definition: Widget.h:22