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.

125 lines
5.8KB

  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. #ifndef JUCE_AUDIODEVICESELECTORCOMPONENT_H_INCLUDED
  18. #define JUCE_AUDIODEVICESELECTORCOMPONENT_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A component containing controls to let the user change the audio settings of
  22. an AudioDeviceManager object.
  23. Very easy to use - just create one of these and show it to the user.
  24. @see AudioDeviceManager
  25. */
  26. class JUCE_API AudioDeviceSelectorComponent : public Component,
  27. private ComboBoxListener, // (can't use ComboBox::Listener due to idiotic VC2005 bug)
  28. private ChangeListener,
  29. private Button::Listener,
  30. private Timer
  31. {
  32. public:
  33. //==============================================================================
  34. /** Creates the component.
  35. If your app needs only output channels, you might ask for a maximum of 0 input
  36. channels, and the component won't display any options for choosing the input
  37. channels. And likewise if you're doing an input-only app.
  38. @param deviceManager the device manager that this component should control
  39. @param minAudioInputChannels the minimum number of audio input channels that the application needs
  40. @param maxAudioInputChannels the maximum number of audio input channels that the application needs
  41. @param minAudioOutputChannels the minimum number of audio output channels that the application needs
  42. @param maxAudioOutputChannels the maximum number of audio output channels that the application needs
  43. @param showMidiInputOptions if true, the component will allow the user to select which midi inputs are enabled
  44. @param showMidiOutputSelector if true, the component will let the user choose a default midi output device
  45. @param showChannelsAsStereoPairs if true, channels will be treated as pairs; if false, channels will be
  46. treated as a set of separate mono channels.
  47. @param hideAdvancedOptionsWithButton if true, only the minimum amount of UI components
  48. are shown, with an "advanced" button that shows the rest of them
  49. */
  50. AudioDeviceSelectorComponent (AudioDeviceManager& deviceManager,
  51. int minAudioInputChannels,
  52. int maxAudioInputChannels,
  53. int minAudioOutputChannels,
  54. int maxAudioOutputChannels,
  55. bool showMidiInputOptions,
  56. bool showMidiOutputSelector,
  57. bool showChannelsAsStereoPairs,
  58. bool hideAdvancedOptionsWithButton);
  59. /** Destructor */
  60. ~AudioDeviceSelectorComponent();
  61. /** The device manager that this component is controlling */
  62. AudioDeviceManager& deviceManager;
  63. /** Sets the standard height used for items in the panel. */
  64. void setItemHeight (int itemHeight);
  65. /** Returns the standard height used for items in the panel. */
  66. int getItemHeight() const noexcept { return itemHeight; }
  67. /** Returns the ListBox that's being used to show the midi inputs, or nullptr if there isn't one. */
  68. ListBox* getMidiInputSelectorListBox() const noexcept;
  69. //==============================================================================
  70. /** @internal */
  71. void resized() override;
  72. /** @internal */
  73. void timerCallback() override;
  74. private:
  75. //==============================================================================
  76. void buttonClicked (Button*) override;
  77. //==============================================================================
  78. ScopedPointer<ComboBox> deviceTypeDropDown;
  79. ScopedPointer<Label> deviceTypeDropDownLabel;
  80. ScopedPointer<Component> audioDeviceSettingsComp;
  81. String audioDeviceSettingsCompType;
  82. int itemHeight;
  83. const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels;
  84. const bool showChannelsAsStereoPairs;
  85. const bool hideAdvancedOptionsWithButton;
  86. class MidiInputSelectorComponentListBox;
  87. friend struct ContainerDeletePolicy<MidiInputSelectorComponentListBox>;
  88. ScopedPointer<MidiInputSelectorComponentListBox> midiInputsList;
  89. ScopedPointer<ComboBox> midiOutputSelector;
  90. ScopedPointer<Label> midiInputsLabel, midiOutputLabel;
  91. ScopedPointer<TextButton> bluetoothButton;
  92. void comboBoxChanged (ComboBox*) override;
  93. void changeListenerCallback (ChangeBroadcaster*) override;
  94. void updateAllControls();
  95. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceSelectorComponent)
  96. };
  97. #endif // JUCE_AUDIODEVICESELECTORCOMPONENT_H_INCLUDED