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.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. A component containing controls to let the user change the audio settings of
  24. an AudioDeviceManager object.
  25. Very easy to use - just create one of these and show it to the user.
  26. @see AudioDeviceManager
  27. */
  28. class JUCE_API AudioDeviceSelectorComponent : public Component,
  29. private ChangeListener,
  30. private ComboBox::Listener,
  31. private Button::Listener,
  32. private Timer
  33. {
  34. public:
  35. //==============================================================================
  36. /** Creates the component.
  37. If your app needs only output channels, you might ask for a maximum of 0 input
  38. channels, and the component won't display any options for choosing the input
  39. channels. And likewise if you're doing an input-only app.
  40. @param deviceManager the device manager that this component should control
  41. @param minAudioInputChannels the minimum number of audio input channels that the application needs
  42. @param maxAudioInputChannels the maximum number of audio input channels that the application needs
  43. @param minAudioOutputChannels the minimum number of audio output channels that the application needs
  44. @param maxAudioOutputChannels the maximum number of audio output channels that the application needs
  45. @param showMidiInputOptions if true, the component will allow the user to select which midi inputs are enabled
  46. @param showMidiOutputSelector if true, the component will let the user choose a default midi output device
  47. @param showChannelsAsStereoPairs if true, channels will be treated as pairs; if false, channels will be
  48. treated as a set of separate mono channels.
  49. @param hideAdvancedOptionsWithButton if true, only the minimum amount of UI components
  50. are shown, with an "advanced" button that shows the rest of them
  51. */
  52. AudioDeviceSelectorComponent (AudioDeviceManager& deviceManager,
  53. int minAudioInputChannels,
  54. int maxAudioInputChannels,
  55. int minAudioOutputChannels,
  56. int maxAudioOutputChannels,
  57. bool showMidiInputOptions,
  58. bool showMidiOutputSelector,
  59. bool showChannelsAsStereoPairs,
  60. bool hideAdvancedOptionsWithButton);
  61. /** Destructor */
  62. ~AudioDeviceSelectorComponent();
  63. /** The device manager that this component is controlling */
  64. AudioDeviceManager& deviceManager;
  65. /** Sets the standard height used for items in the panel. */
  66. void setItemHeight (int itemHeight);
  67. /** Returns the standard height used for items in the panel. */
  68. int getItemHeight() const noexcept { return itemHeight; }
  69. /** Returns the ListBox that's being used to show the midi inputs, or nullptr if there isn't one. */
  70. ListBox* getMidiInputSelectorListBox() const noexcept;
  71. //==============================================================================
  72. /** @internal */
  73. void resized() override;
  74. /** @internal */
  75. void timerCallback() override;
  76. private:
  77. //==============================================================================
  78. void buttonClicked (Button*) override;
  79. //==============================================================================
  80. ScopedPointer<ComboBox> deviceTypeDropDown;
  81. ScopedPointer<Label> deviceTypeDropDownLabel;
  82. ScopedPointer<Component> audioDeviceSettingsComp;
  83. String audioDeviceSettingsCompType;
  84. int itemHeight;
  85. const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels;
  86. const bool showChannelsAsStereoPairs;
  87. const bool hideAdvancedOptionsWithButton;
  88. class MidiInputSelectorComponentListBox;
  89. friend struct ContainerDeletePolicy<MidiInputSelectorComponentListBox>;
  90. ScopedPointer<MidiInputSelectorComponentListBox> midiInputsList;
  91. ScopedPointer<ComboBox> midiOutputSelector;
  92. ScopedPointer<Label> midiInputsLabel, midiOutputLabel;
  93. ScopedPointer<TextButton> bluetoothButton;
  94. void comboBoxChanged (ComboBox*) override;
  95. void changeListenerCallback (ChangeBroadcaster*) override;
  96. void updateAllControls();
  97. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceSelectorComponent)
  98. };
  99. } // namespace juce