plusui-native-core 0.1.21 → 0.1.23

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.
@@ -1,94 +1,94 @@
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 setIconFromMemory(const unsigned char *data, size_t size);
74
- void setTooltip(const std::string &tooltip);
75
- void setVisible(bool visible);
76
-
77
- std::vector<TrayIcon *> getIcons();
78
-
79
- void onTrayCreated(std::function<void(TrayIcon &)> callback);
80
- void onTrayDestroyed(std::function<void(int)> callback);
81
-
82
- void refresh();
83
-
84
- private:
85
- TrayManager(const TrayManager &) = delete;
86
- TrayManager &operator=(const TrayManager &) = delete;
87
-
88
- struct Impl;
89
- std::unique_ptr<Impl> pImpl;
90
- };
91
-
92
- } // namespace plusui
93
-
94
- #endif
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 setIconFromMemory(const unsigned char *data, size_t size);
74
+ void setTooltip(const std::string &tooltip);
75
+ void setVisible(bool visible);
76
+
77
+ std::vector<TrayIcon *> getIcons();
78
+
79
+ void onTrayCreated(std::function<void(TrayIcon &)> callback);
80
+ void onTrayDestroyed(std::function<void(int)> callback);
81
+
82
+ void refresh();
83
+
84
+ private:
85
+ TrayManager(const TrayManager &) = delete;
86
+ TrayManager &operator=(const TrayManager &) = delete;
87
+
88
+ struct Impl;
89
+ std::unique_ptr<Impl> pImpl;
90
+ };
91
+
92
+ } // namespace plusui
93
+
94
+ #endif