| 1 | // Canvas gui/dialog manager |
| 2 | // |
| 3 | // Copyright (C) 2012 Thomas Geymayer <[email protected]> |
| 4 | // |
| 5 | // This program is free software; you can redistribute it and/or |
| 6 | // modify it under the terms of the GNU General Public License as |
| 7 | // published by the Free Software Foundation; either version 2 of the |
| 8 | // License, or (at your option) any later version. |
| 9 | // |
| 10 | // This program is distributed in the hope that it will be useful, but |
| 11 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | // General Public License for more details. |
| 14 | // |
| 15 | // You should have received a copy of the GNU General Public License |
| 16 | // along with this program; if not, write to the Free Software |
| 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | |
| 19 | #ifndef CANVAS_GUI_MGR_HXX_ |
| 20 | #define CANVAS_GUI_MGR_HXX_ |
| 21 | |
| 22 | #include <simgear/canvas/canvas_fwd.hxx> |
| 23 | #include <simgear/canvas/elements/CanvasGroup.hxx> |
| 24 | #include <simgear/props/PropertyBasedMgr.hxx> |
| 25 | #include <simgear/props/propertyObject.hxx> |
| 26 | |
| 27 | #include <osg/ref_ptr> |
| 28 | #include <osg/Geode> |
| 29 | #include <osg/MatrixTransform> |
| 30 | |
| 31 | namespace osgViewer { class View; } |
| 32 | namespace osg { class Camera; } |
| 33 | |
| 34 | namespace osgGA |
| 35 | { |
| 36 | class GUIEventAdapter; |
| 37 | } |
| 38 | |
| 39 | class GUIEventHandler; |
| 40 | class GUIMgr : public SGSubsystem |
| 41 | { |
| 42 | public: |
| 43 | GUIMgr(); |
| 44 | |
| 45 | // Subsystem API. |
| 46 | void init() override; |
| 47 | void shutdown() override; |
| 48 | void update(double dt) override; |
| 49 | |
| 50 | // Subsystem identification. |
| 51 | static const char* staticSubsystemClassId() { return "CanvasGUI"; } |
| 52 | |
| 53 | simgear::canvas::WindowPtr createWindow(const std::string& name = ""); |
| 54 | |
| 55 | /** |
| 56 | * Get simgear::canvas::Group containing all windows |
| 57 | */ |
| 58 | simgear::canvas::GroupPtr getDesktop(); |
| 59 | |
| 60 | /** |
| 61 | * Set the input (keyboard) focus to the given window. |
| 62 | */ |
| 63 | void setInputFocus(const simgear::canvas::WindowPtr& window); |
| 64 | |
| 65 | /** |
| 66 | * Grabs the pointer so that all events are passed to this @a window until |
| 67 | * the pointer is ungrabbed with ungrabPointer(). |
| 68 | */ |
| 69 | bool grabPointer(const simgear::canvas::WindowPtr& window); |
| 70 | |
| 71 | /** |
| 72 | * Releases the grab acquired for this @a window with grabPointer(). |
| 73 | */ |
| 74 | void ungrabPointer(const simgear::canvas::WindowPtr& window); |
| 75 | |
| 76 | /** |
| 77 | * specify the osgViewer::View and Camera |
| 78 | */ |
| 79 | void setGUIViewAndCamera(osgViewer::View* view, osg::Camera* cam); |
| 80 | protected: |
| 81 | simgear::canvas::GroupPtr _desktop; |
| 82 | osg::ref_ptr<GUIEventHandler> _event_handler; |
| 83 | osg::ref_ptr<osgViewer::View> _viewerView; |
| 84 | osg::ref_ptr<osg::Camera> _camera; |
| 85 | |
| 86 | simgear::canvas::Placements |
| 87 | addWindowPlacement( SGPropertyNode* placement, |
| 88 | simgear::canvas::CanvasPtr canvas ); |
| 89 | }; |
| 90 | |
| 91 | #endif /* CANVAS_GUI_MGR_HXX_ */ |