]> git.mxchange.org Git - flightgear.git/blob - src/Canvas/window.hxx
Fix cursor hide timeout if hovering on canvas windows
[flightgear.git] / src / Canvas / window.hxx
1 // Window for placing a Canvas onto it (for dialogs, menus, etc.)
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_WINDOW_HXX_
20 #define CANVAS_WINDOW_HXX_
21
22 #include <simgear/canvas/elements/CanvasImage.hxx>
23 #include <simgear/canvas/MouseEvent.hxx>
24 #include <simgear/props/PropertyBasedElement.hxx>
25 #include <simgear/props/propertyObject.hxx>
26 #include <simgear/misc/CSSBorder.hxx>
27
28 #include <osg/Geode>
29 #include <osg/Geometry>
30
31 namespace canvas
32 {
33   class Window:
34     public simgear::canvas::Image
35   {
36     public:
37       static const std::string TYPE_NAME;
38
39       enum Resize
40       {
41         NONE    = 0,
42         LEFT    = 1,
43         RIGHT   = LEFT << 1,
44         TOP     = RIGHT << 1,
45         BOTTOM  = TOP << 1,
46         INIT    = BOTTOM << 1
47       };
48
49       typedef simgear::canvas::Style Style;
50
51       Window( const simgear::canvas::CanvasWeakPtr& canvas,
52               const SGPropertyNode_ptr& node,
53               const Style& parent_style = Style(),
54               Element* parent = 0 );
55       virtual ~Window();
56
57       virtual void update(double delta_time_sec);
58       virtual void valueChanged(SGPropertyNode* node);
59
60       osg::Group* getGroup();
61       const SGVec2<float> getPosition() const;
62       const SGRect<float>  getScreenRegion() const;
63
64       void setCanvasContent(simgear::canvas::CanvasPtr canvas);
65       simgear::canvas::CanvasWeakPtr getCanvasContent() const;
66
67       simgear::canvas::CanvasPtr getCanvasDecoration();
68
69       bool isResizable() const;
70       bool isCapturingEvents() const;
71
72       /**
73        * Moves window on top of all other windows with the same z-index.
74        *
75        * @note If no z-index is set it defaults to 0.
76        */
77       void raise();
78
79       void handleResize(uint8_t mode, const osg::Vec2f& delta = osg::Vec2f());
80
81     protected:
82
83       enum Attributes
84       {
85         DECORATION = 1
86       };
87
88       uint32_t  _attributes_dirty;
89
90       simgear::canvas::CanvasPtr        _canvas_decoration;
91       simgear::canvas::CanvasWeakPtr    _canvas_content;
92
93       simgear::canvas::ImagePtr _image_content,
94                                 _image_shadow;
95
96       bool _resizable,
97            _capture_events;
98
99       simgear::PropertyObject<int> _resize_top,
100                                    _resize_right,
101                                    _resize_bottom,
102                                    _resize_left,
103                                    _resize_status;
104
105       simgear::CSSBorder    _decoration_border;
106
107       void parseDecorationBorder(const std::string& str);
108       void updateDecoration();
109   };
110 } // namespace canvas
111
112 #endif /* CANVAS_WINDOW_HXX_ */