1 /* 2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> 3 * (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com> 4 * 5 * This file is part of lsp-plugins 6 * Created on: 12 июн. 2017 г. 7 * 8 * lsp-plugins is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * any later version. 12 * 13 * lsp-plugins is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License 19 * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef UI_TK_LSPSLOTSET_H_ 23 #define UI_TK_LSPSLOTSET_H_ 24 25 namespace lsp 26 { 27 namespace tk 28 { 29 class LSPSlotSet 30 { 31 protected: 32 typedef struct item_t 33 { 34 ui_slot_t nType; 35 LSPSlot *pSlot; 36 } item_t; 37 38 protected: 39 cstorage<item_t> vSlots; 40 41 public: 42 explicit LSPSlotSet(); 43 ~LSPSlotSet(); 44 45 public: 46 /** Get slot by identifier 47 * 48 * @param id slot identifier 49 * @return slot or NULL if not present 50 */ 51 LSPSlot *slot(ui_slot_t id); 52 53 /** Add slot 54 * 55 * @param id slot identifier 56 * @return added slot or NULL if no memory 57 */ 58 LSPSlot *add(ui_slot_t id); 59 60 /** Add slot and bind 61 * 62 * @param id slot identifier 63 * @param handler slot handler 64 * @param arg argument 65 * @param enabled enable flag 66 * @return status of operation 67 */ 68 ui_handler_id_t add(ui_slot_t id, ui_event_handler_t handler, void *arg = NULL, bool enabled = true); 69 70 /** Destroy previously allocated structures 71 * 72 */ 73 void destroy(); 74 75 /** Bind slot handler to slot 76 * 77 * @param id slot identifier 78 * @param handler slot handler 79 * @param arg slot argument 80 * @param enabled enable flag 81 * @return status of operation 82 */ 83 ui_handler_id_t bind(ui_slot_t id, ui_event_handler_t handler, void *arg = NULL, bool enabled = true); 84 85 /** Intercept slot 86 * 87 * @param id slot identifier 88 * @param handler interceptor handler 89 * @param arg slot argument 90 * @param enabled enable flag 91 * @return status of operation 92 */ 93 ui_handler_id_t intercept(ui_slot_t id, ui_event_handler_t handler, void *arg = NULL, bool enabled = true); 94 95 /** Unbind slot handler 96 * 97 * @param id slot identifier 98 * @param handler slot handler identifier 99 * @return status of operation 100 */ 101 status_t unbind(ui_slot_t id, ui_handler_id_t handler); 102 103 /** Unbind slot handler 104 * 105 * @param id slot identifier 106 * @param handler slot handler routine 107 * @param arg slot argument 108 * @return status of operation 109 */ 110 ui_handler_id_t unbind(ui_slot_t id, ui_event_handler_t handler, void *arg = NULL); 111 112 /** Unbind all handlers for the slot 113 * 114 * @param id slot identifier 115 * @return number of handlers removed from bindings 116 */ 117 size_t unbind_all(ui_slot_t id); 118 119 /** Disable event handler in the slot 120 * 121 * @param id slot identifier 122 * @param handler handler identifier 123 * @return status of operation 124 */ 125 status_t disable(ui_slot_t id, ui_handler_id_t handler); 126 127 /** Disable all event handlers 128 * 129 * @param id slot identifier 130 * @return number of non-disabled handlers that were disabled 131 */ 132 ssize_t disable_all(ui_slot_t id); 133 134 /** Enable event handler in the slot 135 * 136 * @param id handler identifier 137 * @return status of operation 138 */ 139 status_t enable(ui_slot_t id, ui_handler_id_t handler); 140 141 /** Enable all event handlers for slot 142 * 143 * @param id slot identifier 144 * @return number of non-enabled handlers that were disabled 145 */ 146 size_t enable_all(ui_slot_t id); 147 148 /** Execute slot handlers 149 * 150 * @param sender the widget that initiates an event 151 * @param id slot identifier 152 * @param data data to process 153 * @return status of operation 154 */ 155 status_t execute(ui_slot_t id, LSPWidget *sender, void *data = NULL); 156 157 }; 158 159 } 160 } /* namespace lsp */ 161 162 #endif /* UI_TK_LSPSLOTSET_H_ */ 163