1919
2020#include " aeolus/engine.h"
2121#include " ui/CustomLookAndFeel.h"
22+ #include " ui/GlobalTuningComponent.h"
2223
2324#include " PluginProcessor.h"
2425#include " PluginEditor.h"
@@ -47,6 +48,7 @@ AeolusAudioProcessorEditor::AeolusAudioProcessorEditor (AeolusAudioProcessor& p)
4748 , _volumeSlider{*p.getParametersContainer ().volume , juce::Slider::LinearHorizontal}
4849 , _volumeLevelL{p.getEngine ().getVolumeLevel ().left , ui::LevelIndicator::Orientation::Horizontal}
4950 , _volumeLevelR{p.getEngine ().getVolumeLevel ().right , ui::LevelIndicator::Orientation::Horizontal}
51+ , _tuningButton{" Tune" }
5052 , _panicButton{" PANIC" }
5153 , _cancelButton{" Cancel" }
5254 , _midiControlChannelLabel{{}, {" Control channel" }}
@@ -106,6 +108,31 @@ AeolusAudioProcessorEditor::AeolusAudioProcessorEditor (AeolusAudioProcessor& p)
106108 _volumeSlider.setSkewFactor (0 .5f );
107109 _volumeSlider.setLookAndFeel (&ui::CustomLookAndFeel::getInstance ());
108110
111+ addAndMakeVisible (_tuningButton);
112+ _tuningButton.onClick = [this ] {
113+ auto content = std::make_unique<ui::GlobalTuningComponent>();
114+ content->setSize (240 , 140 );
115+ auto * contentPtr = content.get ();
116+
117+ auto & box = CallOutBox::launchAsynchronously (std::move (content), _tuningButton.getBounds (), this );
118+ contentPtr->onCancel = [&box] { box.dismiss (); };
119+ contentPtr->onOk = [&box, contentPtr] {
120+ const float freq = contentPtr->getTuningFrequency ();
121+ const auto scaleType = contentPtr->getTuningScaleType ();
122+
123+ auto * g = aeolus::EngineGlobal::getInstance ();
124+ const bool changed = (g->getTuningFrequency () != freq) || (g->getScale ().getType () != scaleType);
125+
126+ if (changed) {
127+ g->setTuningFrequency (freq);
128+ g->setScaleType (scaleType);
129+ g->rebuildRankwaves ();
130+ }
131+
132+ box.dismiss ();
133+ };
134+ };
135+
109136 _panicButton.setColour (TextButton::textColourOffId, Colour (0xFF , 0xFF , 0xFF ));
110137 _panicButton.setColour (TextButton::buttonColourId, Colour (0xCC , 0x33 , 0x00 ));
111138 addAndMakeVisible (_panicButton);
@@ -185,7 +212,7 @@ void AeolusAudioProcessorEditor::resized()
185212
186213 constexpr int margin = 5 ;
187214
188- _versionLabel.setBounds (getWidth () - 60 , margin , 60 - margin, 20 );
215+ _versionLabel.setBounds (getWidth () - 60 , getHeight () - 20 , 60 - margin, 20 );
189216
190217 _cpuLoadLabel.setBounds (margin, margin, 70 , 20 );
191218 _cpuLoadValueLabel.setBounds (_cpuLoadLabel.getRight () + margin, margin, 36 , 20 );
@@ -202,7 +229,9 @@ void AeolusAudioProcessorEditor::resized()
202229 _volumeLevelL.setBounds (_volumeSlider.getX () + 5 , _volumeSlider.getY () + 2 , _volumeSlider.getWidth () - 10 , 2 );
203230 _volumeLevelR.setBounds (_volumeSlider.getX () + 5 , _volumeSlider.getY () + _volumeSlider.getHeight () - 4 , _volumeSlider.getWidth () - 10 , 2 );
204231
205- _panicButton.setBounds (_volumeSlider.getRight () + 40 , margin, 50 , 20 );
232+ _tuningButton.setBounds (_volumeSlider.getRight () + 40 , margin, 60 , 20 );
233+
234+ _panicButton.setBounds (getWidth () - 90 , margin, 50 , 20 );
206235
207236 constexpr int T = margin * 2 + 20 ;
208237 constexpr int sequencerHeight = 26 ;
0 commit comments