1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

AudioDeviceSelector: Use make_unique instead of reset

This commit is contained in:
Anthony Nicholls 2023-09-13 15:02:46 +01:00
parent 8c65efe99b
commit 27fad0f975

View file

@ -218,7 +218,7 @@ public:
{
if (hideAdvancedOptionsWithButton)
{
showAdvancedSettingsButton.reset (new TextButton (TRANS("Show advanced settings...")));
showAdvancedSettingsButton = std::make_unique <TextButton> (TRANS ("Show advanced settings..."));
addAndMakeVisible (showAdvancedSettingsButton.get());
showAdvancedSettingsButton->setClickingTogglesState (true);
showAdvancedSettingsButton->onClick = [this] { toggleAdvancedSettings(); };
@ -460,10 +460,10 @@ public:
{
if (outputChanList == nullptr)
{
outputChanList.reset (new ChannelSelectorListBox (setup, ChannelSelectorListBox::audioOutputType,
TRANS ("(no audio output channels found)")));
outputChanList = std::make_unique<ChannelSelectorListBox> (setup, ChannelSelectorListBox::audioOutputType,
TRANS ("(no audio output channels found)"));
addAndMakeVisible (outputChanList.get());
outputChanLabel.reset (new Label ({}, TRANS("Active output channels:")));
outputChanLabel = std::make_unique<Label> (String{}, TRANS ("Active output channels:"));
outputChanLabel->setJustificationType (Justification::centredRight);
outputChanLabel->attachToComponent (outputChanList.get(), true);
}
@ -481,10 +481,10 @@ public:
{
if (inputChanList == nullptr)
{
inputChanList.reset (new ChannelSelectorListBox (setup, ChannelSelectorListBox::audioInputType,
TRANS("(no audio input channels found)")));
inputChanList = std::make_unique<ChannelSelectorListBox> (setup, ChannelSelectorListBox::audioInputType,
TRANS ("(no audio input channels found)"));
addAndMakeVisible (inputChanList.get());
inputChanLabel.reset (new Label ({}, TRANS("Active input channels:")));
inputChanLabel = std::make_unique<Label> (String{}, TRANS ("Active input channels:"));
inputChanLabel->setJustificationType (Justification::centredRight);
inputChanLabel->attachToComponent (inputChanList.get(), true);
}
@ -591,8 +591,8 @@ private:
if (currentDevice != nullptr && currentDevice->hasControlPanel())
{
showUIButton.reset (new TextButton (TRANS ("Control Panel"),
TRANS ("Opens the device's own control panel")));
showUIButton = std::make_unique<TextButton> (TRANS ("Control Panel"),
TRANS ("Opens the device's own control panel"));
addAndMakeVisible (showUIButton.get());
showUIButton->onClick = [this] { showDeviceUIPanel(); };
}
@ -608,8 +608,8 @@ private:
{
if (resetDeviceButton == nullptr)
{
resetDeviceButton.reset (new TextButton (TRANS ("Reset Device"),
TRANS ("Resets the audio interface - sometimes needed after changing a device's properties in its custom control panel")));
resetDeviceButton = std::make_unique<TextButton> (TRANS ("Reset Device"),
TRANS ("Resets the audio interface - sometimes needed after changing a device's properties in its custom control panel"));
addAndMakeVisible (resetDeviceButton.get());
resetDeviceButton->onClick = [this] { resetDevice(); };
resized();
@ -628,18 +628,18 @@ private:
{
if (outputDeviceDropDown == nullptr)
{
outputDeviceDropDown.reset (new ComboBox());
outputDeviceDropDown = std::make_unique<ComboBox>();
outputDeviceDropDown->onChange = [this] { updateConfig (true, false, false, false); };
addAndMakeVisible (outputDeviceDropDown.get());
outputDeviceLabel.reset (new Label ({}, type.hasSeparateInputsAndOutputs() ? TRANS("Output:")
: TRANS("Device:")));
outputDeviceLabel = std::make_unique<Label> (String{}, type.hasSeparateInputsAndOutputs() ? TRANS ("Output:")
: TRANS ("Device:"));
outputDeviceLabel->attachToComponent (outputDeviceDropDown.get(), true);
if (setup.maxNumOutputChannels > 0)
{
testButton.reset (new TextButton (TRANS("Test"), TRANS("Plays a test tone")));
testButton = std::make_unique<TextButton> (TRANS ("Test"), TRANS ("Plays a test tone"));
addAndMakeVisible (testButton.get());
testButton->onClick = [this] { playTestSound(); };
}
@ -657,14 +657,14 @@ private:
{
if (inputDeviceDropDown == nullptr)
{
inputDeviceDropDown.reset (new ComboBox());
inputDeviceDropDown = std::make_unique<ComboBox>();
inputDeviceDropDown->onChange = [this] { updateConfig (false, true, false, false); };
addAndMakeVisible (inputDeviceDropDown.get());
inputDeviceLabel.reset (new Label ({}, TRANS("Input:")));
inputDeviceLabel = std::make_unique<Label> (String{}, TRANS ("Input:"));
inputDeviceLabel->attachToComponent (inputDeviceDropDown.get(), true);
inputLevelMeter.reset (new SimpleDeviceManagerInputLevelMeter (*setup.manager));
inputLevelMeter = std::make_unique<SimpleDeviceManagerInputLevelMeter> (*setup.manager);
addAndMakeVisible (inputLevelMeter.get());
}
@ -678,10 +678,10 @@ private:
{
if (sampleRateDropDown == nullptr)
{
sampleRateDropDown.reset (new ComboBox());
sampleRateDropDown = std::make_unique<ComboBox>();
addAndMakeVisible (sampleRateDropDown.get());
sampleRateLabel.reset (new Label ({}, TRANS("Sample rate:")));
sampleRateLabel = std::make_unique<Label> (String{}, TRANS ("Sample rate:"));
sampleRateLabel->attachToComponent (sampleRateDropDown.get(), true);
}
else
@ -708,10 +708,10 @@ private:
{
if (bufferSizeDropDown == nullptr)
{
bufferSizeDropDown.reset (new ComboBox());
bufferSizeDropDown = std::make_unique<ComboBox>();
addAndMakeVisible (bufferSizeDropDown.get());
bufferSizeLabel.reset (new Label ({}, TRANS("Audio buffer size:")));
bufferSizeLabel = std::make_unique<Label> (String{}, TRANS ("Audio buffer size:"));
bufferSizeLabel->attachToComponent (bufferSizeDropDown.get(), true);
}
else
@ -1000,7 +1000,7 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
if (types.size() > 1)
{
deviceTypeDropDown.reset (new ComboBox());
deviceTypeDropDown = std::make_unique<ComboBox>();
for (int i = 0; i < types.size(); ++i)
deviceTypeDropDown->addItem (types.getUnchecked(i)->getTypeName(), i + 1);
@ -1008,24 +1008,24 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
addAndMakeVisible (deviceTypeDropDown.get());
deviceTypeDropDown->onChange = [this] { updateDeviceType(); };
deviceTypeDropDownLabel.reset (new Label ({}, TRANS("Audio device type:")));
deviceTypeDropDownLabel = std::make_unique<Label> (String{}, TRANS ("Audio device type:"));
deviceTypeDropDownLabel->setJustificationType (Justification::centredRight);
deviceTypeDropDownLabel->attachToComponent (deviceTypeDropDown.get(), true);
}
if (showMidiInputOptions)
{
midiInputsList.reset (new MidiInputSelectorComponentListBox (deviceManager,
"(" + TRANS("No MIDI inputs available") + ")"));
midiInputsList = std::make_unique <MidiInputSelectorComponentListBox> (deviceManager,
"(" + TRANS ("No MIDI inputs available") + ")");
addAndMakeVisible (midiInputsList.get());
midiInputsLabel.reset (new Label ({}, TRANS ("Active MIDI inputs:")));
midiInputsLabel = std::make_unique<Label> (String{}, TRANS ("Active MIDI inputs:"));
midiInputsLabel->setJustificationType (Justification::topRight);
midiInputsLabel->attachToComponent (midiInputsList.get(), true);
if (BluetoothMidiDevicePairingDialogue::isAvailable())
{
bluetoothButton.reset (new TextButton (TRANS("Bluetooth MIDI"), TRANS("Scan for bluetooth MIDI devices")));
bluetoothButton = std::make_unique<TextButton> (TRANS ("Bluetooth MIDI"), TRANS ("Scan for bluetooth MIDI devices"));
addAndMakeVisible (bluetoothButton.get());
bluetoothButton->onClick = [this] { handleBluetoothButton(); };
}
@ -1039,11 +1039,11 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
if (showMidiOutputSelector)
{
midiOutputSelector.reset (new ComboBox());
midiOutputSelector = std::make_unique<ComboBox>();
addAndMakeVisible (midiOutputSelector.get());
midiOutputSelector->onChange = [this] { updateMidiOutput(); };
midiOutputLabel.reset (new Label ("lm", TRANS("MIDI Output:")));
midiOutputLabel = std::make_unique<Label> ("lm", TRANS ("MIDI Output:"));
midiOutputLabel->attachToComponent (midiOutputSelector.get(), true);
}
else
@ -1154,10 +1154,10 @@ void AudioDeviceSelectorComponent::updateAllControls()
details.maxNumOutputChannels = maxOutputChannels;
details.useStereoPairs = showChannelsAsStereoPairs;
auto* sp = new AudioDeviceSettingsPanel (*type, details, hideAdvancedOptionsWithButton);
audioDeviceSettingsComp.reset (sp);
addAndMakeVisible (sp);
auto sp = std::make_unique<AudioDeviceSettingsPanel> (*type, details, hideAdvancedOptionsWithButton);
addAndMakeVisible (*sp);
sp->updateAllControls();
audioDeviceSettingsComp = std::move (sp);
}
}