plusui-native-core 0.1.0
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.
- package/Core/CMakeLists.txt +34 -0
- package/Core/README.md +29 -0
- package/Core/build/win32/x64/ALL_BUILD.vcxproj +185 -0
- package/Core/build/win32/x64/ALL_BUILD.vcxproj.filters +8 -0
- package/Core/build/win32/x64/CMakeCache.txt +335 -0
- package/Core/build/win32/x64/CMakeFiles/11f7f2f432927ec8d1861dc42d4bd679/INSTALL_force.rule +1 -0
- package/Core/build/win32/x64/CMakeFiles/11f7f2f432927ec8d1861dc42d4bd679/generate.stamp.rule +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeCXXCompiler.cmake +104 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeDetermineCompilerABI_CXX.bin +0 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeRCCompiler.cmake +6 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CMakeSystem.cmake +15 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +949 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/CompilerIdCXX.exe +0 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/CompilerIdCXX.vcxproj +72 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CMakeCXXCompilerId.obj +0 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.exe.recipe +11 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog +4 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/Cl.items.tlog +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog +22 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.secondary.1.tlog +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath/x64/Debug/VCTargetsPath.recipe +11 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath/x64/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate +2 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath.txt +1 -0
- package/Core/build/win32/x64/CMakeFiles/4.2.3/VCTargetsPath.vcxproj +31 -0
- package/Core/build/win32/x64/CMakeFiles/CMakeConfigureLog.yaml +2698 -0
- package/Core/build/win32/x64/CMakeFiles/InstallScripts.json +7 -0
- package/Core/build/win32/x64/CMakeFiles/TargetDirectories.txt +4 -0
- package/Core/build/win32/x64/CMakeFiles/cmake.check_cache +1 -0
- package/Core/build/win32/x64/CMakeFiles/generate.stamp +1 -0
- package/Core/build/win32/x64/CMakeFiles/generate.stamp.depend +34 -0
- package/Core/build/win32/x64/CMakeFiles/generate.stamp.list +1 -0
- package/Core/build/win32/x64/Capsule.sln +67 -0
- package/Core/build/win32/x64/INSTALL.vcxproj +209 -0
- package/Core/build/win32/x64/INSTALL.vcxproj.filters +13 -0
- package/Core/build/win32/x64/ZERO_CHECK.vcxproj +179 -0
- package/Core/build/win32/x64/ZERO_CHECK.vcxproj.filters +13 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CL.command.1.tlog +2 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CustomBuild.command.1.tlog +10 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CustomBuild.read.1.tlog +33 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/CustomBuild.write.1.tlog +2 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/capsule.lastbuildstate +2 -0
- package/Core/build/win32/x64/capsule.dir/Release/capsule.tlog/unsuccessfulbuild +0 -0
- package/Core/build/win32/x64/capsule.vcxproj +332 -0
- package/Core/build/win32/x64/capsule.vcxproj.filters +25 -0
- package/Core/build/win32/x64/cmake_install.cmake +72 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.recipe +11 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.command.1.tlog +10 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.read.1.tlog +34 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/CustomBuild.write.1.tlog +2 -0
- package/Core/build/win32/x64/x64/Release/ZERO_CHECK/ZERO_CHECK.tlog/ZERO_CHECK.lastbuildstate +2 -0
- package/Core/include/app.hpp +121 -0
- package/Core/include/display.hpp +90 -0
- package/Core/include/keyboard.hpp +135 -0
- package/Core/include/menu.hpp +79 -0
- package/Core/include/tray.hpp +81 -0
- package/Core/include/window.hpp +106 -0
- package/Core/src/app.cpp +311 -0
- package/Core/src/display.cpp +424 -0
- package/Core/src/tray.cpp +275 -0
- package/Core/src/window.cpp +528 -0
- package/Core/vendor/webview.h +551 -0
- package/dist/index.d.ts +205 -0
- package/dist/index.js +198 -0
- package/package.json +19 -0
- package/src/index.ts +574 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#ifndef PLUSUI_DISPLAY_H
|
|
2
|
+
#define PLUSUI_DISPLAY_H
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <vector>
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <functional>
|
|
8
|
+
|
|
9
|
+
namespace plusui {
|
|
10
|
+
|
|
11
|
+
struct DisplayMode {
|
|
12
|
+
int width = 0;
|
|
13
|
+
int height = 0;
|
|
14
|
+
int refreshRate = 60;
|
|
15
|
+
int bitDepth = 32;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
struct DisplayBounds {
|
|
19
|
+
int x = 0;
|
|
20
|
+
int y = 0;
|
|
21
|
+
int width = 0;
|
|
22
|
+
int height = 0;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
struct DisplayResolution {
|
|
26
|
+
int width = 0;
|
|
27
|
+
int height = 0;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
struct Display {
|
|
31
|
+
int id = 0;
|
|
32
|
+
std::string name;
|
|
33
|
+
bool isPrimary = false;
|
|
34
|
+
DisplayBounds bounds;
|
|
35
|
+
DisplayBounds workArea;
|
|
36
|
+
DisplayResolution resolution;
|
|
37
|
+
DisplayMode currentMode;
|
|
38
|
+
double scaleFactor = 1.0;
|
|
39
|
+
double rotation = 0.0;
|
|
40
|
+
bool isInternal = false;
|
|
41
|
+
bool isConnected = true;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
class DisplayManager {
|
|
45
|
+
public:
|
|
46
|
+
DisplayManager();
|
|
47
|
+
~DisplayManager();
|
|
48
|
+
|
|
49
|
+
static DisplayManager& instance();
|
|
50
|
+
|
|
51
|
+
std::vector<Display> getAllDisplays();
|
|
52
|
+
Display getPrimaryDisplay();
|
|
53
|
+
Display getDisplayAt(int x, int y);
|
|
54
|
+
Display getDisplayAtCursor();
|
|
55
|
+
Display getDisplayById(int id);
|
|
56
|
+
|
|
57
|
+
void onDisplayConnected(std::function<void(const Display&)> callback);
|
|
58
|
+
void onDisplayDisconnected(std::function<void(int displayId)> callback);
|
|
59
|
+
void onDisplayChanged(std::function<void(const Display&)> callback);
|
|
60
|
+
|
|
61
|
+
void refresh();
|
|
62
|
+
|
|
63
|
+
bool setDisplayMode(int displayId, const DisplayMode& mode);
|
|
64
|
+
bool setPosition(int displayId, int x, int y);
|
|
65
|
+
bool turnOff(int displayId);
|
|
66
|
+
|
|
67
|
+
private:
|
|
68
|
+
struct Impl;
|
|
69
|
+
std::unique_ptr<Impl> pImpl;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
class Screen {
|
|
73
|
+
public:
|
|
74
|
+
static int getWidth();
|
|
75
|
+
static int getHeight();
|
|
76
|
+
static int getWidthMM();
|
|
77
|
+
static int getHeightMM();
|
|
78
|
+
|
|
79
|
+
static double getScaleFactor();
|
|
80
|
+
static double getRefreshRate();
|
|
81
|
+
|
|
82
|
+
static bool isMain();
|
|
83
|
+
static bool isMulti();
|
|
84
|
+
|
|
85
|
+
static std::string getName();
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
#endif
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#ifndef PLUSUI_KEYBOARD_H
|
|
2
|
+
#define PLUSUI_KEYBOARD_H
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <vector>
|
|
6
|
+
#include <functional>
|
|
7
|
+
#include <map>
|
|
8
|
+
|
|
9
|
+
namespace plusui {
|
|
10
|
+
|
|
11
|
+
enum class KeyCode {
|
|
12
|
+
Unknown = 0,
|
|
13
|
+
Space = 32,
|
|
14
|
+
Apostrophe = 39,
|
|
15
|
+
Comma = 44,
|
|
16
|
+
Minus = 45,
|
|
17
|
+
Period = 46,
|
|
18
|
+
Slash = 47,
|
|
19
|
+
Num0 = 48, Num1 = 49, Num2 = 50, Num3 = 51, Num4 = 52,
|
|
20
|
+
Num5 = 53, Num6 = 54, Num7 = 55, Num8 = 56, Num9 = 57,
|
|
21
|
+
Semicolon = 59, Equal = 61,
|
|
22
|
+
A = 65, B = 66, C = 67, D = 68, E = 69, F = 70, G = 71,
|
|
23
|
+
H = 72, I = 73, J = 74, K = 75, L = 76, M = 77, N = 78,
|
|
24
|
+
O = 79, P = 80, Q = 81, R = 82, S = 83, T = 84, U = 85,
|
|
25
|
+
V = 86, W = 87, X = 88, Y = 89, Z = 90,
|
|
26
|
+
LeftBracket = 91, Backslash = 92, RightBracket = 93,
|
|
27
|
+
GraveAccent = 96,
|
|
28
|
+
World1 = 161, World2 = 162,
|
|
29
|
+
Escape = 256, Enter = 257, Tab = 258, Backspace = 259,
|
|
30
|
+
Insert = 260, Delete = 261,
|
|
31
|
+
Right = 262, Left = 263, Down = 264, Up = 265,
|
|
32
|
+
PageUp = 266, PageDown = 267, Home = 268, End = 269,
|
|
33
|
+
CapsLock = 280, ScrollLock = 281, NumLock = 282,
|
|
34
|
+
PrintScreen = 283, Pause = 284,
|
|
35
|
+
F1 = 290, F2 = 291, F3 = 292, F4 = 293, F5 = 294,
|
|
36
|
+
F6 = 295, F7 = 296, F8 = 297, F9 = 298, F10 = 299,
|
|
37
|
+
F11 = 300, F12 = 301, F13 = 302, F14 = 303, F15 = 304,
|
|
38
|
+
F16 = 305, F17 = 306, F18 = 307, F19 = 308,
|
|
39
|
+
Kp0 = 320, Kp1 = 321, Kp2 = 322, Kp3 = 323, Kp4 = 324,
|
|
40
|
+
Kp5 = 325, Kp6 = 326, Kp7 = 327, Kp8 = 328, Kp9 = 329,
|
|
41
|
+
KpDecimal = 330, KpDivide = 331, KpMultiply = 332,
|
|
42
|
+
KpSubtract = 333, KpAdd = 334, KpEnter = 335,
|
|
43
|
+
KpEqual = 336,
|
|
44
|
+
LeftShift = 340, LeftControl = 341, LeftAlt = 342,
|
|
45
|
+
LeftSuper = 343, RightShift = 344, RightControl = 345,
|
|
46
|
+
RightAlt = 346, RightSuper = 347,
|
|
47
|
+
Menu = 348
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
enum class KeyMod {
|
|
51
|
+
None = 0,
|
|
52
|
+
Shift = 1,
|
|
53
|
+
Control = 2,
|
|
54
|
+
Alt = 4,
|
|
55
|
+
Super = 8,
|
|
56
|
+
CapsLock = 16,
|
|
57
|
+
NumLock = 32
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
inline KeyMod operator|(KeyMod a, KeyMod b) {
|
|
61
|
+
return static_cast<KeyMod>(static_cast<int>(a) | static_cast<int>(b));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
inline bool operator&(KeyMod a, KeyMod b) {
|
|
65
|
+
return (static_cast<int>(a) & static_cast<int>(b)) != 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
struct KeyEvent {
|
|
69
|
+
KeyCode key = KeyCode::Unknown;
|
|
70
|
+
int scancode = 0;
|
|
71
|
+
KeyMod mods = KeyMod::None;
|
|
72
|
+
bool pressed = false;
|
|
73
|
+
bool repeat = false;
|
|
74
|
+
std::string description;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
struct Shortcut {
|
|
78
|
+
KeyCode key = KeyCode::Unknown;
|
|
79
|
+
KeyMod mods = KeyMod::None;
|
|
80
|
+
|
|
81
|
+
Shortcut() = default;
|
|
82
|
+
Shortcut(KeyCode k, KeyMod m = KeyMod::None) : key(k), mods(m) {}
|
|
83
|
+
|
|
84
|
+
std::string toString() const;
|
|
85
|
+
static Shortcut parse(const std::string& str);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
class Keyboard {
|
|
89
|
+
public:
|
|
90
|
+
Keyboard();
|
|
91
|
+
~Keyboard();
|
|
92
|
+
|
|
93
|
+
static Keyboard& instance();
|
|
94
|
+
|
|
95
|
+
void onKeyDown(std::function<void(const KeyEvent&)> callback);
|
|
96
|
+
void onKeyUp(std::function<void(const KeyEvent&)> callback);
|
|
97
|
+
void onKeyPress(std::function<void(const KeyEvent&)> callback);
|
|
98
|
+
|
|
99
|
+
bool isKeyPressed(KeyCode key) const;
|
|
100
|
+
bool areModsActive(KeyMod mods) const;
|
|
101
|
+
|
|
102
|
+
std::string getKeyName(KeyCode key) const;
|
|
103
|
+
KeyCode getKeyFromName(const std::string& name) const;
|
|
104
|
+
|
|
105
|
+
void setAutoRepeat(bool enabled);
|
|
106
|
+
bool getAutoRepeat() const;
|
|
107
|
+
|
|
108
|
+
private:
|
|
109
|
+
struct Impl;
|
|
110
|
+
class Impl* pImpl;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
class ShortcutManager {
|
|
114
|
+
public:
|
|
115
|
+
ShortcutManager();
|
|
116
|
+
~ShortcutManager();
|
|
117
|
+
|
|
118
|
+
static ShortcutManager& instance();
|
|
119
|
+
|
|
120
|
+
bool registerShortcut(const std::string& id, const Shortcut& shortcut,
|
|
121
|
+
std::function<void()> callback);
|
|
122
|
+
bool unregisterShortcut(const std::string& id);
|
|
123
|
+
void clearShortcuts();
|
|
124
|
+
|
|
125
|
+
bool isRegistered(const std::string& id) const;
|
|
126
|
+
Shortcut getShortcut(const std::string& id) const;
|
|
127
|
+
|
|
128
|
+
void onShortcutTriggered(std::function<void(const std::string& id)> callback);
|
|
129
|
+
|
|
130
|
+
private:
|
|
131
|
+
struct Impl;
|
|
132
|
+
class Impl* pImpl;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#ifndef PLUSUI_MENU_H
|
|
2
|
+
#define PLUSUI_MENU_H
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <vector>
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <functional>
|
|
8
|
+
|
|
9
|
+
namespace plusui {
|
|
10
|
+
|
|
11
|
+
enum class MenuItemType {
|
|
12
|
+
Normal,
|
|
13
|
+
Separator,
|
|
14
|
+
Submenu,
|
|
15
|
+
Checkbox,
|
|
16
|
+
Radio
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
struct MenuItem {
|
|
20
|
+
std::string id;
|
|
21
|
+
std::string label;
|
|
22
|
+
std::string accelerator;
|
|
23
|
+
std::string icon;
|
|
24
|
+
MenuItemType type = MenuItemType::Normal;
|
|
25
|
+
bool enabled = true;
|
|
26
|
+
bool checked = false;
|
|
27
|
+
std::vector<MenuItem> submenu;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
struct MenuBar {
|
|
31
|
+
std::vector<MenuItem> items;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
class Menu {
|
|
35
|
+
public:
|
|
36
|
+
Menu();
|
|
37
|
+
~Menu();
|
|
38
|
+
|
|
39
|
+
static Menu create(const std::vector<MenuItem>& items = {});
|
|
40
|
+
|
|
41
|
+
void setItems(const std::vector<MenuItem>& items);
|
|
42
|
+
std::vector<MenuItem> getItems() const;
|
|
43
|
+
|
|
44
|
+
void append(const MenuItem& item);
|
|
45
|
+
void insert(int index, const MenuItem& item);
|
|
46
|
+
void remove(const std::string& id);
|
|
47
|
+
void clear();
|
|
48
|
+
|
|
49
|
+
void popup(int x, int y);
|
|
50
|
+
void close();
|
|
51
|
+
|
|
52
|
+
private:
|
|
53
|
+
struct Impl;
|
|
54
|
+
std::unique_ptr<Impl> pImpl;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
class MenuBar {
|
|
58
|
+
public:
|
|
59
|
+
MenuBar();
|
|
60
|
+
~MenuBar();
|
|
61
|
+
|
|
62
|
+
static MenuBar& instance();
|
|
63
|
+
|
|
64
|
+
void setMenu(const ::plusui::MenuBar& menu);
|
|
65
|
+
::plusui::MenuBar getMenu() const;
|
|
66
|
+
|
|
67
|
+
void append(const MenuItem& item);
|
|
68
|
+
void insert(int index, const MenuItem& item);
|
|
69
|
+
void remove(const std::string& id);
|
|
70
|
+
void clear();
|
|
71
|
+
|
|
72
|
+
void onMenuItemClick(std::function<void(const std::string& id)> callback);
|
|
73
|
+
|
|
74
|
+
private:
|
|
75
|
+
struct Impl;
|
|
76
|
+
std::unique_ptr<Impl> pImpl;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#ifndef PLUSUI_TRAY_H
|
|
2
|
+
#define PLUSUI_TRAY_H
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <vector>
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <functional>
|
|
8
|
+
|
|
9
|
+
namespace plusui {
|
|
10
|
+
|
|
11
|
+
struct TrayMenuItem {
|
|
12
|
+
std::string id;
|
|
13
|
+
std::string label;
|
|
14
|
+
std::string icon;
|
|
15
|
+
bool enabled = true;
|
|
16
|
+
bool checked = false;
|
|
17
|
+
bool separator = false;
|
|
18
|
+
std::vector<TrayMenuItem> submenu;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
struct TrayIconData {
|
|
22
|
+
int id = 0;
|
|
23
|
+
std::string tooltip;
|
|
24
|
+
std::string iconPath;
|
|
25
|
+
bool isVisible = true;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
class TrayIcon {
|
|
29
|
+
public:
|
|
30
|
+
TrayIcon();
|
|
31
|
+
~TrayIcon();
|
|
32
|
+
|
|
33
|
+
static TrayIcon create(const std::string& tooltip = "", const std::string& iconPath = "");
|
|
34
|
+
|
|
35
|
+
void setTooltip(const std::string& tooltip);
|
|
36
|
+
void setIcon(const std::string& iconPath);
|
|
37
|
+
void setIconFromData(const std::vector<uint8_t>& data, int width = 16, int height = 16);
|
|
38
|
+
|
|
39
|
+
void show();
|
|
40
|
+
void hide();
|
|
41
|
+
bool isVisible() const;
|
|
42
|
+
|
|
43
|
+
void setMenu(const std::vector<TrayMenuItem>& items);
|
|
44
|
+
void setContextMenu(const std::vector<TrayMenuItem>& items);
|
|
45
|
+
|
|
46
|
+
void onClick(std::function<void(int x, int y)> callback);
|
|
47
|
+
void onRightClick(std::function<void(int x, int y)> callback);
|
|
48
|
+
void onDoubleClick(std::function<void()> callback);
|
|
49
|
+
void onMenuItemClick(std::function<void(const std::string& id)> callback);
|
|
50
|
+
|
|
51
|
+
void dispose();
|
|
52
|
+
|
|
53
|
+
private:
|
|
54
|
+
struct Impl;
|
|
55
|
+
std::unique_ptr<Impl> pImpl;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
class TrayManager {
|
|
59
|
+
public:
|
|
60
|
+
static TrayManager& instance();
|
|
61
|
+
|
|
62
|
+
std::vector<TrayIcon*> getIcons();
|
|
63
|
+
|
|
64
|
+
void onTrayCreated(std::function<void(TrayIcon& icon)> callback);
|
|
65
|
+
void onTrayDestroyed(std::function<void(int iconId)> callback);
|
|
66
|
+
|
|
67
|
+
void refresh();
|
|
68
|
+
|
|
69
|
+
private:
|
|
70
|
+
TrayManager() = default;
|
|
71
|
+
~TrayManager() = default;
|
|
72
|
+
TrayManager(const TrayManager&) = delete;
|
|
73
|
+
TrayManager& operator=(const TrayManager&) = delete;
|
|
74
|
+
|
|
75
|
+
struct Impl;
|
|
76
|
+
std::unique_ptr<Impl> pImpl;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#endif
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#ifndef PLUSUI_WINDOW_H
|
|
2
|
+
#define PLUSUI_WINDOW_H
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <functional>
|
|
6
|
+
#include <memory>
|
|
7
|
+
|
|
8
|
+
namespace plusui {
|
|
9
|
+
|
|
10
|
+
struct WindowConfig {
|
|
11
|
+
int x = -1;
|
|
12
|
+
int y = -1;
|
|
13
|
+
int width = 800;
|
|
14
|
+
int height = 600;
|
|
15
|
+
int minWidth = 0;
|
|
16
|
+
int minHeight = 0;
|
|
17
|
+
int maxWidth = 0;
|
|
18
|
+
int maxHeight = 0;
|
|
19
|
+
std::string title = "PlusUI";
|
|
20
|
+
bool resizable = true;
|
|
21
|
+
bool fullscreen = false;
|
|
22
|
+
bool maximized = false;
|
|
23
|
+
bool minimizable = true;
|
|
24
|
+
bool closable = true;
|
|
25
|
+
bool alwaysOnTop = false;
|
|
26
|
+
bool center = true;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
struct WindowState {
|
|
30
|
+
int x = 0;
|
|
31
|
+
int y = 0;
|
|
32
|
+
int width = 800;
|
|
33
|
+
int height = 600;
|
|
34
|
+
bool isFullscreen = false;
|
|
35
|
+
bool isMaximized = false;
|
|
36
|
+
bool isMinimized = false;
|
|
37
|
+
bool isFocused = true;
|
|
38
|
+
bool isVisible = true;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
class Window {
|
|
42
|
+
public:
|
|
43
|
+
Window();
|
|
44
|
+
~Window();
|
|
45
|
+
|
|
46
|
+
static Window create(const WindowConfig& config = {});
|
|
47
|
+
|
|
48
|
+
void setTitle(const std::string& title);
|
|
49
|
+
std::string getTitle() const;
|
|
50
|
+
|
|
51
|
+
void setSize(int width, int height);
|
|
52
|
+
void getSize(int& width, int& height) const;
|
|
53
|
+
|
|
54
|
+
void setMinSize(int minWidth, int minHeight);
|
|
55
|
+
void setMaxSize(int maxWidth, int maxHeight);
|
|
56
|
+
|
|
57
|
+
void setPosition(int x, int y);
|
|
58
|
+
void getPosition(int& x, int& y) const;
|
|
59
|
+
|
|
60
|
+
void center();
|
|
61
|
+
void setFullscreen(bool enabled);
|
|
62
|
+
bool isFullscreen() const;
|
|
63
|
+
|
|
64
|
+
void minimize();
|
|
65
|
+
void maximize();
|
|
66
|
+
void restore();
|
|
67
|
+
bool isMaximized() const;
|
|
68
|
+
bool isMinimized() const;
|
|
69
|
+
|
|
70
|
+
void show();
|
|
71
|
+
void hide();
|
|
72
|
+
bool isVisible() const;
|
|
73
|
+
|
|
74
|
+
void focus();
|
|
75
|
+
bool isFocused() const;
|
|
76
|
+
|
|
77
|
+
void setAlwaysOnTop(bool enabled);
|
|
78
|
+
void setResizable(bool enabled);
|
|
79
|
+
|
|
80
|
+
void setDecorations(bool enabled);
|
|
81
|
+
void setSkipTaskbar(bool enabled);
|
|
82
|
+
|
|
83
|
+
WindowState getState() const;
|
|
84
|
+
|
|
85
|
+
using MoveCallback = std::function<void(int x, int y)>;
|
|
86
|
+
using ResizeCallback = std::function<void(int width, int height)>;
|
|
87
|
+
using CloseCallback = std::function<void()>;
|
|
88
|
+
using FocusCallback = std::function<void(bool focused)>;
|
|
89
|
+
using StateCallback = std::function<void(WindowState state)>;
|
|
90
|
+
|
|
91
|
+
void onMove(MoveCallback callback);
|
|
92
|
+
void onResize(ResizeCallback callback);
|
|
93
|
+
void onClose(CloseCallback callback);
|
|
94
|
+
void onFocus(FocusCallback callback);
|
|
95
|
+
void onStateChange(StateCallback callback);
|
|
96
|
+
|
|
97
|
+
void* nativeHandle() const;
|
|
98
|
+
|
|
99
|
+
private:
|
|
100
|
+
struct Impl;
|
|
101
|
+
std::unique_ptr<Impl> pImpl;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#endif
|