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.

120 lines
5.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A component containing controls to let the user change the audio settings of
  23. an AudioDeviceManager object.
  24. Very easy to use - just create one of these and show it to the user.
  25. @see AudioDeviceManager
  26. @tags{Audio}
  27. */
  28. class JUCE_API AudioDeviceSelectorComponent : public Component,
  29. private ChangeListener
  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() override;
  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. private:
  72. //==============================================================================
  73. void handleBluetoothButton();
  74. void updateDeviceType();
  75. void updateMidiOutput();
  76. void changeListenerCallback (ChangeBroadcaster*) override;
  77. void updateAllControls();
  78. std::unique_ptr<ComboBox> deviceTypeDropDown;
  79. std::unique_ptr<Label> deviceTypeDropDownLabel;
  80. std::unique_ptr<Component> audioDeviceSettingsComp;
  81. String audioDeviceSettingsCompType;
  82. int itemHeight = 0;
  83. const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels;
  84. const bool showChannelsAsStereoPairs;
  85. const bool hideAdvancedOptionsWithButton;
  86. class MidiInputSelectorComponentListBox;
  87. Array<MidiDeviceInfo> currentMidiOutputs;
  88. std::unique_ptr<MidiInputSelectorComponentListBox> midiInputsList;
  89. std::unique_ptr<ComboBox> midiOutputSelector;
  90. std::unique_ptr<Label> midiInputsLabel, midiOutputLabel;
  91. std::unique_ptr<TextButton> bluetoothButton;
  92. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceSelectorComponent)
  93. };
  94. } // namespace juce