11/*
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] > 44 *
55 * This file is part of lsp-tk-lib
66 * Created on: 13 июн. 2020 г.
2222#ifndef LSP_PLUG_IN_TK_PROP_MULTI_SHORTCUT_H_
2323#define LSP_PLUG_IN_TK_PROP_MULTI_SHORTCUT_H_
2424
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+
2531namespace lsp
2632{
2733 namespace tk
@@ -32,10 +38,6 @@ namespace lsp
3238 */
3339 class Shortcut : public MultiProperty
3440 {
35- private:
36- Shortcut & operator = (const Shortcut &);
37- Shortcut (const Shortcut &);
38-
3941 protected:
4042 enum property_t
4143 {
@@ -54,6 +56,7 @@ namespace lsp
5456 atom_t vAtoms[P_COUNT]; // Atom bindings
5557 size_t nMod; // Modifiers
5658 ws::code_t nKey; // Key
59+ Slot sSlot ; // Event handling
5760
5861 protected:
5962 static status_t append_modifier (LSPString *s, size_t mod, size_t index);
@@ -63,6 +66,9 @@ namespace lsp
6366 static status_t format_modifiers (LSPString *s, size_t mod);
6467 static status_t format_key (LSPString *s, ws::code_t key);
6568
69+ static bool check_modifier (size_t mod, size_t check);
70+ static bool check_modifiers (size_t mod, size_t check);
71+
6672 protected:
6773 virtual void push ();
6874 virtual void commit (atom_t property);
@@ -74,6 +80,13 @@ namespace lsp
7480
7581 protected:
7682 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:
7790 virtual ~Shortcut ();
7891
7992 public:
@@ -116,15 +129,40 @@ namespace lsp
116129 inline size_t remove_modifiers (size_t mod) { return set_modifiers (nMod & (~mod)); }
117130 inline size_t toggle_modifiers (size_t mod) { return set_modifiers (nMod ^ mod); }
118131
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);
120150
121151 /* *
122152 * Check that shortcut must trigger
123153 * @param key key to check
124154 * @param mod modifier
125155 * @return true if shortcut must trigger
126156 */
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 ;
128166
129167 /* *
130168 * Format state to the string presentation
@@ -138,13 +176,13 @@ namespace lsp
138176 {
139177 class Shortcut : public tk ::Shortcut
140178 {
141- private:
142- Shortcut & operator = (const Shortcut &);
143- Shortcut (const Shortcut &);
144-
145179 public:
146180 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 ;
148186
149187 public:
150188 /* *
@@ -155,9 +193,8 @@ namespace lsp
155193 inline status_t bind (const LSPString *property, Style *style) { return tk::Shortcut::bind (property, style, vAtoms, DESC, &sListener ); }
156194 };
157195 }
158- }
159- }
160-
196+ } /* namespace tk */
197+ } /* namespace lsp */
161198
162199
163200#endif /* LSP_PLUG_IN_TK_PROP_MULTI_SHORTCUT_H_ */
0 commit comments