The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
5.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. //==============================================================================
  19. /**
  20. A component containing controls to let the user change the audio settings of
  21. an AudioDeviceManager object.
  22. Very easy to use - just create one of these and show it to the user.
  23. @see AudioDeviceManager
  24. */
  25. class JUCE_API AudioDeviceSelectorComponent : public Component,
  26. private ComboBoxListener, // (can't use ComboBox::Listener due to idiotic VC2005 bug)
  27. private ChangeListener,
  28. private Button::Listener,
  29. private Timer
  30. {
  31. public:
  32. //==============================================================================
  33. /** Creates the component.
  34. If your app needs only output channels, you might ask for a maximum of 0 input
  35. channels, and the component won't display any options for choosing the input
  36. channels. And likewise if you're doing an input-only app.
  37. @param deviceManager the device manager that this component should control
  38. @param minAudioInputChannels the minimum number of audio input channels that the application needs
  39. @param maxAudioInputChannels the maximum number of audio input channels that the application needs
  40. @param minAudioOutputChannels the minimum number of audio output channels that the application needs
  41. @param maxAudioOutputChannels the maximum number of audio output channels that the application needs
  42. @param showMidiInputOptions if true, the component will allow the user to select which midi inputs are enabled
  43. @param showMidiOutputSelector if true, the component will let the user choose a default midi output device
  44. @param showChannelsAsStereoPairs if true, channels will be treated as pairs; if false, channels will be
  45. treated as a set of separate mono channels.
  46. @param hideAdvancedOptionsWithButton if true, only the minimum amount of UI components
  47. are shown, with an "advanced" button that shows the rest of them
  48. */
  49. AudioDeviceSelectorComponent (AudioDeviceManager& deviceManager,
  50. int minAudioInputChannels,
  51. int maxAudioInputChannels,
  52. int minAudioOutputChannels,
  53. int maxAudioOutputChannels,
  54. bool showMidiInputOptions,
  55. bool showMidiOutputSelector,
  56. bool showChannelsAsStereoPairs,
  57. bool hideAdvancedOptionsWithButton);
  58. /** Destructor */
  59. ~AudioDeviceSelectorComponent();
  60. /** The device manager that this component is controlling */
  61. AudioDeviceManager& deviceManager;
  62. /** Sets the standard height used for items in the panel. */
  63. void setItemHeight (int itemHeight);
  64. /** Returns the standard height used for items in the panel. */
  65. int getItemHeight() const noexcept { return itemHeight; }
  66. /** Returns the ListBox that's being used to show the midi inputs, or nullptr if there isn't one. */
  67. ListBox* getMidiInputSelectorListBox() const noexcept;
  68. //==============================================================================
  69. /** @internal */
  70. void resized() override;
  71. /** @internal */
  72. void timerCallback() override;
  73. private:
  74. //==============================================================================
  75. void buttonClicked (Button*) override;
  76. //==============================================================================
  77. ScopedPointer<ComboBox> deviceTypeDropDown;
  78. ScopedPointer<Label> deviceTypeDropDownLabel;
  79. ScopedPointer<Component> audioDeviceSettingsComp;
  80. String audioDeviceSettingsCompType;
  81. int itemHeight;
  82. const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels;
  83. const bool showChannelsAsStereoPairs;
  84. const bool hideAdvancedOptionsWithButton;
  85. class MidiInputSelectorComponentListBox;
  86. friend struct ContainerDeletePolicy<MidiInputSelectorComponentListBox>;
  87. ScopedPointer<MidiInputSelectorComponentListBox> midiInputsList;
  88. ScopedPointer<ComboBox> midiOutputSelector;
  89. ScopedPointer<Label> midiInputsLabel, midiOutputLabel;
  90. ScopedPointer<TextButton> bluetoothButton;
  91. void comboBoxChanged (ComboBox*) override;
  92. void changeListenerCallback (ChangeBroadcaster*) override;
  93. void updateAllControls();
  94. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceSelectorComponent)
  95. };