-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwindow.h
More file actions
186 lines (158 loc) · 7.03 KB
/
Copy pathwindow.h
File metadata and controls
186 lines (158 loc) · 7.03 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
* Copyright 2022-2023 - All rights reserved.
* License: https://wiimag.com/LICENSE
*/
#pragma once
#include <framework/common.h>
#include <framework/function.h>
/*! Window user handle. */
typedef object_t window_handle_t;
/*! @typedef Window application callback. */
typedef function<void(window_handle_t)> window_event_handler_t;
typedef function<void(window_handle_t, int, int)> window_resize_callback_t;
typedef enum class WindowFlags {
None = 0,
/*! Make new window size proportional to the desktop monitor size it will open on. */
InitialProportionalSize = 1 << 0,
/*! A Transient window do not restore and save any user window settings. */
Transient = 1 << 1,
/*! The window will be opened maximized. */
Maximized = 1 << 2,
/*! Their can only be one instance of that window. */
Singleton = 1 << 3,
/*! This flags give a dialog behavior to the window. */
Dialog = 1 << 4,
} window_flags_t;
DEFINE_ENUM_FLAGS(WindowFlags);
/*! Create and open a new window.
*
* @param window_id The unique identifier of the window. The window id string gets copied into managed memory.
* It is best to keep window ID simple and to use constant literals
* @param title The title of the window. The title string gets copied into managed memory.
* @param title_length The length of the title string.
* @param render_callback The callback to be called when the window is rendered.
* @param close_callback The callback to be called when the window is closed.
* @param user_data The user data used to restore any user data through #window_get_user_pointer
* @param flags The window flags used to create and show the window.
*
* @return The handle of the window.
*/
window_handle_t window_open(
const char* FOUNDATION_RESTRICT window_id,
const char* title, size_t title_length,
const window_event_handler_t& render_callback,
const window_event_handler_t& close_callback,
void* user_data = nullptr, window_flags_t flags = WindowFlags::None);
/*! Create and open a new window.
*
* @param title The title of the window. The title string gets copied into managed memory.
* @param render_callback The callback to be called when the window is rendered.
* @param flags The window flags used to create and show the window.
*
* @return The handle of the window.
*/
window_handle_t window_open(const char* title, const window_event_handler_t& render_callback, window_flags_t flags = WindowFlags::None);
/*! Create and open a new module window that will act as a singleton.
*
* @param context The context of the window. The context is used to identify the window.
* @param title The title of the window. The title string gets copied into managed memory.
* @param title_length The length of the title string.
* @param render_callback The callback to be called when the window is rendered.
* @param close_callback The callback to be called when the window is closed.
* @param user_data The user data used to restore any user data through #window_get_user_pointer
* @param flags The window flags used to create and show the window and we add the #WindowFlags::Singleton flag.
*
* @return The handle of the window.
*/
window_handle_t window_open(
hash_t context,
const char* title, size_t title_length,
const window_event_handler_t& render_callback,
const window_event_handler_t& close_callback,
void* user_data = nullptr, window_flags_t flags = WindowFlags::None);
/*! Returns the title string of the window.
*
* @param window The handle of the window.
*
* @return The title string of the window.
*/
const char* window_title(window_handle_t window);
/*! Returns any user data associated with the window.
*
* @note The user data is set through #window_open.
* @important The user data is NOT managed by the window system.
*
* @param window The handle of the window.
*
* @return The user data associated with the window.
*/
void* window_get_user_data(window_handle_t window);
/*! Sets any user data associated with the window.
*
* @important The user data is NOT managed by the window system.
*
* @param window The handle of the window.
* @param user_data The user data associated with the window.
*/
void window_set_user_data(window_handle_t window, void* user_data);
/*! Sets the window title. The title string gets copied into managed memory.
*
* @param window_handle The handle of the window.
* @param title The title of the window.
*/
void window_set_title(window_handle_t window_handle, const char* title, size_t title_length);
/*! Sets the window render callback. The callback is called when the window is rendered.
*
* @param window_handle The handle of the window.
* @param callback The callback to be called when the window is rendered.
*/
void window_set_render_callback(window_handle_t window_handle, const window_event_handler_t& callback);
/*! Sets the resize window callback. The callback is called each time the window is resized.
*
* @param window_handle The handle of the window.
* @param callback The callback to be called when the window is resized.
*/
void window_set_resize_callback(window_handle_t window_handle, const window_resize_callback_t& callback);
/*! Sets the window close callback. The callback is called when the window is closed or destroyed.
*
* @param window_handle The handle of the window.
* @param callback The callback to be called when the window is closed.
*/
void window_set_close_callback(window_handle_t window_handle, const window_event_handler_t& callback);
/*! Sets the window menu render callback. The callback is called when the window menu is rendered.
*
* @param window_handle The handle of the window.
* @param callback The callback to be called when the window menu is rendered. (#void(window_handle_t))
*/
void window_set_menu_render_callback(window_handle_t window_handle, const window_event_handler_t& callback);
/*! Focus the window.
*
* @param window_handle The handle of the window.
*
* @return True if the window was focused, false otherwise.
*/
bool window_focus(window_handle_t window_handle);
/*! Request to close the window.
*
* @param window_handle The handle of the window to be closed.
*/
void window_close(window_handle_t window_handle);
/*! Handle the main Windows/ menu items. */
void window_menu();
/*! Update the window system. */
void window_update();
/*! Checks if the window is valid.
*
* @param window_handle The handle of the window.
*
* @return True if the window is valid, false otherwise.
*/
bool window_valid(window_handle_t window_handle);
/*! Returns the active window handle.
*
* @note The active window is the window that has focus.
* @remark If the window handle is null, you can assume that the main window is the active window.
*
* @return The active window handle.
*/
window_handle_t window_current();