1 /*  LADSPAPluginGUI.h
2  *  Copyleft (C) 2000 David Griffiths <dave@pawfal.org>
3  *  LADSPA Plugin by Nicolas Noble <nicolas@nobis-crew.org>
4  *  Modified by Mike Rawes <myk@waxfrenzy.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20 
21 #ifndef __ladspa_plugin_gui_h__
22 #define __ladspa_plugin_gui_h__
23 
24 #include <FL/Fl.H>
25 #include <FL/Fl_Window.H>
26 #include <FL/Fl_Group.H>
27 #include <FL/Fl_Pack.H>
28 #include <FL/Fl_Choice.H>
29 #include <FL/Fl_Tabs.H>
30 #include <FL/Fl_Scroll.H>
31 #include <FL/Fl_Input.H>
32 #include <FL/Fl_Button.H>
33 #include <FL/Fl_Check_Button.H>
34 #include <FL/Fl_Box.H>
35 #include <FL/Fl_Output.H>
36 #include "../Widgets/Fl_Knob.H"
37 #include "../Widgets/Fl_LED_Button.H"
38 
39 #include <vector>
40 #include <string>
41 #include <cstdio>
42 #include <cmath>
43 #include <dlfcn.h>
44 
45 #include "LADSPAPlugin.h"
46 #include "LADSPAInfo.h"
47 #include "../SpiralPluginGUI.h"
48 
49 class LADSPAPluginGUI : public SpiralPluginGUI
50 {
51 public:
52 	LADSPAPluginGUI(int w, int h,
53 	                LADSPAPlugin *o,
54 	                ChannelHandler *ch,
55 	                const HostInfo *Info,
56 	                const std::vector<LADSPAInfo::PluginEntry> &PVec);
57 	~LADSPAPluginGUI(void);
58 
59 	virtual void UpdateValues(SpiralPlugin *o);
60 	virtual void Update(void);
61 
62 protected:
63 	const std::string GetHelpText(const std::string &loc);
64 private:
65 	void ClearPlugin(void);
66 	void SelectPlugin(void);
67 
68 	void SetPage(int index);
69 	void SetUniqueID(unsigned long n);
70 	void SetName(const char *s);
71 	void SetMaker(const char *s);
72 	void SetPortSettings(unsigned long p);
73 	void SetUpdateInputs(bool state);
74 
75 	void AddPortInfo(unsigned long p);
76 	void HandleResize(void);
77 
78 // For SetControlValue
79 	enum WhichControl
80 	{
81 		KNOB,
82 		SLIDER,
83 		BOTH
84 	};
85 
86 	void UpdateKnobs(void);
87 	void UpdateSliders(void);
88     void SetControlValue(unsigned long p, WhichControl wc);
89 	void SetControlRange(unsigned long p, float min, float max);
90 	void SetPortValue(unsigned long p, float value, int frompage);
91 	float ConvertControlValue(unsigned long p, float value);
92 
93 	Fl_Color m_GUIColour;
94 	Fl_Boxtype m_GUIBox;
95 
96 // Buttons
97 	Fl_Button                     *m_BKnob;
98 	Fl_Button                     *m_BSlider;
99 	Fl_Button                     *m_BSetup;
100 // Knobs
101 	Fl_Group                      *m_KnobGroup;
102 	std::vector<Fl_Knob *>         m_Knobs;
103 	std::vector<Fl_Input *>        m_KnobDefaults;
104 	std::vector<Fl_Box *>          m_KnobLabels;
105 	std::vector<char *>            m_KnobLabelBuffers;
106 // Sliders
107 	Fl_Group                      *m_SliderGroup;
108 	std::vector<Fl_Slider *>       m_Sliders;
109 	std::vector<Fl_Input *>        m_SliderDefaults;
110 	std::vector<Fl_Box *>          m_SliderLabels;
111 	std::vector<char *>            m_SliderLabelBuffers;
112 // Setup stuff
113 	Fl_Group                      *m_SetupGroup;
114 	Fl_Choice                     *m_Browser;
115 	Fl_Box                        *m_NameLabel;
116 	Fl_Box                        *m_MakerLabel;
117 	Fl_Box                        *m_ValueLabel;
118 	Fl_Box                        *m_DefaultLabel;
119 	Fl_Box                        *m_MinLabel;
120 	Fl_Box                        *m_MaxLabel;
121 	Fl_Box                        *m_ClampLabel;
122 	Fl_Box                        *m_PortLabel;
123 	std::vector<Fl_Output*>        m_PortValue;
124 	std::vector<Fl_Input*>         m_PortMin;
125 	std::vector<Fl_Input*>         m_PortMax;
126 	std::vector<Fl_Check_Button*>  m_PortClamp;
127 	std::vector<Fl_Input*>         m_PortDefault;
128 
129 	Fl_Scroll                     *m_InputScroll;
130 	Fl_Pack                       *m_InputPack;
131 	Fl_LED_Button                 *m_UpdateInputs;
132 
133 	unsigned long                  m_UnconnectedInputs;
134 
135 	std::vector<LADSPAInfo::PluginEntry> m_PluginList;
136 	std::vector<unsigned long>     m_PluginIDLookup;
137 
138 	unsigned long                  m_PortIndex;
139 	float                          m_Default;
140 	float                          m_Min;
141 	float                          m_Max;
142 	bool                           m_Clamp;
143 
144 	unsigned long                  m_UniqueID;
145 	int                            m_Page;
146 	bool                           m_UpdateInputState;
147 	char                           m_Name[256];
148 	char                           m_Maker[256];
149 	unsigned long                  m_MaxInputPortCount;
150 	unsigned long                  m_InputPortCount;
151 	char                          *m_InputPortNames;
152 	PortSetting                   *m_InputPortSettings;
153 	PortValue                     *m_InputPortValues;
154 	float                         *m_InputPortDefaults;
155 
156 	inline void cb_BKnob_i(Fl_Button* o);
157 	static void cb_BKnob(Fl_Button* o);
158 	inline void cb_BSlider_i(Fl_Button* o);
159 	static void cb_BSlider(Fl_Button* o);
160 	inline void cb_BSetup_i(Fl_Button* o);
161 	static void cb_BSetup(Fl_Button* o);
162 	inline void cb_Select_i(Fl_Choice* o);
163 	static void cb_Select(Fl_Choice* o);
164 	inline void cb_UpdateInputs_i(Fl_LED_Button* o);
165 	static void cb_UpdateInputs(Fl_LED_Button* o);
166 	inline void cb_Default_i(Fl_Input* o);
167 	static void cb_Default(Fl_Input* o);
168 	inline void cb_Min_i(Fl_Input* o);
169 	static void cb_Min(Fl_Input* o);
170 	inline void cb_Max_i(Fl_Input* o);
171 	static void cb_Max(Fl_Input* o);
172 	inline void cb_Clamp_i(Fl_Check_Button* o);
173 	static void cb_Clamp(Fl_Check_Button* o);
174 	inline void cb_Knob_i(Fl_Knob *o);
175 	static void cb_Knob(Fl_Knob *o);
176 	inline void cb_KnobValue_i(Fl_Input *o);
177 	static void cb_KnobValue(Fl_Input *o);
178 	inline void cb_Slider_i(Fl_Slider *o);
179 	static void cb_Slider(Fl_Slider *o);
180 	inline void cb_SliderValue_i(Fl_Input *o);
181 	static void cb_SliderValue(Fl_Input *o);
182 };
183 
184 #endif // __ladspa_plugin_gui_h__
185