1
1
/*
2
- * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3
- * (C) 2020 Vladimir Sadovnikov <[email protected] >
2
+ * Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3
+ * (C) 2024 Vladimir Sadovnikov <[email protected] >
4
4
*
5
5
* This file is part of lsp-tk-lib
6
6
* Created on: 13 июн. 2020 г.
22
22
#ifndef LSP_PLUG_IN_TK_PROP_MULTI_SHORTCUT_H_
23
23
#define LSP_PLUG_IN_TK_PROP_MULTI_SHORTCUT_H_
24
24
25
+ #ifndef LSP_PLUG_IN_TK_IMPL
26
+ #error "use <lsp-plug.in/tk/tk.h>"
27
+ #endif
28
+
29
+ #include < lsp-plug.in/tk/sys/Slot.h>
30
+
25
31
namespace lsp
26
32
{
27
33
namespace tk
@@ -32,10 +38,6 @@ namespace lsp
32
38
*/
33
39
class Shortcut : public MultiProperty
34
40
{
35
- private:
36
- Shortcut & operator = (const Shortcut &);
37
- Shortcut (const Shortcut &);
38
-
39
41
protected:
40
42
enum property_t
41
43
{
@@ -54,6 +56,7 @@ namespace lsp
54
56
atom_t vAtoms[P_COUNT]; // Atom bindings
55
57
size_t nMod; // Modifiers
56
58
ws::code_t nKey; // Key
59
+ Slot sSlot ; // Event handling
57
60
58
61
protected:
59
62
static status_t append_modifier (LSPString *s, size_t mod, size_t index);
@@ -63,6 +66,9 @@ namespace lsp
63
66
static status_t format_modifiers (LSPString *s, size_t mod);
64
67
static status_t format_key (LSPString *s, ws::code_t key);
65
68
69
+ static bool check_modifier (size_t mod, size_t check);
70
+ static bool check_modifiers (size_t mod, size_t check);
71
+
66
72
protected:
67
73
virtual void push ();
68
74
virtual void commit (atom_t property);
@@ -74,6 +80,13 @@ namespace lsp
74
80
75
81
protected:
76
82
explicit Shortcut (prop::Listener *listener = NULL );
83
+ Shortcut (const Shortcut &) = delete ;
84
+ Shortcut (Shortcut &&) = delete ;
85
+
86
+ Shortcut & operator = (const Shortcut &) = delete ;
87
+ Shortcut & operator = (Shortcut &&) = delete ;
88
+
89
+ public:
77
90
virtual ~Shortcut ();
78
91
79
92
public:
@@ -116,15 +129,40 @@ namespace lsp
116
129
inline size_t remove_modifiers (size_t mod) { return set_modifiers (nMod & (~mod)); }
117
130
inline size_t toggle_modifiers (size_t mod) { return set_modifiers (nMod ^ mod); }
118
131
119
- inline void clear () { set (ws::WSK_UNKNOWN, 0 ); }
132
+ inline void clear () { set (ws::WSK_UNKNOWN, KM_NONE); }
133
+
134
+ inline Slot *slot () { return &sSlot ; }
135
+
136
+ bool equals (const Shortcut *scut) const ;
137
+ bool equals (const Shortcut &scut) const ;
138
+
139
+ /* *
140
+ * Set key and modifiers to be equal to the passed shortcut
141
+ * @param scut passed shortcut
142
+ */
143
+ void set (const Shortcut *scut);
144
+
145
+ /* *
146
+ * Set key and modifiers to be equal to the passed shortcut
147
+ * @param scut passed shortcut
148
+ */
149
+ void set (const Shortcut &scut);
120
150
121
151
/* *
122
152
* Check that shortcut must trigger
123
153
* @param key key to check
124
154
* @param mod modifier
125
155
* @return true if shortcut must trigger
126
156
*/
127
- bool check (ws::code_t key, size_t mod);
157
+ bool match (ws::code_t key, size_t mod) const ;
158
+
159
+ /* *
160
+ * Check if shortcut matches another shortcut
161
+ * @param scut shotcut to check
162
+ * @return true if shortcut matches the passed shortcut
163
+ */
164
+ bool match (const Shortcut *scut) const ;
165
+ bool match (const Shortcut &scut) const ;
128
166
129
167
/* *
130
168
* Format state to the string presentation
@@ -138,13 +176,13 @@ namespace lsp
138
176
{
139
177
class Shortcut : public tk ::Shortcut
140
178
{
141
- private:
142
- Shortcut & operator = (const Shortcut &);
143
- Shortcut (const Shortcut &);
144
-
145
179
public:
146
180
inline Shortcut (prop::Listener *listener = NULL ): tk::Shortcut(listener) {}
147
- inline ~Shortcut () {}
181
+ Shortcut (const Shortcut &) = delete ;
182
+ Shortcut (Shortcut &&) = delete ;
183
+
184
+ Shortcut & operator = (const Shortcut &) = delete ;
185
+ Shortcut & operator = (Shortcut &&) = delete ;
148
186
149
187
public:
150
188
/* *
@@ -155,9 +193,8 @@ namespace lsp
155
193
inline status_t bind (const LSPString *property, Style *style) { return tk::Shortcut::bind (property, style, vAtoms, DESC, &sListener ); }
156
194
};
157
195
}
158
- }
159
- }
160
-
196
+ } /* namespace tk */
197
+ } /* namespace lsp */
161
198
162
199
163
200
#endif /* LSP_PLUG_IN_TK_PROP_MULTI_SHORTCUT_H_ */
0 commit comments