plusui-native-core 0.1.4 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/Core/CMakeLists.txt +190 -7
  2. package/Core/Features/App/app.cpp +129 -0
  3. package/Core/Features/App/app.ts +126 -0
  4. package/Core/Features/Browser/browser.cpp +181 -0
  5. package/Core/Features/Browser/browser.ts +182 -0
  6. package/Core/Features/Clipboard/clipboard.cpp +234 -0
  7. package/Core/Features/Clipboard/clipboard.ts +113 -0
  8. package/Core/Features/Display/display.cpp +209 -0
  9. package/Core/Features/Display/display.ts +104 -0
  10. package/Core/Features/Event/Events.ts +166 -0
  11. package/Core/Features/Event/events.cpp +200 -0
  12. package/Core/Features/Keyboard/keyboard.cpp +186 -0
  13. package/Core/Features/Keyboard/keyboard.ts +175 -0
  14. package/Core/Features/Menu/context-menu.css +293 -0
  15. package/Core/Features/Menu/menu.cpp +481 -0
  16. package/Core/Features/Menu/menu.ts +439 -0
  17. package/Core/Features/Tray/tray.cpp +310 -0
  18. package/Core/Features/Tray/tray.ts +68 -0
  19. package/Core/Features/WebGPU/webgpu.cpp +939 -0
  20. package/Core/Features/WebGPU/webgpu.ts +1013 -0
  21. package/Core/Features/WebView/webview.cpp +1052 -0
  22. package/Core/Features/WebView/webview.ts +510 -0
  23. package/Core/Features/Window/window.cpp +664 -0
  24. package/Core/Features/Window/window.ts +142 -0
  25. package/Core/Features/WindowManager/window_manager.cpp +341 -0
  26. package/Core/include/plusui/app.hpp +73 -0
  27. package/Core/include/plusui/browser.hpp +66 -0
  28. package/Core/include/plusui/clipboard.hpp +41 -0
  29. package/Core/include/plusui/events.hpp +58 -0
  30. package/Core/include/{keyboard.hpp → plusui/keyboard.hpp} +21 -44
  31. package/Core/include/plusui/menu.hpp +153 -0
  32. package/Core/include/plusui/tray.hpp +93 -0
  33. package/Core/include/plusui/webgpu.hpp +434 -0
  34. package/Core/include/plusui/webview.hpp +142 -0
  35. package/Core/include/plusui/window.hpp +111 -0
  36. package/Core/include/plusui/window_manager.hpp +57 -0
  37. package/Core/vendor/WebView2EnvironmentOptions.h +406 -0
  38. package/Core/vendor/stb_image.h +7988 -0
  39. package/Core/vendor/webview.h +618 -510
  40. package/Core/vendor/webview2.h +52079 -0
  41. package/README.md +19 -0
  42. package/package.json +12 -15
  43. package/Core/include/app.hpp +0 -121
  44. package/Core/include/menu.hpp +0 -79
  45. package/Core/include/tray.hpp +0 -81
  46. package/Core/include/window.hpp +0 -106
  47. package/Core/src/app.cpp +0 -311
  48. package/Core/src/display.cpp +0 -424
  49. package/Core/src/tray.cpp +0 -275
  50. package/Core/src/window.cpp +0 -528
  51. package/dist/index.d.ts +0 -205
  52. package/dist/index.js +0 -198
  53. package/src/index.ts +0 -574
  54. /package/Core/include/{display.hpp → plusui/display.hpp} +0 -0
