diff --git a/extras/Introjucer/Source/Application/jucer_JuceUpdater.cpp b/extras/Introjucer/Source/Application/jucer_JuceUpdater.cpp index 02e8b3d8b1..f7685a9bb0 100644 --- a/extras/Introjucer/Source/Application/jucer_JuceUpdater.cpp +++ b/extras/Introjucer/Source/Application/jucer_JuceUpdater.cpp @@ -207,7 +207,7 @@ void JuceUpdater::updateInstallButtonStatus() { const int numChecked = getNumCheckedModules(); installButton.setEnabled (numChecked > 0); - selectAllButton.setToggleState (numChecked > latestList.modules.size() / 2, false); + selectAllButton.setToggleState (numChecked > latestList.modules.size() / 2, dontSendNotification); } void JuceUpdater::filenameComponentChanged (FilenameComponent*) diff --git a/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp b/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp index b56a502e11..3ce061f5b3 100644 --- a/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp +++ b/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp @@ -320,7 +320,7 @@ public: addAndMakeVisible (&caseButton); caseButton.setColour (ToggleButton::textColourId, Colours::white); - caseButton.setToggleState (isCaseSensitiveSearch(), false); + caseButton.setToggleState (isCaseSensitiveSearch(), dontSendNotification); caseButton.addListener (this); findPrev.setConnectedEdges (Button::ConnectedOnRight); diff --git a/extras/Introjucer/Source/ComponentEditor/components/jucer_ToggleButtonHandler.h b/extras/Introjucer/Source/ComponentEditor/components/jucer_ToggleButtonHandler.h index 1c7dbfd1f9..4b77d50a78 100644 --- a/extras/Introjucer/Source/ComponentEditor/components/jucer_ToggleButtonHandler.h +++ b/extras/Introjucer/Source/ComponentEditor/components/jucer_ToggleButtonHandler.h @@ -62,7 +62,7 @@ public: if (! ButtonHandler::restoreFromXml (xml, comp, layout)) return false; - tb->setToggleState (xml.getBoolAttribute ("state", false), false); + tb->setToggleState (xml.getBoolAttribute ("state", false), dontSendNotification); return true; } @@ -75,7 +75,7 @@ public: String s; if (tb->getToggleState()) - s << memberVariableName << "->setToggleState (true, false);\n"; + s << memberVariableName << "->setToggleState (true, dontSendNotification);\n"; s << getColourIntialisationCode (component, memberVariableName) << '\n'; @@ -117,7 +117,7 @@ private: bool perform() { showCorrectTab(); - getComponent()->setToggleState (newState, false); + getComponent()->setToggleState (newState, dontSendNotification); changed(); return true; } @@ -125,7 +125,7 @@ private: bool undo() { showCorrectTab(); - getComponent()->setToggleState (oldState, false); + getComponent()->setToggleState (oldState, dontSendNotification); changed(); return true; } diff --git a/extras/Introjucer/Source/Project/jucer_NewProjectWizard.cpp b/extras/Introjucer/Source/Project/jucer_NewProjectWizard.cpp index c848eb95e2..bd7ae805bd 100644 --- a/extras/Introjucer/Source/Project/jucer_NewProjectWizard.cpp +++ b/extras/Introjucer/Source/Project/jucer_NewProjectWizard.cpp @@ -42,7 +42,7 @@ struct NewProjectWizardClasses setupComp.addChildAndSetID (c, "filesToCreate"); c->addItemList (fileOptions, 1); - c->setSelectedId (1, false); + c->setSelectedId (1, dontSendNotification); Label* l = new Label (String::empty, TRANS("Files to Auto-Generate") + ":"); l->attachToComponent (c, true); @@ -482,7 +482,7 @@ struct NewProjectWizardClasses addChildAndSetID (&projectType, "projectType"); projectType.addItemList (getWizardNames(), 1); - projectType.setSelectedId (1, true); + projectType.setSelectedId (1, dontSendNotification); projectType.setBounds ("100, projectName.bottom + 4, projectName.right, top + 22"); typeLabel.attachToComponent (&projectType, true); projectType.addListener (this); diff --git a/extras/JuceDemo/Source/demos/AudioDemoSynthPage.cpp b/extras/JuceDemo/Source/demos/AudioDemoSynthPage.cpp index c25049fc64..4072f6dbe7 100644 --- a/extras/JuceDemo/Source/demos/AudioDemoSynthPage.cpp +++ b/extras/JuceDemo/Source/demos/AudioDemoSynthPage.cpp @@ -253,7 +253,7 @@ AudioDemoSynthPage::AudioDemoSynthPage (AudioDeviceManager& deviceManager_) sineButton->setButtonText ("Use sine wave"); sineButton->setRadioGroupId (321); sineButton->addListener (this); - sineButton->setToggleState (true, false); + sineButton->setToggleState (true, dontSendNotification); addAndMakeVisible (sampledButton = new ToggleButton (String::empty)); sampledButton->setButtonText ("Use sampled sound"); diff --git a/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp b/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp index cf6fa8d185..3d99121f6f 100644 --- a/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp +++ b/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp @@ -520,7 +520,7 @@ RenderingTestComponent::RenderingTestComponent () testTypeComboBox->setSelectedId (2); sizeSlider->setValue (1.0, dontSendNotification); opacitySlider->setValue (1.0, dontSendNotification); - highQualityToggle->setToggleState (true, false); + highQualityToggle->setToggleState (true, dontSendNotification); //[/Constructor] } diff --git a/extras/JuceDemo/Source/demos/TableDemo.cpp b/extras/JuceDemo/Source/demos/TableDemo.cpp index 03ae1899a9..b40b97b9a3 100644 --- a/extras/JuceDemo/Source/demos/TableDemo.cpp +++ b/extras/JuceDemo/Source/demos/TableDemo.cpp @@ -242,7 +242,7 @@ private: { row = newRow; columnId = newColumn; - comboBox.setSelectedId (owner.getRating (row), true); + comboBox.setSelectedId (owner.getRating (row), dontSendNotification); } void comboBoxChanged (ComboBox* /*comboBoxThatHasChanged*/) diff --git a/extras/JuceDemo/Source/demos/WidgetsDemo.cpp b/extras/JuceDemo/Source/demos/WidgetsDemo.cpp index e3dcf92aee..423d10f7fb 100644 --- a/extras/JuceDemo/Source/demos/WidgetsDemo.cpp +++ b/extras/JuceDemo/Source/demos/WidgetsDemo.cpp @@ -399,7 +399,7 @@ static Component* createRadioButtonPage() tb->setTooltip ("a set of mutually-exclusive radio buttons"); if (i == 0) - tb->setToggleState (true, false); + tb->setToggleState (true, dontSendNotification); } for (int i = 0; i < 4; ++i) @@ -429,7 +429,7 @@ static Component* createRadioButtonPage() db->setBounds (25 + i * buttonSize, 180, buttonSize, buttonSize); if (i == 0) - db->setToggleState (true, false); + db->setToggleState (true, dontSendNotification); } for (int i = 0; i < 4; ++i) @@ -447,7 +447,7 @@ static Component* createRadioButtonPage() | ((i != 3) ? Button::ConnectedOnRight : 0)); if (i == 0) - tb->setToggleState (true, false); + tb->setToggleState (true, dontSendNotification); } return page; @@ -1074,7 +1074,7 @@ public: addAndMakeVisible (&enableButton); enableButton.setBounds (230, 10, 180, 24); enableButton.setTooltip ("Enables/disables all the components"); - enableButton.setToggleState (true, false); + enableButton.setToggleState (true, dontSendNotification); enableButton.addListener (this); addAndMakeVisible (&transformSlider); diff --git a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp index aec819fcbc..38973fe466 100644 --- a/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioDeviceSelectorComponent.cpp @@ -465,10 +465,10 @@ public: bufferSizeDropDown = nullptr; if (outputDeviceDropDown != nullptr) - outputDeviceDropDown->setSelectedId (-1, true); + outputDeviceDropDown->setSelectedId (-1, dontSendNotification); if (inputDeviceDropDown != nullptr) - inputDeviceDropDown->setSelectedId (-1, true); + inputDeviceDropDown->setSelectedId (-1, dontSendNotification); } resized(); @@ -498,7 +498,7 @@ private: const int index = type->getIndexOfDevice (currentDevice, isInput); - box->setSelectedId (index + 1, true); + box->setSelectedId (index + 1, dontSendNotification); if (testButton != nullptr && ! isInput) testButton->setEnabled (index >= 0); @@ -509,13 +509,13 @@ private: { const StringArray devs (type->getDeviceNames (isInputs)); - combo.clear (true); + combo.clear (dontSendNotification); for (int i = 0; i < devs.size(); ++i) combo.addItem (devs[i], i + 1); combo.addItem (getNoDeviceString(), -1); - combo.setSelectedId (-1, true); + combo.setSelectedId (-1, dontSendNotification); } int getLowestY() const @@ -617,7 +617,7 @@ private: sampleRateDropDown->addItem (String (rate) + " Hz", rate); } - sampleRateDropDown->setSelectedId (roundToInt (currentDevice->getCurrentSampleRate()), true); + sampleRateDropDown->setSelectedId (roundToInt (currentDevice->getCurrentSampleRate()), dontSendNotification); sampleRateDropDown->addListener (this); } @@ -651,7 +651,7 @@ private: bs); } - bufferSizeDropDown->setSelectedId (currentDevice->getCurrentBufferSizeSamples(), true); + bufferSizeDropDown->setSelectedId (currentDevice->getCurrentBufferSizeSamples(), dontSendNotification); bufferSizeDropDown->addListener (this); } @@ -1059,7 +1059,7 @@ void AudioDeviceSelectorComponent::changeListenerCallback (ChangeBroadcaster*) void AudioDeviceSelectorComponent::updateAllControls() { if (deviceTypeDropDown != nullptr) - deviceTypeDropDown->setText (deviceManager.getCurrentAudioDeviceType(), false); + deviceTypeDropDown->setText (deviceManager.getCurrentAudioDeviceType(), dontSendNotification); if (audioDeviceSettingsComp == nullptr || audioDeviceSettingsCompType != deviceManager.getCurrentAudioDeviceType()) @@ -1112,7 +1112,7 @@ void AudioDeviceSelectorComponent::updateAllControls() if (deviceManager.getDefaultMidiOutput() != nullptr) current = 1 + midiOuts.indexOf (deviceManager.getDefaultMidiOutputName()); - midiOutputSelector->setSelectedId (current, true); + midiOutputSelector->setSelectedId (current, dontSendNotification); } resized(); diff --git a/modules/juce_core/system/juce_PlatformDefs.h b/modules/juce_core/system/juce_PlatformDefs.h index 487cb686e0..a5abe4165c 100644 --- a/modules/juce_core/system/juce_PlatformDefs.h +++ b/modules/juce_core/system/juce_PlatformDefs.h @@ -271,10 +271,12 @@ namespace juce //============================================================================== // Cross-compiler deprecation macros.. -#if DOXYGEN || (JUCE_MSVC && ! JUCE_NO_DEPRECATION_WARNINGS) - /** This can be used to wrap a function which has been deprecated. */ +#ifdef DOXYGEN + /** This macro can be used to wrap a function which has been deprecated. */ + #define JUCE_DEPRECATED(functionDef) +#elif JUCE_MSVC && ! JUCE_NO_DEPRECATION_WARNINGS #define JUCE_DEPRECATED(functionDef) __declspec(deprecated) functionDef -#elif JUCE_GCC && ! JUCE_NO_DEPRECATION_WARNINGS +#elif JUCE_GCC && ! JUCE_NO_DEPRECATION_WARNINGS #define JUCE_DEPRECATED(functionDef) functionDef __attribute__ ((deprecated)) #else #define JUCE_DEPRECATED(functionDef) functionDef diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index ca15017189..b5183d4eb0 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -1224,7 +1224,7 @@ private: explicit String (const PreallocationBytes&); // This constructor preallocates a certain amount of memory void appendFixedLength (const char* text, int numExtraChars); size_t getByteOffsetOfEnd() const noexcept; - JUCE_DEPRECATED (String (const String& stringToCopy, size_t charsToAllocate)); + JUCE_DEPRECATED (String (const String&, size_t)); // This private cast operator should prevent strings being accidentally cast // to bools (this is possible because the compiler can add an implicit cast diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index f1012d86aa..668e05aa73 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -124,7 +124,7 @@ void Button::setConnectedEdges (const int connectedEdgeFlags_) //============================================================================== void Button::setToggleState (const bool shouldBeOn, - const bool sendChangeNotification) + const NotificationType notification) { if (shouldBeOn != lastToggleState) { @@ -136,8 +136,11 @@ void Button::setToggleState (const bool shouldBeOn, WeakReference deletionWatcher (this); - if (sendChangeNotification) + if (notification != dontSendNotification) { + // async callbacks aren't possible here + jassert (notification != sendNotificationAsync); + sendClickMessage (ModifierKeys()); if (deletionWatcher == nullptr) @@ -146,7 +149,7 @@ void Button::setToggleState (const bool shouldBeOn, if (lastToggleState) { - turnOffOtherButtonsInGroup (sendChangeNotification); + turnOffOtherButtonsInGroup (notification); if (deletionWatcher == nullptr) return; @@ -156,6 +159,11 @@ void Button::setToggleState (const bool shouldBeOn, } } +void Button::setToggleState (const bool shouldBeOn, bool sendChange) +{ + setToggleState (shouldBeOn, sendChange ? sendNotification : dontSendNotification); +} + void Button::setClickingTogglesState (const bool shouldToggle) noexcept { clickTogglesState = shouldToggle; @@ -175,7 +183,7 @@ bool Button::getClickingTogglesState() const noexcept void Button::valueChanged (Value& value) { if (value.refersToSameSourceAs (isOn)) - setToggleState (isOn.getValue(), true); + setToggleState (isOn.getValue(), sendNotification); } void Button::setRadioGroupId (const int newGroupId) @@ -185,11 +193,11 @@ void Button::setRadioGroupId (const int newGroupId) radioGroupId = newGroupId; if (lastToggleState) - turnOffOtherButtonsInGroup (true); + turnOffOtherButtonsInGroup (sendNotification); } } -void Button::turnOffOtherButtonsInGroup (const bool sendChangeNotification) +void Button::turnOffOtherButtonsInGroup (const NotificationType notification) { if (Component* const p = getParentComponent()) { @@ -207,7 +215,7 @@ void Button::turnOffOtherButtonsInGroup (const bool sendChangeNotification) { if (b->getRadioGroupId() == radioGroupId) { - b->setToggleState (false, sendChangeNotification); + b->setToggleState (false, notification); if (deletionWatcher == nullptr) return; @@ -309,7 +317,7 @@ void Button::triggerClick() void Button::internalClickCallback (const ModifierKeys& modifiers) { if (clickTogglesState) - setToggleState ((radioGroupId != 0) || ! lastToggleState, false); + setToggleState ((radioGroupId != 0) || ! lastToggleState, dontSendNotification); sendClickMessage (modifiers); } @@ -351,9 +359,6 @@ void Button::removeListener (ButtonListener* const listener) buttonListeners.remove (listener); } -void Button::addButtonListener (ButtonListener* l) { addListener (l); } -void Button::removeButtonListener (ButtonListener* l) { removeListener (l); } - void Button::sendClickMessage (const ModifierKeys& modifiers) { Component::BailOutChecker checker (this); @@ -523,7 +528,7 @@ void Button::applicationCommandListChanged() setEnabled (target != nullptr && (info.flags & ApplicationCommandInfo::isDisabled) == 0); if (target != nullptr) - setToggleState ((info.flags & ApplicationCommandInfo::isTicked) != 0, false); + setToggleState ((info.flags & ApplicationCommandInfo::isTicked) != 0, dontSendNotification); } } diff --git a/modules/juce_gui_basics/buttons/juce_Button.h b/modules/juce_gui_basics/buttons/juce_Button.h index 3ceac62a14..021f244c90 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.h +++ b/modules/juce_gui_basics/buttons/juce_Button.h @@ -90,17 +90,17 @@ public: an action you won't change this. Toggle buttons, however will want to change their state when turned on or off. - @param shouldBeOn whether to set the button's toggle state to be on or - off. If it's a member of a button group, this will - always try to turn it on, and to turn off any other - buttons in the group - @param sendChangeNotification if true, a callback will be made to clicked(); if false - the button will be repainted but no notification will - be sent + @param shouldBeOn whether to set the button's toggle state to be on or + off. If it's a member of a button group, this will + always try to turn it on, and to turn off any other + buttons in the group + @param notification determines the behaviour if the value changes - this + can invoke a synchronous call to clicked(), but + sendNotificationAsync is not supported @see getToggleState, setRadioGroupId */ void setToggleState (bool shouldBeOn, - bool sendChangeNotification); + NotificationType notification); /** Returns true if the button is 'on'. @@ -353,6 +353,8 @@ public: */ void setState (const ButtonState newState); + // This method's parameters have changed - see the new version. + JUCE_DEPRECATED (void setToggleState (bool, bool)); protected: //============================================================================== @@ -474,16 +476,12 @@ private: ButtonState updateState(); ButtonState updateState (bool isOver, bool isDown); bool isShortcutPressed() const; - void turnOffOtherButtonsInGroup (bool sendChangeNotification); + void turnOffOtherButtonsInGroup (NotificationType); void flashButtonState(); void sendClickMessage (const ModifierKeys&); void sendStateMessage(); - // These are deprecated - please use addListener() and removeListener() instead! - JUCE_DEPRECATED (void addButtonListener (Listener*)); - JUCE_DEPRECATED (void removeButtonListener (Listener*)); - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Button) }; diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 9579731c93..b2fc9f75e0 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -2214,12 +2214,10 @@ public: CachedComponentImage* getCachedComponentImage() const noexcept { return cachedImage; } //============================================================================== - #ifndef DOXYGEN // These methods are deprecated - use localPointToGlobal, getLocalPoint, getLocalPoint, etc instead. JUCE_DEPRECATED (Point relativePositionToGlobal (Point) const); JUCE_DEPRECATED (Point globalPositionToRelative (Point) const); JUCE_DEPRECATED (Point relativePositionToOtherComponent (const Component*, Point) const); - #endif private: //============================================================================== diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index 8777ce675e..8e6f282298 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -244,7 +244,7 @@ void FileBrowserComponent::setRoot (const File& newRootDirectory) if (currentRootName.isEmpty()) currentRootName = File::separatorString; - currentPathBox.setText (currentRootName, true); + currentPathBox.setText (currentRootName, dontSendNotification); goUpButton->setEnabled (currentRoot.getParentDirectory().isDirectory() && currentRoot.getParentDirectory() != currentRoot); diff --git a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp index c2eec28a9b..0b54115f17 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.cpp @@ -174,7 +174,7 @@ void FilenameComponent::setCurrentFile (File newFile, if (addToRecentlyUsedList) addRecentlyUsedFile (newFile); - filenameBox.setText (lastFilename, true); + filenameBox.setText (lastFilename, dontSendNotification); if (notification != dontSendNotification) { diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp index cdd49bf494..000c3d0fd5 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp @@ -321,7 +321,7 @@ void TabbedButtonBar::setCurrentTabIndex (int newIndex, const bool sendChangeMes for (int i = 0; i < tabs.size(); ++i) { TabBarButton* tb = tabs.getUnchecked(i)->button; - tb->setToggleState (i == newIndex, false); + tb->setToggleState (i == newIndex, dontSendNotification); } resized(); diff --git a/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp index 2f8e568bc1..adf1ecf1be 100644 --- a/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_BooleanPropertyComponent.cpp @@ -54,7 +54,7 @@ BooleanPropertyComponent::~BooleanPropertyComponent() void BooleanPropertyComponent::setState (const bool newState) { - button.setToggleState (newState, true); + button.setToggleState (newState, sendNotification); } bool BooleanPropertyComponent::getState() const @@ -75,7 +75,7 @@ void BooleanPropertyComponent::paint (Graphics& g) void BooleanPropertyComponent::refresh() { - button.setToggleState (getState(), false); + button.setToggleState (getState(), dontSendNotification); button.setButtonText (button.getToggleState() ? onText : offText); } diff --git a/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp index 367626d732..9168e43ee3 100644 --- a/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_ChoicePropertyComponent.cpp @@ -136,7 +136,7 @@ void ChoicePropertyComponent::refresh() comboBox.addListener (this); } - comboBox.setSelectedId (getIndex() + 1, true); + comboBox.setSelectedId (getIndex() + 1, dontSendNotification); } } diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 07006b9cb8..502f53ac9d 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -165,13 +165,13 @@ void ComboBox::changeItemText (const int itemId, const String& newText) jassertfalse; } -void ComboBox::clear (const bool dontSendChangeMessage) +void ComboBox::clear (const NotificationType notification) { items.clear(); separatorPending = false; if (! label->isEditable()) - setSelectedItemIndex (-1, dontSendChangeMessage); + setSelectedItemIndex (-1, notification); } //============================================================================== @@ -257,9 +257,9 @@ int ComboBox::getSelectedItemIndex() const return index; } -void ComboBox::setSelectedItemIndex (const int index, const bool dontSendChangeMessage) +void ComboBox::setSelectedItemIndex (const int index, const NotificationType notification) { - setSelectedId (getItemId (index), dontSendChangeMessage); + setSelectedId (getItemId (index), notification); } int ComboBox::getSelectedId() const noexcept @@ -269,21 +269,20 @@ int ComboBox::getSelectedId() const noexcept return (item != nullptr && getText() == item->name) ? item->itemId : 0; } -void ComboBox::setSelectedId (const int newItemId, const bool dontSendChangeMessage) +void ComboBox::setSelectedId (const int newItemId, const NotificationType notification) { const ItemInfo* const item = getItemForId (newItemId); const String newItemText (item != nullptr ? item->name : String::empty); if (lastCurrentId != newItemId || label->getText() != newItemText) { - if (! dontSendChangeMessage) - triggerAsyncUpdate(); - label->setText (newItemText, dontSendNotification); lastCurrentId = newItemId; currentId = newItemId; repaint(); // for the benefit of the 'none selected' text + + sendChange (notification); } } @@ -304,7 +303,7 @@ bool ComboBox::selectIfEnabled (const int index) void ComboBox::valueChanged (Value&) { if (lastCurrentId != (int) currentId.getValue()) - setSelectedId (currentId.getValue(), false); + setSelectedId (currentId.getValue()); } //============================================================================== @@ -313,7 +312,7 @@ String ComboBox::getText() const return label->getText(); } -void ComboBox::setText (const String& newText, const bool dontSendChangeMessage) +void ComboBox::setText (const String& newText, const NotificationType notification) { for (int i = items.size(); --i >= 0;) { @@ -322,23 +321,20 @@ void ComboBox::setText (const String& newText, const bool dontSendChangeMessage) if (item->isRealItem() && item->name == newText) { - setSelectedId (item->itemId, dontSendChangeMessage); + setSelectedId (item->itemId, notification); return; } } lastCurrentId = 0; currentId = 0; + repaint(); if (label->getText() != newText) { label->setText (newText, dontSendNotification); - - if (! dontSendChangeMessage) - triggerAsyncUpdate(); + sendChange (notification); } - - repaint(); } void ComboBox::showEditor() @@ -594,3 +590,18 @@ void ComboBox::handleAsyncUpdate() Component::BailOutChecker checker (this); listeners.callChecked (checker, &ComboBoxListener::comboBoxChanged, this); // (can't use ComboBox::Listener due to idiotic VC2005 bug) } + +void ComboBox::sendChange (const NotificationType notification) +{ + if (notification != dontSendNotification) + triggerAsyncUpdate(); + + if (notification == sendNotificationSync) + handleUpdateNowIfNeeded(); +} + +// Old deprecated methods - remove eventually... +void ComboBox::clear (const bool dontSendChange) { clear (dontSendChange ? dontSendNotification : sendNotification); } +void ComboBox::setSelectedItemIndex (const int index, const bool dontSendChange) { setSelectedItemIndex (index, dontSendChange ? dontSendNotification : sendNotification); } +void ComboBox::setSelectedId (const int newItemId, const bool dontSendChange) { setSelectedId (newItemId, dontSendChange ? dontSendNotification : sendNotification); } +void ComboBox::setText (const String& newText, const bool dontSendChange) { setText (newText, dontSendChange ? dontSendNotification : sendNotification); } diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.h b/modules/juce_gui_basics/widgets/juce_ComboBox.h index a77539feee..07aeeb2a04 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.h +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.h @@ -141,12 +141,12 @@ public: /** Removes all the items from the drop-down list. - If this call causes the content to be cleared, then a change-message - will be broadcast unless dontSendChangeMessage is true. + If this call causes the content to be cleared, and a change-message + will be broadcast according to the notification parameter. @see addItem, removeItem, getNumItems */ - void clear (bool dontSendChangeMessage = false); + void clear (NotificationType notification = sendNotificationAsync); /** Returns the number of items that have been added to the list. @@ -196,12 +196,13 @@ public: This will set the ComboBox's text to that of the item that matches this ID. - @param newItemId the new item to select - @param dontSendChangeMessage if set to true, this method won't trigger a - change notification + @param newItemId the new item to select + @param notification determines the type of change notification that will + be sent to listeners if the value changes @see getSelectedId, setSelectedItemIndex, setText */ - void setSelectedId (int newItemId, bool dontSendChangeMessage = false); + void setSelectedId (int newItemId, + NotificationType notification = sendNotificationAsync); //============================================================================== /** Returns the index of the item that's currently shown in the box. @@ -219,12 +220,13 @@ public: This will set the ComboBox's text to that of the item at the given index in the list. - @param newItemIndex the new item to select - @param dontSendChangeMessage if set to true, this method won't trigger a - change notification + @param newItemIndex the new item to select + @param notification determines the type of change notification that will + be sent to listeners if the value changes @see getSelectedItemIndex, setSelectedId, setText */ - void setSelectedItemIndex (int newItemIndex, bool dontSendChangeMessage = false); + void setSelectedItemIndex (int newItemIndex, + NotificationType notification = sendNotificationAsync); //============================================================================== /** Returns the text that is currently shown in the combo-box's text field. @@ -244,12 +246,13 @@ public: items, then getSelectedId() will return -1, otherwise it wil return the approriate ID. - @param newText the text to select - @param dontSendChangeMessage if set to true, this method won't trigger a - change notification + @param newText the text to select + @param notification determines the type of change notification that will + be sent to listeners if the text changes @see getText */ - void setText (const String& newText, bool dontSendChangeMessage = false); + void setText (const String& newText, + NotificationType notification = sendNotificationAsync); /** Programmatically opens the text editor to allow the user to edit the current item. @@ -371,6 +374,12 @@ public: /** @internal */ void valueChanged (Value&) override; + // These methods' bool parameters have changed: see their new method signatures. + JUCE_DEPRECATED (void clear (bool)); + JUCE_DEPRECATED (void setSelectedId (int, bool)); + JUCE_DEPRECATED (void setSelectedItemIndex (int, bool)); + JUCE_DEPRECATED (void setText (const String&, bool)); + private: //============================================================================== struct ItemInfo @@ -395,6 +404,7 @@ private: ItemInfo* getItemForId (int itemId) const noexcept; ItemInfo* getItemForIndex (int index) const noexcept; bool selectIfEnabled (int index); + void sendChange (NotificationType); static void popupMenuFinishedCallback (int, ComboBox*); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBox) diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index e63b8db687..336fde6bcb 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp @@ -232,7 +232,7 @@ void DocumentWindow::resized() ResizableWindow::resized(); if (Button* const b = getMaximiseButton()) - b->setToggleState (isFullScreen(), false); + b->setToggleState (isFullScreen(), dontSendNotification); const Rectangle titleBarArea (getTitleBarArea()); diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.h b/modules/juce_gui_basics/windows/juce_ResizableWindow.h index 1b2dd4fc04..be8e58e4f7 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.h +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.h @@ -312,7 +312,7 @@ public: }; //============================================================================== - /** @deprecated - use setContentOwned() and setContentNonOwned() instead. */ + // Deprecated: use setContentOwned() and setContentNonOwned() instead. JUCE_DEPRECATED (void setContentComponent (Component* newContentComponent, bool deleteOldOne = true, bool resizeToFit = false)); diff --git a/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp b/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp index 9d4c579a71..4563883d06 100644 --- a/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp +++ b/modules/juce_gui_extra/misc/juce_PreferencesPanel.cpp @@ -130,7 +130,7 @@ void PreferencesPanel::setCurrentPage (const String& pageName) { if (buttons.getUnchecked(i)->getName() == pageName) { - buttons.getUnchecked(i)->setToggleState (true, false); + buttons.getUnchecked(i)->setToggleState (true, dontSendNotification); break; } }