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.

116 lines
5.1KB

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