@@ -0,0 +1,434 @@
1
+ #pragma once
2
+
3
+ #include <string>
4
+ #include <memory>
5
+ #include <unordered_map>
6
+ #include <vector>
7
+ #include <functional>
8
+ #include <optional>
9
+
10
+ namespace plusui {
11
+
12
+ // Forward declarations for WebGPU types
13
+ class WebGPU;
14
+
15
+ /**
16
+ * @brief Configuration options for WebGPU initialization
17
+ */
18
+ struct WebGPUConfig {
19
+ /// Enable WebGPU feature
20
+ bool enabled = false;
21
+
22
+ /// Enable API validation in debug builds
23
+ bool validateAPI = true;
24
+
25
+ /// Enable verbose logging for debugging
26
+ bool verbose = false;
27
+ };
28
+
29
+ /**
30
+ * @brief WebGPU Resource Manager
31
+ *
32
+ * Manages GPU resources and provides access to WebGPU API.
33
+ * Uses handle-based resource management to support JSON-RPC communication.
34
+ */
35
+ class WebGPU {
36
+ public:
37
+ WebGPU();
38
+ ~WebGPU();
39
+
40
+ // Prevent copying but allow moving
41
+ WebGPU(const WebGPU&) = delete;
42
+ WebGPU& operator=(const WebGPU&) = delete;
43
+ WebGPU(WebGPU&&) noexcept;
44
+ WebGPU& operator=(WebGPU&&) noexcept;
45
+
46
+ /**
47
+ * @brief Create a WebGPU instance with configuration
48
+ * @param config WebGPU configuration options
49
+ * @return New WebGPU instance
50
+ */
51
+ static WebGPU create(const WebGPUConfig& config);
52
+
53
+ /**
54
+ * @brief Initialize the WebGPU subsystem
55
+ * @return true if initialization successful, false otherwise
56
+ */
57
+ bool initialize();
58
+
59
+ /**
60
+ * @brief Destroy all GPU resources and shut down WebGPU
61
+ */
62
+ void destroy();
63
+
64
+ /**
65
+ * @brief Check if WebGPU is initialized and available
66
+ * @return true if WebGPU is ready to use
67
+ */
68
+ bool isAvailable() const;
69
+
70
+ // ========================================================================
71
+ // Adapter API
72
+ // ========================================================================
73
+
74
+ /**
75
+ * @brief Request a GPU adapter with specified options
76
+ * @param options JSON string with request options (e.g., power preference)
77
+ * @return JSON string with adapter info and handle, or empty string if failed
78
+ */
79
+ std::string requestAdapter(const std::string& options);
80
+
81
+ /**
82
+ * @brief Get all available GPU adapters
83
+ * @return JSON string with array of adapters
84
+ */
85
+ std::string getAdapters();
86
+
87
+ // ========================================================================
88
+ // Device API
89
+ // ========================================================================
90
+
91
+ /**
92
+ * @brief Request a logical GPU device from an adapter
93
+ * @param adapterId Adapter handle (from requestAdapter)
94
+ * @param descriptor JSON string with device descriptor
95
+ * @return JSON string with device info and handle, or empty string if failed
96
+ */
97
+ std::string requestDevice(const std::string& adapterId, const std::string& descriptor);
98
+
99
+ /**
100
+ * @brief Get device info and features
101
+ * @param deviceId Device handle
102
+ * @return JSON string with device information
103
+ */
104
+ std::string getDeviceInfo(const std::string& deviceId);
105
+
106
+ // ========================================================================
107
+ // Buffer API
108
+ // ========================================================================
109
+
110
+ /**
111
+ * @brief Create a GPU buffer
112
+ * @param deviceId Device handle
113
+ * @param descriptor JSON string with buffer descriptor
114
+ * @return Buffer handle (string ID), or empty string if failed
115
+ */
116
+ std::string createBuffer(const std::string& deviceId, const std::string& descriptor);
117
+
118
+ /**
119
+ * @brief Write data to a GPU buffer
120
+ * @param bufferId Buffer handle
121
+ * @param offset Offset in bytes
122
+ * @param data Raw binary data as base64 or hex string
123
+ * @return true if successful
124
+ */
125
+ bool writeBuffer(const std::string& bufferId, uint32_t offset, const std::string& data);
126
+
127
+ /**
128
+ * @brief Map a buffer for CPU access
129
+ * @param bufferId Buffer handle
130
+ * @param mode Access mode ("read" or "write")
131
+ * @return true if mapping successful
132
+ */
133
+ bool mapBuffer(const std::string& bufferId, const std::string& mode);
134
+
135
+ /**
136
+ * @brief Unmap a previously mapped buffer
137
+ * @param bufferId Buffer handle
138
+ * @return true if unmapping successful
139
+ */
140
+ bool unmapBuffer(const std::string& bufferId);
141
+
142
+ /**
143
+ * @brief Get mapped buffer data
144
+ * @param bufferId Buffer handle
145
+ * @return Data as base64 or hex string
146
+ */
147
+ std::string getMappedBufferData(const std::string& bufferId);
148
+
149
+ // ========================================================================
150
+ // Texture API
151
+ // ========================================================================
152
+
153
+ /**
154
+ * @brief Create a GPU texture
155
+ * @param deviceId Device handle
156
+ * @param descriptor JSON string with texture descriptor
157
+ * @return Texture handle, or empty string if failed
158
+ */
159
+ std::string createTexture(const std::string& deviceId, const std::string& descriptor);
160
+
161
+ /**
162
+ * @brief Write data to a GPU texture
163
+ * @param textureId Texture handle
164
+ * @param descriptor JSON string with write descriptor
165
+ * @param data Raw texture data
166
+ * @return true if successful
167
+ */
168
+ bool writeTexture(const std::string& textureId, const std::string& descriptor, const std::string& data);
169
+
170
+ /**
171
+ * @brief Create a texture view
172
+ * @param textureId Texture handle
173
+ * @param descriptor JSON string with view descriptor
174
+ * @return Texture view handle
175
+ */
176
+ std::string createTextureView(const std::string& textureId, const std::string& descriptor);
177
+
178
+ // ========================================================================
179
+ // Sampler API
180
+ // ========================================================================
181
+
182
+ /**
183
+ * @brief Create a GPU sampler for texture sampling
184
+ * @param deviceId Device handle
185
+ * @param descriptor JSON string with sampler descriptor
186
+ * @return Sampler handle
187
+ */
188
+ std::string createSampler(const std::string& deviceId, const std::string& descriptor);
189
+
190
+ // ========================================================================
191
+ // Shader API
192
+ // ========================================================================
193
+
194
+ /**
195
+ * @brief Create a shader module from WGSL source code
196
+ * @param deviceId Device handle
197
+ * @param wgslSource WGSL shader source code
198
+ * @return Shader module handle, or empty string if compilation failed
199
+ */
200
+ std::string createShaderModule(const std::string& deviceId, const std::string& wgslSource);
201
+
202
+ /**
203
+ * @brief Get shader compilation errors
204
+ * @param shaderId Shader module handle
205
+ * @return Error messages as JSON string
206
+ */
207
+ std::string getShaderErrors(const std::string& shaderId);
208
+
209
+ // ========================================================================
210
+ // Pipeline API
211
+ // ========================================================================
212
+
213
+ /**
214
+ * @brief Create a render pipeline
215
+ * @param deviceId Device handle
216
+ * @param descriptor JSON string with pipeline descriptor
217
+ * @return Pipeline handle, or empty string if failed
218
+ */
219
+ std::string createRenderPipeline(const std::string& deviceId, const std::string& descriptor);
220
+
221
+ /**
222
+ * @brief Create a compute pipeline
223
+ * @param deviceId Device handle
224
+ * @param descriptor JSON string with pipeline descriptor
225
+ * @return Pipeline handle, or empty string if failed
226
+ */
227
+ std::string createComputePipeline(const std::string& deviceId, const std::string& descriptor);
228
+
229
+ /**
230
+ * @brief Get pipeline info
231
+ * @param pipelineId Pipeline handle
232
+ * @return Pipeline information as JSON
233
+ */
234
+ std::string getPipelineInfo(const std::string& pipelineId);
235
+
236
+ // ========================================================================
237
+ // Bind Group API
238
+ // ========================================================================
239
+
240
+ /**
241
+ * @brief Create a bind group layout
242
+ * @param deviceId Device handle
243
+ * @param descriptor JSON string with layout descriptor
244
+ * @return Layout handle
245
+ */
246
+ std::string createBindGroupLayout(const std::string& deviceId, const std::string& descriptor);
247
+
248
+ /**
249
+ * @brief Create a bind group
250
+ * @param deviceId Device handle
251
+ * @param descriptor JSON string with bind group descriptor
252
+ * @return Bind group handle
253
+ */
254
+ std::string createBindGroup(const std::string& deviceId, const std::string& descriptor);
255
+
256
+ // ========================================================================
257
+ // Surface API
258
+ // ========================================================================
259
+
260
+ /**
261
+ * @brief Create a GPU surface for rendering
262
+ * @param windowHandle Native window handle (HWND on Windows, NSView* on macOS, etc.)
263
+ * @param width Surface width
264
+ * @param height Surface height
265
+ * @return Surface handle
266
+ */
267
+ std::string createSurface(void* windowHandle, uint32_t width, uint32_t height);
268
+
269
+ /**
270
+ * @brief Configure a surface
271
+ * @param surfaceId Surface handle
272
+ * @param descriptor JSON string with configuration
273
+ * @return true if successful
274
+ */
275
+ bool configureSurface(const std::string& surfaceId, const std::string& descriptor);
276
+
277
+ /**
278
+ * @brief Resize a surface
279
+ * @param surfaceId Surface handle
280
+ * @param width New width
281
+ * @param height New height
282
+ * @return true if successful
283
+ */
284
+ bool resizeSurface(const std::string& surfaceId, uint32_t width, uint32_t height);
285
+
286
+ /**
287
+ * @brief Get the next texture from the swap chain
288
+ * @param surfaceId Surface handle
289
+ * @return Texture handle for current frame
290
+ */
291
+ std::string getNextTexture(const std::string& surfaceId);
292
+
293
+ // ========================================================================
294
+ // Command Encoding API
295
+ // ========================================================================
296
+
297
+ /**
298
+ * @brief Create a command encoder
299
+ * @param deviceId Device handle
300
+ * @return Command encoder handle
301
+ */
302
+ std::string createCommandEncoder(const std::string& deviceId);
303
+
304
+ /**
305
+ * @brief Begin a render pass
306
+ * @param encoderId Command encoder handle
307
+ * @param descriptor JSON string with render pass descriptor
308
+ * @return Render pass encoder handle
309
+ */
310
+ std::string beginRenderPass(const std::string& encoderId, const std::string& descriptor);
311
+
312
+ /**
313
+ * @brief End a render pass
314
+ * @param passId Render pass encoder handle
315
+ * @return true if successful
316
+ */
317
+ bool endRenderPass(const std::string& passId);
318
+
319
+ /**
320
+ * @brief Set the current render pipeline
321
+ * @param passId Render pass encoder handle
322
+ * @param pipelineId Pipeline handle
323
+ * @return true if successful
324
+ */
325
+ bool setRenderPipeline(const std::string& passId, const std::string& pipelineId);
326
+
327
+ /**
328
+ * @brief Set a bind group for rendering
329
+ * @param passId Render pass encoder handle
330
+ * @param groupIndex Bind group index
331
+ * @param bindGroupId Bind group handle
332
+ * @return true if successful
333
+ */
334
+ bool setBindGroup(const std::string& passId, uint32_t groupIndex, const std::string& bindGroupId);
335
+
336
+ /**
337
+ * @brief Set vertex buffer
338
+ * @param passId Render pass encoder handle
339
+ * @param slot Vertex buffer slot
340
+ * @param bufferId Buffer handle
341
+ * @param offset Offset in buffer
342
+ * @return true if successful
343
+ */
344
+ bool setVertexBuffer(const std::string& passId, uint32_t slot, const std::string& bufferId, uint64_t offset);
345
+
346
+ /**
347
+ * @brief Set index buffer
348
+ * @param passId Render pass encoder handle
349
+ * @param bufferId Buffer handle
350
+ * @param format Index format ("uint16" or "uint32")
351
+ * @param offset Offset in buffer
352
+ * @return true if successful
353
+ */
354
+ bool setIndexBuffer(const std::string& passId, const std::string& bufferId, const std::string& format, uint64_t offset);
355
+
356
+ /**
357
+ * @brief Issue a draw command
358
+ * @param passId Render pass encoder handle
359
+ * @param vertexCount Number of vertices to draw
360
+ * @param instanceCount Number of instances
361
+ * @param firstVertex First vertex index
362
+ * @param firstInstance First instance index
363
+ * @return true if successful
364
+ */
365
+ bool draw(const std::string& passId, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance);
366
+
367
+ /**
368
+ * @brief Issue an indexed draw command
369
+ * @param passId Render pass encoder handle
370
+ * @param indexCount Number of indices
371
+ * @param instanceCount Number of instances
372
+ * @param firstIndex First index
373
+ * @param baseVertex Base vertex offset
374
+ * @param firstInstance First instance index
375
+ * @return true if successful
376
+ */
377
+ bool drawIndexed(const std::string& passId, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t baseVertex, uint32_t firstInstance);
378
+
379
+ /**
380
+ * @brief Finish command encoding and get the command buffer
381
+ * @param encoderId Command encoder handle
382
+ * @return Command buffer handle
383
+ */
384
+ std::string finish(const std::string& encoderId);
385
+
386
+ // ========================================================================
387
+ // Queue API
388
+ // ========================================================================
389
+
390
+ /**
391
+ * @brief Submit command buffers to the GPU queue
392
+ * @param deviceId Device handle
393
+ * @param commandBufferIds JSON array of command buffer handles
394
+ * @return true if submission successful
395
+ */
396
+ bool submitCommands(const std::string& deviceId, const std::string& commandBufferIds);
397
+
398
+ /**
399
+ * @brief Present a surface
400
+ * @param surfaceId Surface handle
401
+ * @return true if presentation successful
402
+ */
403
+ bool presentSurface(const std::string& surfaceId);
404
+
405
+ // ========================================================================
406
+ // Resource Management
407
+ // ========================================================================
408
+
409
+ /**
410
+ * @brief Destroy a GPU resource
411
+ * @param handle Resource handle
412
+ * @return true if destroyed successfully
413
+ */
414
+ bool destroyResource(const std::string& handle);
415
+
416
+ /**
417
+ * @brief Destroy a device and all its resources
418
+ * @param deviceId Device handle
419
+ * @return true if destroyed successfully
420
+ */
421
+ bool destroyDevice(const std::string& deviceId);
422
+
423
+ /**
424
+ * @brief Get memory usage statistics
425
+ * @return JSON string with memory usage info
426
+ */
427
+ std::string getMemoryStats();
428
+
429
+ private:
430
+ struct Impl;
431
+ std::shared_ptr<Impl> pImpl;
432
+ };
433
+
434
+ } // namespace plusui
@@ -0,0 +1,142 @@
1
+ #pragma once
2
+
3
+ #include <functional>
4
+ #include <future>
5
+ #include <map>
6
+ #include <memory>
7
+ #include <string>
8
+ #include <vector>
9
+
10
+ namespace plusui {
11
+
12
+ class TrayManager;
13
+ class WindowManager;
14
+ class Window;
15
+
16
+ struct WebViewConfig {
17
+ std::string userAgent = "";
18
+ bool devtools = true;
19
+ bool contextMenu = true;
20
+ bool javascript = true;
21
+ bool webSecurity = true;
22
+ bool allowFileAccess = false;
23
+ bool allowRemoteContent = true;
24
+ std::string dataPath = "";
25
+ int cacheSize = 100; // MB
26
+ bool scrollbars = true; // Show/hide scrollbars
27
+
28
+ // App Builder style config
29
+ std::string title;
30
+ int width = 800;
31
+ int height = 600;
32
+ bool resizable = true;
33
+ };
34
+
35
+ class WebView {
36
+ public:
37
+ using WindowId = uint64_t;
38
+
39
+ // Callback types
40
+ using VoidCallback = std::function<void()>;
41
+ using StringCallback = std::function<void(const std::string &result)>;
42
+ using BoolCallback = std::function<bool(const std::string &url)>;
43
+ using ErrorCallback = std::function<void(const std::string &error, int code)>;
44
+ using ConsoleCallback = std::function<void(
45
+ const std::string &message, int level, const std::string &source)>;
46
+ using JSCallback = std::function<std::string(const std::string &args)>;
47
+ using NavigationCallback = std::function<bool(const std::string &url)>;
48
+ using LoadCallback = std::function<void()>;
49
+
50
+ WebView();
51
+ // Constructor used by App::Builder
52
+ struct AppConfig;
53
+ // WebView(const AppConfig& config); // We'll handle this via create or
54
+ // similar
55
+
56
+ ~WebView();
57
+
58
+ // Move only
59
+ WebView(WebView &&other) noexcept;
60
+ WebView &operator=(WebView &&other) noexcept;
61
+ WebView(const WebView &) = delete;
62
+ WebView &operator=(const WebView &) = delete;
63
+
64
+ static WebView create(void *windowHandle, const WebViewConfig &config = {});
65
+
66
+ // Content loading
67
+ void loadURL(const std::string &url);
68
+ void loadHTML(const std::string &html);
69
+ void loadHTML(const std::string &html, const std::string &baseURL);
70
+ void loadFile(const std::string &filePath);
71
+ void navigate(const std::string &url);
72
+
73
+ // Navigation
74
+ void reload();
75
+ void stop();
76
+ void goBack();
77
+ void goForward();
78
+ bool canGoBack() const;
79
+ bool canGoForward() const;
80
+
81
+ // Scripting
82
+ void executeScript(const std::string &script);
83
+ void executeScript(const std::string &script, StringCallback callback);
84
+ void eval(const std::string &js) {
85
+ executeScript(js);
86
+ } // Alias for compatibility
87
+
88
+ template <typename T> std::future<T> evaluate(const std::string &js) {
89
+ // Implementation in cpp or inline
90
+ return std::future<T>();
91
+ }
92
+
93
+ // Bindings
94
+ void bind(const std::string &name, JSCallback callback);
95
+ void unbind(const std::string &name);
96
+
97
+ template <typename F> void expose(const std::string &name, F &&callback) {
98
+ // Implementation for simplified expose
99
+ }
100
+
101
+ // Dev tools
102
+ void openDevTools();
103
+ void closeDevTools();
104
+
105
+ // Events
106
+ void on(const std::string &event,
107
+ std::function<void(const std::string &)> callback);
108
+ void emit(const std::string &event, const std::string &data = "");
109
+
110
+ // Settings
111
+ void setUserAgent(const std::string &userAgent);
112
+ std::string getUserAgent() const;
113
+ void setZoom(double factor);
114
+ double getZoom() const;
115
+ void injectCSS(const std::string &css);
116
+
117
+ // Callbacks
118
+ void onNavigationStart(NavigationCallback callback);
119
+ void onNavigationComplete(LoadCallback callback);
120
+ void onLoadStart(LoadCallback callback);
121
+ void onLoadEnd(LoadCallback callback);
122
+ void onLoadError(ErrorCallback callback);
123
+ void onConsoleMessage(ConsoleCallback callback);
124
+
125
+ // State
126
+ bool isLoading() const;
127
+ std::string getURL() const;
128
+ std::string getTitle() const;
129
+ void *nativeHandle() const;
130
+ void *nativeWindow() { return nativeHandle(); } // Alias
131
+
132
+ // Features
133
+ void setWindow(std::shared_ptr<Window> win);
134
+ TrayManager &tray();
135
+ WindowManager &window();
136
+
137
+ private:
138
+ struct Impl;
139
+ std::shared_ptr<Impl> pImpl;
140
+ };
141
+
142
+ } // namespace plusui
@@ -0,0 +1,111 @@
1
+ #pragma once
2
+
3
+ #include <functional>
4
+ #include <memory>
5
+ #include <string>
6
+ #include <vector>
7
+
8
+ namespace plusui {
9
+
10
+ struct WindowConfig {
11
+ std::string title = "PlusUI Window";
12
+ int x = -1;
13
+ int y = -1;
14
+ int width = 800;
15
+ int height = 600;
16
+ int minWidth = 100;
17
+ int minHeight = 100;
18
+ int maxWidth = -1;
19
+ int maxHeight = -1;
20
+ bool resizable = true;
21
+ bool minimizable = true;
22
+ bool maximizable = true;
23
+ bool closable = true;
24
+ bool alwaysOnTop = false;
25
+ bool center = true;
26
+ bool frame = true;
27
+ bool transparent = false;
28
+ bool decorations = true;
29
+ bool skipTaskbar = false;
30
+ double opacity = 1.0;
31
+ bool fullscreen = false;
32
+ };
33
+
34
+ struct WindowState {
35
+ int x = 0;
36
+ int y = 0;
37
+ int width = 0;
38
+ int height = 0;
39
+ bool isMinimized = false;
40
+ bool isMaximized = false;
41
+ bool isVisible = true;
42
+ bool isFocused = false;
43
+ bool isFullscreen = false;
44
+ bool isHidden = false;
45
+ };
46
+
47
+ class Window {
48
+ public:
49
+ using MoveCallback = std::function<void(int x, int y)>;
50
+ using ResizeCallback = std::function<void(int w, int h)>;
51
+ using CloseCallback = std::function<void()>;
52
+ using FocusCallback = std::function<void(bool focused)>;
53
+ using StateCallback = std::function<void(const WindowState &state)>;
54
+
55
+ Window();
56
+ ~Window();
57
+
58
+ static Window create(const WindowConfig &config);
59
+
60
+ void setTitle(const std::string &title);
61
+ std::string getTitle() const;
62
+
63
+ void setSize(int width, int height);
64
+ void getSize(int &width, int &height) const;
65
+ void setMinSize(int width, int height);
66
+ void setMaxSize(int width, int height);
67
+
68
+ void setPosition(int x, int y);
69
+ void getPosition(int &x, int &y) const;
70
+ void center();
71
+
72
+ void setFullscreen(bool enabled);
73
+ bool isFullscreen() const;
74
+
75
+ void minimize();
76
+ void maximize();
77
+ void restore();
78
+ bool isMaximized() const;
79
+ bool isMinimized() const;
80
+
81
+ void show();
82
+ void hide();
83
+ bool isVisible() const;
84
+ bool isHidden() const;
85
+
86
+ void focus();
87
+ bool isFocused() const;
88
+
89
+ void setAlwaysOnTop(bool enabled);
90
+ void setResizable(bool enabled);
91
+ void setDecorations(bool enabled);
92
+ void setSkipTaskbar(bool enabled);
93
+ void setOpacity(double opacity);
94
+ void setIconFromMemory(const unsigned char *data, size_t size);
95
+
96
+ WindowState getState() const;
97
+
98
+ void onMove(MoveCallback callback);
99
+ void onResize(ResizeCallback callback);
100
+ void onClose(CloseCallback callback);
101
+ void onFocus(FocusCallback callback);
102
+ void onStateChange(StateCallback callback);
103
+
104
+ void *nativeHandle() const;
105
+
106
+ private:
107
+ struct Impl;
108
+ std::shared_ptr<Impl> pImpl;
109
+ };
110
+
111
+ } // namespace plusui