1
+ #include " SurgeFXDefaultEditor.h"
2
+
3
+ SurgeFXDefaultEditor::SurgeFXDefaultEditor (SurgefxAudioProcessor &p) : processor(p)
4
+ {
5
+
6
+ for (int i = 0 ; i < n_fx_params; ++i)
7
+ {
8
+ auto knob = std::make_unique<sst::jucegui::components::Knob>();
9
+ auto knobSource = std::make_unique<KnobSource>(processor, fxParamDisplay[i], i);
10
+
11
+ // knob->setStyle(styleSheet);
12
+ knob->setModulationDisplay (sst::jucegui::components::Knob::Modulatable::NONE);
13
+
14
+ auto paramName = processor.getParamName (i) + " " + processor.getParamGroup (i);
15
+ knobSource->setValueFromGUI (processor.getFXStorageValue01 (i));
16
+ knobSource->setLabel (paramName + " Knob" );
17
+
18
+ knob->setSource (knobSource.get ());
19
+
20
+ addAndMakeVisible (knob.get ());
21
+ knobs.push_back (std::move (knob));
22
+ sources.push_back (std::move (knobSource));
23
+
24
+ fxTempoSync[i].setOnOffImage (BinaryData::TS_Act_svg, BinaryData::TS_Act_svgSize,
25
+ BinaryData::TS_Deact_svg, BinaryData::TS_Deact_svgSize);
26
+ fxTempoSync[i].setEnabled (processor.canTempoSync (i));
27
+ fxTempoSync[i].setToggleState (processor.getFXStorageTempoSync (i),
28
+ juce::NotificationType::dontSendNotification);
29
+ fxTempoSync[i].onClick = [i, this ]() {
30
+ this ->processor .setUserEditingParamFeature (i, true );
31
+ this ->processor .setFXParamTempoSync (i, this ->fxTempoSync [i].getToggleState ());
32
+ this ->processor .setFXStorageTempoSync (i, this ->fxTempoSync [i].getToggleState ());
33
+ fxParamDisplay[i].setDisplay (
34
+ processor.getParamValueFromFloat (i, processor.getFXStorageValue01 (i)));
35
+ this ->processor .setUserEditingParamFeature (i, false );
36
+ };
37
+
38
+ fxTempoSync[i].setTitle (" Parameter " + std::to_string (i) + " TempoSync" );
39
+ addAndMakeVisible (&(fxTempoSync[i]));
40
+
41
+ fxDeactivated[i].setOnOffImage (BinaryData::DE_Act_svg, BinaryData::DE_Act_svgSize,
42
+ BinaryData::DE_Deact_svg, BinaryData::DE_Deact_svgSize);
43
+ fxDeactivated[i].setEnabled (processor.canDeactitvate (i));
44
+ fxDeactivated[i].setToggleState (processor.getFXStorageDeactivated (i),
45
+ juce::NotificationType::dontSendNotification);
46
+ fxDeactivated[i].onClick = [i, this ]() {
47
+ this ->processor .setUserEditingParamFeature (i, true );
48
+ this ->processor .setFXParamDeactivated (i, this ->fxDeactivated [i].getToggleState ());
49
+ this ->processor .setFXStorageDeactivated (i, this ->fxDeactivated [i].getToggleState ());
50
+ // Special case - coupled dectivation
51
+ this ->reset ();
52
+ this ->processor .setUserEditingParamFeature (i, false );
53
+ };
54
+ fxDeactivated[i].setTitle (" Parameter " + std::to_string (i) + " Deactivate" );
55
+ addAndMakeVisible (&(fxDeactivated[i]));
56
+
57
+ fxExtended[i].setOnOffImage (BinaryData::EX_Act_svg, BinaryData::EX_Act_svgSize,
58
+ BinaryData::EX_Deact_svg, BinaryData::EX_Deact_svgSize);
59
+ fxExtended[i].setEnabled (processor.canExtend (i));
60
+ fxExtended[i].setToggleState (processor.getFXStorageExtended (i),
61
+ juce::NotificationType::dontSendNotification);
62
+ fxExtended[i].onClick = [i, this ]() {
63
+ this ->processor .setUserEditingParamFeature (i, true );
64
+ this ->processor .setFXParamExtended (i, this ->fxExtended [i].getToggleState ());
65
+ this ->processor .setFXStorageExtended (i, this ->fxExtended [i].getToggleState ());
66
+ fxParamDisplay[i].setDisplay (
67
+ processor.getParamValueFromFloat (i, processor.getFXStorageValue01 (i)));
68
+ this ->processor .setUserEditingParamFeature (i, false );
69
+ };
70
+ fxExtended[i].setTitle (" Parameter " + std::to_string (i) + " Extended" );
71
+ addAndMakeVisible (&(fxExtended[i]));
72
+
73
+ fxAbsoluted[i].setOnOffImage (BinaryData::AB_Act_svg, BinaryData::AB_Act_svgSize,
74
+ BinaryData::AB_Deact_svg, BinaryData::AB_Deact_svgSize);
75
+ fxAbsoluted[i].setEnabled (processor.canAbsolute (i));
76
+ fxAbsoluted[i].setToggleState (processor.getFXParamAbsolute (i),
77
+ juce::NotificationType::dontSendNotification);
78
+ fxAbsoluted[i].onClick = [i, this ]() {
79
+ this ->processor .setUserEditingParamFeature (i, true );
80
+ this ->processor .setFXParamAbsolute (i, this ->fxAbsoluted [i].getToggleState ());
81
+ this ->processor .setFXStorageAbsolute (i, this ->fxAbsoluted [i].getToggleState ());
82
+
83
+ fxParamDisplay[i].setDisplay (
84
+ processor.getParamValueFromFloat (i, processor.getFXStorageValue01 (i)));
85
+ this ->processor .setUserEditingParamFeature (i, false );
86
+ };
87
+
88
+ fxAbsoluted[i].setTitle (" Parameter " + std::to_string (i) + " Absoluted" );
89
+ addAndMakeVisible (&(fxAbsoluted[i]));
90
+
91
+ processor.prepareParametersAbsentAudio ();
92
+ fxParamDisplay[i].setGroup (processor.getParamGroup (i).c_str ());
93
+ fxParamDisplay[i].setName (processor.getParamName (i).c_str ());
94
+ fxParamDisplay[i].setDisplay (processor.getParamValue (i));
95
+ fxParamDisplay[i].setEnabled (processor.getParamEnabled (i));
96
+ fxParamDisplay[i].onOverlayEntered = [i, this ](const std::string &s) {
97
+ processor.setParameterByString (i, s);
98
+ };
99
+
100
+ addAndMakeVisible (&(fxParamDisplay[i]));
101
+ }
102
+ }
103
+
104
+ SurgeFXDefaultEditor::~SurgeFXDefaultEditor () {}
105
+
106
+ void SurgeFXDefaultEditor::paint (juce::Graphics &g) { g.fillAll (juce::Colours::darkgrey); }
107
+
108
+ void SurgeFXDefaultEditor::reset ()
109
+ {
110
+ knobs.clear ();
111
+ sources.clear ();
112
+
113
+ auto st = [](auto &thing, const std::string &title) {
114
+ thing.setTitle (title);
115
+ if (auto *handler = thing.getAccessibilityHandler ())
116
+ {
117
+ handler->notifyAccessibilityEvent (juce::AccessibilityEvent::titleChanged);
118
+ handler->notifyAccessibilityEvent (juce::AccessibilityEvent::valueChanged);
119
+ }
120
+ };
121
+
122
+ for (int i = 0 ; i < n_fx_params; ++i)
123
+ {
124
+ auto knob = std::make_unique<sst::jucegui::components::Knob>();
125
+ auto knobSource = std::make_unique<KnobSource>(processor, fxParamDisplay[i], i);
126
+
127
+ // knob->setStyle(styleSheet);
128
+ knob->setModulationDisplay (sst::jucegui::components::Knob::Modulatable::NONE);
129
+
130
+ auto paramName = processor.getParamName (i) + " " + processor.getParamGroup (i);
131
+ knobSource->setValueFromGUI (processor.getFXStorageValue01 (i));
132
+ auto name = paramName + " Knob" ;
133
+ knobSource->setLabel (name);
134
+
135
+ knob->setSource (knobSource.get ());
136
+ knob->setEnabled (processor.getParamEnabled (i));
137
+
138
+ addAndMakeVisible (*knob);
139
+ knobs.push_back (std::move (knob));
140
+ sources.push_back (std::move (knobSource));
141
+
142
+ fxParamDisplay[i].setDisplay (processor.getParamValue (i).c_str ());
143
+ fxParamDisplay[i].setGroup (processor.getParamGroup (i).c_str ());
144
+ fxParamDisplay[i].setName (processor.getParamName (i).c_str ());
145
+ fxParamDisplay[i].allowsTypein = processor.canSetParameterByString (i);
146
+
147
+ fxParamDisplay[i].setEnabled (processor.getParamEnabled (i));
148
+ fxParamDisplay[i].setAppearsDeactivated (processor.getFXStorageAppearsDeactivated (i));
149
+
150
+ fxTempoSync[i].setEnabled (processor.canTempoSync (i));
151
+ fxTempoSync[i].setAccessible (processor.canTempoSync (i));
152
+ fxTempoSync[i].setToggleState (processor.getFXStorageTempoSync (i),
153
+ juce::NotificationType::dontSendNotification);
154
+ st (fxTempoSync[i], name + " Tempo Synced" );
155
+ fxDeactivated[i].setEnabled (false );
156
+
157
+ fxExtended[i].setEnabled (processor.canExtend (i));
158
+ fxExtended[i].setToggleState (processor.getFXStorageExtended (i),
159
+ juce::NotificationType::dontSendNotification);
160
+ fxExtended[i].setAccessible (processor.canExtend (i));
161
+ st (fxExtended[i], name + " Extended" );
162
+ fxAbsoluted[i].setEnabled (processor.canAbsolute (i));
163
+ fxAbsoluted[i].setToggleState (processor.getFXStorageAbsolute (i),
164
+ juce::NotificationType::dontSendNotification);
165
+ fxAbsoluted[i].setAccessible (processor.canAbsolute (i));
166
+ st (fxAbsoluted[i], name + " Absolute" );
167
+ fxDeactivated[i].setEnabled (processor.canDeactitvate (i));
168
+ fxDeactivated[i].setToggleState (processor.getFXStorageDeactivated (i),
169
+ juce::NotificationType::dontSendNotification);
170
+ fxDeactivated[i].setAccessible (processor.canDeactitvate (i));
171
+ st (fxDeactivated[i], name + " Deactivated" );
172
+ }
173
+ }
174
+ void SurgeFXDefaultEditor::resized ()
175
+ {
176
+ int ypos0 = topSection - 5 ;
177
+ int rowHeight = (getHeight () - topSection - 40 - 10 ) / 6.0 ;
178
+ int byoff = 7 ;
179
+
180
+ int sliderOff = 5 ;
181
+ if (getWidth () < baseWidth)
182
+ sliderOff = 2 ;
183
+
184
+ for (int i = 0 ; i < n_fx_params; ++i)
185
+ {
186
+ juce::Rectangle<int > position{(i / 6 ) * getWidth () / 2 + sliderOff,
187
+ (i % 6 ) * rowHeight + ypos0, rowHeight - sliderOff,
188
+ rowHeight - sliderOff};
189
+
190
+ position = position.reduced (position.getWidth () * 0.10 , position.getHeight () * 0.10 );
191
+
192
+ knobs.at (i).get ()->setBounds (position);
193
+
194
+ int buttonSize = 19 ;
195
+ if (getWidth () < baseWidth)
196
+ buttonSize = 17 ;
197
+ int buttonMargin = 1 ;
198
+ juce::Rectangle<int > tsPos{(i / 6 ) * getWidth () / 2 + 2 + rowHeight - 5 ,
199
+ (i % 6 ) * rowHeight + ypos0 + byoff + buttonMargin, buttonSize,
200
+ buttonSize};
201
+ fxTempoSync[i].setBounds (tsPos);
202
+
203
+ juce::Rectangle<int > daPos{(i / 6 ) * getWidth () / 2 + 2 + rowHeight - 5 ,
204
+ (i % 6 ) * rowHeight + ypos0 + byoff + 2 * buttonMargin +
205
+ buttonSize,
206
+ buttonSize, buttonSize};
207
+ fxDeactivated[i].setBounds (daPos);
208
+
209
+ juce::Rectangle<int > exPos{
210
+ (i / 6 ) * getWidth () / 2 + 2 + rowHeight - 5 + buttonMargin + buttonSize,
211
+ (i % 6 ) * rowHeight + ypos0 + byoff + 1 * buttonMargin + 0 * buttonSize, buttonSize,
212
+ buttonSize};
213
+ fxExtended[i].setBounds (exPos);
214
+
215
+ juce::Rectangle<int > abPos{
216
+ (i / 6 ) * getWidth () / 2 + 2 + rowHeight - 5 + buttonMargin + buttonSize,
217
+ (i % 6 ) * rowHeight + ypos0 + byoff + 2 * buttonMargin + 1 * buttonSize, buttonSize,
218
+ buttonSize};
219
+ fxAbsoluted[i].setBounds (abPos);
220
+
221
+ juce::Rectangle<int > dispPos{
222
+ (i / 6 ) * getWidth () / 2 + 4 + rowHeight - 5 + 2 * buttonMargin + 2 * buttonSize,
223
+ (i % 6 ) * rowHeight + ypos0,
224
+ getWidth () / 2 - rowHeight - 8 - 2 * buttonMargin - 2 * buttonSize, rowHeight - 5 };
225
+ fxParamDisplay[i].setBounds (dispPos);
226
+ }
227
+ }
0 commit comments