plusui-native-core 0.1.4 → 0.1.5
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 +190 -7
- package/Core/Features/App/app.cpp +129 -0
- package/Core/Features/App/app.ts +126 -0
- package/Core/Features/Browser/browser.cpp +181 -0
- package/Core/Features/Browser/browser.ts +182 -0
- package/Core/Features/Clipboard/clipboard.cpp +234 -0
- package/Core/Features/Clipboard/clipboard.ts +113 -0
- package/Core/Features/Display/display.cpp +209 -0
- package/Core/Features/Display/display.ts +104 -0
- package/Core/Features/Event/Events.ts +166 -0
- package/Core/Features/Event/events.cpp +200 -0
- package/Core/Features/Keyboard/keyboard.cpp +186 -0
- package/Core/Features/Keyboard/keyboard.ts +175 -0
- package/Core/Features/Menu/context-menu.css +293 -0
- package/Core/Features/Menu/menu.cpp +481 -0
- package/Core/Features/Menu/menu.ts +439 -0
- package/Core/Features/Tray/tray.cpp +310 -0
- package/Core/Features/Tray/tray.ts +68 -0
- package/Core/Features/WebGPU/webgpu.cpp +937 -0
- package/Core/Features/WebGPU/webgpu.ts +1013 -0
- package/Core/Features/WebView/webview.cpp +1052 -0
- package/Core/Features/WebView/webview.ts +510 -0
- package/Core/Features/Window/window.cpp +664 -0
- package/Core/Features/Window/window.ts +142 -0
- package/Core/Features/WindowManager/window_manager.cpp +341 -0
- package/Core/include/plusui/app.hpp +73 -0
- package/Core/include/plusui/browser.hpp +66 -0
- package/Core/include/plusui/clipboard.hpp +41 -0
- package/Core/include/plusui/events.hpp +58 -0
- package/Core/include/{keyboard.hpp → plusui/keyboard.hpp} +21 -44
- package/Core/include/plusui/menu.hpp +153 -0
- package/Core/include/plusui/tray.hpp +93 -0
- package/Core/include/plusui/webgpu.hpp +434 -0
- package/Core/include/plusui/webview.hpp +142 -0
- package/Core/include/plusui/window.hpp +111 -0
- package/Core/include/plusui/window_manager.hpp +57 -0
- package/Core/vendor/WebView2EnvironmentOptions.h +406 -0
- package/Core/vendor/stb_image.h +7988 -0
- package/Core/vendor/webview.h +618 -510
- package/Core/vendor/webview2.h +52079 -0
- package/README.md +19 -0
- package/package.json +12 -15
- package/Core/include/app.hpp +0 -121
- package/Core/include/menu.hpp +0 -79
- package/Core/include/tray.hpp +0 -81
- package/Core/include/window.hpp +0 -106
- package/Core/src/app.cpp +0 -311
- package/Core/src/display.cpp +0 -424
- package/Core/src/tray.cpp +0 -275
- package/Core/src/window.cpp +0 -528
- package/dist/index.d.ts +0 -205
- package/dist/index.js +0 -198
- package/src/index.ts +0 -574
- /package/Core/include/{display.hpp → plusui/display.hpp} +0 -0
|
@@ -5,56 +5,32 @@
|
|
|
5
5
|
#include <vector>
|
|
6
6
|
#include <functional>
|
|
7
7
|
#include <map>
|
|
8
|
+
#include <memory>
|
|
8
9
|
|
|
9
10
|
namespace plusui {
|
|
10
11
|
|
|
11
12
|
enum class KeyCode {
|
|
12
13
|
Unknown = 0,
|
|
13
|
-
Space = 32,
|
|
14
|
-
|
|
15
|
-
Comma = 44,
|
|
16
|
-
Minus = 45,
|
|
17
|
-
Period = 46,
|
|
18
|
-
Slash = 47,
|
|
19
|
-
Num0 = 48, Num1 = 49, Num2 = 50, Num3 = 51, Num4 = 52,
|
|
14
|
+
Space = 32, Apostrophe = 39, Comma = 44, Minus = 45, Period = 46,
|
|
15
|
+
Slash = 47, Num0 = 48, Num1 = 49, Num2 = 50, Num3 = 51, Num4 = 52,
|
|
20
16
|
Num5 = 53, Num6 = 54, Num7 = 55, Num8 = 56, Num9 = 57,
|
|
21
|
-
Semicolon = 59, Equal = 61,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
LeftBracket = 91, Backslash = 92, RightBracket = 93,
|
|
27
|
-
GraveAccent = 96,
|
|
28
|
-
World1 = 161, World2 = 162,
|
|
17
|
+
Semicolon = 59, Equal = 61, A = 65, B = 66, C = 67, D = 68, E = 69,
|
|
18
|
+
F = 70, G = 71, H = 72, I = 73, J = 74, K = 75, L = 76, M = 77,
|
|
19
|
+
N = 78, O = 79, P = 80, Q = 81, R = 82, S = 83, T = 84, U = 85,
|
|
20
|
+
V = 86, W = 87, X = 88, Y = 89, Z = 90, LeftBracket = 91,
|
|
21
|
+
Backslash = 92, RightBracket = 93, GraveAccent = 96,
|
|
29
22
|
Escape = 256, Enter = 257, Tab = 258, Backspace = 259,
|
|
30
|
-
Insert = 260, Delete = 261,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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,
|
|
23
|
+
Insert = 260, Delete = 261, Right = 262, Left = 263, Down = 264,
|
|
24
|
+
Up = 265, PageUp = 266, PageDown = 267, Home = 268, End = 269,
|
|
25
|
+
CapsLock = 280, F1 = 290, F2 = 291, F3 = 292, F4 = 293, F5 = 294,
|
|
26
|
+
F6 = 295, F7 = 296, F8 = 297, F9 = 298, F10 = 299, F11 = 300,
|
|
27
|
+
F12 = 301, LeftShift = 340, LeftControl = 341, LeftAlt = 342,
|
|
45
28
|
LeftSuper = 343, RightShift = 344, RightControl = 345,
|
|
46
|
-
RightAlt = 346, RightSuper = 347
|
|
47
|
-
Menu = 348
|
|
29
|
+
RightAlt = 346, RightSuper = 347
|
|
48
30
|
};
|
|
49
31
|
|
|
50
32
|
enum class KeyMod {
|
|
51
|
-
None = 0,
|
|
52
|
-
Shift = 1,
|
|
53
|
-
Control = 2,
|
|
54
|
-
Alt = 4,
|
|
55
|
-
Super = 8,
|
|
56
|
-
CapsLock = 16,
|
|
57
|
-
NumLock = 32
|
|
33
|
+
None = 0, Shift = 1, Control = 2, Alt = 4, Super = 8
|
|
58
34
|
};
|
|
59
35
|
|
|
60
36
|
inline KeyMod operator|(KeyMod a, KeyMod b) {
|
|
@@ -71,7 +47,7 @@ struct KeyEvent {
|
|
|
71
47
|
KeyMod mods = KeyMod::None;
|
|
72
48
|
bool pressed = false;
|
|
73
49
|
bool repeat = false;
|
|
74
|
-
std::string
|
|
50
|
+
std::string keyName;
|
|
75
51
|
};
|
|
76
52
|
|
|
77
53
|
struct Shortcut {
|
|
@@ -94,7 +70,6 @@ public:
|
|
|
94
70
|
|
|
95
71
|
void onKeyDown(std::function<void(const KeyEvent&)> callback);
|
|
96
72
|
void onKeyUp(std::function<void(const KeyEvent&)> callback);
|
|
97
|
-
void onKeyPress(std::function<void(const KeyEvent&)> callback);
|
|
98
73
|
|
|
99
74
|
bool isKeyPressed(KeyCode key) const;
|
|
100
75
|
bool areModsActive(KeyMod mods) const;
|
|
@@ -107,7 +82,7 @@ public:
|
|
|
107
82
|
|
|
108
83
|
private:
|
|
109
84
|
struct Impl;
|
|
110
|
-
|
|
85
|
+
std::unique_ptr<Impl> pImpl;
|
|
111
86
|
};
|
|
112
87
|
|
|
113
88
|
class ShortcutManager {
|
|
@@ -117,7 +92,7 @@ public:
|
|
|
117
92
|
|
|
118
93
|
static ShortcutManager& instance();
|
|
119
94
|
|
|
120
|
-
bool registerShortcut(const std::string& id, const Shortcut& shortcut,
|
|
95
|
+
bool registerShortcut(const std::string& id, const Shortcut& shortcut,
|
|
121
96
|
std::function<void()> callback);
|
|
122
97
|
bool unregisterShortcut(const std::string& id);
|
|
123
98
|
void clearShortcuts();
|
|
@@ -129,7 +104,9 @@ public:
|
|
|
129
104
|
|
|
130
105
|
private:
|
|
131
106
|
struct Impl;
|
|
132
|
-
|
|
107
|
+
std::unique_ptr<Impl> pImpl;
|
|
133
108
|
};
|
|
134
109
|
|
|
135
110
|
}
|
|
111
|
+
|
|
112
|
+
#endif
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#ifndef PLUSUI_MENU_H
|
|
2
|
+
#define PLUSUI_MENU_H
|
|
3
|
+
|
|
4
|
+
#include <functional>
|
|
5
|
+
#include <map>
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
namespace plusui {
|
|
11
|
+
class WebView;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
namespace plusui {
|
|
15
|
+
|
|
16
|
+
enum class MenuItemType { Normal, Separator, Submenu, Checkbox, Radio };
|
|
17
|
+
|
|
18
|
+
struct MenuItem {
|
|
19
|
+
std::string id;
|
|
20
|
+
std::string label;
|
|
21
|
+
std::string accelerator;
|
|
22
|
+
std::string icon;
|
|
23
|
+
MenuItemType type = MenuItemType::Normal;
|
|
24
|
+
bool enabled = true;
|
|
25
|
+
bool checked = false;
|
|
26
|
+
std::vector<MenuItem> submenu;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
struct MenuBarData {
|
|
30
|
+
std::vector<MenuItem> items;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
class Menu {
|
|
34
|
+
public:
|
|
35
|
+
Menu();
|
|
36
|
+
~Menu();
|
|
37
|
+
|
|
38
|
+
// Move semantics
|
|
39
|
+
Menu(Menu &&other) noexcept;
|
|
40
|
+
Menu &operator=(Menu &&other) noexcept;
|
|
41
|
+
|
|
42
|
+
// Disable copy
|
|
43
|
+
Menu(const Menu &) = delete;
|
|
44
|
+
Menu &operator=(const Menu &) = delete;
|
|
45
|
+
|
|
46
|
+
static Menu create(const std::vector<MenuItem> &items = {});
|
|
47
|
+
|
|
48
|
+
void setItems(const std::vector<MenuItem> &items);
|
|
49
|
+
std::vector<MenuItem> getItems() const;
|
|
50
|
+
|
|
51
|
+
void append(const MenuItem &item);
|
|
52
|
+
void insert(int index, const MenuItem &item);
|
|
53
|
+
void remove(const std::string &id);
|
|
54
|
+
void clear();
|
|
55
|
+
|
|
56
|
+
void popup(int x, int y);
|
|
57
|
+
void close();
|
|
58
|
+
|
|
59
|
+
private:
|
|
60
|
+
struct Impl;
|
|
61
|
+
std::unique_ptr<Impl> pImpl;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
class MenuBar {
|
|
65
|
+
public:
|
|
66
|
+
MenuBar();
|
|
67
|
+
~MenuBar();
|
|
68
|
+
|
|
69
|
+
static MenuBar &instance();
|
|
70
|
+
|
|
71
|
+
void setMenu(const MenuBarData &menu);
|
|
72
|
+
MenuBarData getMenu() const;
|
|
73
|
+
|
|
74
|
+
void append(const MenuItem &item);
|
|
75
|
+
void insert(int index, const MenuItem &item);
|
|
76
|
+
void remove(const std::string &id);
|
|
77
|
+
void clear();
|
|
78
|
+
|
|
79
|
+
void onMenuItemClick(std::function<void(const std::string &id)> callback);
|
|
80
|
+
|
|
81
|
+
private:
|
|
82
|
+
struct Impl;
|
|
83
|
+
std::unique_ptr<Impl> pImpl;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
class MenuManager {
|
|
87
|
+
public:
|
|
88
|
+
static MenuManager &instance();
|
|
89
|
+
|
|
90
|
+
// Manage ID to Menu mapping
|
|
91
|
+
std::string createMenu(const std::vector<MenuItem> &items);
|
|
92
|
+
Menu *getMenu(const std::string &id);
|
|
93
|
+
void destroyMenu(const std::string &id);
|
|
94
|
+
|
|
95
|
+
private:
|
|
96
|
+
MenuManager();
|
|
97
|
+
~MenuManager();
|
|
98
|
+
struct Impl;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
namespace bindings {
|
|
102
|
+
|
|
103
|
+
class MenuBindings {
|
|
104
|
+
public:
|
|
105
|
+
MenuBindings() = default;
|
|
106
|
+
~MenuBindings() = default;
|
|
107
|
+
|
|
108
|
+
void registerBindings(WebView &webview);
|
|
109
|
+
void setItemClickCallback(
|
|
110
|
+
std::function<void(const std::string &menuId, const std::string &itemId)>
|
|
111
|
+
callback);
|
|
112
|
+
void setContextMenu(const std::vector<MenuItem> &items);
|
|
113
|
+
void enableContextMenu(bool enable);
|
|
114
|
+
void showContextMenuAtCursor();
|
|
115
|
+
|
|
116
|
+
private:
|
|
117
|
+
std::function<void(const std::string &, const std::string &)>
|
|
118
|
+
itemClickCallback_;
|
|
119
|
+
std::vector<MenuItem> contextMenuItems_;
|
|
120
|
+
bool contextMenuEnabled_ = false;
|
|
121
|
+
std::string currentContextMenuId_;
|
|
122
|
+
|
|
123
|
+
std::vector<MenuItem> parseMenuItems(const std::string &json);
|
|
124
|
+
std::string menuItemToJson(const MenuItem &item);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
class ContextMenuManager {
|
|
128
|
+
public:
|
|
129
|
+
static ContextMenuManager &instance();
|
|
130
|
+
|
|
131
|
+
void setDefaultMenu(const std::vector<MenuItem> &items);
|
|
132
|
+
void setMenuForSelector(const std::string &selector,
|
|
133
|
+
const std::vector<MenuItem> &items);
|
|
134
|
+
void attachToWebView(WebView &webview);
|
|
135
|
+
void handleRightClick(int x, int y, const std::string &targetSelector);
|
|
136
|
+
void onItemClick(std::function<void(const std::string &itemId,
|
|
137
|
+
const std::string &targetSelector)>
|
|
138
|
+
callback);
|
|
139
|
+
|
|
140
|
+
private:
|
|
141
|
+
ContextMenuManager() = default;
|
|
142
|
+
~ContextMenuManager() = default;
|
|
143
|
+
|
|
144
|
+
std::vector<MenuItem> defaultMenu_;
|
|
145
|
+
std::map<std::string, std::vector<MenuItem>> selectorMenus_;
|
|
146
|
+
std::function<void(const std::string &, const std::string &)> clickCallback_;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
} // namespace bindings
|
|
150
|
+
|
|
151
|
+
} // namespace plusui
|
|
152
|
+
|
|
153
|
+
#endif
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#ifndef PLUSUI_TRAY_HPP
|
|
2
|
+
#define PLUSUI_TRAY_HPP
|
|
3
|
+
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <functional>
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
namespace plusui {
|
|
11
|
+
|
|
12
|
+
struct TrayMenuItem {
|
|
13
|
+
std::string id;
|
|
14
|
+
std::string label;
|
|
15
|
+
bool enabled = true;
|
|
16
|
+
bool checked = false;
|
|
17
|
+
bool separator = false;
|
|
18
|
+
std::vector<TrayMenuItem> submenu;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
struct TrayIconData {
|
|
22
|
+
std::string tooltip;
|
|
23
|
+
std::string iconPath;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
class TrayIcon {
|
|
27
|
+
public:
|
|
28
|
+
TrayIcon();
|
|
29
|
+
~TrayIcon();
|
|
30
|
+
|
|
31
|
+
TrayIcon(TrayIcon &&other) noexcept;
|
|
32
|
+
TrayIcon &operator=(TrayIcon &&other) noexcept;
|
|
33
|
+
TrayIcon(const TrayIcon &) = delete;
|
|
34
|
+
TrayIcon &operator=(const TrayIcon &) = delete;
|
|
35
|
+
|
|
36
|
+
static TrayIcon create(const std::string &tooltip = "",
|
|
37
|
+
const std::string &iconPath = "");
|
|
38
|
+
|
|
39
|
+
void setTooltip(const std::string &tooltip);
|
|
40
|
+
void setIcon(const std::string &iconPath);
|
|
41
|
+
void setIconFromData(const std::vector<uint8_t> &data, int width, int height);
|
|
42
|
+
void setIconFromMemory(const unsigned char *data, size_t size);
|
|
43
|
+
|
|
44
|
+
void show();
|
|
45
|
+
void hide();
|
|
46
|
+
bool isVisible() const;
|
|
47
|
+
|
|
48
|
+
void setMenu(const std::vector<TrayMenuItem> &items);
|
|
49
|
+
void setContextMenu(const std::vector<TrayMenuItem> &items);
|
|
50
|
+
|
|
51
|
+
void onClick(std::function<void(int x, int y)> callback);
|
|
52
|
+
void onRightClick(std::function<void(int x, int y)> callback);
|
|
53
|
+
void onDoubleClick(std::function<void()> callback);
|
|
54
|
+
void onMenuItemClick(std::function<void(const std::string &id)> callback);
|
|
55
|
+
|
|
56
|
+
void dispose();
|
|
57
|
+
friend class TrayManager;
|
|
58
|
+
|
|
59
|
+
private:
|
|
60
|
+
struct Impl;
|
|
61
|
+
std::unique_ptr<Impl> pImpl;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
class TrayManager {
|
|
65
|
+
public:
|
|
66
|
+
TrayManager();
|
|
67
|
+
~TrayManager();
|
|
68
|
+
|
|
69
|
+
static TrayManager &instance();
|
|
70
|
+
|
|
71
|
+
void setWindowHandle(void *hwnd);
|
|
72
|
+
void setIcon(const std::string &iconPath);
|
|
73
|
+
void setTooltip(const std::string &tooltip);
|
|
74
|
+
void setVisible(bool visible);
|
|
75
|
+
|
|
76
|
+
std::vector<TrayIcon *> getIcons();
|
|
77
|
+
|
|
78
|
+
void onTrayCreated(std::function<void(TrayIcon &)> callback);
|
|
79
|
+
void onTrayDestroyed(std::function<void(int)> callback);
|
|
80
|
+
|
|
81
|
+
void refresh();
|
|
82
|
+
|
|
83
|
+
private:
|
|
84
|
+
TrayManager(const TrayManager &) = delete;
|
|
85
|
+
TrayManager &operator=(const TrayManager &) = delete;
|
|
86
|
+
|
|
87
|
+
struct Impl;
|
|
88
|
+
std::unique_ptr<Impl> pImpl;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
} // namespace plusui
|
|
92
|
+
|
|
93
|
+
#endif
|