/
clientwindow.h
155 lines (129 loc) · 4.78 KB
/
clientwindow.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
148
149
150
151
152
153
154
155
/** @file clientwindow.h Top-level window with UI widgets.
*
* @authors Copyright © 2012-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 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 General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#ifndef CLIENT_CLIENTWINDOW_H
#define CLIENT_CLIENTWINDOW_H
#include <de/PersistentCanvasWindow>
#include "GuiRootWidget"
#include "resource/image.h"
#include "ui/widgets/legacywidget.h"
/**
* Macro for conveniently accessing the current active window. There is always
* one active window, so no need to worry about NULLs. The easiest way to get
* information about the window where drawing is done.
*/
//#define DENG_WINDOW (&ClientWindow::main())
#define DENG_GAMEVIEW_WIDTH ClientWindow::main().game().rule().width().valuei()
#define DENG_GAMEVIEW_HEIGHT ClientWindow::main().game().rule().height().valuei()
/**
* A helpful macro that changes the origin of the window space coordinate system.
*/
#define FLIP(y) (ClientWindow::main().height() - ((y)+1))
class ConsoleWidget;
class TaskBarWidget;
class NotificationWidget;
class BusyWidget;
/**
* Top-level window that contains a libdeng2 UI widgets. @ingroup gui
*/
class ClientWindow : public de::PersistentCanvasWindow,
DENG2_OBSERVES(de::Canvas, GLInit),
DENG2_OBSERVES(de::Canvas, GLResize)
{
Q_OBJECT
public:
enum Mode
{
Normal,
Busy
};
enum SidebarLocation
{
RightEdge
};
public:
ClientWindow(de::String const &id = "main");
GuiRootWidget &root();
TaskBarWidget &taskBar();
ConsoleWidget &console();
NotificationWidget ¬ifications();
LegacyWidget &game();
BusyWidget &busy();
/**
* Installs a sidebar widget into the window. If there is an existing
* sidebar, it will be deleted. Sidebar widgets are expected to control
* their own width (on the right/left edges) or height (on the top/bottom
* edges).
*
* @param location Location to attach the sidebar. Window takes ownership
* of the widget.
* @param sidebar Widget to install, or @c NULL to remove the sidebar.
*/
void setSidebar(SidebarLocation location, GuiWidget *sidebar);
void unsetSidebar(SidebarLocation location) { setSidebar(location, 0); }
/**
* Sets the operating mode of the window. In Busy mode, the normal
* widgets of the window will be replaced with a single BusyWidget.
*
* @param mode Mode.
*/
void setMode(Mode const &mode);
/**
* Must be called before any canvas windows are created. Defines the
* default OpenGL format settings for the contained canvases.
*
* @return @c true, if the new format was applied. @c false, if the new
* format remains the same because none of the settings have changed.
*/
static bool setDefaultGLFormat();
/**
* Request drawing the contents of the window as soon as possible.
*/
void draw();
/**
* Determines whether the contents of a window should be drawn during the
* execution of the main loop callback, or should we wait for an update event
* from the windowing system.
*/
bool shouldRepaintManually() const;
/**
* Grab the contents of the window into the supplied @a image. Ownership of
* the image passes to the window for the duration of this call.
*
* @param image Image to fill with the grabbed frame contents.
* @param halfSized If @c true, scales the image to half the full size.
*/
void grab(image_t &image, bool halfSized = false) const;
void updateCanvasFormat();
// Notifications.
bool isFPSCounterVisible() const;
// Events.
void closeEvent(QCloseEvent *);
void canvasGLReady(de::Canvas &);
void canvasGLInit(de::Canvas &);
void canvasGLDraw(de::Canvas &);
void canvasGLResized(de::Canvas &);
static ClientWindow &main();
public slots:
void toggleFPSCounter();
void showColorAdjustments();
private:
DENG2_PRIVATE(d)
};
#endif // CANVASWINDOW_H