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.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. #pragma once
  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. */
  27. class JUCE_API AudioDeviceSelectorComponent : public Component,
  28. private ComboBoxListener, // (can't use ComboBox::Listener due to idiotic VC2005 bug)
  29. private ChangeListener,
  30. private Button::Listener,
  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. void buttonClicked (Button*) override;
  78. //==============================================================================
  79. ScopedPointer<ComboBox> deviceTypeDropDown;
  80. ScopedPointer<Label> deviceTypeDropDownLabel;
  81. ScopedPointer<Component> audioDeviceSettingsComp;
  82. String audioDeviceSettingsCompType;
  83. int itemHeight;
  84. const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels;
  85. const bool showChannelsAsStereoPairs;
  86. const bool hideAdvancedOptionsWithButton;
  87. class MidiInputSelectorComponentListBox;
  88. friend struct ContainerDeletePolicy<MidiInputSelectorComponentListBox>;
  89. ScopedPointer<MidiInputSelectorComponentListBox> midiInputsList;
  90. ScopedPointer<ComboBox> midiOutputSelector;
  91. ScopedPointer<Label> midiInputsLabel, midiOutputLabel;
  92. ScopedPointer<TextButton> bluetoothButton;
  93. void comboBoxChanged (ComboBox*) override;
  94. void changeListenerCallback (ChangeBroadcaster*) override;
  95. void updateAllControls();
  96. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioDeviceSelectorComponent)
  97. };