-
-
Notifications
You must be signed in to change notification settings - Fork 78
/
dialog.h
81 lines (66 loc) · 1.28 KB
/
dialog.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
#ifndef ZC_GUI_DIALOG_H
#define ZC_GUI_DIALOG_H
#include "base/zapp.h"
#include "dialog_message.h"
#include "gui/dialog_runner.h"
#include "gui/widget.h"
#include <base/gui.h>
#include <dialog/common.h>
#include <memory>
namespace GUI
{
template<typename T>
class Dialog
{
public:
virtual ~Dialog() {}
/* Creates and initializes the dialog's window. */
virtual std::shared_ptr<Widget> view()=0;
DialogRunner runner;
bool rerun_dlg;
inline void show()
{
if (is_headless() || is_ci())
return;
clear_keybuf();
auto oz = gui_mouse_z();
runner = DialogRunner();
rerun_dlg = false;
popup_zqdialog_start();
runner.run(*static_cast<T*>(this));
while(rerun_dlg)
{
while(gui_mouse_b()); //wait for mouseup
rerun_dlg = false;
runner.clear();
clear_tooltip();
runner.run(*static_cast<T*>(this));
}
popup_zqdialog_end();
position_mouse_z(oz);
}
inline void pendDraw()
{
runner.pendDraw();
}
inline void forceDraw()
{
runner.forceDraw();
}
inline void close()
{
runner.done = true;
}
inline void refresh_dlg()
{
rerun_dlg = true;
close();
}
virtual void post_realize(){}
/* Subclasses must define an int32_t-convertible type called `message`
* and implement:
* bool handleMessage(const DialogMessage<message>&)
*/
};
}
#endif