diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index af08235643..a9cd7df0fe 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -213,8 +213,9 @@ class AudioDeviceSettingsPanel : public Component, { public: AudioDeviceSettingsPanel (AudioIODeviceType& t, AudioDeviceSetupDetails& setupDetails, - const bool hideAdvancedOptionsWithButton) - : type (t), setup (setupDetails) + const bool hideAdvancedOptionsWithButton, + AudioDeviceSelectorComponent& p) + : type (t), setup (setupDetails), parent (p) { if (hideAdvancedOptionsWithButton) { @@ -238,120 +239,113 @@ public: void resized() override { - if (auto* parent = findParentComponentOfClass()) + Rectangle r (proportionOfWidth (0.35f), 0, proportionOfWidth (0.6f), 3000); + + const int maxListBoxHeight = 100; + const int h = parent.getItemHeight(); + const int space = h / 4; + + if (outputDeviceDropDown != nullptr) { - Rectangle r (proportionOfWidth (0.35f), 0, proportionOfWidth (0.6f), 3000); + auto row = r.removeFromTop (h); - const int maxListBoxHeight = 100; - const int h = parent->getItemHeight(); - const int space = h / 4; - - if (outputDeviceDropDown != nullptr) + if (testButton != nullptr) { - auto row = r.removeFromTop (h); - - if (testButton != nullptr) - { - testButton->changeWidthToFitText (h); - testButton->setBounds (row.removeFromRight (testButton->getWidth())); - row.removeFromRight (space); - } - - outputDeviceDropDown->setBounds (row); - r.removeFromTop (space); - } - - if (inputDeviceDropDown != nullptr) - { - auto row = r.removeFromTop (h); - - inputLevelMeter->setBounds (row.removeFromRight (testButton != nullptr ? testButton->getWidth() : row.getWidth() / 6)); + testButton->changeWidthToFitText (h); + testButton->setBounds (row.removeFromRight (testButton->getWidth())); row.removeFromRight (space); - inputDeviceDropDown->setBounds (row); + } + + outputDeviceDropDown->setBounds (row); + r.removeFromTop (space); + } + + if (inputDeviceDropDown != nullptr) + { + auto row = r.removeFromTop (h); + + inputLevelMeter->setBounds (row.removeFromRight (testButton != nullptr ? testButton->getWidth() : row.getWidth() / 6)); + row.removeFromRight (space); + inputDeviceDropDown->setBounds (row); + r.removeFromTop (space); + } + + if (outputChanList != nullptr) + { + outputChanList->setRowHeight (jmin (22, h)); + outputChanList->setBounds (r.removeFromTop (outputChanList->getBestHeight (maxListBoxHeight))); + outputChanLabel->setBounds (0, outputChanList->getBounds().getCentreY() - h / 2, r.getX(), h); + r.removeFromTop (space); + } + + if (inputChanList != nullptr) + { + inputChanList->setRowHeight (jmin (22, h)); + inputChanList->setBounds (r.removeFromTop (inputChanList->getBestHeight (maxListBoxHeight))); + inputChanLabel->setBounds (0, inputChanList->getBounds().getCentreY() - h / 2, r.getX(), h); + r.removeFromTop (space); + } + + r.removeFromTop (space * 2); + + if (showAdvancedSettingsButton != nullptr + && sampleRateDropDown != nullptr && bufferSizeDropDown != nullptr) + { + showAdvancedSettingsButton->setBounds (r.removeFromTop (h)); + r.removeFromTop (space); + showAdvancedSettingsButton->changeWidthToFitText(); + } + + auto advancedSettingsVisible = showAdvancedSettingsButton == nullptr + || showAdvancedSettingsButton->getToggleState(); + + if (sampleRateDropDown != nullptr) + { + sampleRateDropDown->setVisible (advancedSettingsVisible); + + if (advancedSettingsVisible) + { + sampleRateDropDown->setBounds (r.removeFromTop (h)); r.removeFromTop (space); } + } - if (outputChanList != nullptr) + if (bufferSizeDropDown != nullptr) + { + bufferSizeDropDown->setVisible (advancedSettingsVisible); + + if (advancedSettingsVisible) { - outputChanList->setRowHeight (jmin (22, h)); - outputChanList->setBounds (r.removeFromTop (outputChanList->getBestHeight (maxListBoxHeight))); - outputChanLabel->setBounds (0, outputChanList->getBounds().getCentreY() - h / 2, r.getX(), h); + bufferSizeDropDown->setBounds (r.removeFromTop (h)); r.removeFromTop (space); } + } - if (inputChanList != nullptr) + r.removeFromTop (space); + + if (showUIButton != nullptr || resetDeviceButton != nullptr) + { + auto buttons = r.removeFromTop (h); + + if (showUIButton != nullptr) { - inputChanList->setRowHeight (jmin (22, h)); - inputChanList->setBounds (r.removeFromTop (inputChanList->getBestHeight (maxListBoxHeight))); - inputChanLabel->setBounds (0, inputChanList->getBounds().getCentreY() - h / 2, r.getX(), h); - r.removeFromTop (space); + showUIButton->setVisible (advancedSettingsVisible); + showUIButton->changeWidthToFitText (h); + showUIButton->setBounds (buttons.removeFromLeft (showUIButton->getWidth())); + buttons.removeFromLeft (space); } - r.removeFromTop (space * 2); - - if (showAdvancedSettingsButton != nullptr - && sampleRateDropDown != nullptr && bufferSizeDropDown != nullptr) + if (resetDeviceButton != nullptr) { - showAdvancedSettingsButton->setBounds (r.removeFromTop (h)); - r.removeFromTop (space); - showAdvancedSettingsButton->changeWidthToFitText(); - } - - auto advancedSettingsVisible = showAdvancedSettingsButton == nullptr - || showAdvancedSettingsButton->getToggleState(); - - if (sampleRateDropDown != nullptr) - { - sampleRateDropDown->setVisible (advancedSettingsVisible); - - if (advancedSettingsVisible) - { - sampleRateDropDown->setBounds (r.removeFromTop (h)); - r.removeFromTop (space); - } - } - - if (bufferSizeDropDown != nullptr) - { - bufferSizeDropDown->setVisible (advancedSettingsVisible); - - if (advancedSettingsVisible) - { - bufferSizeDropDown->setBounds (r.removeFromTop (h)); - r.removeFromTop (space); - } + resetDeviceButton->setVisible (advancedSettingsVisible); + resetDeviceButton->changeWidthToFitText (h); + resetDeviceButton->setBounds (buttons.removeFromLeft (resetDeviceButton->getWidth())); } r.removeFromTop (space); - - if (showUIButton != nullptr || resetDeviceButton != nullptr) - { - auto buttons = r.removeFromTop (h); - - if (showUIButton != nullptr) - { - showUIButton->setVisible (advancedSettingsVisible); - showUIButton->changeWidthToFitText (h); - showUIButton->setBounds (buttons.removeFromLeft (showUIButton->getWidth())); - buttons.removeFromLeft (space); - } - - if (resetDeviceButton != nullptr) - { - resetDeviceButton->setVisible (advancedSettingsVisible); - resetDeviceButton->changeWidthToFitText (h); - resetDeviceButton->setBounds (buttons.removeFromLeft (resetDeviceButton->getWidth())); - } - - r.removeFromTop (space); - } - - setSize (getWidth(), r.getY()); - } - else - { - jassertfalse; } + + setSize (getWidth(), r.getY()); } void updateConfig (bool updateOutputDevice, bool updateInputDevice, bool updateSampleRate, bool updateBufferSize) @@ -542,6 +536,7 @@ public: private: AudioIODeviceType& type; const AudioDeviceSetupDetails setup; + AudioDeviceSelectorComponent& parent; std::unique_ptr outputDeviceDropDown, inputDeviceDropDown, sampleRateDropDown, bufferSizeDropDown; std::unique_ptr