12
12
#include " PluginEditor.h"
13
13
14
14
// ==============================================================================
15
- WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProcessor& p)
16
- : AudioProcessorEditor (&p), processor (p)
15
+ WaveNetVaComponent::WaveNetVaComponent (WaveNetVaAudioProcessor& p)
16
+ : processor (p)
17
17
{
18
18
// Make sure that before the constructor has finished, you've set the
19
19
// editor's size to whatever you need it to
@@ -124,14 +124,11 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc
124
124
ampMasterKnob.setTextBoxStyle (juce::Slider::TextEntryBoxPosition::NoTextBox, false , 50 , 20 );
125
125
ampMasterKnob.setDoubleClickReturnValue (true , 0.5 );
126
126
127
- // Size of plugin GUI
128
- setSize (1085 , 540 );
129
-
130
127
processor.loadConfigAmp ();
131
128
resetImages ();
132
129
}
133
130
134
- WaveNetVaAudioProcessorEditor ::~WaveNetVaAudioProcessorEditor ()
131
+ WaveNetVaComponent ::~WaveNetVaComponent ()
135
132
{
136
133
ampPresenceKnob.setLookAndFeel (nullptr );
137
134
ampCleanBassKnob.setLookAndFeel (nullptr );
@@ -146,7 +143,7 @@ WaveNetVaAudioProcessorEditor::~WaveNetVaAudioProcessorEditor()
146
143
}
147
144
148
145
// ==============================================================================
149
- void WaveNetVaAudioProcessorEditor ::paint (Graphics& g)
146
+ void WaveNetVaComponent ::paint (Graphics& g)
150
147
{
151
148
152
149
// Workaround for graphics on Windows builds (clipping code doesn't work correctly on Windows)
@@ -160,7 +157,7 @@ void WaveNetVaAudioProcessorEditor::paint (Graphics& g)
160
157
161
158
}
162
159
163
- void WaveNetVaAudioProcessorEditor ::resized ()
160
+ void WaveNetVaComponent ::resized ()
164
161
{
165
162
// This is generally where you'll want to lay out the positions of any
166
163
// subcomponents in your editor..
@@ -183,7 +180,7 @@ void WaveNetVaAudioProcessorEditor::resized()
183
180
ampLED.setBounds (975 , 40 , 15 , 25 );
184
181
}
185
182
186
- void WaveNetVaAudioProcessorEditor ::buttonClicked (juce::Button* button)
183
+ void WaveNetVaComponent ::buttonClicked (juce::Button* button)
187
184
{
188
185
if (button == &OnButton) {
189
186
ampOnButtonClicked ();
@@ -192,7 +189,7 @@ void WaveNetVaAudioProcessorEditor::buttonClicked(juce::Button* button)
192
189
}
193
190
}
194
191
195
- void WaveNetVaAudioProcessorEditor ::ampOnButtonClicked () {
192
+ void WaveNetVaComponent ::ampOnButtonClicked () {
196
193
if (processor.amp_state == 0 ) {
197
194
processor.amp_state = 1 ;
198
195
}
@@ -202,7 +199,7 @@ void WaveNetVaAudioProcessorEditor::ampOnButtonClicked() {
202
199
resetImages ();
203
200
}
204
201
205
- void WaveNetVaAudioProcessorEditor ::ampCleanLeadButtonClicked () {
202
+ void WaveNetVaComponent ::ampCleanLeadButtonClicked () {
206
203
if (processor.amp_lead == 1 ) {
207
204
processor.amp_lead = 0 ;
208
205
processor.loadConfigAmp ();
@@ -217,7 +214,7 @@ void WaveNetVaAudioProcessorEditor::ampCleanLeadButtonClicked() {
217
214
resetImages ();
218
215
}
219
216
220
- void WaveNetVaAudioProcessorEditor ::sliderValueChanged (Slider* slider)
217
+ void WaveNetVaComponent ::sliderValueChanged (Slider* slider)
221
218
{
222
219
// Amp
223
220
@@ -238,7 +235,7 @@ void WaveNetVaAudioProcessorEditor::sliderValueChanged(Slider* slider)
238
235
239
236
}
240
237
241
- void WaveNetVaAudioProcessorEditor ::resetImages ()
238
+ void WaveNetVaComponent ::resetImages ()
242
239
{
243
240
if (processor.amp_state == 1 && processor.amp_lead == 1 ) {
244
241
background_set = background_lead;
@@ -289,3 +286,45 @@ void WaveNetVaAudioProcessorEditor::resetImages()
289
286
}
290
287
repaint ();
291
288
}
289
+
290
+ float WaveNetVaComponent::getGuiScaleFactor ()
291
+ {
292
+ return static_cast <float > (processor.gui_scale_factor );
293
+ }
294
+
295
+ void WaveNetVaComponent::persistGuiScaleFactor (float scaleFactor)
296
+ {
297
+ processor.gui_scale_factor = static_cast <double > (scaleFactor);
298
+ }
299
+
300
+ // Wrapper implementation
301
+ WrappedWaveNetVaAudioProcessorEditor::WrappedWaveNetVaAudioProcessorEditor (WaveNetVaAudioProcessor& p)
302
+ : AudioProcessorEditor(p), waveNetVaComponent(p)
303
+ {
304
+ addAndMakeVisible (waveNetVaComponent);
305
+
306
+ if (auto * constrainer = getConstrainer ())
307
+ {
308
+ constrainer->setFixedAspectRatio (static_cast <double > (originalWidth) / static_cast <double > (originalHeight));
309
+ constrainer->setSizeLimits (originalWidth / 4 , originalHeight / 4 , originalWidth * 2 , originalHeight * 2 );
310
+ }
311
+
312
+ setResizable (true , true );
313
+ float scaledWidth = static_cast <float > (originalWidth) * waveNetVaComponent.getGuiScaleFactor ();
314
+ float scaledHeight = static_cast <float > (originalHeight) * waveNetVaComponent.getGuiScaleFactor ();
315
+ setSize (scaledWidth, scaledHeight);
316
+ resetImages ();
317
+ }
318
+
319
+ void WrappedWaveNetVaAudioProcessorEditor::resized ()
320
+ {
321
+ const auto scaleFactor = static_cast <float > (getWidth ()) / originalWidth;
322
+ waveNetVaComponent.setTransform (AffineTransform::scale (scaleFactor));
323
+ waveNetVaComponent.setBounds (0 , 0 , originalWidth, originalHeight);
324
+ waveNetVaComponent.persistGuiScaleFactor (scaleFactor);
325
+ }
326
+
327
+ void WrappedWaveNetVaAudioProcessorEditor::resetImages ()
328
+ {
329
+ waveNetVaComponent.resetImages ();
330
+ }
0 commit comments