-
Notifications
You must be signed in to change notification settings - Fork 3
/
Controls.h
239 lines (187 loc) · 5.5 KB
/
Controls.h
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
//
// Controls.h
// Evaluator
//
// Created by Damien Quartz on 10/23/17.
//
#pragma once
#include "IControl.h"
#include "KnobLineCoronaControl.h"
#include "Params.h"
#include <string>
class Interface;
// originally cribbed from the IPlugEEL example
class ITextEdit : public IControl
{
public:
ITextEdit(IPlugBase* pPlug, IRECT pR, int paramIdx, IText* pText, const char* str, ETextEntryOptions textEntryOptions);
~ITextEdit();
// IControl overrides
bool Draw(IGraphics* pGraphics) override;
void OnMouseDown(int x, int y, IMouseMod* pMod) override;
void TextFromTextEntry(const char* txt) override;
// text accessss
const char * GetText() const
{
return mStr.c_str();
}
void SetTextFromPlug(const char * text)
{
mStr = text;
}
int GetTextLength() const
{
return mStr.size();
}
protected:
int mIdx;
std::string mStr;
};
class TextBox : public ICaptionControl
{
public:
TextBox(IPlugBase* pPlug, IRECT pR, int paramIdx, IText* pText, IRECT textRect, bool showParamUnits = false);
bool Draw(IGraphics* pGraphics) override;
void OnMouseDown(int x, int y, IMouseMod* pMod) override;
void OnMouseDrag(int x, int y, int dX, int dY, IMouseMod* pMod) override;
void OnMouseWheel(int x, int y, IMouseMod* pMod, int d) override;
private:
bool mShowParamUnits;
IRECT mTextRect;
};
class TextTable : public IControl
{
public:
TextTable(IPlugBase* pPlug, IRECT pR, IText* pText, const char** data, int iColumns, int iRows);
bool Draw(IGraphics* pGraphics) override;
private:
const char** tableData;
int columns;
int rows;
};
class ConsoleText : public IControl
{
public:
ConsoleText(IPlugBase* plug, IRECT pR, IText* textStyle, const IColor* backgroundColor, int margin);
bool Draw(IGraphics* pGraphics) override;
void SetTextFromPlug(const char * text);
private:
IPanelControl mPanel;
ITextControl mText;
};
class EnumControl : public IControl
{
public:
EnumControl(IPlugBase* pPlug, IRECT rect, int paramIdx, IText* textStyle);
bool Draw(IGraphics* pGraphics) override;
void OnMouseDown(int x, int y, IMouseMod* pMod) override;
};
class ToggleControl : public IControl
{
public:
ToggleControl(IPlugBase* pPlug, IRECT rect, int paramIdx, IColor backgroundColor, IColor fillColor);
bool Draw(IGraphics* pGraphics) override;
void OnMouseDown(int x, int y, IMouseMod* pMod) override;
};
class Oscilloscope : public IControl
{
public:
Oscilloscope(IPlugBase* pPlug, IRECT pR, const IColor* backgroundColor, const IColor* lineColorLeft, const IColor* lineColorRight);
~Oscilloscope();
bool Draw(IGraphics* pGraphics) override;
void AddSample(double left, double right);
private:
void DrawWaveform(IGraphics* pGraphics);
void DrawGrid(IGraphics* pGraphics);
IColor mBackgroundColor;
IColor mLineColorLeft;
IColor mLineColorRight;
double* mBuffer;
int mBufferSize;
int mBufferBegin;
};
class LoadButton : public IBitmapControl
{
public:
LoadButton(IPlugBase* pPlug, int x, int y, IBitmap* pButtonBack, IText* pButtonTextStyle, IRECT menuRect, IText* pMenuTextStyle, Interface* pInterface);
bool Draw(IGraphics* pGraphics) override;
void OnMouseDown(int x, int y, IMouseMod* pMod) override;
void OnMouseOver(int x, int y, IMouseMod* pMod) override;
private:
enum
{
kClosed,
kOpen,
}
mState;
Interface* mInterface;
IRECT mButtonRect; // where the button goes
IRECT mTextRect; // where the text in the button goes
IRECT mMenuRect; // where the menu goes
// rects for all the selections in the menu
WDL_TypedBuf<IRECT> mRECTs;
IText mButtonText;
IText mMenuText;
int mSelection;
};
class SaveButton : public IBitmapControl
{
public:
SaveButton(IPlugBase* pPlug, int x, int y, IBitmap* pButtonBack, IText* pButtonTextStyle, Interface* pInterface);
bool Draw(IGraphics* pGraphics) override;
void OnMouseDown(int x, int y, IMouseMod* pMod) override;
private:
Interface* mInterface;
IText mButtonText;
IRECT mTextRect;
};
class ManualButton : public IBitmapControl
{
public:
ManualButton(IPlugBase* pPlug, int x, int y, IBitmap* pButtonBack, IText* pButtonTextStyle, Interface* pInterface);
bool Draw(IGraphics* pGraphics) override;
void OnMouseDown(int x, int y, IMouseMod* pMod) override;
private:
Interface* mInterface;
IText mButtonText;
IRECT mTextRect;
};
class HelpButton : public IControl
{
public:
HelpButton(IPlugBase* pPlug, IRECT rect, IText* pButtonTextStyle, Interface* pInterface);
bool Draw(IGraphics* pGraphics) override;
void OnMouseDown(int x, int y, IMouseMod* pMod) override;
private:
Interface* mInterface;
IText mButtonText;
IRECT mTextRect;
};
// play, pause, and stop buttons used by the standalone to control how t increments
// essentially makes TTAlways behave like TTProjectTime
class TransportButtons : public IControl
{
public:
// give the rect that the three buttons should occupy and we split it into three sections
TransportButtons(IPlugBase* pPlug, IRECT rect, const IColor& backgroundColor, const IColor& foregroundColor);
bool Draw(IGraphics* pGraphics) override;
void OnMouseDown(int x, int y, IMouseMod* pMod) override;
TransportState GetTransportState() const;
private:
void SetTransportState( TransportState state );
TransportState mState;
IRECT mPlayRect;
IRECT mPauseRect;
IRECT mStopRect;
IColor mBack;
IColor mFore;
};
// catch keyboard events and generate midi events from them.
// not a great implementation due to input limitations of IPlug.
class MidiControl : public IControl
{
public:
MidiControl(IPlugBase* pPlug);
bool Draw(IGraphics* pGraphics) override { return false; }
bool OnKeyDown(int x, int y, int key) override;
};