| @@ -30,7 +30,6 @@ | |||||
| //============================================================================== | //============================================================================== | ||||
| class CameraDemo : public Component, | class CameraDemo : public Component, | ||||
| private ComboBox::Listener, | |||||
| private CameraDevice::Listener, | private CameraDevice::Listener, | ||||
| private AsyncUpdater | private AsyncUpdater | ||||
| { | { | ||||
| @@ -46,7 +45,7 @@ public: | |||||
| addAndMakeVisible (cameraSelectorComboBox); | addAndMakeVisible (cameraSelectorComboBox); | ||||
| updateCameraList(); | updateCameraList(); | ||||
| cameraSelectorComboBox.setSelectedId (1); | cameraSelectorComboBox.setSelectedId (1); | ||||
| cameraSelectorComboBox.addListener (this); | |||||
| cameraSelectorComboBox.onChange = [this] { cameraChanged(); }; | |||||
| addAndMakeVisible (snapshotButton); | addAndMakeVisible (snapshotButton); | ||||
| snapshotButton.onClick = [this]() { takeSnapshot(); }; | snapshotButton.onClick = [this]() { takeSnapshot(); }; | ||||
| @@ -117,7 +116,7 @@ private: | |||||
| cameraSelectorComboBox.addItem (cameras[i], i + 2); | cameraSelectorComboBox.addItem (cameras[i], i + 2); | ||||
| } | } | ||||
| void comboBoxChanged (ComboBox*) override | |||||
| void cameraChanged() | |||||
| { | { | ||||
| // This is called when the user chooses a camera from the drop-down list. | // This is called when the user chooses a camera from the drop-down list. | ||||
| cameraDevice = nullptr; | cameraDevice = nullptr; | ||||
| @@ -30,8 +30,7 @@ | |||||
| #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS | #if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS | ||||
| struct DemoFlexPanel : public juce::Component, | struct DemoFlexPanel : public juce::Component, | ||||
| private juce::TextEditor::Listener, | |||||
| private juce::ComboBox::Listener | |||||
| private juce::TextEditor::Listener | |||||
| { | { | ||||
| DemoFlexPanel (juce::Colour col, FlexItem& item) : flexItem (item), colour (col) | DemoFlexPanel (juce::Colour col, FlexItem& item) : flexItem (item), colour (col) | ||||
| { | { | ||||
| @@ -61,7 +60,7 @@ struct DemoFlexPanel : public juce::Component, | |||||
| alignSelfCombo.addItem ("stretch", 5); | alignSelfCombo.addItem ("stretch", 5); | ||||
| alignSelfCombo.setBounds (x, y, 90, 18); | alignSelfCombo.setBounds (x, y, 90, 18); | ||||
| alignSelfCombo.addListener (this); | |||||
| alignSelfCombo.onChange = [this] { updateAssignSelf(); }; | |||||
| alignSelfCombo.setSelectedId (5); | alignSelfCombo.setSelectedId (5); | ||||
| alignSelfCombo.setColour (ComboBox::outlineColourId, Colours::transparentBlack); | alignSelfCombo.setColour (ComboBox::outlineColourId, Colours::transparentBlack); | ||||
| addAndMakeVisible (alignSelfCombo); | addAndMakeVisible (alignSelfCombo); | ||||
| @@ -85,15 +84,16 @@ struct DemoFlexPanel : public juce::Component, | |||||
| addAndMakeVisible (label); | addAndMakeVisible (label); | ||||
| } | } | ||||
| void comboBoxChanged (ComboBox* cb) override | |||||
| void updateAssignSelf() | |||||
| { | { | ||||
| auto selectedID = cb->getSelectedId(); | |||||
| if (selectedID == 1) flexItem.alignSelf = FlexItem::AlignSelf::autoAlign; | |||||
| if (selectedID == 2) flexItem.alignSelf = FlexItem::AlignSelf::flexStart; | |||||
| if (selectedID == 3) flexItem.alignSelf = FlexItem::AlignSelf::flexEnd; | |||||
| if (selectedID == 4) flexItem.alignSelf = FlexItem::AlignSelf::center; | |||||
| if (selectedID == 5) flexItem.alignSelf = FlexItem::AlignSelf::stretch; | |||||
| switch (alignSelfCombo.getSelectedId()) | |||||
| { | |||||
| case 1: flexItem.alignSelf = FlexItem::AlignSelf::autoAlign; break; | |||||
| case 2: flexItem.alignSelf = FlexItem::AlignSelf::flexStart; break; | |||||
| case 3: flexItem.alignSelf = FlexItem::AlignSelf::flexEnd; break; | |||||
| case 4: flexItem.alignSelf = FlexItem::AlignSelf::center; break; | |||||
| case 5: flexItem.alignSelf = FlexItem::AlignSelf::stretch; break; | |||||
| } | |||||
| if (auto parent = getParentComponent()) | if (auto parent = getParentComponent()) | ||||
| parent->resized(); | parent->resized(); | ||||
| @@ -30,8 +30,7 @@ | |||||
| //============================================================================== | //============================================================================== | ||||
| class FontsDemo : public Component, | class FontsDemo : public Component, | ||||
| private ListBoxModel, | private ListBoxModel, | ||||
| private Slider::Listener, | |||||
| private ComboBox::Listener | |||||
| private Slider::Listener | |||||
| { | { | ||||
| public: | public: | ||||
| FontsDemo() | FontsDemo() | ||||
| @@ -58,9 +57,10 @@ public: | |||||
| heightSlider.addListener (this); | heightSlider.addListener (this); | ||||
| kerningSlider.addListener (this); | kerningSlider.addListener (this); | ||||
| scaleSlider.addListener (this); | scaleSlider.addListener (this); | ||||
| boldToggle.onClick = [this]() { refreshPreviewBoxFont(); }; | boldToggle.onClick = [this]() { refreshPreviewBoxFont(); }; | ||||
| italicToggle.onClick = [this]() { refreshPreviewBoxFont(); }; | italicToggle.onClick = [this]() { refreshPreviewBoxFont(); }; | ||||
| styleBox.addListener (this); | |||||
| styleBox.onChange = [this]() { refreshPreviewBoxFont(); }; | |||||
| Font::findFonts (fonts); // Generate the list of fonts | Font::findFonts (fonts); // Generate the list of fonts | ||||
| @@ -244,12 +244,6 @@ private: | |||||
| } | } | ||||
| } | } | ||||
| void comboBoxChanged (ComboBox* box) override | |||||
| { | |||||
| if (box == &styleBox) | |||||
| refreshPreviewBoxFont(); | |||||
| } | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FontsDemo) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FontsDemo) | ||||
| }; | }; | ||||
| @@ -504,8 +504,7 @@ struct LookAndFeelDemoComponent : public Component | |||||
| }; | }; | ||||
| //============================================================================== | //============================================================================== | ||||
| class LookAndFeelDemo : public Component, | |||||
| private ComboBox::Listener | |||||
| class LookAndFeelDemo : public Component | |||||
| { | { | ||||
| public: | public: | ||||
| LookAndFeelDemo() | LookAndFeelDemo() | ||||
| @@ -536,7 +535,7 @@ public: | |||||
| addLookAndFeel (slaf, "Square Look And Feel"); | addLookAndFeel (slaf, "Square Look And Feel"); | ||||
| setupSquareLookAndFeelColours (*slaf); | setupSquareLookAndFeelColours (*slaf); | ||||
| lafBox.addListener (this); | |||||
| lafBox.onChange = [this]() { setAllLookAndFeels (lookAndFeels[lafBox.getSelectedItemIndex()]); }; | |||||
| lafBox.setSelectedItemIndex (3); | lafBox.setSelectedItemIndex (3); | ||||
| addAndMakeVisible (randomButton); | addAndMakeVisible (randomButton); | ||||
| @@ -612,12 +611,6 @@ private: | |||||
| child->setLookAndFeel (laf); | child->setLookAndFeel (laf); | ||||
| } | } | ||||
| void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override | |||||
| { | |||||
| if (comboBoxThatHasChanged == &lafBox) | |||||
| setAllLookAndFeels (lookAndFeels[lafBox.getSelectedItemIndex()]); | |||||
| } | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeelDemo) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeelDemo) | ||||
| }; | }; | ||||
| @@ -68,7 +68,6 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| class MidiDemo : public Component, | class MidiDemo : public Component, | ||||
| private ComboBox::Listener, | |||||
| private MidiInputCallback, | private MidiInputCallback, | ||||
| private MidiKeyboardStateListener, | private MidiKeyboardStateListener, | ||||
| private AsyncUpdater | private AsyncUpdater | ||||
| @@ -76,7 +75,6 @@ class MidiDemo : public Component, | |||||
| public: | public: | ||||
| MidiDemo() | MidiDemo() | ||||
| : deviceManager (MainAppWindow::getSharedAudioDeviceManager()), | : deviceManager (MainAppWindow::getSharedAudioDeviceManager()), | ||||
| lastInputIndex (0), isAddingFromMidiInput (false), | |||||
| keyboardComponent (keyboardState, MidiKeyboardComponent::horizontalKeyboard), | keyboardComponent (keyboardState, MidiKeyboardComponent::horizontalKeyboard), | ||||
| midiLogListBoxModel (midiMessageList) | midiLogListBoxModel (midiMessageList) | ||||
| { | { | ||||
| @@ -89,9 +87,10 @@ public: | |||||
| addAndMakeVisible (midiInputList); | addAndMakeVisible (midiInputList); | ||||
| midiInputList.setTextWhenNoChoicesAvailable ("No MIDI Inputs Enabled"); | midiInputList.setTextWhenNoChoicesAvailable ("No MIDI Inputs Enabled"); | ||||
| const StringArray midiInputs (MidiInput::getDevices()); | |||||
| auto midiInputs = MidiInput::getDevices(); | |||||
| midiInputList.addItemList (midiInputs, 1); | midiInputList.addItemList (midiInputs, 1); | ||||
| midiInputList.addListener (this); | |||||
| midiInputList.onChange = [this]() { setMidiInput (midiInputList.getSelectedItemIndex()); }; | |||||
| // find the first enabled device and use that by default | // find the first enabled device and use that by default | ||||
| for (int i = 0; i < midiInputs.size(); ++i) | for (int i = 0; i < midiInputs.size(); ++i) | ||||
| @@ -116,7 +115,7 @@ public: | |||||
| addAndMakeVisible (midiOutputList); | addAndMakeVisible (midiOutputList); | ||||
| midiOutputList.setTextWhenNoChoicesAvailable ("No MIDI Output Enabled"); | midiOutputList.setTextWhenNoChoicesAvailable ("No MIDI Output Enabled"); | ||||
| midiOutputList.addItemList (MidiOutput::getDevices(), 1); | midiOutputList.addItemList (MidiOutput::getDevices(), 1); | ||||
| midiOutputList.addListener (this); | |||||
| midiOutputList.onChange = [this]() { setMidiOutput (midiOutputList.getSelectedItemIndex()); }; | |||||
| addAndMakeVisible (keyboardComponent); | addAndMakeVisible (keyboardComponent); | ||||
| keyboardState.addListener (this); | keyboardState.addListener (this); | ||||
| @@ -129,7 +128,6 @@ public: | |||||
| { | { | ||||
| keyboardState.removeListener (this); | keyboardState.removeListener (this); | ||||
| deviceManager.removeMidiInputCallback (MidiInput::getDevices()[midiInputList.getSelectedItemIndex()], this); | deviceManager.removeMidiInputCallback (MidiInput::getDevices()[midiInputList.getSelectedItemIndex()], this); | ||||
| midiInputList.removeListener (this); | |||||
| } | } | ||||
| void paint (Graphics& g) override | void paint (Graphics& g) override | ||||
| @@ -139,7 +137,7 @@ public: | |||||
| void resized() override | void resized() override | ||||
| { | { | ||||
| Rectangle<int> area (getLocalBounds()); | |||||
| auto area = getLocalBounds(); | |||||
| midiInputList.setBounds (area.removeFromTop (36).removeFromRight (getWidth() - 150).reduced (8)); | midiInputList.setBounds (area.removeFromTop (36).removeFromRight (getWidth() - 150).reduced (8)); | ||||
| midiOutputList.setBounds (area.removeFromTop (36).removeFromRight (getWidth() - 150).reduced (8)); | midiOutputList.setBounds (area.removeFromTop (36).removeFromRight (getWidth() - 150).reduced (8)); | ||||
| keyboardComponent.setBounds (area.removeFromTop (80).reduced(8)); | keyboardComponent.setBounds (area.removeFromTop (80).reduced(8)); | ||||
| @@ -150,8 +148,8 @@ private: | |||||
| AudioDeviceManager& deviceManager; | AudioDeviceManager& deviceManager; | ||||
| ComboBox midiInputList, midiOutputList; | ComboBox midiInputList, midiOutputList; | ||||
| Label midiInputListLabel, midiOutputListLabel; | Label midiInputListLabel, midiOutputListLabel; | ||||
| int lastInputIndex; | |||||
| bool isAddingFromMidiInput; | |||||
| int lastInputIndex = 0; | |||||
| bool isAddingFromMidiInput = false; | |||||
| MidiKeyboardState keyboardState; | MidiKeyboardState keyboardState; | ||||
| MidiKeyboardComponent keyboardComponent; | MidiKeyboardComponent keyboardComponent; | ||||
| @@ -165,11 +163,11 @@ private: | |||||
| /** Starts listening to a MIDI input device, enabling it if necessary. */ | /** Starts listening to a MIDI input device, enabling it if necessary. */ | ||||
| void setMidiInput (int index) | void setMidiInput (int index) | ||||
| { | { | ||||
| const StringArray list (MidiInput::getDevices()); | |||||
| auto list = MidiInput::getDevices(); | |||||
| deviceManager.removeMidiInputCallback (list[lastInputIndex], this); | deviceManager.removeMidiInputCallback (list[lastInputIndex], this); | ||||
| const String newInput (list[index]); | |||||
| auto newInput = list[index]; | |||||
| if (! deviceManager.isMidiInputEnabled (newInput)) | if (! deviceManager.isMidiInputEnabled (newInput)) | ||||
| deviceManager.setMidiInputEnabled (newInput, true); | deviceManager.setMidiInputEnabled (newInput, true); | ||||
| @@ -192,12 +190,6 @@ private: | |||||
| } | } | ||||
| } | } | ||||
| void comboBoxChanged (ComboBox* box) override | |||||
| { | |||||
| if (box == &midiInputList) setMidiInput (midiInputList.getSelectedItemIndex()); | |||||
| if (box == &midiOutputList) setMidiOutput (midiOutputList.getSelectedItemIndex()); | |||||
| } | |||||
| // These methods handle callbacks from the midi device + on-screen keyboard.. | // These methods handle callbacks from the midi device + on-screen keyboard.. | ||||
| void handleIncomingMidiMessage (MidiInput*, const MidiMessage& message) override | void handleIncomingMidiMessage (MidiInput*, const MidiMessage& message) override | ||||
| { | { | ||||
| @@ -210,7 +202,7 @@ private: | |||||
| { | { | ||||
| if (! isAddingFromMidiInput) | if (! isAddingFromMidiInput) | ||||
| { | { | ||||
| MidiMessage m (MidiMessage::noteOn (midiChannel, midiNoteNumber, velocity)); | |||||
| auto m = MidiMessage::noteOn (midiChannel, midiNoteNumber, velocity); | |||||
| m.setTimeStamp (Time::getMillisecondCounterHiRes() * 0.001); | m.setTimeStamp (Time::getMillisecondCounterHiRes() * 0.001); | ||||
| postMessageToList (m); | postMessageToList (m); | ||||
| } | } | ||||
| @@ -220,7 +212,7 @@ private: | |||||
| { | { | ||||
| if (! isAddingFromMidiInput) | if (! isAddingFromMidiInput) | ||||
| { | { | ||||
| MidiMessage m (MidiMessage::noteOff (midiChannel, midiNoteNumber, velocity)); | |||||
| auto m = MidiMessage::noteOff (midiChannel, midiNoteNumber, velocity); | |||||
| m.setTimeStamp (Time::getMillisecondCounterHiRes() * 0.001); | m.setTimeStamp (Time::getMillisecondCounterHiRes() * 0.001); | ||||
| postMessageToList (m); | postMessageToList (m); | ||||
| } | } | ||||
| @@ -329,7 +329,6 @@ struct OpenGLDemoClasses | |||||
| */ | */ | ||||
| class DemoControlsOverlay : public Component, | class DemoControlsOverlay : public Component, | ||||
| private CodeDocument::Listener, | private CodeDocument::Listener, | ||||
| private ComboBox::Listener, | |||||
| private Slider::Listener, | private Slider::Listener, | ||||
| private Timer | private Timer | ||||
| { | { | ||||
| @@ -378,11 +377,11 @@ struct OpenGLDemoClasses | |||||
| textures.add (new DynamicTexture()); | textures.add (new DynamicTexture()); | ||||
| addAndMakeVisible (textureBox); | addAndMakeVisible (textureBox); | ||||
| textureBox.addListener (this); | |||||
| textureBox.onChange = [this]() { selectTexture (textureBox.getSelectedId()); }; | |||||
| updateTexturesList(); | updateTexturesList(); | ||||
| addAndMakeVisible (presetBox); | addAndMakeVisible (presetBox); | ||||
| presetBox.addListener (this); | |||||
| presetBox.onChange = [this]() { selectPreset (presetBox.getSelectedItemIndex()); }; | |||||
| auto presets = getPresets(); | auto presets = getPresets(); | ||||
| StringArray presetNames; | StringArray presetNames; | ||||
| @@ -539,14 +538,6 @@ struct OpenGLDemoClasses | |||||
| fragmentDocument.getAllContent()); | fragmentDocument.getAllContent()); | ||||
| } | } | ||||
| void comboBoxChanged (ComboBox* box) override | |||||
| { | |||||
| if (box == &presetBox) | |||||
| selectPreset (presetBox.getSelectedItemIndex()); | |||||
| else if (box == &textureBox) | |||||
| selectTexture (textureBox.getSelectedId()); | |||||
| } | |||||
| void lookAndFeelChanged() override | void lookAndFeelChanged() override | ||||
| { | { | ||||
| auto editorBackground = getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground, | auto editorBackground = getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground, | ||||
| @@ -31,7 +31,6 @@ | |||||
| //============================================================================== | //============================================================================== | ||||
| class OpenGL2DShaderDemo : public Component, | class OpenGL2DShaderDemo : public Component, | ||||
| private CodeDocument::Listener, | private CodeDocument::Listener, | ||||
| private ComboBox::Listener, | |||||
| private Timer | private Timer | ||||
| { | { | ||||
| public: | public: | ||||
| @@ -40,14 +39,14 @@ public: | |||||
| { | { | ||||
| setOpaque (true); | setOpaque (true); | ||||
| if (MainAppWindow* mw = MainAppWindow::getMainAppWindow()) | |||||
| if (auto* mw = MainAppWindow::getMainAppWindow()) | |||||
| mw->setOpenGLRenderingEngine(); | mw->setOpenGLRenderingEngine(); | ||||
| addAndMakeVisible (statusLabel); | addAndMakeVisible (statusLabel); | ||||
| statusLabel.setJustificationType (Justification::topLeft); | statusLabel.setJustificationType (Justification::topLeft); | ||||
| statusLabel.setFont (Font (14.0f)); | statusLabel.setFont (Font (14.0f)); | ||||
| Array<ShaderPreset> presets (getPresets()); | |||||
| auto presets = getPresets(); | |||||
| StringArray presetNames; | StringArray presetNames; | ||||
| for (int i = 0; i < presets.size(); ++i) | for (int i = 0; i < presets.size(); ++i) | ||||
| @@ -58,7 +57,7 @@ public: | |||||
| presetLabel.attachToComponent (&presetBox, true); | presetLabel.attachToComponent (&presetBox, true); | ||||
| addAndMakeVisible (presetBox); | addAndMakeVisible (presetBox); | ||||
| presetBox.addListener (this); | |||||
| presetBox.onChange = [this]() { selectPreset (presetBox.getSelectedItemIndex()); }; | |||||
| fragmentEditorComp.setOpaque (false); | fragmentEditorComp.setOpaque (false); | ||||
| fragmentDocument.addListener (this); | fragmentDocument.addListener (this); | ||||
| @@ -152,11 +151,6 @@ private: | |||||
| repaint(); | repaint(); | ||||
| } | } | ||||
| void comboBoxChanged (ComboBox*) override | |||||
| { | |||||
| selectPreset (presetBox.getSelectedItemIndex()); | |||||
| } | |||||
| struct ShaderPreset | struct ShaderPreset | ||||
| { | { | ||||
| const char* name; | const char* name; | ||||
| @@ -950,8 +950,7 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| // This is a custom component containing a combo box, which we're going to put inside | // This is a custom component containing a combo box, which we're going to put inside | ||||
| // our table's "rating" column. | // our table's "rating" column. | ||||
| class RatingColumnCustomComponent : public Component, | |||||
| private ComboBox::Listener | |||||
| class RatingColumnCustomComponent : public Component | |||||
| { | { | ||||
| public: | public: | ||||
| RatingColumnCustomComponent (TableDemoComponent& td) : owner (td) | RatingColumnCustomComponent (TableDemoComponent& td) : owner (td) | ||||
| @@ -966,8 +965,7 @@ private: | |||||
| comboBox.addItem ("swingin", 6); | comboBox.addItem ("swingin", 6); | ||||
| comboBox.addItem ("wild", 7); | comboBox.addItem ("wild", 7); | ||||
| // when the combo is changed, we'll get a callback. | |||||
| comboBox.addListener (this); | |||||
| comboBox.onChange = [this]() { owner.setRating (row, comboBox.getSelectedId()); }; | |||||
| comboBox.setWantsKeyboardFocus (false); | comboBox.setWantsKeyboardFocus (false); | ||||
| } | } | ||||
| @@ -984,11 +982,6 @@ private: | |||||
| comboBox.setSelectedId (owner.getRating (row), dontSendNotification); | comboBox.setSelectedId (owner.getRating (row), dontSendNotification); | ||||
| } | } | ||||
| void comboBoxChanged (ComboBox*) override | |||||
| { | |||||
| owner.setRating (row, comboBox.getSelectedId()); | |||||
| } | |||||
| private: | private: | ||||
| TableDemoComponent& owner; | TableDemoComponent& owner; | ||||
| ComboBox comboBox; | ComboBox comboBox; | ||||
| @@ -208,7 +208,6 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| class StringsDemo : public Component, | class StringsDemo : public Component, | ||||
| private ComboBox::Listener, | |||||
| private CodeDocument::Listener | private CodeDocument::Listener | ||||
| { | { | ||||
| public: | public: | ||||
| @@ -225,10 +224,17 @@ public: | |||||
| setOpaque (true); | setOpaque (true); | ||||
| addAndMakeVisible (typeBox); | addAndMakeVisible (typeBox); | ||||
| typeBox.addListener (this); | |||||
| typeBox.addItem ("XML", 1); | typeBox.addItem ("XML", 1); | ||||
| typeBox.addItem ("JSON", 2); | typeBox.addItem ("JSON", 2); | ||||
| typeBox.onChange = [this]() | |||||
| { | |||||
| if (typeBox.getSelectedId() == 1) | |||||
| reset (xml); | |||||
| else | |||||
| reset (json); | |||||
| }; | |||||
| comboBoxLabel.setText ("Database Type:", dontSendNotification); | comboBoxLabel.setText ("Database Type:", dontSendNotification); | ||||
| comboBoxLabel.attachToComponent (&typeBox, true); | comboBoxLabel.attachToComponent (&typeBox, true); | ||||
| @@ -364,17 +370,6 @@ private: | |||||
| } | } | ||||
| } | } | ||||
| void comboBoxChanged (ComboBox* box) override | |||||
| { | |||||
| if (box == &typeBox) | |||||
| { | |||||
| if (typeBox.getSelectedId() == 1) | |||||
| reset (xml); | |||||
| else | |||||
| reset (json); | |||||
| } | |||||
| } | |||||
| void codeDocumentTextInserted (const String&, int) override { rebuildTree(); } | void codeDocumentTextInserted (const String&, int) override { rebuildTree(); } | ||||
| void codeDocumentTextDeleted (int, int) override { rebuildTree(); } | void codeDocumentTextDeleted (int, int) override { rebuildTree(); } | ||||
| @@ -985,7 +985,7 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager& | |||||
| deviceTypeDropDown->addItem (types.getUnchecked(i)->getTypeName(), i + 1); | deviceTypeDropDown->addItem (types.getUnchecked(i)->getTypeName(), i + 1); | ||||
| addAndMakeVisible (deviceTypeDropDown); | addAndMakeVisible (deviceTypeDropDown); | ||||
| deviceTypeDropDown->addListener (this); | |||||
| deviceTypeDropDown->onChange = [this]() { updateDeviceType(); }; | |||||
| deviceTypeDropDownLabel = new Label ({}, TRANS("Audio device type:")); | deviceTypeDropDownLabel = new Label ({}, TRANS("Audio device type:")); | ||||
| deviceTypeDropDownLabel->setJustificationType (Justification::centredRight); | deviceTypeDropDownLabel->setJustificationType (Justification::centredRight); | ||||
| @@ -1019,7 +1019,7 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager& | |||||
| if (showMidiOutputSelector) | if (showMidiOutputSelector) | ||||
| { | { | ||||
| addAndMakeVisible (midiOutputSelector = new ComboBox()); | addAndMakeVisible (midiOutputSelector = new ComboBox()); | ||||
| midiOutputSelector->addListener (this); | |||||
| midiOutputSelector->onChange = [this]() { updateMidiOutput(); }; | |||||
| midiOutputLabel = new Label ("lm", TRANS("MIDI Output:")); | midiOutputLabel = new Label ("lm", TRANS("MIDI Output:")); | ||||
| midiOutputLabel->attachToComponent (midiOutputSelector, true); | midiOutputLabel->attachToComponent (midiOutputSelector, true); | ||||
| @@ -1095,26 +1095,24 @@ void AudioDeviceSelectorComponent::timerCallback() | |||||
| updateAllControls(); | updateAllControls(); | ||||
| } | } | ||||
| void AudioDeviceSelectorComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged) | |||||
| void AudioDeviceSelectorComponent::updateDeviceType() | |||||
| { | { | ||||
| if (comboBoxThatHasChanged == deviceTypeDropDown) | |||||
| if (auto* type = deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown->getSelectedId() - 1]) | |||||
| { | { | ||||
| if (auto* type = deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown->getSelectedId() - 1]) | |||||
| { | |||||
| audioDeviceSettingsComp.reset(); | |||||
| deviceManager.setCurrentAudioDeviceType (type->getTypeName(), true); | |||||
| updateAllControls(); // needed in case the type hasn't actually changed | |||||
| } | |||||
| audioDeviceSettingsComp.reset(); | |||||
| deviceManager.setCurrentAudioDeviceType (type->getTypeName(), true); | |||||
| updateAllControls(); // needed in case the type hasn't actually changed | |||||
| } | } | ||||
| else if (comboBoxThatHasChanged == midiOutputSelector) | |||||
| { | |||||
| auto midiDeviceName = midiOutputSelector->getText(); | |||||
| } | |||||
| void AudioDeviceSelectorComponent::updateMidiOutput() | |||||
| { | |||||
| auto midiDeviceName = midiOutputSelector->getText(); | |||||
| if (midiDeviceName == getNoDeviceString()) | |||||
| midiDeviceName = {}; | |||||
| if (midiDeviceName == getNoDeviceString()) | |||||
| midiDeviceName = {}; | |||||
| deviceManager.setDefaultMidiOutput (midiDeviceName); | |||||
| } | |||||
| deviceManager.setDefaultMidiOutput (midiDeviceName); | |||||
| } | } | ||||
| void AudioDeviceSelectorComponent::changeListenerCallback (ChangeBroadcaster*) | void AudioDeviceSelectorComponent::changeListenerCallback (ChangeBroadcaster*) | ||||
| @@ -38,7 +38,6 @@ namespace juce | |||||
| */ | */ | ||||
| class JUCE_API AudioDeviceSelectorComponent : public Component, | class JUCE_API AudioDeviceSelectorComponent : public Component, | ||||
| private ChangeListener, | private ChangeListener, | ||||
| private ComboBox::Listener, | |||||
| private Timer | private Timer | ||||
| { | { | ||||
| public: | public: | ||||
| @@ -111,7 +110,8 @@ private: | |||||
| ScopedPointer<TextButton> bluetoothButton; | ScopedPointer<TextButton> bluetoothButton; | ||||
| void handleBluetoothButton(); | void handleBluetoothButton(); | ||||
| void comboBoxChanged (ComboBox*) override; | |||||
| void updateDeviceType(); | |||||
| void updateMidiOutput(); | |||||
| void changeListenerCallback (ChangeBroadcaster*) override; | void changeListenerCallback (ChangeBroadcaster*) override; | ||||
| void updateAllControls(); | void updateAllControls(); | ||||
| @@ -1,75 +0,0 @@ | |||||
| /* | |||||
| ============================================================================== | |||||
| This file is part of the JUCE library. | |||||
| Copyright (c) 2017 - ROLI Ltd. | |||||
| JUCE is an open source library subject to commercial or open-source | |||||
| licensing. | |||||
| The code included in this file is provided under the terms of the ISC license | |||||
| http://www.isc.org/downloads/software-support-policy/isc-license. Permission | |||||
| To use, copy, modify, and/or distribute this software for any purpose with or | |||||
| without fee is hereby granted provided that the above copyright notice and | |||||
| this permission notice appear in all copies. | |||||
| JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER | |||||
| EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE | |||||
| DISCLAIMED. | |||||
| ============================================================================== | |||||
| */ | |||||
| namespace juce | |||||
| { | |||||
| //============================================================================== | |||||
| /** | |||||
| Helper class for dispatching callbacks to a lambda function. | |||||
| This class probably isn't something many users will use in their own code, but | |||||
| some juce classes use it as a helper to allow lambdas to be assigned to callback | |||||
| hooks - e.g. see its use in Button::onClick | |||||
| */ | |||||
| template <typename OwnerClass> | |||||
| struct EventHandler | |||||
| { | |||||
| EventHandler() {} | |||||
| ~EventHandler() {} | |||||
| /** Assigns a lambda to this callback. | |||||
| Note that this will replace any existing function that was previously assigned. | |||||
| */ | |||||
| void operator= (const std::function<void()>& callbackToAttach) | |||||
| { | |||||
| callback = callbackToAttach; | |||||
| } | |||||
| /** Assigns a lambda to this callback. | |||||
| Note that this will replace any existing function that was previously assigned. | |||||
| */ | |||||
| void operator= (std::function<void()>&& callbackToAttach) | |||||
| { | |||||
| callback = static_cast<std::function<void()>&&> (callbackToAttach); | |||||
| } | |||||
| /** Removes any existing function that was previously assigned to the callback. */ | |||||
| void reset() noexcept | |||||
| { | |||||
| callback = {}; | |||||
| } | |||||
| /** @internal */ | |||||
| void invoke() | |||||
| { | |||||
| if (callback != nullptr) | |||||
| callback(); | |||||
| } | |||||
| private: | |||||
| std::function<void()> callback; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EventHandler) | |||||
| }; | |||||
| } // namespace juce | |||||
| @@ -76,7 +76,6 @@ | |||||
| #include "broadcasters/juce_AsyncUpdater.h" | #include "broadcasters/juce_AsyncUpdater.h" | ||||
| #include "broadcasters/juce_ChangeListener.h" | #include "broadcasters/juce_ChangeListener.h" | ||||
| #include "broadcasters/juce_ChangeBroadcaster.h" | #include "broadcasters/juce_ChangeBroadcaster.h" | ||||
| #include "broadcasters/juce_EventHandler.h" | |||||
| #include "timers/juce_Timer.h" | #include "timers/juce_Timer.h" | ||||
| #include "timers/juce_MultiTimer.h" | #include "timers/juce_MultiTimer.h" | ||||
| #include "interprocess/juce_InterprocessConnection.h" | #include "interprocess/juce_InterprocessConnection.h" | ||||
| @@ -399,7 +399,8 @@ void Button::sendClickMessage (const ModifierKeys& modifiers) | |||||
| if (checker.shouldBailOut()) | if (checker.shouldBailOut()) | ||||
| return; | return; | ||||
| onClick.invoke(); | |||||
| if (onClick != nullptr) | |||||
| onClick(); | |||||
| } | } | ||||
| void Button::sendStateMessage() | void Button::sendStateMessage() | ||||
| @@ -416,7 +417,8 @@ void Button::sendStateMessage() | |||||
| if (checker.shouldBailOut()) | if (checker.shouldBailOut()) | ||||
| return; | return; | ||||
| onStateChange.invoke(); | |||||
| if (onStateChange != nullptr) | |||||
| onStateChange(); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -186,10 +186,10 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** You can assign a lambda to this callback object to have it called when the button is clicked. */ | /** You can assign a lambda to this callback object to have it called when the button is clicked. */ | ||||
| EventHandler<Button> onClick; | |||||
| std::function<void()> onClick; | |||||
| /** You can assign a lambda to this callback object to have it called when the button's state changes. */ | /** You can assign a lambda to this callback object to have it called when the button's state changes. */ | ||||
| EventHandler<Button> onStateChange; | |||||
| std::function<void()> onStateChange; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Causes the button to act as if it's been clicked. | /** Causes the button to act as if it's been clicked. | ||||
| @@ -43,9 +43,9 @@ FilenameComponent::FilenameComponent (const String& name, | |||||
| { | { | ||||
| addAndMakeVisible (filenameBox); | addAndMakeVisible (filenameBox); | ||||
| filenameBox.setEditableText (canEditFilename); | filenameBox.setEditableText (canEditFilename); | ||||
| filenameBox.addListener (this); | |||||
| filenameBox.setTextWhenNothingSelected (textWhenNothingSelected); | filenameBox.setTextWhenNothingSelected (textWhenNothingSelected); | ||||
| filenameBox.setTextWhenNoChoicesAvailable (TRANS ("(no recently selected files)")); | filenameBox.setTextWhenNoChoicesAvailable (TRANS ("(no recently selected files)")); | ||||
| filenameBox.onChange = [this]() { setCurrentFile (getCurrentFile(), true); }; | |||||
| setBrowseButtonText ("..."); | setBrowseButtonText ("..."); | ||||
| @@ -131,11 +131,6 @@ void FilenameComponent::showChooser() | |||||
| #endif | #endif | ||||
| } | } | ||||
| void FilenameComponent::comboBoxChanged (ComboBox*) | |||||
| { | |||||
| setCurrentFile (getCurrentFile(), true); | |||||
| } | |||||
| bool FilenameComponent::isInterestedInFileDrag (const StringArray&) | bool FilenameComponent::isInterestedInFileDrag (const StringArray&) | ||||
| { | { | ||||
| return true; | return true; | ||||
| @@ -64,8 +64,7 @@ public: | |||||
| class JUCE_API FilenameComponent : public Component, | class JUCE_API FilenameComponent : public Component, | ||||
| public SettableTooltipClient, | public SettableTooltipClient, | ||||
| public FileDragAndDropTarget, | public FileDragAndDropTarget, | ||||
| private AsyncUpdater, | |||||
| private ComboBox::Listener | |||||
| private AsyncUpdater | |||||
| { | { | ||||
| public: | public: | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -223,7 +222,6 @@ private: | |||||
| ListenerList <FilenameComponentListener> listeners; | ListenerList <FilenameComponentListener> listeners; | ||||
| File defaultBrowseFile; | File defaultBrowseFile; | ||||
| void comboBoxChanged (ComboBox*) override; | |||||
| void showChooser(); | void showChooser(); | ||||
| void handleAsyncUpdate() override; | void handleAsyncUpdate() override; | ||||
| @@ -630,6 +630,12 @@ void ComboBox::handleAsyncUpdate() | |||||
| { | { | ||||
| Component::BailOutChecker checker (this); | Component::BailOutChecker checker (this); | ||||
| listeners.callChecked (checker, [this] (Listener& l) { l.comboBoxChanged (this); }); | listeners.callChecked (checker, [this] (Listener& l) { l.comboBoxChanged (this); }); | ||||
| if (checker.shouldBailOut()) | |||||
| return; | |||||
| if (onChange != nullptr) | |||||
| onChange(); | |||||
| } | } | ||||
| void ComboBox::sendChange (const NotificationType notification) | void ComboBox::sendChange (const NotificationType notification) | ||||
| @@ -300,6 +300,10 @@ public: | |||||
| /** Deregisters a previously-registered listener. */ | /** Deregisters a previously-registered listener. */ | ||||
| void removeListener (Listener* listener); | void removeListener (Listener* listener); | ||||
| //============================================================================== | |||||
| /** You can assign a lambda to this callback object to have it called when the selected ID is changed. */ | |||||
| std::function<void()> onChange; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Sets a message to display when there is no item currently selected. | /** Sets a message to display when there is no item currently selected. | ||||
| @see getTextWhenNothingSelected | @see getTextWhenNothingSelected | ||||
| @@ -573,7 +573,7 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails) | |||||
| updateAllItemPositions (true); | updateAllItemPositions (true); | ||||
| } | } | ||||
| ComponentAnimator& animator = Desktop::getInstance().getAnimator(); | |||||
| auto& animator = Desktop::getInstance().getAnimator(); | |||||
| for (int i = getNumItems(); --i >= 0;) | for (int i = getNumItems(); --i >= 0;) | ||||
| { | { | ||||
| @@ -700,8 +700,7 @@ public: | |||||
| private: | private: | ||||
| Toolbar& toolbar; | Toolbar& toolbar; | ||||
| class CustomiserPanel : public Component, | |||||
| private ComboBox::Listener | |||||
| class CustomiserPanel : public Component | |||||
| { | { | ||||
| public: | public: | ||||
| CustomiserPanel (ToolbarItemFactory& tbf, Toolbar& bar, int optionFlags) | CustomiserPanel (ToolbarItemFactory& tbf, Toolbar& bar, int optionFlags) | ||||
| @@ -734,7 +733,7 @@ private: | |||||
| styleBox.setSelectedId (selectedStyle); | styleBox.setSelectedId (selectedStyle); | ||||
| styleBox.addListener (this); | |||||
| styleBox.onChange = [this]() { updateStyle(); }; | |||||
| } | } | ||||
| if ((optionFlags & Toolbar::showResetToDefaultsButton) != 0) | if ((optionFlags & Toolbar::showResetToDefaultsButton) != 0) | ||||
| @@ -749,7 +748,7 @@ private: | |||||
| setSize (500, 300); | setSize (500, 300); | ||||
| } | } | ||||
| void comboBoxChanged (ComboBox*) override | |||||
| void updateStyle() | |||||
| { | { | ||||
| switch (styleBox.getSelectedId()) | switch (styleBox.getSelectedId()) | ||||
| { | { | ||||