/
imainframe.h
140 lines (116 loc) · 4.15 KB
/
imainframe.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
#pragma once
#include "imodule.h"
#include <sigc++/signal.h>
const char* const MODULE_MAINFRAME("MainFrame");
class wxFrame;
class wxToolBar;
class wxBoxSizer;
/**
* Scoped object to block screen updates and display a modal message,
* used while reloading shaders, for instance.
*/
class IScopedScreenUpdateBlocker
{
public:
virtual ~IScopedScreenUpdateBlocker() {}
// For operations without calculatable duration, call pulse() regularly to
// provide some visual feedback
virtual void pulse() = 0;
// Update the progress fraction [0..1]
virtual void setProgress(float progress) = 0;
// Set the status message that might be displayed to the user
virtual void setMessage(const std::string& message) = 0;
};
typedef std::shared_ptr<IScopedScreenUpdateBlocker> IScopedScreenUpdateBlockerPtr;
/**
* The MainFrame represents the top-level application window.
*/
class IMainFrame :
public RegisterableModule
{
public:
// Constructs the toplevel mainframe window and issues the "radiant startup" signal
virtual void construct() = 0;
// Returns TRUE if screen updates are enabled
virtual bool screenUpdatesEnabled() = 0;
// Use this to (re-)enable camera and xyview draw updates
virtual void enableScreenUpdates() = 0;
// Use this to disable camera and xyview draw updates until enableScreenUpdates is called.
virtual void disableScreenUpdates() = 0;
/**
* Returns the main application window widget. Returns NULL if no window
* has been constructed yet.
*/
virtual wxFrame* getWxTopLevelWindow() = 0;
/**
* Returns TRUE if DarkRadiant is currently "in focus", i.e. the app in the foreground.
*/
virtual bool isActiveApp() = 0;
/**
* greebo: Returns the main container widget (a box sizer), where layouts
* can start packing widgets into. This resembles the large grey area
* in the main window.
* May return NULL if mainframe is not constructed yet.
*/
virtual wxBoxSizer* getWxMainContainer() = 0;
enum Toolbar
{
TOOLBAR_HORIZONTAL, // the "view" toolbar (on the top)
TOOLBAR_VERTICAL, // the "edit" toolbar (on the left)
};
/**
* greebo: Returns a toolbar widget, as specified by the
* passed enum value.
*/
virtual wxToolBar* getToolbar(Toolbar type) = 0;
/**
* Updates all viewports which are child of the toplevel window.
* Set the force flag to true to redraw immediately insteaf of queueing.
*/
virtual void updateAllWindows(bool force = false) = 0;
/**
* Applies the named layout to the MainFrame window. See MainFrameLayout class.
*/
virtual void applyLayout(const std::string& name) = 0;
/// Store the layout name, but do not immediately apply it
virtual void setActiveLayoutName(const std::string& name) = 0;
/**
* Returns the name of the currently activated layout or
* an empty string if no layout is applied.
*/
virtual std::string getCurrentLayout() = 0;
/**
* Acquire a screen update blocker object that displays a modal message.
* As soon as the object is destroyed screen updates are allowed again.
*
* Pass the title and the message to display in the small modal window.
*/
virtual IScopedScreenUpdateBlockerPtr getScopedScreenUpdateBlocker(const std::string& title,
const std::string& message, bool forceDisplay = false) = 0;
/**
* A signal emitted when the MainFrame window has been set up. Modules can
* subscribe to this to register any UI parts that require a valid main window
* or sub component like the group dialog to be constructed.
* This is a one-time signal, after emission the subscribers will be
* automatically removed by this class.
*/
virtual sigc::signal<void>& signal_MainFrameConstructed() = 0;
/**
* Signal fired after the MainFrame window is shown the first time
* during application start up.
* This is a one-time signal, after emission the subscribers will be
* automatically removed by this class.
*/
virtual sigc::signal<void>& signal_MainFrameReady() = 0;
};
// This is the accessor for the mainframe module
inline IMainFrame& GlobalMainFrame()
{
// Cache the reference locally
static IMainFrame& _mainFrame(
*std::static_pointer_cast<IMainFrame>(
module::GlobalModuleRegistry().getModule(MODULE_MAINFRAME)
)
);
return _mainFrame;
}