44 if (std::abs (level -
newLevel) > 0.005f)
70static void drawTextLayout (Graphics& g, Component& owner, StringRef text,
const Rectangle<int>&
textBounds,
bool enabled)
80 TextLayout textLayout;
119 .withMultipliedAlpha (0.3f));
121 auto item = items[row];
128 enabled,
true,
true,
false);
130 drawTextLayout (g, *
this, item.name, { x + 5, 0, width - x - 5, height }, enabled);
138 if (e.
x < getTickX())
139 flipEnablement (row);
144 flipEnablement (row);
149 flipEnablement (row);
166 int getBestHeight (
int preferredHeight)
178 const String noItemsMessage;
181 void flipEnablement (
const int row)
185 auto identifier = items[row].identifier;
203 int minNumInputChannels, maxNumInputChannels;
204 int minNumOutputChannels, maxNumOutputChannels;
208static String getNoDeviceString() {
return "<< " +
TRANS (
"none") +
" >>"; }
230 updateListOfDevices();
242 void updateListOfDevices()
248 selector.
addItem (getNoDeviceString(), -1);
254 selector.
addItem (midiOutput.name,
id);
261 void changeListenerCallback (ChangeBroadcaster*)
final { updateListOfDevices(); }
264 AudioDeviceManager& deviceManager;
273 const bool hideAdvancedOptionsWithButton,
277 if (hideAdvancedOptionsWithButton)
279 showAdvancedSettingsButton = std::make_unique <TextButton> (
TRANS (
"Show advanced settings..."));
281 showAdvancedSettingsButton->setClickingTogglesState (
true);
282 showAdvancedSettingsButton->onClick = [
this] { toggleAdvancedSettings(); };
303 const int space = h / 4;
305 if (outputDeviceDropDown !=
nullptr)
309 if (testButton !=
nullptr)
311 testButton->changeWidthToFitText (h);
312 testButton->setBounds (row.removeFromRight (testButton->getWidth()));
313 row.removeFromRight (space);
316 outputDeviceDropDown->setBounds (row);
320 if (inputDeviceDropDown !=
nullptr)
324 inputLevelMeter->setBounds (row.removeFromRight (testButton !=
nullptr ? testButton->getWidth() : row.getWidth() / 6));
325 row.removeFromRight (space);
326 inputDeviceDropDown->setBounds (row);
330 if (outputChanList !=
nullptr)
332 outputChanList->setRowHeight (
jmin (22, h));
334 outputChanLabel->setBounds (0, outputChanList->getBounds().getCentreY() - h / 2, r.
getX(), h);
338 if (inputChanList !=
nullptr)
340 inputChanList->setRowHeight (
jmin (22, h));
342 inputChanLabel->setBounds (0, inputChanList->getBounds().getCentreY() - h / 2, r.
getX(), h);
348 if (showAdvancedSettingsButton !=
nullptr
349 && sampleRateDropDown !=
nullptr && bufferSizeDropDown !=
nullptr)
353 showAdvancedSettingsButton->changeWidthToFitText();
357 || showAdvancedSettingsButton->getToggleState();
359 if (sampleRateDropDown !=
nullptr)
370 if (bufferSizeDropDown !=
nullptr)
383 if (showUIButton !=
nullptr || resetDeviceButton !=
nullptr)
387 if (showUIButton !=
nullptr)
390 showUIButton->changeWidthToFitText (h);
391 showUIButton->setBounds (buttons.removeFromLeft (showUIButton->getWidth()));
392 buttons.removeFromLeft (space);
395 if (resetDeviceButton !=
nullptr)
398 resetDeviceButton->changeWidthToFitText (h);
399 resetDeviceButton->setBounds (buttons.removeFromLeft (resetDeviceButton->getWidth()));
415 if (outputDeviceDropDown !=
nullptr)
416 config.outputDeviceName = outputDeviceDropDown->getSelectedId() < 0 ?
String()
417 : outputDeviceDropDown->getText();
419 if (inputDeviceDropDown !=
nullptr)
420 config.inputDeviceName = inputDeviceDropDown->getSelectedId() < 0 ?
String()
421 : inputDeviceDropDown->getText();
427 config.useDefaultInputChannels =
true;
429 config.useDefaultOutputChannels =
true;
433 showCorrectDeviceName (inputDeviceDropDown.get(),
true);
434 showCorrectDeviceName (outputDeviceDropDown.get(),
false);
436 updateControlPanelButton();
441 if (sampleRateDropDown->getSelectedId() > 0)
443 config.sampleRate = sampleRateDropDown->getSelectedId();
449 if (bufferSizeDropDown->getSelectedId() > 0)
451 config.bufferSize = bufferSizeDropDown->getSelectedId();
458 .withTitle (
TRANS (
"Error when trying to open audio device!"))
460 .withButton (
TRANS (
"OK")),
464 bool showDeviceControlPanel()
473 return device->showControlPanel();
479 void toggleAdvancedSettings()
481 showAdvancedSettingsButton->setButtonText ((showAdvancedSettingsButton->getToggleState() ?
"Hide " :
"Show ")
482 + String (
"advanced settings..."));
486 void showDeviceUIPanel()
488 if (showDeviceControlPanel())
501 void updateAllControls()
503 updateOutputsComboBox();
504 updateInputsComboBox();
506 updateControlPanelButton();
511 if (setup.maxNumOutputChannels > 0
514 if (outputChanList ==
nullptr)
516 outputChanList = std::make_unique<ChannelSelectorListBox> (setup, ChannelSelectorListBox::audioOutputType,
517 TRANS (
"(no audio output channels found)"));
519 outputChanLabel = std::make_unique<Label> (String{},
TRANS (
"Active output channels:"));
521 outputChanLabel->attachToComponent (outputChanList.get(),
true);
524 outputChanList->refresh();
528 outputChanLabel.reset();
529 outputChanList.reset();
532 if (setup.maxNumInputChannels > 0
535 if (inputChanList ==
nullptr)
537 inputChanList = std::make_unique<ChannelSelectorListBox> (setup, ChannelSelectorListBox::audioInputType,
538 TRANS (
"(no audio input channels found)"));
540 inputChanLabel = std::make_unique<Label> (String{},
TRANS (
"Active input channels:"));
542 inputChanLabel->attachToComponent (inputChanList.get(),
true);
545 inputChanList->refresh();
549 inputChanLabel.reset();
550 inputChanList.reset();
553 updateSampleRateComboBox (currentDevice);
554 updateBufferSizeComboBox (currentDevice);
560 inputChanLabel.reset();
561 outputChanLabel.reset();
562 sampleRateLabel.reset();
563 bufferSizeLabel.reset();
565 inputChanList.reset();
566 outputChanList.reset();
567 sampleRateDropDown.reset();
568 bufferSizeDropDown.reset();
570 if (outputDeviceDropDown !=
nullptr)
573 if (inputDeviceDropDown !=
nullptr)
594 AudioIODeviceType& type;
595 const AudioDeviceSetupDetails setup;
596 AudioDeviceSelectorComponent& parent;
599 std::unique_ptr<Label> outputDeviceLabel, inputDeviceLabel, sampleRateLabel, bufferSizeLabel, inputChanLabel, outputChanLabel;
604 void showCorrectDeviceName (ComboBox* box,
bool isInput)
608 auto* currentDevice = setup.manager->getCurrentAudioDevice();
609 auto index = type.getIndexOfDevice (currentDevice, isInput);
613 if (testButton !=
nullptr && ! isInput)
614 testButton->setEnabled (index >= 0);
620 const StringArray
devs (type.getDeviceNames (
isInputs));
624 for (
int i = 0; i <
devs.size(); ++i)
627 combo.addItem (getNoDeviceString(), -1);
631 int getLowestY()
const
641 void updateControlPanelButton()
643 auto* currentDevice = setup.manager->getCurrentAudioDevice();
644 showUIButton.
reset();
646 if (currentDevice !=
nullptr && currentDevice->hasControlPanel())
648 showUIButton = std::make_unique<TextButton> (
TRANS (
"Control Panel"),
649 TRANS (
"Opens the device's own control panel"));
651 showUIButton->onClick = [
this] { showDeviceUIPanel(); };
657 void updateResetButton()
659 if (
auto* currentDevice = setup.manager->getCurrentAudioDevice())
661 if (currentDevice->hasControlPanel())
663 if (resetDeviceButton ==
nullptr)
665 resetDeviceButton = std::make_unique<TextButton> (
TRANS (
"Reset Device"),
666 TRANS (
"Resets the audio interface - sometimes needed after changing a device's properties in its custom control panel"));
668 resetDeviceButton->onClick = [
this] { resetDevice(); };
676 resetDeviceButton.
reset();
679 void updateOutputsComboBox()
681 if (setup.maxNumOutputChannels > 0 || ! type.hasSeparateInputsAndOutputs())
683 if (outputDeviceDropDown ==
nullptr)
685 outputDeviceDropDown = std::make_unique<ComboBox>();
686 outputDeviceDropDown->onChange = [
this] { updateConfig (
true,
false,
false,
false); };
690 outputDeviceLabel = std::make_unique<Label> (String{}, type.hasSeparateInputsAndOutputs() ?
TRANS (
"Output:")
691 :
TRANS (
"Device:"));
692 outputDeviceLabel->attachToComponent (outputDeviceDropDown.
get(),
true);
694 if (setup.maxNumOutputChannels > 0)
696 testButton = std::make_unique<TextButton> (
TRANS (
"Test"),
TRANS (
"Plays a test tone"));
698 testButton->onClick = [
this] { playTestSound(); };
702 addNamesToDeviceBox (*outputDeviceDropDown,
false);
705 showCorrectDeviceName (outputDeviceDropDown.
get(),
false);
708 void updateInputsComboBox()
710 if (setup.maxNumInputChannels > 0 && type.hasSeparateInputsAndOutputs())
712 if (inputDeviceDropDown ==
nullptr)
714 inputDeviceDropDown = std::make_unique<ComboBox>();
715 inputDeviceDropDown->onChange = [
this] { updateConfig (
false,
true,
false,
false); };
718 inputDeviceLabel = std::make_unique<Label> (String{},
TRANS (
"Input:"));
719 inputDeviceLabel->attachToComponent (inputDeviceDropDown.
get(),
true);
721 inputLevelMeter = std::make_unique<SimpleDeviceManagerInputLevelMeter> (*setup.manager);
725 addNamesToDeviceBox (*inputDeviceDropDown,
true);
728 showCorrectDeviceName (inputDeviceDropDown.
get(),
true);
731 void updateSampleRateComboBox (AudioIODevice* currentDevice)
733 if (sampleRateDropDown ==
nullptr)
735 sampleRateDropDown = std::make_unique<ComboBox>();
738 sampleRateLabel = std::make_unique<Label> (String{},
TRANS (
"Sample rate:"));
739 sampleRateLabel->attachToComponent (sampleRateDropDown.
get(),
true);
743 sampleRateDropDown->clear();
744 sampleRateDropDown->onChange =
nullptr;
749 for (
auto rate : currentDevice->getAvailableSampleRates())
758 sampleRateDropDown->onChange = [
this] { updateConfig (
false,
false,
true,
false); };
761 void updateBufferSizeComboBox (AudioIODevice* currentDevice)
763 if (bufferSizeDropDown ==
nullptr)
765 bufferSizeDropDown = std::make_unique<ComboBox>();
768 bufferSizeLabel = std::make_unique<Label> (String{},
TRANS (
"Audio buffer size:"));
769 bufferSizeLabel->attachToComponent (bufferSizeDropDown.
get(),
true);
773 bufferSizeDropDown->clear();
774 bufferSizeDropDown->onChange =
nullptr;
777 auto currentRate = currentDevice->getCurrentSampleRate();
782 for (
auto bs : currentDevice->getAvailableBufferSizes())
783 bufferSizeDropDown->addItem (String (
bs) +
" samples (" + String (
bs * 1000.0 /
currentRate, 1) +
" ms)",
bs);
785 bufferSizeDropDown->setSelectedId (currentDevice->getCurrentBufferSizeSamples(),
dontSendNotification);
786 bufferSizeDropDown->onChange = [
this] { updateConfig (
false,
false,
false,
true); };
814 if (
auto* currentDevice = setup.manager->getCurrentAudioDevice())
816 if (type == audioInputType)
817 items = currentDevice->getInputChannelNames();
818 else if (type == audioOutputType)
819 items = currentDevice->getOutputChannelNames();
821 if (setup.useStereoPairs)
825 for (
int i = 0; i < items.
size(); i += 2)
827 auto& name = items[i];
829 if (i + 1 >= items.
size())
832 pairs.add (getNameForChannelPair (name, items[i + 1]));
854 auto item = items[row];
855 bool enabled =
false;
856 auto config = setup.manager->getAudioDeviceSetup();
858 if (setup.useStereoPairs)
860 if (type == audioInputType)
861 enabled =
config.inputChannels[row * 2] ||
config.inputChannels[row * 2 + 1];
862 else if (type == audioOutputType)
863 enabled =
config.outputChannels[row * 2] ||
config.outputChannels[row * 2 + 1];
867 if (type == audioInputType)
868 enabled =
config.inputChannels[row];
869 else if (type == audioOutputType)
870 enabled =
config.outputChannels[row];
877 enabled,
true,
true,
false);
879 drawTextLayout (g, *
this, item, { x + 5, 0, width - x - 5, height }, enabled);
887 if (e.
x < getTickX())
888 flipEnablement (row);
893 flipEnablement (row);
898 flipEnablement (row);
915 int getBestHeight (
int maxHeight)
926 const String noItemsMessage;
933 for (
int j = 0;
j <
name1.length(); ++
j)
934 if (
name1.substring (0,
j).equalsIgnoreCase (
name2.substring (0,
j)))
945 void flipEnablement (
int row)
947 jassert (type == audioInputType || type == audioOutputType);
953 if (setup.useStereoPairs)
959 for (
int i = 0; i < 256; i += 2)
962 if (type == audioInputType)
965 flipBit (bits, row, setup.minNumInputChannels / 2, setup.maxNumInputChannels / 2);
969 config.useDefaultOutputChannels =
false;
970 flipBit (bits, row, setup.minNumOutputChannels / 2, setup.maxNumOutputChannels / 2);
973 for (
int i = 0; i < 256; ++i)
978 if (type == audioInputType)
980 config.useDefaultInputChannels =
false;
981 flipBit (
config.inputChannels, row, setup.minNumInputChannels, setup.maxNumInputChannels);
985 config.useDefaultOutputChannels =
false;
986 flipBit (
config.outputChannels, row, setup.minNumOutputChannels, setup.maxNumOutputChannels);
1001 chans.setBit (index,
false);
1011 chans.setBit (index,
true);
1015 int getTickX()
const
1025 ScopedMessageBox messageBox;
1041 : deviceManager (
dm),
1050 jassert (minOutputChannels >= 0 && minOutputChannels <= maxOutputChannels);
1051 jassert (minInputChannels >= 0 && minInputChannels <= maxInputChannels);
1055 if (types.
size() > 1)
1057 deviceTypeDropDown = std::make_unique<ComboBox>();
1059 for (
int i = 0; i < types.
size(); ++i)
1060 deviceTypeDropDown->addItem (types.
getUnchecked (i)->getTypeName(), i + 1);
1063 deviceTypeDropDown->onChange = [
this] { updateDeviceType(); };
1065 deviceTypeDropDownLabel = std::make_unique<Label> (
String{},
TRANS (
"Audio device type:"));
1067 deviceTypeDropDownLabel->attachToComponent (deviceTypeDropDown.get(),
true);
1072 midiInputsList = std::make_unique <MidiInputSelectorComponentListBox> (
deviceManager,
1073 "(" +
TRANS (
"No MIDI inputs available") +
")");
1076 midiInputsLabel = std::make_unique<Label> (
String{},
TRANS (
"Active MIDI inputs:"));
1078 midiInputsLabel->attachToComponent (midiInputsList.get(),
true);
1082 bluetoothButton = std::make_unique<TextButton> (
TRANS (
"Bluetooth MIDI"),
TRANS (
"Scan for bluetooth MIDI devices"));
1084 bluetoothButton->onClick = [
this] { handleBluetoothButton(); };
1089 midiInputsList.reset();
1090 midiInputsLabel.reset();
1091 bluetoothButton.reset();
1096 midiOutputSelector = std::make_unique<MidiOutputSelector> (
deviceManager);
1099 midiOutputLabel = std::make_unique<Label> (
"lm",
TRANS (
"MIDI Output:"));
1100 midiOutputLabel->attachToComponent (midiOutputSelector.get(),
true);
1104 midiOutputSelector.reset();
1105 midiOutputLabel.reset();
1109 updateAllControls();
1126 auto space = itemHeight / 4;
1128 if (deviceTypeDropDown !=
nullptr)
1130 deviceTypeDropDown->setBounds (r.
removeFromTop (itemHeight));
1134 if (audioDeviceSettingsComp !=
nullptr)
1136 audioDeviceSettingsComp->resized();
1137 audioDeviceSettingsComp->setBounds (r.
removeFromTop (audioDeviceSettingsComp->getHeight())
1142 if (midiInputsList !=
nullptr)
1144 midiInputsList->setRowHeight (
jmin (22, itemHeight));
1145 midiInputsList->setBounds (r.
removeFromTop (midiInputsList->getBestHeight (
jmin (itemHeight * 8,
1150 if (bluetoothButton !=
nullptr)
1156 if (midiOutputSelector !=
nullptr)
1157 midiOutputSelector->setBounds (r.
removeFromTop (itemHeight));
1165 if (child == audioDeviceSettingsComp.get())
1169void AudioDeviceSelectorComponent::updateDeviceType()
1173 audioDeviceSettingsComp.reset();
1175 updateAllControls();
1179void AudioDeviceSelectorComponent::changeListenerCallback (ChangeBroadcaster*)
1181 updateAllControls();
1184void AudioDeviceSelectorComponent::updateAllControls()
1186 if (deviceTypeDropDown !=
nullptr)
1189 if (audioDeviceSettingsComp ==
nullptr
1193 audioDeviceSettingsComp.reset();
1196 ? 0 : deviceTypeDropDown->getSelectedId() - 1])
1198 AudioDeviceSetupDetails
details;
1200 details.minNumInputChannels = minInputChannels;
1201 details.maxNumInputChannels = maxInputChannels;
1202 details.minNumOutputChannels = minOutputChannels;
1203 details.maxNumOutputChannels = maxOutputChannels;
1204 details.useStereoPairs = showChannelsAsStereoPairs;
1206 audioDeviceSettingsComp = std::make_unique<AudioDeviceSettingsPanel> (*type,
details, hideAdvancedOptionsWithButton, *
this);
1211 if (midiInputsList !=
nullptr)
1213 midiInputsList->updateDevices();
1214 midiInputsList->updateContent();
1215 midiInputsList->repaint();
1221void AudioDeviceSelectorComponent::handleBluetoothButton()
1239 return midiInputsList.get();
static ScopedMessageBox showScopedAsync(const MessageBoxOptions &options, std::function< void(int)> callback)
Shows an alert window using the specified options.
Holds a resizable array of primitive or copy-by-value objects.
bool isEmpty() const noexcept
Returns true if the array is empty, false otherwise.
int size() const noexcept
Returns the current number of elements in the array.
void add(const ElementType &newElement)
Appends a new element at the end of the array.
void clear()
Removes all elements from the array.
@ none
No word-wrapping: lines extend indefinitely.
Manages the state of some audio and midi i/o devices.
bool isMidiInputDeviceEnabled(const String &deviceIdentifier) const
Returns true if a given midi input device is being used.
LevelMeter::Ptr getInputLevelGetter() noexcept
Returns a reference-counted object that can be used to get the current input level.
AudioDeviceSetup getAudioDeviceSetup() const
Returns the current device properties that are in use.
const String & getDefaultMidiOutputIdentifier() const noexcept
Returns the name of the default midi output.
String setAudioDeviceSetup(const AudioDeviceSetup &newSetup, bool treatAsChosenDevice)
Changes the current device or its settings.
AudioIODevice * getCurrentAudioDevice() const noexcept
Returns the currently-active audio device.
String getCurrentAudioDeviceType() const
Returns the type of audio device currently in use.
void setDefaultMidiOutputDevice(const String &deviceIdentifier)
Sets a midi output device to use as the default.
void setMidiInputDeviceEnabled(const String &deviceIdentifier, bool enabled)
Enables or disables a midi input device.
void setCurrentAudioDeviceType(const String &type, bool treatAsChosenDevice)
Changes the class of audio device being used.
const OwnedArray< AudioIODeviceType > & getAvailableDeviceTypes()
Returns a list of the types of device supported.
void restartLastAudioDevice()
Tries to reload the last audio device that was running.
void playTestSound()
Plays a beep through the current audio device.
void closeAudioDevice()
Closes the currently-open device.
void resized() final
Called when this component's size has been changed.
A component containing controls to let the user change the audio settings of an AudioDeviceManager ob...
void resized() override
Called when this component's size has been changed.
ListBox * getMidiInputSelectorListBox() const noexcept
Returns the ListBox that's being used to show the midi inputs, or nullptr if there isn't one.
AudioDeviceManager & deviceManager
The device manager that this component is controlling.
AudioDeviceSelectorComponent(AudioDeviceManager &deviceManager, int minAudioInputChannels, int maxAudioInputChannels, int minAudioOutputChannels, int maxAudioOutputChannels, bool showMidiInputOptions, bool showMidiOutputSelector, bool showChannelsAsStereoPairs, bool hideAdvancedOptionsWithButton)
Creates the component.
void setItemHeight(int itemHeight)
Sets the standard height used for items in the panel.
int getItemHeight() const noexcept
Returns the standard height used for items in the panel.
~AudioDeviceSelectorComponent() override
Destructor.
void childBoundsChanged(Component *child) override
Called when one of this component's children is moved or resized.
void listBoxItemClicked(int row, const MouseEvent &e) override
This can be overridden to react to the user clicking on a row.
void paint(Graphics &g) override
Components can override this method to draw their content.
void listBoxItemDoubleClicked(int row, const MouseEvent &) override
This can be overridden to react to the user double-clicking on a row.
void returnKeyPressed(int row) override
Override this to be informed when the return key is pressed.
void paintListBoxItem(int row, Graphics &g, int width, int height, bool) override
This method must be implemented to draw a row of the list.
int getNumRows() override
This has to return the number of items in the list.
void changeListenerCallback(ChangeBroadcaster *) override
Your subclass should implement this method to receive the callback.
void resized() override
Called when this component's size has been changed.
Represents a type of audio driver, such as DirectSound, ASIO, CoreAudio, etc.
virtual bool hasSeparateInputsAndOutputs() const =0
Returns true if two different devices can be used for the input and output.
virtual void scanForDevices()=0
Refreshes the object's cached list of known devices.
virtual StringArray getOutputChannelNames()=0
Returns the names of all the available output channels on this device.
virtual StringArray getInputChannelNames()=0
Returns the names of all the available input channels on this device.
static bool isAvailable()
Checks if a Bluetooth MIDI pairing dialogue is available on this platform.
static bool open(ModalComponentManager::Callback *exitCallback=nullptr, Rectangle< int > *btWindowBounds=nullptr)
Opens the Bluetooth MIDI pairing dialogue, if it is available.
Holds a list of ChangeListeners, and sends messages to them when instructed.
void addChangeListener(ChangeListener *listener)
Registers a listener to receive change callbacks from this broadcaster.
void removeChangeListener(ChangeListener *listener)
Unregisters a listener from the list.
Receives change event callbacks that are sent out by a ChangeBroadcaster.
static bool isWhitespace(char character) noexcept
Checks whether a character is whitespace.
void clear(NotificationType notification=sendNotificationAsync)
Removes all the items from the drop-down list.
void setSelectedId(int newItemId, NotificationType notification=sendNotificationAsync)
Sets one of the items to be the current selection.
std::function< void()> onChange
You can assign a lambda to this callback object to have it called when the selected ID is changed.
void addSeparator()
Adds a separator line to the drop-down list.
int getSelectedId() const noexcept
Returns the ID of the item that's currently shown in the box.
void addItem(const String &newItemText, int newItemId)
Adds an item to be shown in the drop-down list.
The base class for all JUCE user-interface objects.
int proportionOfWidth(float proportion) const noexcept
Returns a proportion of the component's width.
Component * getTopLevelComponent() const noexcept
Returns the highest-level component which contains this one or its parents.
int getBottom() const noexcept
Returns the y coordinate of the bottom edge of this component.
int getHeight() const noexcept
Returns the component's height in pixels.
void toFront(bool shouldAlsoGainKeyboardFocus)
Brings the component to the front of its siblings.
bool isShowing() const
Tests whether this component and all its parents are visible.
void sendLookAndFeelChange()
Calls the methods repaint(), lookAndFeelChanged(), and colourChanged() in this component and all its ...
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void repaint()
Marks the whole component as needing to be redrawn.
Component() noexcept
Creates a component.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
Colour findColour(int colourID, bool inheritFromParent=false) const
Looks for a colour that has been registered with the given colour ID number.
int getWidth() const noexcept
Returns the component's width in pixels.
LookAndFeel & getLookAndFeel() const noexcept
Finds the appropriate look-and-feel to use for this component.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
const Array< Component * > & getChildren() const noexcept
Provides access to the underlying array of child components.
A graphics context, used for drawing a component or image.
void drawText(const String &text, int x, int y, int width, int height, Justification justificationType, bool useEllipsesIfTooBig=true) const
Draws a line of text within a specified rectangle.
void setFont(const Font &newFont)
Changes the font to use for subsequent text-drawing functions.
void setColour(Colour newColour)
Changes the current drawing colour.
void fillAll() const
Fills the context's entire clip region with the current colour or brush.
@ centredRight
Indicates that the item should be centred vertically but placed on the right hand side.
@ centred
Indicates that the item should be centred vertically and horizontally.
@ centredLeft
Indicates that the item should be centred vertically but placed on the left hand side.
@ topRight
Indicates that the item should be placed in the top-right corner.
A subclass of this is used to drive a ListBox.
A list of items that can be scrolled vertically.
void paint(Graphics &) override
Components can override this method to draw their content.
void setOutlineThickness(int outlineThickness)
Sets the thickness of a border that will be drawn around the box.
void setModel(ListBoxModel *newModel)
Changes the current data model to display.
@ textColourId
The preferred colour to use for drawing text in the listbox.
@ backgroundColourId
The background colour to fill the list with.
int getOutlineThickness() const noexcept
Returns the thickness of outline that will be drawn around the listbox.
void updateContent()
Causes the list to refresh its content.
int getRowHeight() const noexcept
Returns the height of a row in the list.
void selectRow(int rowNumber, bool dontScrollToShowThisRow=false, bool deselectOthersFirst=true)
Selects a row.
static Array< MidiDeviceInfo > getAvailableDevices()
Returns a list of the available midi output devices.
Contains position and status information about a mouse event.
const int x
The x-position of the mouse when the event occurred.
An array designed for holding objects.
int size() const noexcept
Returns the number of items currently in the array.
ObjectClass * getUnchecked(int index) const noexcept
Returns a pointer to the object at this index in the array, without checking whether the index is in-...
Manages a rectangle and allows geometric operations to be performed on it.
Rectangle withX(ValueType newX) const noexcept
Returns a rectangle which has the same size and y-position as this one, but with a different x-positi...
ValueType getX() const noexcept
Returns the x coordinate of the rectangle's left-hand-side.
Rectangle removeFromTop(ValueType amountToRemove) noexcept
Removes a strip from the top of this rectangle, reducing this rectangle by the specified amount and r...
ValueType getY() const noexcept
Returns the y coordinate of the rectangle's top edge.
Rectangle withWidth(ValueType newWidth) const noexcept
Returns a rectangle which has the same position and height as this one, but with a different width.
@ bluetoothMidi
Permission to scan for and pair to Bluetooth MIDI devices (required on Android).
static bool isGranted(PermissionID permission)
Returns true if the app has been already granted this permission, either via a previous runtime reque...
static void request(PermissionID permission, Callback callback)
Call this method to request a runtime permission.
A special array for holding a list of strings.
int size() const noexcept
Returns the number of strings in the array.
String trim() const
Returns a copy of this string with any whitespace characters removed from the start and end.
String dropLastCharacters(int numberToDrop) const
Returns a version of this string with a number of characters removed from the end.
String substring(int startIndex, int endIndex) const
Returns a subsection of the string.
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
@ highlightColourId
The colour with which to fill the background of highlighted sections of the text - this can be transp...
Makes repeated callbacks to a virtual method at a specified time interval.
void startTimerHz(int timerFrequencyHz) noexcept
Starts the timer with an interval specified in Hertz.
#define TRANS(stringLiteral)
Uses the LocalisedStrings class to translate the given string literal.
constexpr auto enumerate(Range &&range, Index startingValue={})
Given a range and an optional starting offset, returns an IteratorPair that holds EnumerateIterators ...
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr bool exactlyEqual(Type a, Type b)
Equivalent to operator==, but suppresses float-equality warnings.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
@ WarningIcon
An exclamation mark to indicate that the dialog is a warning about something and shouldn't be ignored...
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
@ dontSendNotification
No notification message should be sent.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.
bool useDefaultInputChannels
If this is true, it indicates that the inputChannels array should be ignored, and instead,...