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: 28 мая 2019 г. 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_PLUGINS_ROOM_BUILDER_UI_H_ 23 #define UI_PLUGINS_ROOM_BUILDER_UI_H_ 24 25 #include <ui/ui.h> 26 #include <ui/ctl/ctl.h> 27 28 namespace lsp 29 { 30 31 class room_builder_ui: public plugin_ui 32 { 33 protected: 34 class CtlFloatPort: public CtlPort, public CtlKvtListener 35 { 36 protected: 37 room_builder_ui *pUI; 38 const char *sPattern; 39 osc::pattern_t sOscPattern; 40 float fValue; 41 42 public: 43 explicit CtlFloatPort(room_builder_ui *ui, const char *pattern, const port_t *meta); 44 virtual ~CtlFloatPort(); 45 46 public: 47 virtual float get_value(); 48 virtual void set_value(float value); 49 virtual bool changed(KVTStorage *storage, const char *id, const kvt_param_t *value); 50 virtual bool match(const char *id); 51 virtual const char *name(); 52 }; 53 54 class CtlListPort: public CtlPort, public CtlKvtListener 55 { 56 protected: 57 room_builder_ui *pUI; 58 port_t sMetadata; 59 port_item_t *pItems; 60 size_t nCapacity; 61 size_t nItems; 62 cvector<CtlPort> vKvtPorts; 63 osc::pattern_t sOscPattern; 64 ssize_t nSelectedReq; 65 66 protected: 67 void set_list_item(size_t id, const char *value); 68 69 public: 70 explicit CtlListPort(room_builder_ui *ui, const port_t *meta); 71 virtual ~CtlListPort(); 72 73 public: 74 virtual float get_value(); 75 virtual void set_value(float value); 76 virtual bool changed(KVTStorage *storage, const char *id, const kvt_param_t *value); 77 virtual bool match(const char *id); 78 virtual const char *name(); 79 80 void add_port(CtlPort *port); 81 }; 82 83 class CtlMaterialPreset: public CtlPortListener 84 { 85 protected: 86 room_builder_ui *pUI; 87 LSPComboBox *pCBox; 88 ui_handler_id_t hHandler; 89 CtlPort *pSpeed; 90 CtlPort *pAbsorption; 91 CtlPort *pSelected; 92 93 public: 94 explicit CtlMaterialPreset(room_builder_ui *ui); 95 virtual ~CtlMaterialPreset(); 96 97 void init(const char *preset, const char *selected, const char *speed, const char *absorption); 98 99 public: 100 virtual void notify(CtlPort *port); 101 102 static status_t slot_change(LSPWidget *sender, void *ptr, void *data); 103 }; 104 105 class CtlKnobBinding: public CtlPortListener 106 { 107 protected: 108 room_builder_ui *pUI; 109 CtlPort *pOuter; 110 CtlPort *pInner; 111 CtlPort *pLink; 112 bool bReverse; 113 114 public: 115 explicit CtlKnobBinding(room_builder_ui *ui, bool reverse); 116 virtual ~CtlKnobBinding(); 117 118 void init(const char *outer, const char *inner, const char *link); 119 120 public: 121 virtual void notify(CtlPort *port); 122 }; 123 124 protected: 125 ssize_t nSelected; 126 CtlMaterialPreset sPresets; 127 CtlKnobBinding sAbsorption; 128 CtlKnobBinding sTransparency; 129 CtlKnobBinding sDispersion; 130 CtlKnobBinding sDiffuse; 131 132 public: 133 explicit room_builder_ui(const plugin_metadata_t *mdata, void *root_widget); 134 virtual ~room_builder_ui(); 135 136 public: 137 virtual status_t init(IUIWrapper *wrapper, int argc, const char **argv); 138 139 virtual status_t build(); 140 }; 141 142 } /* namespace lsp */ 143 144 #endif /* UI_PLUGINS_ROOM_BUILDER_UI_H_ */ 145