From 5ed768e95353df8fb9b842e744a7eb23b8743d9d Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 18 Oct 2012 13:53:02 +0100 Subject: [PATCH] New enum: NotificationType, to indicate whether to send a change message or not (and whether it should be async). Updates to ListBox, TreeView and Slider methods to use this type instead of bools. --- .../Source/demos/AudioDemoPlaybackPage.cpp | 2 +- .../JuceDemo/Source/demos/DirectShowDemo.cpp | 2 +- extras/JuceDemo/Source/demos/OpenGLDemo.cpp | 4 +- .../Source/demos/RenderingTestComponent.cpp | 6 +- extras/JuceDemo/Source/demos/WidgetsDemo.cpp | 4 +- .../audio plugin demo/Source/PluginEditor.cpp | 4 +- .../processors/juce_AudioProcessor.cpp | 2 +- .../juce_GenericAudioProcessorEditor.cpp | 2 +- modules/juce_events/juce_events.h | 3 + .../messages/juce_NotificationType.h | 43 +++++++++ .../juce_SliderPropertyComponent.cpp | 2 +- .../juce_gui_basics/widgets/juce_ListBox.cpp | 18 ++-- .../juce_gui_basics/widgets/juce_ListBox.h | 7 +- .../juce_gui_basics/widgets/juce_Slider.cpp | 95 +++++++++---------- modules/juce_gui_basics/widgets/juce_Slider.h | 82 ++++++++-------- .../juce_gui_basics/widgets/juce_TreeView.cpp | 6 +- .../juce_gui_basics/widgets/juce_TreeView.h | 6 +- 17 files changed, 172 insertions(+), 116 deletions(-) create mode 100644 modules/juce_events/messages/juce_NotificationType.h diff --git a/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp b/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp index 346eb7d24e..84db3b850e 100644 --- a/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp +++ b/extras/JuceDemo/Source/demos/AudioDemoPlaybackPage.cpp @@ -330,7 +330,7 @@ void AudioDemoPlaybackPage::showFile (const File& file) { loadFileIntoTransport (file); - zoomSlider->setValue (0, false, false); + zoomSlider->setValue (0, dontSendNotification); thumbnail->setFile (file); } diff --git a/extras/JuceDemo/Source/demos/DirectShowDemo.cpp b/extras/JuceDemo/Source/demos/DirectShowDemo.cpp index a7de04f553..00b00927df 100644 --- a/extras/JuceDemo/Source/demos/DirectShowDemo.cpp +++ b/extras/JuceDemo/Source/demos/DirectShowDemo.cpp @@ -99,7 +99,7 @@ private: void timerCallback() { if (! position.isMouseButtonDown()) - position.setValue (dshowComp.getPosition(), false); + position.setValue (dshowComp.getPosition(), dontSendNotification); } private: diff --git a/extras/JuceDemo/Source/demos/OpenGLDemo.cpp b/extras/JuceDemo/Source/demos/OpenGLDemo.cpp index 1a9f73be4b..e4f0ffbac4 100644 --- a/extras/JuceDemo/Source/demos/OpenGLDemo.cpp +++ b/extras/JuceDemo/Source/demos/OpenGLDemo.cpp @@ -45,7 +45,7 @@ public: speedSlider.setRange (-10.0, 10.0, 0.1); speedSlider.setPopupMenuEnabled (true); - speedSlider.setValue (Random::getSystemRandom().nextDouble() * 3.0, false, false); + speedSlider.setValue (Random::getSystemRandom().nextDouble() * 3.0, dontSendNotification); speedSlider.setSliderStyle (Slider::LinearHorizontal); speedSlider.setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20); addAndMakeVisible (&speedSlider); @@ -53,7 +53,7 @@ public: sizeSlider.setRange (0.2, 2.0, 0.01); sizeSlider.setPopupMenuEnabled (true); - sizeSlider.setValue (Random::getSystemRandom().nextDouble() + 0.5, false, false); + sizeSlider.setValue (Random::getSystemRandom().nextDouble() + 0.5, dontSendNotification); sizeSlider.setSliderStyle (Slider::LinearHorizontal); sizeSlider.setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20); addAndMakeVisible (&sizeSlider); diff --git a/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp b/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp index 3ebbc0523b..0f2a38ed67 100644 --- a/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp +++ b/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp @@ -360,7 +360,7 @@ private: else if (v >= slider->getMaximum()) speed = -fabsf (speed); - slider->setValue (v, false); + slider->setValue (v, dontSendNotification); } }; @@ -536,8 +536,8 @@ RenderingTestComponent::RenderingTestComponent () //[Constructor] You can add your own custom stuff here.. testTypeComboBox->setSelectedId (2); - sizeSlider->setValue (1.0, false); - opacitySlider->setValue (1.0, false); + sizeSlider->setValue (1.0, dontSendNotification); + opacitySlider->setValue (1.0, dontSendNotification); highQualityToggle->setToggleState (true, false); //[/Constructor] } diff --git a/extras/JuceDemo/Source/demos/WidgetsDemo.cpp b/extras/JuceDemo/Source/demos/WidgetsDemo.cpp index 2d02bb4a5d..3d32fd9637 100644 --- a/extras/JuceDemo/Source/demos/WidgetsDemo.cpp +++ b/extras/JuceDemo/Source/demos/WidgetsDemo.cpp @@ -293,7 +293,7 @@ static Component* createSlidersPage() sliders[i]->setRange (0.0, 100.0, 0.1); sliders[i]->setPopupMenuEnabled (true); - sliders[i]->setValue (Random::getSystemRandom().nextDouble() * 100.0, false, false); + sliders[i]->setValue (Random::getSystemRandom().nextDouble() * 100.0, dontSendNotification); } sliders[0]->setSliderStyle (Slider::LinearVertical); @@ -655,7 +655,7 @@ public: addAndMakeVisible (&depthSlider); depthSlider.setRange (10.0, 200.0, 1.0); - depthSlider.setValue (50, false); + depthSlider.setValue (50, dontSendNotification); depthSlider.setSliderStyle (Slider::LinearHorizontal); depthSlider.setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20); depthSlider.addListener (this); diff --git a/extras/audio plugin demo/Source/PluginEditor.cpp b/extras/audio plugin demo/Source/PluginEditor.cpp index b36d550806..3feff16a6d 100644 --- a/extras/audio plugin demo/Source/PluginEditor.cpp +++ b/extras/audio plugin demo/Source/PluginEditor.cpp @@ -94,8 +94,8 @@ void JuceDemoPluginAudioProcessorEditor::timerCallback() if (lastDisplayedPosition != newPos) displayPositionInfo (newPos); - gainSlider.setValue (ourProcessor->gain, false); - delaySlider.setValue (ourProcessor->delay, false); + gainSlider.setValue (ourProcessor->gain, dontSendNotification); + delaySlider.setValue (ourProcessor->delay, dontSendNotification); } // This is our Slider::Listener callback, when the user drags a slider. diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp index 1d1ed9a2da..40d06bb2ed 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp @@ -316,4 +316,4 @@ void AudioPlayHead::CurrentPositionInfo::resetToDefault() timeSigNumerator = 4; timeSigDenominator = 4; bpm = 120; -} \ No newline at end of file +} diff --git a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp index cac02c82b4..2bf17a2b1c 100644 --- a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp @@ -48,7 +48,7 @@ public: void refresh() { paramHasChanged = false; - slider.setValue (owner.getParameter (index), false); + slider.setValue (owner.getParameter (index), dontSendNotification); } void audioProcessorChanged (AudioProcessor*) {} diff --git a/modules/juce_events/juce_events.h b/modules/juce_events/juce_events.h index 778ccf22ae..a67f24e5ee 100644 --- a/modules/juce_events/juce_events.h +++ b/modules/juce_events/juce_events.h @@ -52,6 +52,9 @@ namespace juce #ifndef __JUCE_MESSAGEMANAGER_JUCEHEADER__ #include "messages/juce_MessageManager.h" #endif +#ifndef __JUCE_NOTIFICATIONTYPE_JUCEHEADER__ + #include "messages/juce_NotificationType.h" +#endif #ifndef __JUCE_ACTIONBROADCASTER_JUCEHEADER__ #include "broadcasters/juce_ActionBroadcaster.h" #endif diff --git a/modules/juce_events/messages/juce_NotificationType.h b/modules/juce_events/messages/juce_NotificationType.h new file mode 100644 index 0000000000..00e0e7affd --- /dev/null +++ b/modules/juce_events/messages/juce_NotificationType.h @@ -0,0 +1,43 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-11 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + JUCE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +#ifndef __JUCE_NOTIFICATIONTYPE_JUCEHEADER__ +#define __JUCE_NOTIFICATIONTYPE_JUCEHEADER__ + +//============================================================================== +/** + These enums are used in various classes to indicate whether a notification + event should be sent out. +*/ +enum NotificationType +{ + dontSendNotification = 0, /**< No notification message should be sent. */ + sendNotification = 1, /**< Requests a notification message, either synchronous or not. */ + sendNotificationSync, /**< Requests a synchronous notification. */ + sendNotificationAsync, /**< Requests a asynchronous notification. */ +}; + + +#endif // __JUCE_NOTIFICATIONTYPE_JUCEHEADER__ diff --git a/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp index e73589072d..cdfb0257c5 100644 --- a/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_SliderPropertyComponent.cpp @@ -71,7 +71,7 @@ double SliderPropertyComponent::getValue() const void SliderPropertyComponent::refresh() { - slider.setValue (getValue(), false); + slider.setValue (getValue(), dontSendNotification); } void SliderPropertyComponent::sliderValueChanged (Slider*) diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 9faef2d7f8..f1f16e0ed9 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -233,9 +233,8 @@ public: for (int i = 0; i < numNeeded; ++i) { const int row = i + firstIndex; - RowComponent* const rowComp = getComponentForRow (row); - if (rowComp != nullptr) + if (RowComponent* const rowComp = getComponentForRow (row)) { rowComp->setBounds (0, row * rowH, w, rowH); rowComp->update (row, owner.isRowSelected (row)); @@ -500,7 +499,7 @@ void ListBox::deselectRow (const int row) } void ListBox::setSelectedRows (const SparseSet& setOfRowsToBeSelected, - const bool sendNotificationEventToModel) + const NotificationType sendNotificationEventToModel) { selected = setOfRowsToBeSelected; selected.removeRange (Range (totalItems, std::numeric_limits::max())); @@ -510,7 +509,7 @@ void ListBox::setSelectedRows (const SparseSet& setOfRowsToBeSelected, viewport->updateContents(); - if ((model != nullptr) && sendNotificationEventToModel) + if ((model != nullptr) && sendNotificationEventToModel == sendNotification) model->selectedRowsChanged (lastRowSelected); } @@ -624,8 +623,10 @@ int ListBox::getInsertionIndexForPosition (const int x, const int y) const noexc Component* ListBox::getComponentForRowNumber (const int row) const noexcept { - RowComponent* const listRowComp = viewport->getComponentForRowIfOnscreen (row); - return listRowComp != nullptr ? static_cast (listRowComp->customComponent) : nullptr; + if (RowComponent* const listRowComp = viewport->getComponentForRowIfOnscreen (row)) + return static_cast (listRowComp->customComponent); + + return nullptr; } int ListBox::getRowNumberOfComponent (Component* const rowComponent) const noexcept @@ -907,10 +908,7 @@ Image ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY) void ListBox::startDragAndDrop (const MouseEvent& e, const var& dragDescription, bool allowDraggingToOtherWindows) { - DragAndDropContainer* const dragContainer - = DragAndDropContainer::findParentDragContainerFor (this); - - if (dragContainer != nullptr) + if (DragAndDropContainer* const dragContainer = DragAndDropContainer::findParentDragContainerFor (this)) { int x, y; Image dragImage (createSnapshotOfSelectedRows (x, y)); diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.h b/modules/juce_gui_basics/widgets/juce_ListBox.h index d37af9664f..230ace8caf 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -286,7 +286,7 @@ public: @see getSelectedRows */ void setSelectedRows (const SparseSet& setOfRowsToBeSelected, - bool sendNotificationEventToModel = true); + NotificationType sendNotificationEventToModel = sendNotification); /** Checks whether a row is selected. */ @@ -569,6 +569,11 @@ private: void selectRowInternal (int rowNumber, bool dontScrollToShowThisRow, bool deselectOthersFirst, bool isMouseClick); + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // This method's bool parameter has changed: see the new method signature. + JUCE_DEPRECATED (void setSelectedRows (const SparseSet&, bool)); + #endif + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ListBox); }; diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 33a2acac97..943ad73818 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -144,12 +144,12 @@ public: // keep the current values inside the new range.. if (style != TwoValueHorizontal && style != TwoValueVertical) { - setValue (getValue(), false, false); + setValue (getValue(), dontSendNotification); } else { - setMinValue (getMinValue(), false, false, false); - setMaxValue (getMaxValue(), false, false, false); + setMinValue (getMinValue(), dontSendNotification, false); + setMaxValue (getMaxValue(), dontSendNotification, false); } updateText(); @@ -165,7 +165,7 @@ public: return currentValue.getValue(); } - void setValue (double newValue, const bool sendUpdateMessage, const bool sendMessageSynchronously) + void setValue (double newValue, const NotificationType notification) { // for a two-value style slider, you should use the setMinValue() and setMaxValue() // methods to set the two values. @@ -200,13 +200,12 @@ public: if (popupDisplay != nullptr) popupDisplay->updatePosition (owner.getTextFromValue (newValue)); - if (sendUpdateMessage) - triggerChangeMessage (sendMessageSynchronously); + triggerChangeMessage (notification); } } - void setMinValue (double newValue, const bool sendUpdateMessage, - const bool sendMessageSynchronously, const bool allowNudgingOfOtherValues) + void setMinValue (double newValue, const NotificationType notification, + const bool allowNudgingOfOtherValues) { // The minimum value only applies to sliders that are in two- or three-value mode. jassert (style == TwoValueHorizontal || style == TwoValueVertical @@ -217,14 +216,14 @@ public: if (style == TwoValueHorizontal || style == TwoValueVertical) { if (allowNudgingOfOtherValues && newValue > (double) valueMax.getValue()) - setMaxValue (newValue, sendUpdateMessage, sendMessageSynchronously, false); + setMaxValue (newValue, notification, false); newValue = jmin ((double) valueMax.getValue(), newValue); } else { if (allowNudgingOfOtherValues && newValue > lastCurrentValue) - setValue (newValue, sendUpdateMessage, sendMessageSynchronously); + setValue (newValue, notification); newValue = jmin (lastCurrentValue, newValue); } @@ -238,13 +237,12 @@ public: if (popupDisplay != nullptr) popupDisplay->updatePosition (owner.getTextFromValue (newValue)); - if (sendUpdateMessage) - triggerChangeMessage (sendMessageSynchronously); + triggerChangeMessage (notification); } } - void setMaxValue (double newValue, const bool sendUpdateMessage, - const bool sendMessageSynchronously, const bool allowNudgingOfOtherValues) + void setMaxValue (double newValue, const NotificationType notification, + const bool allowNudgingOfOtherValues) { // The maximum value only applies to sliders that are in two- or three-value mode. jassert (style == TwoValueHorizontal || style == TwoValueVertical @@ -255,14 +253,14 @@ public: if (style == TwoValueHorizontal || style == TwoValueVertical) { if (allowNudgingOfOtherValues && newValue < (double) valueMin.getValue()) - setMinValue (newValue, sendUpdateMessage, sendMessageSynchronously, false); + setMinValue (newValue, notification, false); newValue = jmax ((double) valueMin.getValue(), newValue); } else { if (allowNudgingOfOtherValues && newValue < lastCurrentValue) - setValue (newValue, sendUpdateMessage, sendMessageSynchronously); + setValue (newValue, notification); newValue = jmax (lastCurrentValue, newValue); } @@ -276,12 +274,11 @@ public: if (popupDisplay != nullptr) popupDisplay->updatePosition (owner.getTextFromValue (valueMax.getValue())); - if (sendUpdateMessage) - triggerChangeMessage (sendMessageSynchronously); + triggerChangeMessage (notification); } } - void setMinAndMaxValues (double newMinValue, double newMaxValue, bool sendUpdateMessage, bool sendMessageSynchronously) + void setMinAndMaxValues (double newMinValue, double newMaxValue, const NotificationType notification) { // The maximum value only applies to sliders that are in two- or three-value mode. jassert (style == TwoValueHorizontal || style == TwoValueVertical @@ -301,8 +298,7 @@ public: valueMax = newMaxValue; owner.repaint(); - if (sendUpdateMessage) - triggerChangeMessage (sendMessageSynchronously); + triggerChangeMessage (notification); } } @@ -324,14 +320,17 @@ public: return valueMax.getValue(); } - void triggerChangeMessage (const bool synchronous) + void triggerChangeMessage (const NotificationType notification) { - if (synchronous) - handleAsyncUpdate(); - else - triggerAsyncUpdate(); + if (notification != dontSendNotification) + { + if (notification == sendNotificationSync) + handleAsyncUpdate(); + else + triggerAsyncUpdate(); - owner.valueChanged(); + owner.valueChanged(); + } } void handleAsyncUpdate() @@ -370,7 +369,7 @@ public: const double delta = (button == incButton) ? interval : -interval; sendDragStart(); - setValue (owner.snapValue (getValue() + delta, false), true, true); + setValue (owner.snapValue (getValue() + delta, false), sendNotificationSync); sendDragEnd(); } } @@ -380,12 +379,12 @@ public: if (value.refersToSameSourceAs (currentValue)) { if (style != TwoValueHorizontal && style != TwoValueVertical) - setValue (currentValue.getValue(), false, false); + setValue (currentValue.getValue(), dontSendNotification); } else if (value.refersToSameSourceAs (valueMin)) - setMinValue (valueMin.getValue(), false, false, true); + setMinValue (valueMin.getValue(), dontSendNotification, true); else if (value.refersToSameSourceAs (valueMax)) - setMaxValue (valueMax.getValue(), false, false, true); + setMaxValue (valueMax.getValue(), dontSendNotification, true); } void labelTextChanged (Label* label) @@ -395,7 +394,7 @@ public: if (newValue != (double) currentValue.getValue()) { sendDragStart(); - setValue (newValue, true, true); + setValue (newValue, sendNotificationSync); sendDragEnd(); } @@ -905,25 +904,25 @@ public: if (sliderBeingDragged == 0) { setValue (owner.snapValue (valueWhenLastDragged, true), - ! sendChangeOnlyOnRelease, true); + sendChangeOnlyOnRelease ? dontSendNotification : sendNotificationSync); } else if (sliderBeingDragged == 1) { setMinValue (owner.snapValue (valueWhenLastDragged, true), - ! sendChangeOnlyOnRelease, false, true); + sendChangeOnlyOnRelease ? dontSendNotification : sendNotificationAsync, true); if (e.mods.isShiftDown()) - setMaxValue (getMinValue() + minMaxDiff, false, false, true); + setMaxValue (getMinValue() + minMaxDiff, dontSendNotification, true); else minMaxDiff = (double) valueMax.getValue() - (double) valueMin.getValue(); } else if (sliderBeingDragged == 2) { setMaxValue (owner.snapValue (valueWhenLastDragged, true), - ! sendChangeOnlyOnRelease, false, true); + sendChangeOnlyOnRelease ? dontSendNotification : sendNotificationAsync, true); if (e.mods.isShiftDown()) - setMinValue (getMaxValue() - minMaxDiff, false, false, true); + setMinValue (getMaxValue() - minMaxDiff, dontSendNotification, true); else minMaxDiff = (double) valueMax.getValue() - (double) valueMin.getValue(); } @@ -942,7 +941,7 @@ public: restoreMouseIfHidden(); if (sendChangeOnlyOnRelease && valueOnMouseDown != (double) currentValue.getValue()) - triggerChangeMessage (false); + triggerChangeMessage (sendNotificationAsync); sendDragEnd(); popupDisplay = nullptr; @@ -967,7 +966,7 @@ public: && maximum >= doubleClickReturnValue) { sendDragStart(); - setValue (doubleClickReturnValue, true, true); + setValue (doubleClickReturnValue, sendNotificationSync); sendDragEnd(); } } @@ -994,7 +993,7 @@ public: delta = -delta; sendDragStart(); - setValue (owner.snapValue (value + delta, false), true, true); + setValue (owner.snapValue (value + delta, false), sendNotificationSync); sendDragEnd(); } @@ -1427,27 +1426,27 @@ Value& Slider::getMaxValueObject() noexcept { return pimpl->valueMax; } double Slider::getValue() const { return pimpl->getValue(); } -void Slider::setValue (double newValue, bool sendUpdateMessage, bool sendMessageSynchronously) +void Slider::setValue (double newValue, const NotificationType notification) { - pimpl->setValue (newValue, sendUpdateMessage, sendMessageSynchronously); + pimpl->setValue (newValue, notification); } double Slider::getMinValue() const { return pimpl->getMinValue(); } double Slider::getMaxValue() const { return pimpl->getMaxValue(); } -void Slider::setMinValue (double newValue, bool sendUpdateMessage, bool sendMessageSynchronously, bool allowNudgingOfOtherValues) +void Slider::setMinValue (double newValue, const NotificationType notification, bool allowNudgingOfOtherValues) { - pimpl->setMinValue (newValue, sendUpdateMessage, sendMessageSynchronously, allowNudgingOfOtherValues); + pimpl->setMinValue (newValue, notification, allowNudgingOfOtherValues); } -void Slider::setMaxValue (double newValue, bool sendUpdateMessage, bool sendMessageSynchronously, bool allowNudgingOfOtherValues) +void Slider::setMaxValue (double newValue, const NotificationType notification, bool allowNudgingOfOtherValues) { - pimpl->setMaxValue (newValue, sendUpdateMessage, sendMessageSynchronously, allowNudgingOfOtherValues); + pimpl->setMaxValue (newValue, notification, allowNudgingOfOtherValues); } -void Slider::setMinAndMaxValues (double newMinValue, double newMaxValue, bool sendUpdateMessage, bool sendMessageSynchronously) +void Slider::setMinAndMaxValues (double newMinValue, double newMaxValue, const NotificationType notification) { - pimpl->setMinAndMaxValues (newMinValue, newMaxValue, sendUpdateMessage, sendMessageSynchronously); + pimpl->setMinAndMaxValues (newMinValue, newMaxValue, notification); } void Slider::setDoubleClickReturnValue (bool isDoubleClickEnabled, double valueToSetOnDoubleClick) diff --git a/modules/juce_gui_basics/widgets/juce_Slider.h b/modules/juce_gui_basics/widgets/juce_Slider.h index 4c975c1e9e..fb5177ef26 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.h +++ b/modules/juce_gui_basics/widgets/juce_Slider.h @@ -125,7 +125,6 @@ public: void setSliderStyle (SliderStyle newStyle); /** Returns the slider's current style. - @see setSliderStyle */ SliderStyle getSliderStyle() const noexcept; @@ -340,17 +339,14 @@ public: that are registered, and will synchronously call the valueChanged() method in case subclasses want to handle it. - @param newValue the new value to set - this will be restricted by the - minimum and maximum range, and will be snapped to the - nearest interval if one has been set - @param sendUpdateMessage if false, a change to the value will not trigger a call to - any Slider::Listeners or the valueChanged() method - @param sendMessageSynchronously if true, then a call to the Slider::Listeners will be made - synchronously; if false, it will be asynchronous + @param newValue the new value to set - this will be restricted by the + minimum and maximum range, and will be snapped to the + nearest interval if one has been set + @param notification can be one of the NotificationType values, to request + a synchronous or asynchronous call to the valueChanged() method + of any Slider::Listeners that are registered. */ - void setValue (double newValue, - bool sendUpdateMessage = true, - bool sendMessageSynchronously = false); + void setValue (double newValue, NotificationType notification = sendNotificationAsync); /** Returns the slider's current value. */ double getValue() const; @@ -415,13 +411,12 @@ public: that are registered, and will synchronously call the valueChanged() method in case subclasses want to handle it. - @param newValue the new value to set - this will be restricted by the - minimum and maximum range, and will be snapped to the nearest - interval if one has been set. - @param sendUpdateMessage if false, a change to the value will not trigger a call to - any Slider::Listeners or the valueChanged() method - @param sendMessageSynchronously if true, then a call to the Slider::Listeners will be made - synchronously; if false, it will be asynchronous + @param newValue the new value to set - this will be restricted by the + minimum and maximum range, and will be snapped to the nearest + interval if one has been set. + @param notification can be one of the NotificationType values, to request + a synchronous or asynchronous call to the valueChanged() method + of any Slider::Listeners that are registered. @param allowNudgingOfOtherValues if false, this value will be restricted to being below the max value (in a two-value slider) or the mid value (in a three-value slider). If true, then if this value goes beyond those values, @@ -429,8 +424,7 @@ public: @see getMinValue, setMaxValue, setValue */ void setMinValue (double newValue, - bool sendUpdateMessage = true, - bool sendMessageSynchronously = false, + NotificationType notification = sendNotificationAsync, bool allowNudgingOfOtherValues = false); /** For a slider with two or three thumbs, this returns the higher of its values. @@ -457,13 +451,12 @@ public: that are registered, and will synchronously call the valueChanged() method in case subclasses want to handle it. - @param newValue the new value to set - this will be restricted by the - minimum and maximum range, and will be snapped to the nearest - interval if one has been set. - @param sendUpdateMessage if false, a change to the value will not trigger a call to - any Slider::Listeners or the valueChanged() method - @param sendMessageSynchronously if true, then a call to the Slider::Listeners will be made - synchronously; if false, it will be asynchronous + @param newValue the new value to set - this will be restricted by the + minimum and maximum range, and will be snapped to the nearest + interval if one has been set. + @param notification can be one of the NotificationType values, to request + a synchronous or asynchronous call to the valueChanged() method + of any Slider::Listeners that are registered. @param allowNudgingOfOtherValues if false, this value will be restricted to being above the min value (in a two-value slider) or the mid value (in a three-value slider). If true, then if this value goes beyond those values, @@ -471,8 +464,7 @@ public: @see getMaxValue, setMinValue, setValue */ void setMaxValue (double newValue, - bool sendUpdateMessage = true, - bool sendMessageSynchronously = false, + NotificationType notification = sendNotificationAsync, bool allowNudgingOfOtherValues = false); /** For a slider with two or three thumbs, this sets the minimum and maximum thumb positions. @@ -481,19 +473,17 @@ public: that are registered, and will synchronously call the valueChanged() method in case subclasses want to handle it. - @param newMinValue the new minimum value to set - this will be snapped to the - nearest interval if one has been set. - @param newMaxValue the new minimum value to set - this will be snapped to the - nearest interval if one has been set. - @param sendUpdateMessage if false, a change to the value will not trigger a call to - any Slider::Listeners or the valueChanged() method - @param sendMessageSynchronously if true, then a call to the Slider::Listeners will be made - synchronously; if false, it will be asynchronous + @param newMinValue the new minimum value to set - this will be snapped to the + nearest interval if one has been set. + @param newMaxValue the new minimum value to set - this will be snapped to the + nearest interval if one has been set. + @param notification can be one of the NotificationType values, to request + a synchronous or asynchronous call to the valueChanged() method + of any Slider::Listeners that are registered. @see setMaxValue, setMinValue, setValue */ void setMinAndMaxValues (double newMinValue, double newMaxValue, - bool sendUpdateMessage = true, - bool sendMessageSynchronously = false); + NotificationType notification = sendNotificationAsync); //============================================================================== /** A class for receiving callbacks from a Slider. @@ -820,6 +810,20 @@ private: void init (SliderStyle, TextEntryBoxPosition); + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // These methods' bool parameters have changed: see the new method signature. + JUCE_DEPRECATED (void setValue (double, bool)); + JUCE_DEPRECATED (void setValue (double, bool, bool)); + JUCE_DEPRECATED (void setMinValue (double, bool, bool, bool)); + JUCE_DEPRECATED (void setMinValue (double, bool, bool)); + JUCE_DEPRECATED (void setMinValue (double, bool)); + JUCE_DEPRECATED (void setMaxValue (double, bool, bool, bool)); + JUCE_DEPRECATED (void setMaxValue (double, bool, bool)); + JUCE_DEPRECATED (void setMaxValue (double, bool)); + JUCE_DEPRECATED (void setMinAndMaxValues (double, double, bool, bool)); + JUCE_DEPRECATED (void setMinAndMaxValues (double, double, bool)); + #endif + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Slider); }; diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/modules/juce_gui_basics/widgets/juce_TreeView.cpp index ba8d40e430..81bc135012 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -1271,7 +1271,8 @@ void TreeViewItem::deselectAllRecursively() } void TreeViewItem::setSelected (const bool shouldBeSelected, - const bool deselectOtherItemsFirst) + const bool deselectOtherItemsFirst, + const NotificationType notify) { if (shouldBeSelected && ! canBeSelected()) return; @@ -1285,7 +1286,8 @@ void TreeViewItem::setSelected (const bool shouldBeSelected, if (ownerView != nullptr) ownerView->repaint(); - itemSelectionChanged (shouldBeSelected); + if (notify != dontSendNotification) + itemSelectionChanged (shouldBeSelected); } } diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.h b/modules/juce_gui_basics/widgets/juce_TreeView.h index 9243339f31..793aede743 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.h +++ b/modules/juce_gui_basics/widgets/juce_TreeView.h @@ -142,10 +142,12 @@ public: bool isSelected() const noexcept; /** Selects or deselects the item. - This will cause a callback to itemSelectionChanged() + If shouldNotify == sendNotification, then a callback will be made + to itemSelectionChanged() */ void setSelected (bool shouldBeSelected, - bool deselectOtherItemsFirst); + bool deselectOtherItemsFirst, + NotificationType shouldNotify = sendNotification); /** Returns the rectangle that this item occupies.