1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
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.
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.
14#ifndef OSGUI_CALLBACKS
15#define OSGUI_CALLBACKS
17#include <osg/Callback>
18#include <osgGA/EventVisitor>
20#include <osgUI/Export>
21#include <osgUI/Widget>
27class OSGUI_EXPORT CloseCallback : public osg::CallbackObject
30 CloseCallback(const std::string& callbackName=std::string("close"), osgUI::Widget* closeWidget=0);
31 CloseCallback(const CloseCallback& hc, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
32 META_Object(osgUI, CloseCallback);
34 void setCloseWidget(osgUI::Widget* widget) { _closeWidget = widget; }
35 osgUI::Widget* getCloseWidget() { return _closeWidget.get(); }
36 const osgUI::Widget* getCloseWidget() const { return _closeWidget.get(); }
38 virtual bool run(osg::Object* object, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const;
41 virtual ~CloseCallback() {}
42 osg::observer_ptr<osgUI::Widget> _closeWidget;
45class OSGUI_EXPORT HandleCallback : public osg::CallbackObject
49 HandleCallback(const HandleCallback& hc, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
50 META_Object(osgUI, HandleCallback);
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;
56 virtual ~HandleCallback() {}
59class OSGUI_EXPORT DragCallback : public HandleCallback
63 DragCallback(const DragCallback& dc, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
64 META_Object(osgUI, DragCallback);
66 void setDragging(bool v) { _dragging = v; }
67 bool getDragging() const { return _dragging; }
69 void setPreviousPosition(const osg::Vec3d& position) { _previousPosition = position; }
70 const osg::Vec3d& getPreviousPosition() const { return _previousPosition; }
72 virtual bool handle(osgGA::EventVisitor* ev, osgGA::Event* event) const;
75 virtual ~DragCallback() {}
78 osg::Vec3d _previousPosition;