/
guirootwidget.h
147 lines (121 loc) · 3.93 KB
/
guirootwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/** @file guirootwidget.h Graphical root widget.
*
* @authors Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* LGPL: http://www.gnu.org/licenses/lgpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef LIBAPPFW_GUIROOTWIDGET_H
#define LIBAPPFW_GUIROOTWIDGET_H
#include <de/RootWidget>
#include <de/AtlasTexture>
#include <de/GLShaderBank>
#include <de/GLUniform>
#include <de/Matrix>
#include <de/CanvasWindow>
#include "../libappfw.h"
namespace de {
class GuiWidget;
/**
* Graphical root widget.
*
* @ingroup gui
*/
class LIBAPPFW_PUBLIC GuiRootWidget : public RootWidget
{
public:
GuiRootWidget(CanvasWindow *window = 0);
/**
* Sets the window in which the root widget resides.
*
* @param window Client window instance.
*/
void setWindow(CanvasWindow *window);
/**
* Returns the window in which the root widget resides.
*/
CanvasWindow &window();
AtlasTexture &atlas();
GLUniform &uAtlas();
Id solidWhitePixel() const;
Id roundCorners() const;
Id boldRoundCorners() const;
Id borderGlow() const;
Id tinyDot() const;
/**
* Gets the identifier of a style image allocated on the shared UI atlas texture.
*
* @param styleImagePath Path of the style image in the style's image bank.
*
* @return Id of the texture allocation.
*/
Id styleTexture(DotPath const &styleImagePath) const;
static GLShaderBank &shaders();
/**
* Returns the default projection for 2D graphics.
*/
Matrix4f projMatrix2D() const;
void routeMouse(Widget *routeTo);
bool processEvent(Event const &event);
/**
* Finds the widget that occupies the given point, looking through the entire tree. The
* returned widget is the one that will first handle a received event associated with this
* position.
*
* @param pos Position in the view.
*
* @return Widget, or @c NULL if none were found.
*/
GuiWidget const *globalHitTest(Vector2i const &pos) const;
GuiWidget const *guiFind(String const &name) const;
// Events.
void update();
void draw();
/**
* Draws until the widget @a until is encountered during tree notification.
*
* @param until Widget to stop drawing at. @a until is not drawn.
*/
void drawUntil(Widget &until);
/**
* Adds a widget over all others.
*
* @param widget Widget to add on top.
*/
virtual void addOnTop(GuiWidget *widget);
/**
* Reorders the children of the root widget so that @a widget is added to the top.
*
* @param widget Widget to move to the top.
*/
void moveToTop(GuiWidget &widget);
/**
* Sends the current mouse position as a mouse event, just like the mouse would've
* been moved.
*/
virtual void dispatchLatestMousePosition();
/**
* If the event is not used by any widget, this will be called so the application may
* still handle the event for other, non-widget-related purposes. No widget will be
* offered the event after this is called.
*
* @param event Event.
*/
virtual void handleEventAsFallback(Event const &event);
protected:
virtual void loadCommonTextures();
private:
DENG2_PRIVATE(d)
};
} // namespace de
#endif // LIBAPPFW_GUIROOTWIDGET_H