-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenu.hpp
236 lines (164 loc) · 4.37 KB
/
Menu.hpp
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
#ifndef MENU_HPP
#define MENU_HPP
#include <string>
#include <cstring>
#include <algorithm>
#include "daisysp.h"
#include "daisy_patch.h"
using namespace daisy;
using namespace daisysp;
extern DaisyPatch patch;
class Menu {
public:
virtual bool process() = 0;
};
class ParentMenu;
class MenuEntry {
public:
virtual void print(int line, bool on) = 0;
virtual void onClick() = 0;
void setParentMenu(ParentMenu* parent);
protected:
ParentMenu* m_parentMenu = nullptr;
};
class ParentMenu : public Menu
{
public:
virtual void leaveSubMenu();
virtual void enterSubMenu(Menu* menu);
protected:
Menu* m_subMenu = nullptr;
};
class SimpleMenu : public ParentMenu {
public:
SimpleMenu( MenuEntry** entries, int32_t count);
bool process() override;
int32_t m_idx = 0;
int32_t m_showIdx = 0;
MenuEntry** m_entryList = nullptr;
int32_t m_entryCount = 0;
};
class KVMenuEntry : public MenuEntry {
public:
KVMenuEntry(const char* name);
void print(int line, bool on) override;
const std::string label() const;
virtual std::string repr() const = 0;
private:
const char* m_name;
int m_paramPos = 0;
};
class KVEditMenuEntry : public KVMenuEntry, public Menu {
public:
KVEditMenuEntry(const char* name);
bool process() override;
void onClick() override;
virtual void increment(int inc) = 0;
};
class LabelEntry : public MenuEntry {
public:
LabelEntry(const char* name);
void print(int line, bool on) override;
void onClick() override;
private:
const char* m_name;
};
class BackMenuEntry : public MenuEntry {
public:
void print(int line, bool on) override;
void onClick() override;
};
class BoolMenuEntry : public KVMenuEntry {
public:
BoolMenuEntry(const char* name, bool defaultValue = false);
std::string repr() const override;
void onClick() override;
inline bool value() { return m_value; }
private:
bool m_value;
};
class SubMenuEntry : public MenuEntry, public SimpleMenu {
public:
SubMenuEntry(const char* name, MenuEntry **entries, int32_t count);
void print(int line, bool on) override;
void onClick() override;
private:
const char* m_name;
};
class SetMenuEntry : public KVEditMenuEntry {
public:
SetMenuEntry(const char* name, const char** labels = nullptr, int32_t maxValue = 0);
void setSet(const char** labels, int32_t maxValue);
void increment(int val) override;
std::string repr() const override;
int32_t value() const;
private:
const char* m_name = nullptr;
const char** m_labels = nullptr;
int32_t m_maxValue = 0;
int32_t m_value = 0;
int m_paramPos = 0;
};
class ShowParamEntry : public KVMenuEntry {
public:
ShowParamEntry(const char* name);
std::string repr() const override;
void onClick() override;
void setParam(Parameter* param);
private:
Parameter* m_param = nullptr;
};
class ShowROStringEntry : public KVMenuEntry {
public:
ShowROStringEntry(const char* name);
std::string repr() const override;
void onClick() override;
void setValue(const std::string& value);
private:
std::string m_value;
};
class RangeParamEntry : public KVEditMenuEntry {
public:
RangeParamEntry(const char* name, float min, float max, int initial, int steps, Parameter::Curve scale);
std::string repr() const override;
void increment(int val) override;
inline float value() const { return m_value; }
void bind(int b);
void processParam();
private:
float m_min;
float m_max;
float m_lmin;
float m_lmax;
int m_intValue;
float m_value;
int m_steps = 0;
Parameter::Curve m_scale;
int m_bind = -1;
Parameter m_param;
};
class BindParamEntry : public KVEditMenuEntry {
public:
BindParamEntry(const char* name, int hwCtrl, RangeParamEntry** entries, BindParamEntry** bindedEntries, size_t count);
std::string repr() const override;
void increment(int val) override;
private:
int m_hwCtrl;
RangeParamEntry** m_entries;
BindParamEntry** m_bindedEntries;
size_t m_count;
int m_index = -1;
};
class BindAllParamEntry {
public:
BindAllParamEntry(RangeParamEntry** entries, size_t count);
~BindAllParamEntry();
private:
BindParamEntry** m_bindedEntries = nullptr;
public:
BindParamEntry p1;
BindParamEntry p2;
BindParamEntry p3;
BindParamEntry p4;
};
#endif // MENU_HPP