summaryrefslogtreecommitdiff
path: root/muse2/synti/simpledrums2/ssplugingui.h
blob: 3d77ecf0087bc55b049e1220197017e955257dd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
//
// C++ Interface: ssplugingui
//
// Description:
//
//
// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//

#ifndef __SS_PLUGINGUI_H__
#define __SS_PLUGINGUI_H__
#include <QDialog>
#include <QSlider>
#include <QButtonGroup>
#include <QtGui>
//#include <QHBoxLayout>
//#include <QVBoxLayout>

#include "ui_sspluginchooserbase.h"
#include "common.h"
#include "ssplugin.h"

class SS_ParameterWidget
      {
   protected:
      int fxid;
      int parameter;

      LadspaPlugin* plugin;

   public:
      SS_ParameterWidget() { }
      virtual ~SS_ParameterWidget() { }
      int getFxId() { SS_TRACE_IN SS_TRACE_OUT return fxid; }
      bool isBool() { SS_TRACE_IN SS_TRACE_OUT return plugin->isBool(parameter); }
      bool isLog()  { SS_TRACE_IN SS_TRACE_OUT return plugin->isLog(parameter); }
      bool isInt()  { SS_TRACE_IN SS_TRACE_OUT return plugin->isInt(parameter); }
      virtual void setParamValue(int) { printf("Virtual function - should not be called!"); };
      };

class SS_ParameterCheckBox : public QCheckBox, public SS_ParameterWidget
   {
   Q_OBJECT

   public:
      SS_ParameterCheckBox(QWidget* parent, LadspaPlugin* in_plugin, int in_id, int in_parameter)
         : QCheckBox(parent) , SS_ParameterWidget()
         {
         SS_TRACE_IN
         plugin = in_plugin;
         fxid = in_id;
         parameter = in_parameter;
         connect(this, SIGNAL(clicked()), SLOT(isClicked()));
         SS_TRACE_OUT
         }

      virtual void setParamValue(int val) { SS_TRACE_IN setChecked(val); SS_TRACE_OUT}

   private slots:
      void isClicked() { SS_TRACE_IN emit valueChanged(fxid, parameter, (int)this->isChecked()); SS_TRACE_OUT}

   signals:
      void valueChanged(int id, int param, int val);
   };

class SS_ParameterSlider : public QSlider, public SS_ParameterWidget
   {
   Q_OBJECT

   public:
      SS_ParameterSlider(QWidget* parent, LadspaPlugin* in_plugin, int in_id, int in_parameter)
         : QSlider(Qt::Horizontal, parent), SS_ParameterWidget()
         {
         SS_TRACE_IN
         plugin = in_plugin;
         fxid = in_id;
         parameter = in_parameter;
         SS_TRACE_OUT
         }

      virtual void setParamValue(int val) { SS_TRACE_IN setValue(val); SS_TRACE_OUT}

   public slots:
      virtual void setValue(int val) { SS_TRACE_IN QSlider::setValue(val); emit valueChanged(fxid, parameter, val); SS_TRACE_OUT }

   signals:
      void valueChanged(int id, int param, int val);
   };

typedef std::list<SS_ParameterWidget*>           SS_ParameterWidgetList;
typedef std::list<SS_ParameterWidget*>::iterator SS_iParameterWidgetList ;

//-------------------------------
// SS_PluginChooser
//-------------------------------
class SS_PluginChooser : public QDialog, Ui::SS_PluginChooserBase
{
   Q_OBJECT
   private:
         LadspaPlugin* selectedPlugin;
   protected:

   public:
         SS_PluginChooser(QWidget* parent);
         LadspaPlugin* getSelectedPlugin() { SS_TRACE_IN SS_TRACE_OUT return selectedPlugin; }

   private slots:
      void okPressed();
      void cancelPressed();
      void selectionChanged(QTreeWidgetItem* item);
      void doubleClicked(QTreeWidgetItem* item);

   private:
      QTreeWidgetItem* selectedItem;
      LadspaPlugin* findSelectedPlugin();

};

//-------------------------------
// SS_PluginGuiFront
//-------------------------------
class SS_PluginFront : public QGroupBox
   {
   Q_OBJECT
   private:
      QHBoxLayout*      layout;
      QVBoxLayout*      expLayout;
      QLineEdit*        pluginName;
      QCheckBox*        onOff;
      QPushButton*      loadFxButton;
      QPushButton*      clearFxButton;
      QPushButton*      expandButton;
      QSlider*          outGainSlider;
      SS_PluginChooser* pluginChooser;
      LadspaPlugin*     plugin;
      QGroupBox*     expGroup;

      int               fxid;
      bool              expanded;

      //For effect parameters:
      SS_ParameterWidgetList  paramWidgets;

   protected:

   public:
      SS_PluginFront(QWidget* parent, int id);
      void setPluginName(QString name);
      ~SS_PluginFront();
      void updatePluginValue(unsigned i);
      void clearPluginDisplay();
      void setParameterValue(int param, int val);
      void setRetGain(int val);

   protected:
      virtual QSize sizeHint() const;
      virtual QSizePolicy sizePolicy() const;

   private slots:
      void loadButton();
      void returnSliderMoved(int val);
      void onOffToggled(bool state);
      void clearButtonPressed();
      void expandButtonPressed();
      void parameterValueChanged(int fxid, int parameter, int val);

   signals:
      void loadPlugin(int fxid, QString lib, QString name);
      void returnLevelChanged(int fxid, int val);
      void fxToggled(int fxid, int state);
      void clearPlugin(int fxid);
      void sizeChanged(int fxid, int val);
      void effectParameterChanged(int fxid, int param, int val);

   private:
      void createPluginParameters();
   };


//-------------------------------
// SS_PluginGui
// Main plugin class, dialog
//-------------------------------
class SS_PluginGui : public QDialog
   {
   Q_OBJECT
   private:
      QVBoxLayout* layout;
      SS_PluginFront* pluginFronts[4];

   public:
      SS_PluginGui(QWidget* parent);
      SS_PluginFront* getPluginFront(unsigned i);
      ~SS_PluginGui() {}
private slots:
    void pluginFrontSizeChanged(int fxid, int val);
   };


#endif