FlightGear next
gui_mgr.hxx
Go to the documentation of this file.
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
31namespace osgViewer { class View; }
32namespace osg { class Camera; }
33
34namespace osgGA
35{
36 class GUIEventAdapter;
37}
38
39class GUIEventHandler;
40class GUIMgr : public SGSubsystem
41{
42public:
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
58 simgear::canvas::GroupPtr getDesktop();
59
63 void setInputFocus(const simgear::canvas::WindowPtr& window);
64
69 bool grabPointer(const simgear::canvas::WindowPtr& window);
70
74 void ungrabPointer(const simgear::canvas::WindowPtr& window);
75
79 void setGUIViewAndCamera(osgViewer::View* view, osg::Camera* cam);
80protected:
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_ */
Event handler.
Definition gui_mgr.cxx:67
void setInputFocus(const simgear::canvas::WindowPtr &window)
Set the input (keyboard) focus to the given window.
Definition gui_mgr.cxx:745
void update(double dt) override
Definition gui_mgr.cxx:733
void init() override
Definition gui_mgr.cxx:666
simgear::canvas::WindowPtr createWindow(const std::string &name="")
Definition gui_mgr.cxx:657
void shutdown() override
Definition gui_mgr.cxx:705
void setGUIViewAndCamera(osgViewer::View *view, osg::Camera *cam)
specify the osgViewer::View and Camera
Definition gui_mgr.cxx:650
osg::ref_ptr< osgViewer::View > _viewerView
Definition gui_mgr.hxx:83
simgear::canvas::GroupPtr getDesktop()
Get simgear::canvas::Group containing all windows.
Definition gui_mgr.cxx:739
bool grabPointer(const simgear::canvas::WindowPtr &window)
Grabs the pointer so that all events are passed to this window until the pointer is ungrabbed with un...
Definition gui_mgr.cxx:751
void ungrabPointer(const simgear::canvas::WindowPtr &window)
Releases the grab acquired for this window with grabPointer().
Definition gui_mgr.cxx:757
simgear::canvas::GroupPtr _desktop
Definition gui_mgr.hxx:81
osg::ref_ptr< osg::Camera > _camera
Definition gui_mgr.hxx:84
osg::ref_ptr< GUIEventHandler > _event_handler
Definition gui_mgr.hxx:82
simgear::canvas::Placements addWindowPlacement(SGPropertyNode *placement, simgear::canvas::CanvasPtr canvas)
Definition gui_mgr.cxx:764
static const char * staticSubsystemClassId()
Definition gui_mgr.hxx:51
const char * name
Definition AIBase.hxx:25