@@ -122,84 +122,85 @@ class LimiterSettings final : public Component {
122122 TextButton four = TextButton(" 3db" );
123123};
124124
125- class AudioOutputSettings final : public Component {
126-
125+ class AudioSettingsCallout final : public Component {
127126public:
128- enum Type {
129- Limiter,
130- Oversampling
131- };
132-
133- AudioOutputSettings (PluginProcessor* pd, AudioOutputSettings::Type const typeToShow, std::function<void ()> const & changeCallback)
134- : limiterSettings(SettingsFile::getInstance()->getProperty<int >(" limiter_threshold" ))
127+ explicit AudioSettingsCallout (PluginEditor* editor)
128+ : pd(editor->pd)
129+ , limiterSettings(SettingsFile::getInstance()->getProperty<int>(" limiter_threshold" ))
135130 , oversampleSettings(std::clamp(SettingsFile::getInstance()->getProperty<int>(" oversampling" ), 0, 3))
136- , type(typeToShow)
137- , onChange(changeCallback)
138- {
139- if (type == Limiter) {
140- addAndMakeVisible (limiterSettings);
141- limiterSettings.onChange = [this , pd](int const value) {
142- pd->setLimiterThreshold (value);
143- onChange ();
144- };
145- } else {
146- addAndMakeVisible (oversampleSettings);
147- oversampleSettings.onChange = [this , pd](int const value) {
148- pd->setOversampling (value);
149- onChange ();
150- };
151- }
152-
153- setSize (170 , 60 );
154- }
155-
156- ~AudioOutputSettings () override
157131 {
158- isShowing = false ;
132+ limiterLabel.setText (" Limiter" , dontSendNotification);
133+ limiterLabel.setFont (Fonts::getSemiBoldFont ().withHeight (13 .5f ));
134+ addAndMakeVisible (limiterLabel);
135+
136+ limiterSettings.onChange = [this ](int const value) {
137+ pd->setLimiterThreshold (value);
138+ };
139+ addAndMakeVisible (limiterSettings);
140+
141+ oversamplingLabel.setText (" Oversampling" , dontSendNotification);
142+ oversamplingLabel.setFont (Fonts::getSemiBoldFont ().withHeight (13 .5f ));
143+ addAndMakeVisible (oversamplingLabel);
144+
145+ oversampleSettings.onChange = [this , editor](int const value) {
146+ pd->setOversampling (value);
147+ editor->audioToolbar ->updateOversampling ();
148+ };
149+ addAndMakeVisible (oversampleSettings);
150+
151+ audioSettingsButton.setButtonText (" Audio Settings..." );
152+ audioSettingsButton.onClick = [this , editor] {
153+ Dialogs::showSettingsDialog (editor);
154+ closeCalloutBox ();
155+ };
156+
157+ audioSettingsButton.setColour (TextButton::textColourOffId, PlugDataColours::popupMenuTextColour);
158+ audioSettingsButton.setColour (TextButton::textColourOnId, PlugDataColours::popupMenuTextColour);
159+ audioSettingsButton.setColour (TextButton::buttonColourId, PlugDataColours::popupMenuBackgroundColour.contrasting (0 .04f ));
160+ audioSettingsButton.setColour (TextButton::buttonOnColourId, PlugDataColours::popupMenuBackgroundColour.contrasting (0 .075f ));
161+ audioSettingsButton.setColour (ComboBox::outlineColourId, Colours::transparentBlack);
162+ addAndMakeVisible (audioSettingsButton);
163+
164+ setSize (200 , 146 );
159165 }
160166
161167 void resized () override
162168 {
163- auto bounds = getLocalBounds ().reduced (4 .0f ).withTrimmedTop (24 );
169+ auto b = getLocalBounds ().reduced (10 , 8 );
170+ constexpr int labelHeight = 18 ;
171+ constexpr int selectorHeight = 28 ;
172+ constexpr int gap = 6 ;
164173
165- if (type == Limiter) {
166- limiterSettings.setBounds (bounds.removeFromTop (28 ));
167- } else {
168- oversampleSettings.setBounds (bounds.removeFromTop (28 ));
169- }
170- }
174+ limiterLabel.setBounds (b.removeFromTop (labelHeight));
175+ limiterSettings.setBounds (b.removeFromTop (selectorHeight));
176+ b.removeFromTop (gap);
171177
172- void paint (Graphics& g) override
173- {
174- if (type == Limiter) {
175- g.setColour (PlugDataColours::popupMenuTextColour);
176- g.setFont (Fonts::getBoldFont ().withHeight (15 ));
177- g.drawText (" Limiter Threshold" , 0 , 0 , getWidth (), 24 , Justification::centred);
178- } else {
179- g.setColour (PlugDataColours::popupMenuTextColour);
180- g.setFont (Fonts::getBoldFont ().withHeight (15 ));
181- g.drawText (" Oversampling" , 0 , 0 , getWidth (), 24 , Justification::centred);
182- }
178+ oversamplingLabel.setBounds (b.removeFromTop (labelHeight));
179+ oversampleSettings.setBounds (b.removeFromTop (selectorHeight));
180+ b.removeFromTop (gap + 4 );
183181
184- g.setColour (PlugDataColours::toolbarOutlineColour);
185- g.drawLine (4 , 24 , getWidth () - 8 , 24 );
182+ audioSettingsButton.setBounds (b.removeFromTop (selectorHeight - 4 ));
186183 }
187184
188- static void show (PluginEditor* editor, Rectangle< int > const bounds, AudioOutputSettings::Type typeToShow, std::function< void ()> changeCallback = [] { } )
185+ void closeCalloutBox ( )
189186 {
190- if (isShowing)
191- return ;
192-
193- isShowing = true ;
194-
195- auto audioOutputSettings = std::make_unique<AudioOutputSettings>(editor->pd , typeToShow, changeCallback);
196- editor->showCalloutBox (std::move (audioOutputSettings), bounds);
187+ MessageManager::callAsync ([_callout = SafePointer (findParentComponentOfClass<CallOutBox>())]() {
188+ if (_callout)
189+ _callout->dismiss ();
190+ });
197191 }
198192
199193private:
200- static inline bool isShowing = false ;
194+ PluginProcessor* pd;
195+
196+ Label limiterLabel;
201197 LimiterSettings limiterSettings;
198+
199+ Label oversamplingLabel;
202200 OversampleSettings oversampleSettings;
203- Type type;
204- std::function<void ()> onChange;
201+
202+ TextButton audioSettingsButton;
203+
204+ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSettingsCallout)
205205};
206+
0 commit comments