@@ -207,7 +207,7 @@ void JuceUpdater::updateInstallButtonStatus() | |||||
{ | { | ||||
const int numChecked = getNumCheckedModules(); | const int numChecked = getNumCheckedModules(); | ||||
installButton.setEnabled (numChecked > 0); | installButton.setEnabled (numChecked > 0); | ||||
selectAllButton.setToggleState (numChecked > latestList.modules.size() / 2, false); | |||||
selectAllButton.setToggleState (numChecked > latestList.modules.size() / 2, dontSendNotification); | |||||
} | } | ||||
void JuceUpdater::filenameComponentChanged (FilenameComponent*) | void JuceUpdater::filenameComponentChanged (FilenameComponent*) | ||||
@@ -320,7 +320,7 @@ public: | |||||
addAndMakeVisible (&caseButton); | addAndMakeVisible (&caseButton); | ||||
caseButton.setColour (ToggleButton::textColourId, Colours::white); | caseButton.setColour (ToggleButton::textColourId, Colours::white); | ||||
caseButton.setToggleState (isCaseSensitiveSearch(), false); | |||||
caseButton.setToggleState (isCaseSensitiveSearch(), dontSendNotification); | |||||
caseButton.addListener (this); | caseButton.addListener (this); | ||||
findPrev.setConnectedEdges (Button::ConnectedOnRight); | findPrev.setConnectedEdges (Button::ConnectedOnRight); | ||||
@@ -62,7 +62,7 @@ public: | |||||
if (! ButtonHandler::restoreFromXml (xml, comp, layout)) | if (! ButtonHandler::restoreFromXml (xml, comp, layout)) | ||||
return false; | return false; | ||||
tb->setToggleState (xml.getBoolAttribute ("state", false), false); | |||||
tb->setToggleState (xml.getBoolAttribute ("state", false), dontSendNotification); | |||||
return true; | return true; | ||||
} | } | ||||
@@ -75,7 +75,7 @@ public: | |||||
String s; | String s; | ||||
if (tb->getToggleState()) | if (tb->getToggleState()) | ||||
s << memberVariableName << "->setToggleState (true, false);\n"; | |||||
s << memberVariableName << "->setToggleState (true, dontSendNotification);\n"; | |||||
s << getColourIntialisationCode (component, memberVariableName) | s << getColourIntialisationCode (component, memberVariableName) | ||||
<< '\n'; | << '\n'; | ||||
@@ -117,7 +117,7 @@ private: | |||||
bool perform() | bool perform() | ||||
{ | { | ||||
showCorrectTab(); | showCorrectTab(); | ||||
getComponent()->setToggleState (newState, false); | |||||
getComponent()->setToggleState (newState, dontSendNotification); | |||||
changed(); | changed(); | ||||
return true; | return true; | ||||
} | } | ||||
@@ -125,7 +125,7 @@ private: | |||||
bool undo() | bool undo() | ||||
{ | { | ||||
showCorrectTab(); | showCorrectTab(); | ||||
getComponent()->setToggleState (oldState, false); | |||||
getComponent()->setToggleState (oldState, dontSendNotification); | |||||
changed(); | changed(); | ||||
return true; | return true; | ||||
} | } | ||||
@@ -42,7 +42,7 @@ struct NewProjectWizardClasses | |||||
setupComp.addChildAndSetID (c, "filesToCreate"); | setupComp.addChildAndSetID (c, "filesToCreate"); | ||||
c->addItemList (fileOptions, 1); | c->addItemList (fileOptions, 1); | ||||
c->setSelectedId (1, false); | |||||
c->setSelectedId (1, dontSendNotification); | |||||
Label* l = new Label (String::empty, TRANS("Files to Auto-Generate") + ":"); | Label* l = new Label (String::empty, TRANS("Files to Auto-Generate") + ":"); | ||||
l->attachToComponent (c, true); | l->attachToComponent (c, true); | ||||
@@ -482,7 +482,7 @@ struct NewProjectWizardClasses | |||||
addChildAndSetID (&projectType, "projectType"); | addChildAndSetID (&projectType, "projectType"); | ||||
projectType.addItemList (getWizardNames(), 1); | projectType.addItemList (getWizardNames(), 1); | ||||
projectType.setSelectedId (1, true); | |||||
projectType.setSelectedId (1, dontSendNotification); | |||||
projectType.setBounds ("100, projectName.bottom + 4, projectName.right, top + 22"); | projectType.setBounds ("100, projectName.bottom + 4, projectName.right, top + 22"); | ||||
typeLabel.attachToComponent (&projectType, true); | typeLabel.attachToComponent (&projectType, true); | ||||
projectType.addListener (this); | projectType.addListener (this); | ||||
@@ -253,7 +253,7 @@ AudioDemoSynthPage::AudioDemoSynthPage (AudioDeviceManager& deviceManager_) | |||||
sineButton->setButtonText ("Use sine wave"); | sineButton->setButtonText ("Use sine wave"); | ||||
sineButton->setRadioGroupId (321); | sineButton->setRadioGroupId (321); | ||||
sineButton->addListener (this); | sineButton->addListener (this); | ||||
sineButton->setToggleState (true, false); | |||||
sineButton->setToggleState (true, dontSendNotification); | |||||
addAndMakeVisible (sampledButton = new ToggleButton (String::empty)); | addAndMakeVisible (sampledButton = new ToggleButton (String::empty)); | ||||
sampledButton->setButtonText ("Use sampled sound"); | sampledButton->setButtonText ("Use sampled sound"); | ||||
@@ -520,7 +520,7 @@ RenderingTestComponent::RenderingTestComponent () | |||||
testTypeComboBox->setSelectedId (2); | testTypeComboBox->setSelectedId (2); | ||||
sizeSlider->setValue (1.0, dontSendNotification); | sizeSlider->setValue (1.0, dontSendNotification); | ||||
opacitySlider->setValue (1.0, dontSendNotification); | opacitySlider->setValue (1.0, dontSendNotification); | ||||
highQualityToggle->setToggleState (true, false); | |||||
highQualityToggle->setToggleState (true, dontSendNotification); | |||||
//[/Constructor] | //[/Constructor] | ||||
} | } | ||||
@@ -242,7 +242,7 @@ private: | |||||
{ | { | ||||
row = newRow; | row = newRow; | ||||
columnId = newColumn; | columnId = newColumn; | ||||
comboBox.setSelectedId (owner.getRating (row), true); | |||||
comboBox.setSelectedId (owner.getRating (row), dontSendNotification); | |||||
} | } | ||||
void comboBoxChanged (ComboBox* /*comboBoxThatHasChanged*/) | void comboBoxChanged (ComboBox* /*comboBoxThatHasChanged*/) | ||||
@@ -399,7 +399,7 @@ static Component* createRadioButtonPage() | |||||
tb->setTooltip ("a set of mutually-exclusive radio buttons"); | tb->setTooltip ("a set of mutually-exclusive radio buttons"); | ||||
if (i == 0) | if (i == 0) | ||||
tb->setToggleState (true, false); | |||||
tb->setToggleState (true, dontSendNotification); | |||||
} | } | ||||
for (int i = 0; i < 4; ++i) | for (int i = 0; i < 4; ++i) | ||||
@@ -429,7 +429,7 @@ static Component* createRadioButtonPage() | |||||
db->setBounds (25 + i * buttonSize, 180, buttonSize, buttonSize); | db->setBounds (25 + i * buttonSize, 180, buttonSize, buttonSize); | ||||
if (i == 0) | if (i == 0) | ||||
db->setToggleState (true, false); | |||||
db->setToggleState (true, dontSendNotification); | |||||
} | } | ||||
for (int i = 0; i < 4; ++i) | for (int i = 0; i < 4; ++i) | ||||
@@ -447,7 +447,7 @@ static Component* createRadioButtonPage() | |||||
| ((i != 3) ? Button::ConnectedOnRight : 0)); | | ((i != 3) ? Button::ConnectedOnRight : 0)); | ||||
if (i == 0) | if (i == 0) | ||||
tb->setToggleState (true, false); | |||||
tb->setToggleState (true, dontSendNotification); | |||||
} | } | ||||
return page; | return page; | ||||
@@ -1074,7 +1074,7 @@ public: | |||||
addAndMakeVisible (&enableButton); | addAndMakeVisible (&enableButton); | ||||
enableButton.setBounds (230, 10, 180, 24); | enableButton.setBounds (230, 10, 180, 24); | ||||
enableButton.setTooltip ("Enables/disables all the components"); | enableButton.setTooltip ("Enables/disables all the components"); | ||||
enableButton.setToggleState (true, false); | |||||
enableButton.setToggleState (true, dontSendNotification); | |||||
enableButton.addListener (this); | enableButton.addListener (this); | ||||
addAndMakeVisible (&transformSlider); | addAndMakeVisible (&transformSlider); | ||||
@@ -465,10 +465,10 @@ public: | |||||
bufferSizeDropDown = nullptr; | bufferSizeDropDown = nullptr; | ||||
if (outputDeviceDropDown != nullptr) | if (outputDeviceDropDown != nullptr) | ||||
outputDeviceDropDown->setSelectedId (-1, true); | |||||
outputDeviceDropDown->setSelectedId (-1, dontSendNotification); | |||||
if (inputDeviceDropDown != nullptr) | if (inputDeviceDropDown != nullptr) | ||||
inputDeviceDropDown->setSelectedId (-1, true); | |||||
inputDeviceDropDown->setSelectedId (-1, dontSendNotification); | |||||
} | } | ||||
resized(); | resized(); | ||||
@@ -498,7 +498,7 @@ private: | |||||
const int index = type->getIndexOfDevice (currentDevice, isInput); | const int index = type->getIndexOfDevice (currentDevice, isInput); | ||||
box->setSelectedId (index + 1, true); | |||||
box->setSelectedId (index + 1, dontSendNotification); | |||||
if (testButton != nullptr && ! isInput) | if (testButton != nullptr && ! isInput) | ||||
testButton->setEnabled (index >= 0); | testButton->setEnabled (index >= 0); | ||||
@@ -509,13 +509,13 @@ private: | |||||
{ | { | ||||
const StringArray devs (type->getDeviceNames (isInputs)); | const StringArray devs (type->getDeviceNames (isInputs)); | ||||
combo.clear (true); | |||||
combo.clear (dontSendNotification); | |||||
for (int i = 0; i < devs.size(); ++i) | for (int i = 0; i < devs.size(); ++i) | ||||
combo.addItem (devs[i], i + 1); | combo.addItem (devs[i], i + 1); | ||||
combo.addItem (getNoDeviceString(), -1); | combo.addItem (getNoDeviceString(), -1); | ||||
combo.setSelectedId (-1, true); | |||||
combo.setSelectedId (-1, dontSendNotification); | |||||
} | } | ||||
int getLowestY() const | int getLowestY() const | ||||
@@ -617,7 +617,7 @@ private: | |||||
sampleRateDropDown->addItem (String (rate) + " Hz", rate); | sampleRateDropDown->addItem (String (rate) + " Hz", rate); | ||||
} | } | ||||
sampleRateDropDown->setSelectedId (roundToInt (currentDevice->getCurrentSampleRate()), true); | |||||
sampleRateDropDown->setSelectedId (roundToInt (currentDevice->getCurrentSampleRate()), dontSendNotification); | |||||
sampleRateDropDown->addListener (this); | sampleRateDropDown->addListener (this); | ||||
} | } | ||||
@@ -651,7 +651,7 @@ private: | |||||
bs); | bs); | ||||
} | } | ||||
bufferSizeDropDown->setSelectedId (currentDevice->getCurrentBufferSizeSamples(), true); | |||||
bufferSizeDropDown->setSelectedId (currentDevice->getCurrentBufferSizeSamples(), dontSendNotification); | |||||
bufferSizeDropDown->addListener (this); | bufferSizeDropDown->addListener (this); | ||||
} | } | ||||
@@ -1059,7 +1059,7 @@ void AudioDeviceSelectorComponent::changeListenerCallback (ChangeBroadcaster*) | |||||
void AudioDeviceSelectorComponent::updateAllControls() | void AudioDeviceSelectorComponent::updateAllControls() | ||||
{ | { | ||||
if (deviceTypeDropDown != nullptr) | if (deviceTypeDropDown != nullptr) | ||||
deviceTypeDropDown->setText (deviceManager.getCurrentAudioDeviceType(), false); | |||||
deviceTypeDropDown->setText (deviceManager.getCurrentAudioDeviceType(), dontSendNotification); | |||||
if (audioDeviceSettingsComp == nullptr | if (audioDeviceSettingsComp == nullptr | ||||
|| audioDeviceSettingsCompType != deviceManager.getCurrentAudioDeviceType()) | || audioDeviceSettingsCompType != deviceManager.getCurrentAudioDeviceType()) | ||||
@@ -1112,7 +1112,7 @@ void AudioDeviceSelectorComponent::updateAllControls() | |||||
if (deviceManager.getDefaultMidiOutput() != nullptr) | if (deviceManager.getDefaultMidiOutput() != nullptr) | ||||
current = 1 + midiOuts.indexOf (deviceManager.getDefaultMidiOutputName()); | current = 1 + midiOuts.indexOf (deviceManager.getDefaultMidiOutputName()); | ||||
midiOutputSelector->setSelectedId (current, true); | |||||
midiOutputSelector->setSelectedId (current, dontSendNotification); | |||||
} | } | ||||
resized(); | resized(); | ||||
@@ -271,10 +271,12 @@ namespace juce | |||||
//============================================================================== | //============================================================================== | ||||
// Cross-compiler deprecation macros.. | // 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 | #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)) | #define JUCE_DEPRECATED(functionDef) functionDef __attribute__ ((deprecated)) | ||||
#else | #else | ||||
#define JUCE_DEPRECATED(functionDef) functionDef | #define JUCE_DEPRECATED(functionDef) functionDef | ||||
@@ -1224,7 +1224,7 @@ private: | |||||
explicit String (const PreallocationBytes&); // This constructor preallocates a certain amount of memory | explicit String (const PreallocationBytes&); // This constructor preallocates a certain amount of memory | ||||
void appendFixedLength (const char* text, int numExtraChars); | void appendFixedLength (const char* text, int numExtraChars); | ||||
size_t getByteOffsetOfEnd() const noexcept; | 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 | // This private cast operator should prevent strings being accidentally cast | ||||
// to bools (this is possible because the compiler can add an implicit cast | // to bools (this is possible because the compiler can add an implicit cast | ||||
@@ -124,7 +124,7 @@ void Button::setConnectedEdges (const int connectedEdgeFlags_) | |||||
//============================================================================== | //============================================================================== | ||||
void Button::setToggleState (const bool shouldBeOn, | void Button::setToggleState (const bool shouldBeOn, | ||||
const bool sendChangeNotification) | |||||
const NotificationType notification) | |||||
{ | { | ||||
if (shouldBeOn != lastToggleState) | if (shouldBeOn != lastToggleState) | ||||
{ | { | ||||
@@ -136,8 +136,11 @@ void Button::setToggleState (const bool shouldBeOn, | |||||
WeakReference<Component> deletionWatcher (this); | WeakReference<Component> deletionWatcher (this); | ||||
if (sendChangeNotification) | |||||
if (notification != dontSendNotification) | |||||
{ | { | ||||
// async callbacks aren't possible here | |||||
jassert (notification != sendNotificationAsync); | |||||
sendClickMessage (ModifierKeys()); | sendClickMessage (ModifierKeys()); | ||||
if (deletionWatcher == nullptr) | if (deletionWatcher == nullptr) | ||||
@@ -146,7 +149,7 @@ void Button::setToggleState (const bool shouldBeOn, | |||||
if (lastToggleState) | if (lastToggleState) | ||||
{ | { | ||||
turnOffOtherButtonsInGroup (sendChangeNotification); | |||||
turnOffOtherButtonsInGroup (notification); | |||||
if (deletionWatcher == nullptr) | if (deletionWatcher == nullptr) | ||||
return; | 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 | void Button::setClickingTogglesState (const bool shouldToggle) noexcept | ||||
{ | { | ||||
clickTogglesState = shouldToggle; | clickTogglesState = shouldToggle; | ||||
@@ -175,7 +183,7 @@ bool Button::getClickingTogglesState() const noexcept | |||||
void Button::valueChanged (Value& value) | void Button::valueChanged (Value& value) | ||||
{ | { | ||||
if (value.refersToSameSourceAs (isOn)) | if (value.refersToSameSourceAs (isOn)) | ||||
setToggleState (isOn.getValue(), true); | |||||
setToggleState (isOn.getValue(), sendNotification); | |||||
} | } | ||||
void Button::setRadioGroupId (const int newGroupId) | void Button::setRadioGroupId (const int newGroupId) | ||||
@@ -185,11 +193,11 @@ void Button::setRadioGroupId (const int newGroupId) | |||||
radioGroupId = newGroupId; | radioGroupId = newGroupId; | ||||
if (lastToggleState) | if (lastToggleState) | ||||
turnOffOtherButtonsInGroup (true); | |||||
turnOffOtherButtonsInGroup (sendNotification); | |||||
} | } | ||||
} | } | ||||
void Button::turnOffOtherButtonsInGroup (const bool sendChangeNotification) | |||||
void Button::turnOffOtherButtonsInGroup (const NotificationType notification) | |||||
{ | { | ||||
if (Component* const p = getParentComponent()) | if (Component* const p = getParentComponent()) | ||||
{ | { | ||||
@@ -207,7 +215,7 @@ void Button::turnOffOtherButtonsInGroup (const bool sendChangeNotification) | |||||
{ | { | ||||
if (b->getRadioGroupId() == radioGroupId) | if (b->getRadioGroupId() == radioGroupId) | ||||
{ | { | ||||
b->setToggleState (false, sendChangeNotification); | |||||
b->setToggleState (false, notification); | |||||
if (deletionWatcher == nullptr) | if (deletionWatcher == nullptr) | ||||
return; | return; | ||||
@@ -309,7 +317,7 @@ void Button::triggerClick() | |||||
void Button::internalClickCallback (const ModifierKeys& modifiers) | void Button::internalClickCallback (const ModifierKeys& modifiers) | ||||
{ | { | ||||
if (clickTogglesState) | if (clickTogglesState) | ||||
setToggleState ((radioGroupId != 0) || ! lastToggleState, false); | |||||
setToggleState ((radioGroupId != 0) || ! lastToggleState, dontSendNotification); | |||||
sendClickMessage (modifiers); | sendClickMessage (modifiers); | ||||
} | } | ||||
@@ -351,9 +359,6 @@ void Button::removeListener (ButtonListener* const listener) | |||||
buttonListeners.remove (listener); | buttonListeners.remove (listener); | ||||
} | } | ||||
void Button::addButtonListener (ButtonListener* l) { addListener (l); } | |||||
void Button::removeButtonListener (ButtonListener* l) { removeListener (l); } | |||||
void Button::sendClickMessage (const ModifierKeys& modifiers) | void Button::sendClickMessage (const ModifierKeys& modifiers) | ||||
{ | { | ||||
Component::BailOutChecker checker (this); | Component::BailOutChecker checker (this); | ||||
@@ -523,7 +528,7 @@ void Button::applicationCommandListChanged() | |||||
setEnabled (target != nullptr && (info.flags & ApplicationCommandInfo::isDisabled) == 0); | setEnabled (target != nullptr && (info.flags & ApplicationCommandInfo::isDisabled) == 0); | ||||
if (target != nullptr) | if (target != nullptr) | ||||
setToggleState ((info.flags & ApplicationCommandInfo::isTicked) != 0, false); | |||||
setToggleState ((info.flags & ApplicationCommandInfo::isTicked) != 0, dontSendNotification); | |||||
} | } | ||||
} | } | ||||
@@ -90,17 +90,17 @@ public: | |||||
an action you won't change this. Toggle buttons, however will want to | an action you won't change this. Toggle buttons, however will want to | ||||
change their state when turned on or off. | 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 | @see getToggleState, setRadioGroupId | ||||
*/ | */ | ||||
void setToggleState (bool shouldBeOn, | void setToggleState (bool shouldBeOn, | ||||
bool sendChangeNotification); | |||||
NotificationType notification); | |||||
/** Returns true if the button is 'on'. | /** Returns true if the button is 'on'. | ||||
@@ -353,6 +353,8 @@ public: | |||||
*/ | */ | ||||
void setState (const ButtonState newState); | void setState (const ButtonState newState); | ||||
// This method's parameters have changed - see the new version. | |||||
JUCE_DEPRECATED (void setToggleState (bool, bool)); | |||||
protected: | protected: | ||||
//============================================================================== | //============================================================================== | ||||
@@ -474,16 +476,12 @@ private: | |||||
ButtonState updateState(); | ButtonState updateState(); | ||||
ButtonState updateState (bool isOver, bool isDown); | ButtonState updateState (bool isOver, bool isDown); | ||||
bool isShortcutPressed() const; | bool isShortcutPressed() const; | ||||
void turnOffOtherButtonsInGroup (bool sendChangeNotification); | |||||
void turnOffOtherButtonsInGroup (NotificationType); | |||||
void flashButtonState(); | void flashButtonState(); | ||||
void sendClickMessage (const ModifierKeys&); | void sendClickMessage (const ModifierKeys&); | ||||
void sendStateMessage(); | 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) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Button) | ||||
}; | }; | ||||
@@ -2214,12 +2214,10 @@ public: | |||||
CachedComponentImage* getCachedComponentImage() const noexcept { return cachedImage; } | CachedComponentImage* getCachedComponentImage() const noexcept { return cachedImage; } | ||||
//============================================================================== | //============================================================================== | ||||
#ifndef DOXYGEN | |||||
// These methods are deprecated - use localPointToGlobal, getLocalPoint, getLocalPoint, etc instead. | // These methods are deprecated - use localPointToGlobal, getLocalPoint, getLocalPoint, etc instead. | ||||
JUCE_DEPRECATED (Point<int> relativePositionToGlobal (Point<int>) const); | JUCE_DEPRECATED (Point<int> relativePositionToGlobal (Point<int>) const); | ||||
JUCE_DEPRECATED (Point<int> globalPositionToRelative (Point<int>) const); | JUCE_DEPRECATED (Point<int> globalPositionToRelative (Point<int>) const); | ||||
JUCE_DEPRECATED (Point<int> relativePositionToOtherComponent (const Component*, Point<int>) const); | JUCE_DEPRECATED (Point<int> relativePositionToOtherComponent (const Component*, Point<int>) const); | ||||
#endif | |||||
private: | private: | ||||
//============================================================================== | //============================================================================== | ||||
@@ -244,7 +244,7 @@ void FileBrowserComponent::setRoot (const File& newRootDirectory) | |||||
if (currentRootName.isEmpty()) | if (currentRootName.isEmpty()) | ||||
currentRootName = File::separatorString; | currentRootName = File::separatorString; | ||||
currentPathBox.setText (currentRootName, true); | |||||
currentPathBox.setText (currentRootName, dontSendNotification); | |||||
goUpButton->setEnabled (currentRoot.getParentDirectory().isDirectory() | goUpButton->setEnabled (currentRoot.getParentDirectory().isDirectory() | ||||
&& currentRoot.getParentDirectory() != currentRoot); | && currentRoot.getParentDirectory() != currentRoot); | ||||
@@ -174,7 +174,7 @@ void FilenameComponent::setCurrentFile (File newFile, | |||||
if (addToRecentlyUsedList) | if (addToRecentlyUsedList) | ||||
addRecentlyUsedFile (newFile); | addRecentlyUsedFile (newFile); | ||||
filenameBox.setText (lastFilename, true); | |||||
filenameBox.setText (lastFilename, dontSendNotification); | |||||
if (notification != dontSendNotification) | if (notification != dontSendNotification) | ||||
{ | { | ||||
@@ -321,7 +321,7 @@ void TabbedButtonBar::setCurrentTabIndex (int newIndex, const bool sendChangeMes | |||||
for (int i = 0; i < tabs.size(); ++i) | for (int i = 0; i < tabs.size(); ++i) | ||||
{ | { | ||||
TabBarButton* tb = tabs.getUnchecked(i)->button; | TabBarButton* tb = tabs.getUnchecked(i)->button; | ||||
tb->setToggleState (i == newIndex, false); | |||||
tb->setToggleState (i == newIndex, dontSendNotification); | |||||
} | } | ||||
resized(); | resized(); | ||||
@@ -54,7 +54,7 @@ BooleanPropertyComponent::~BooleanPropertyComponent() | |||||
void BooleanPropertyComponent::setState (const bool newState) | void BooleanPropertyComponent::setState (const bool newState) | ||||
{ | { | ||||
button.setToggleState (newState, true); | |||||
button.setToggleState (newState, sendNotification); | |||||
} | } | ||||
bool BooleanPropertyComponent::getState() const | bool BooleanPropertyComponent::getState() const | ||||
@@ -75,7 +75,7 @@ void BooleanPropertyComponent::paint (Graphics& g) | |||||
void BooleanPropertyComponent::refresh() | void BooleanPropertyComponent::refresh() | ||||
{ | { | ||||
button.setToggleState (getState(), false); | |||||
button.setToggleState (getState(), dontSendNotification); | |||||
button.setButtonText (button.getToggleState() ? onText : offText); | button.setButtonText (button.getToggleState() ? onText : offText); | ||||
} | } | ||||
@@ -136,7 +136,7 @@ void ChoicePropertyComponent::refresh() | |||||
comboBox.addListener (this); | comboBox.addListener (this); | ||||
} | } | ||||
comboBox.setSelectedId (getIndex() + 1, true); | |||||
comboBox.setSelectedId (getIndex() + 1, dontSendNotification); | |||||
} | } | ||||
} | } | ||||
@@ -165,13 +165,13 @@ void ComboBox::changeItemText (const int itemId, const String& newText) | |||||
jassertfalse; | jassertfalse; | ||||
} | } | ||||
void ComboBox::clear (const bool dontSendChangeMessage) | |||||
void ComboBox::clear (const NotificationType notification) | |||||
{ | { | ||||
items.clear(); | items.clear(); | ||||
separatorPending = false; | separatorPending = false; | ||||
if (! label->isEditable()) | if (! label->isEditable()) | ||||
setSelectedItemIndex (-1, dontSendChangeMessage); | |||||
setSelectedItemIndex (-1, notification); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -257,9 +257,9 @@ int ComboBox::getSelectedItemIndex() const | |||||
return index; | 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 | int ComboBox::getSelectedId() const noexcept | ||||
@@ -269,21 +269,20 @@ int ComboBox::getSelectedId() const noexcept | |||||
return (item != nullptr && getText() == item->name) ? item->itemId : 0; | 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 ItemInfo* const item = getItemForId (newItemId); | ||||
const String newItemText (item != nullptr ? item->name : String::empty); | const String newItemText (item != nullptr ? item->name : String::empty); | ||||
if (lastCurrentId != newItemId || label->getText() != newItemText) | if (lastCurrentId != newItemId || label->getText() != newItemText) | ||||
{ | { | ||||
if (! dontSendChangeMessage) | |||||
triggerAsyncUpdate(); | |||||
label->setText (newItemText, dontSendNotification); | label->setText (newItemText, dontSendNotification); | ||||
lastCurrentId = newItemId; | lastCurrentId = newItemId; | ||||
currentId = newItemId; | currentId = newItemId; | ||||
repaint(); // for the benefit of the 'none selected' text | 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&) | void ComboBox::valueChanged (Value&) | ||||
{ | { | ||||
if (lastCurrentId != (int) currentId.getValue()) | if (lastCurrentId != (int) currentId.getValue()) | ||||
setSelectedId (currentId.getValue(), false); | |||||
setSelectedId (currentId.getValue()); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -313,7 +312,7 @@ String ComboBox::getText() const | |||||
return label->getText(); | 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;) | for (int i = items.size(); --i >= 0;) | ||||
{ | { | ||||
@@ -322,23 +321,20 @@ void ComboBox::setText (const String& newText, const bool dontSendChangeMessage) | |||||
if (item->isRealItem() | if (item->isRealItem() | ||||
&& item->name == newText) | && item->name == newText) | ||||
{ | { | ||||
setSelectedId (item->itemId, dontSendChangeMessage); | |||||
setSelectedId (item->itemId, notification); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
lastCurrentId = 0; | lastCurrentId = 0; | ||||
currentId = 0; | currentId = 0; | ||||
repaint(); | |||||
if (label->getText() != newText) | if (label->getText() != newText) | ||||
{ | { | ||||
label->setText (newText, dontSendNotification); | label->setText (newText, dontSendNotification); | ||||
if (! dontSendChangeMessage) | |||||
triggerAsyncUpdate(); | |||||
sendChange (notification); | |||||
} | } | ||||
repaint(); | |||||
} | } | ||||
void ComboBox::showEditor() | void ComboBox::showEditor() | ||||
@@ -594,3 +590,18 @@ void ComboBox::handleAsyncUpdate() | |||||
Component::BailOutChecker checker (this); | Component::BailOutChecker checker (this); | ||||
listeners.callChecked (checker, &ComboBoxListener::comboBoxChanged, this); // (can't use ComboBox::Listener due to idiotic VC2005 bug) | 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); } |
@@ -141,12 +141,12 @@ public: | |||||
/** Removes all the items from the drop-down list. | /** 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 | @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. | /** 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 will set the ComboBox's text to that of the item that matches | ||||
this ID. | 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 | @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. | /** 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 | This will set the ComboBox's text to that of the item at the given | ||||
index in the list. | 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 | @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. | /** 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 | items, then getSelectedId() will return -1, otherwise it wil return | ||||
the approriate ID. | 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 | @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. | /** Programmatically opens the text editor to allow the user to edit the current item. | ||||
@@ -371,6 +374,12 @@ public: | |||||
/** @internal */ | /** @internal */ | ||||
void valueChanged (Value&) override; | 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: | private: | ||||
//============================================================================== | //============================================================================== | ||||
struct ItemInfo | struct ItemInfo | ||||
@@ -395,6 +404,7 @@ private: | |||||
ItemInfo* getItemForId (int itemId) const noexcept; | ItemInfo* getItemForId (int itemId) const noexcept; | ||||
ItemInfo* getItemForIndex (int index) const noexcept; | ItemInfo* getItemForIndex (int index) const noexcept; | ||||
bool selectIfEnabled (int index); | bool selectIfEnabled (int index); | ||||
void sendChange (NotificationType); | |||||
static void popupMenuFinishedCallback (int, ComboBox*); | static void popupMenuFinishedCallback (int, ComboBox*); | ||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBox) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBox) | ||||
@@ -232,7 +232,7 @@ void DocumentWindow::resized() | |||||
ResizableWindow::resized(); | ResizableWindow::resized(); | ||||
if (Button* const b = getMaximiseButton()) | if (Button* const b = getMaximiseButton()) | ||||
b->setToggleState (isFullScreen(), false); | |||||
b->setToggleState (isFullScreen(), dontSendNotification); | |||||
const Rectangle<int> titleBarArea (getTitleBarArea()); | const Rectangle<int> titleBarArea (getTitleBarArea()); | ||||
@@ -312,7 +312,7 @@ public: | |||||
}; | }; | ||||
//============================================================================== | //============================================================================== | ||||
/** @deprecated - use setContentOwned() and setContentNonOwned() instead. */ | |||||
// Deprecated: use setContentOwned() and setContentNonOwned() instead. | |||||
JUCE_DEPRECATED (void setContentComponent (Component* newContentComponent, | JUCE_DEPRECATED (void setContentComponent (Component* newContentComponent, | ||||
bool deleteOldOne = true, | bool deleteOldOne = true, | ||||
bool resizeToFit = false)); | bool resizeToFit = false)); | ||||
@@ -130,7 +130,7 @@ void PreferencesPanel::setCurrentPage (const String& pageName) | |||||
{ | { | ||||
if (buttons.getUnchecked(i)->getName() == pageName) | if (buttons.getUnchecked(i)->getName() == pageName) | ||||
{ | { | ||||
buttons.getUnchecked(i)->setToggleState (true, false); | |||||
buttons.getUnchecked(i)->setToggleState (true, dontSendNotification); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||