]> git.mxchange.org Git - flightgear.git/blob - src/Canvas/gui_mgr.hxx
Code cleanups, code updates and fix at least on (possible) devide-by-zero
[flightgear.git] / src / Canvas / gui_mgr.hxx
1 // Canvas gui/dialog manager
2 //
3 // Copyright (C) 2012  Thomas Geymayer <tomgey@gmail.com>
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 osgGA
32 {
33   class GUIEventAdapter;
34 }
35
36 class GUIEventHandler;
37 class GUIMgr:
38   public SGSubsystem
39 {
40   public:
41     GUIMgr();
42
43     simgear::canvas::WindowPtr createWindow(const std::string& name = "");
44
45     virtual void init();
46     virtual void shutdown();
47
48     virtual void update(double dt);
49
50     /**
51      * Get simgear::canvas::Group containing all windows
52      */
53     simgear::canvas::GroupPtr getDesktop();
54
55     /**
56      * Set the input (keyboard) focus to the given window.
57      */
58     void setInputFocus(const simgear::canvas::WindowPtr& window);
59
60     /**
61      * Grabs the pointer so that all events are passed to this @a window until
62      * the pointer is ungrabbed with ungrabPointer().
63      */
64     bool grabPointer(const simgear::canvas::WindowPtr& window);
65
66     /**
67      * Releases the grab acquired for this @a window with grabPointer().
68      */
69     void ungrabPointer(const simgear::canvas::WindowPtr& window);
70
71   protected:
72
73     simgear::canvas::GroupPtr           _desktop;
74     osg::ref_ptr<GUIEventHandler>       _event_handler;
75
76     simgear::canvas::Placements
77     addWindowPlacement( SGPropertyNode* placement,
78                         simgear::canvas::CanvasPtr canvas );
79 };
80
81 #endif /* CANVAS_GUI_MGR_HXX_ */