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.

123 lines
5.4KB

  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. @tags{Audio}
  28. */
  29. class JUCE_API AudioDeviceSelectorComponent : public Component,
  30. private ChangeListener,
  31. private Timer
  32. {
  33. public:
  34. //==============================================================================
  35. /** Creates the component.
  36. If your app needs only output channels, you might ask for a maximum of 0 input
  37. channels, and the component won't display any options for choosing the input
  38. channels. And likewise if you're doing an input-only app.
  39. @param deviceManager the device manager that this component should control
  40. @param minAudioInputChannels the minimum number of audio input channels that the application needs
  41. @param maxAudioInputChannels the maximum number of audio input channels that the application needs
  42. @param minAudioOutputChannels the minimum number of audio output channels that the application needs
  43. @param maxAudioOutputChannels the maximum number of audio output channels that the application needs
  44. @param showMidiInputOptions if true, the component will allow the user to select which midi inputs are enabled
  45. @param showMidiOutputSelector if true, the component will let the user choose a default midi output device
  46. @param showChannelsAsStereoPairs if true, channels will be treated as pairs; if false, channels will be
  47. treated as a set of separate mono channels.
  48. @param hideAdvancedOptionsWithButton if true, only the minimum amount of UI components
  49. are shown, with an "advanced" button that shows the rest of them
  50. */
  51. AudioDeviceSelectorComponent (AudioDeviceManager& deviceManager,
  52. int minAudioInputChannels,
  53. int maxAudioInputChannels,
  54. int minAudioOutputChannels,
  55. int maxAudioOutputChannels,
  56. bool showMidiInputOptions,
  57. bool showMidiOutputSelector,
  58. bool showChannelsAsStereoPairs,
  59. bool hideAdvancedOptionsWithButton);
  60. /** Destructor */
  61. ~AudioDeviceSelectorComponent();
  62. /** The device manager that this component is controlling */
  63. AudioDeviceManager& deviceManager;
  64. /** Sets the standard height used for items in the panel. */
  65. void setItemHeight (int itemHeight);
  66. /** Returns the standard height used for items in the panel. */
  67. int getItemHeight() const noexcept { return itemHeight; }
  68. /** Returns the ListBox that's being used to show the midi inputs, or nullptr if there isn't one. */
  69. ListBox* getMidiInputSelectorListBox() const noexcept;
  70. //==============================================================================
  71. /** @internal */
  72. void resized() override;
  73. /** @internal */
  74. void timerCallback() override;
  75. private:
  76. //==============================================================================
  77. std::unique_ptr<ComboBox> deviceTypeDropDown;
  78. std::unique_ptr<Label> deviceTypeDropDownLabel;
  79. std::unique_ptr<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. std::unique_ptr<MidiInputSelectorComponentListBox> midiInputsList;
  87. std::unique_ptr<ComboBox> midiOutputSelector;
  88. std::unique_ptr<Label> midiInputsLabel, midiOutputLabel;
  89. std::unique_ptr<TextButton> bluetoothButton;
  90. void handleBluetoothButton();
  91. void updateDeviceType();
  92. void updateMidiOutput();
  93. void changeListenerCallback (ChangeBroadcaster*) override;
  94. void updateAllControls();
  95. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceSelectorComponent)
  96. };
  97. } // namespace juce