diff --git a/extras/Introjucer/Source/Application/jucer_JuceUpdater.cpp b/extras/Introjucer/Source/Application/jucer_JuceUpdater.cpp index 860b0d29ee..cfd0928f5c 100644 --- a/extras/Introjucer/Source/Application/jucer_JuceUpdater.cpp +++ b/extras/Introjucer/Source/Application/jucer_JuceUpdater.cpp @@ -55,7 +55,7 @@ JuceUpdater::JuceUpdater (ModuleList& moduleList_, const String& message) currentVersionLabel.setFont (Font (14.0f, Font::italic)); label.setFont (Font (12.0f)); - label.setText ("Local modules folder:", false); + label.setText ("Local modules folder:", dontSendNotification); addAndMakeVisible (&availableVersionsList); availableVersionsList.setModel (this); @@ -219,9 +219,9 @@ void JuceUpdater::filenameComponentChanged (FilenameComponent*) filenameComp.setCurrentFile (moduleList.getModulesFolder(), true, dontSendNotification); if (! ModuleList::isModulesFolder (moduleList.getModulesFolder())) - currentVersionLabel.setText ("(Not a Juce folder)", false); + currentVersionLabel.setText ("(Not a Juce folder)", dontSendNotification); else - currentVersionLabel.setText (String::empty, false); + currentVersionLabel.setText (String::empty, dontSendNotification); refresh(); } diff --git a/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp b/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp index 94523379ff..9efffd14f1 100644 --- a/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp +++ b/extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp @@ -308,7 +308,7 @@ public: editor.setColour (CaretComponent::caretColourId, Colours::black); addAndMakeVisible (&editor); - label.setText ("Find:", false); + label.setText ("Find:", dontSendNotification); label.setColour (Label::textColourId, Colours::white); label.attachToComponent (&editor, false); diff --git a/extras/Introjucer/Source/ComponentEditor/components/jucer_LabelHandler.h b/extras/Introjucer/Source/ComponentEditor/components/jucer_LabelHandler.h index 318d91d13a..0afbe7f58e 100644 --- a/extras/Introjucer/Source/ComponentEditor/components/jucer_LabelHandler.h +++ b/extras/Introjucer/Source/ComponentEditor/components/jucer_LabelHandler.h @@ -83,7 +83,7 @@ public: l->setJustificationType (Justification (xml.getIntAttribute ("justification", Justification::centred))); - l->setText (xml.getStringAttribute ("labelText", "Label Text"), false); + l->setText (xml.getStringAttribute ("labelText", "Label Text"), dontSendNotification); l->setEditable (xml.getBoolAttribute ("editableSingleClick", defaultLabel.isEditableOnSingleClick()), xml.getBoolAttribute ("editableDoubleClick", defaultLabel.isEditableOnDoubleClick()), @@ -220,7 +220,7 @@ private: bool perform() { showCorrectTab(); - getComponent()->setText (newState, false); + getComponent()->setText (newState, dontSendNotification); changed(); return true; } @@ -228,7 +228,7 @@ private: bool undo() { showCorrectTab(); - getComponent()->setText (oldState, false); + getComponent()->setText (oldState, dontSendNotification); changed(); return true; } diff --git a/extras/Introjucer/Source/ComponentEditor/properties/jucer_PositionPropertyBase.h b/extras/Introjucer/Source/ComponentEditor/properties/jucer_PositionPropertyBase.h index 2b254a11d2..0ef8816257 100644 --- a/extras/Introjucer/Source/ComponentEditor/properties/jucer_PositionPropertyBase.h +++ b/extras/Introjucer/Source/ComponentEditor/properties/jucer_PositionPropertyBase.h @@ -387,7 +387,7 @@ public: void refresh() { - textEditor->setText (getText(), false); + textEditor->setText (getText(), dontSendNotification); } void buttonClicked (Button*) diff --git a/extras/JuceDemo/Source/demos/OpenGLDemo.cpp b/extras/JuceDemo/Source/demos/OpenGLDemo.cpp index 3bc0d7591a..11e3b9d284 100644 --- a/extras/JuceDemo/Source/demos/OpenGLDemo.cpp +++ b/extras/JuceDemo/Source/demos/OpenGLDemo.cpp @@ -38,7 +38,7 @@ public: textScrollPos (200) { infoLabel.setText ("These sliders demonstrate how components and 2D graphics can be rendered " - "using OpenGL by using the OpenGLContext class.", false); + "using OpenGL by using the OpenGLContext class.", dontSendNotification); infoLabel.setInterceptsMouseClicks (false, false); addAndMakeVisible (&infoLabel); infoLabel.setBounds ("parent.width * 0.05, bottom - 150, parent.width * 0.4, parent.height - 60"); diff --git a/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp b/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp index 0f2a38ed67..9f3a63482c 100644 --- a/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp +++ b/extras/JuceDemo/Source/demos/RenderingTestComponent.cpp @@ -118,7 +118,8 @@ public: bounce (bouncingNumber[i], bouncingNumberDelta[i], 1.0f); owner.speedLabel->setText (String (getWidth()) + "x" + String (getHeight()) - + " - Render time: " + String (averageTime, 2) + "ms", false); + + " - Render time: " + String (averageTime, 2) + "ms", + dontSendNotification); if (owner.animatePositionToggle->getToggleState()) { diff --git a/extras/audio plugin demo/Source/PluginEditor.cpp b/extras/audio plugin demo/Source/PluginEditor.cpp index 3feff16a6d..bde4ae19c7 100644 --- a/extras/audio plugin demo/Source/PluginEditor.cpp +++ b/extras/audio plugin demo/Source/PluginEditor.cpp @@ -172,5 +172,5 @@ void JuceDemoPluginAudioProcessorEditor::displayPositionInfo (const AudioPlayHea else if (pos.isPlaying) displayText << " (playing)"; - infoLabel.setText (displayText, false); + infoLabel.setText (displayText, dontSendNotification); } diff --git a/extras/the jucer/src/model/components/jucer_LabelHandler.h b/extras/the jucer/src/model/components/jucer_LabelHandler.h index fc80a82f67..a0bbfede11 100644 --- a/extras/the jucer/src/model/components/jucer_LabelHandler.h +++ b/extras/the jucer/src/model/components/jucer_LabelHandler.h @@ -95,7 +95,7 @@ public: l->setJustificationType (Justification (xml.getIntAttribute ("justification", Justification::centred))); - l->setText (xml.getStringAttribute ("labelText", "Label Text"), false); + l->setText (xml.getStringAttribute ("labelText", "Label Text"), dontSendNotification); l->setEditable (xml.getBoolAttribute ("editableSingleClick", defaultLabel.isEditableOnSingleClick()), xml.getBoolAttribute ("editableDoubleClick", defaultLabel.isEditableOnDoubleClick()), @@ -232,7 +232,7 @@ private: bool perform() { showCorrectTab(); - getComponent()->setText (newState, false); + getComponent()->setText (newState, dontSendNotification); changed(); return true; } @@ -240,7 +240,7 @@ private: bool undo() { showCorrectTab(); - getComponent()->setText (oldState, false); + getComponent()->setText (oldState, dontSendNotification); changed(); return true; } diff --git a/extras/the jucer/src/properties/jucer_PositionPropertyBase.h b/extras/the jucer/src/properties/jucer_PositionPropertyBase.h index 1a6ad89fd2..9ceaac99b5 100644 --- a/extras/the jucer/src/properties/jucer_PositionPropertyBase.h +++ b/extras/the jucer/src/properties/jucer_PositionPropertyBase.h @@ -394,7 +394,7 @@ public: void refresh() { - textEditor->setText (getText(), false); + textEditor->setText (getText(), dontSendNotification); } void buttonClicked (Button*) diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index f2c9f898cf..0b38a6b97b 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -310,7 +310,7 @@ String FileBrowserComponent::getActionVerb() const void FileBrowserComponent::setFilenameBoxLabel (const String& name) { - fileLabel.setText (name, false); + fileLabel.setText (name, dontSendNotification); } FilePreviewComponent* FileBrowserComponent::getPreviewComponent() const noexcept diff --git a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp index 194c5aab58..a4d674021c 100644 --- a/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp @@ -47,7 +47,7 @@ public: void filesDropped (const StringArray& files, int, int) { - setText (getText() + files.joinIntoString (isMultiline ? "\n" : ", "), true); + setText (getText() + files.joinIntoString (isMultiline ? "\n" : ", "), sendNotificationSync); showEditor(); } @@ -102,7 +102,7 @@ TextPropertyComponent::~TextPropertyComponent() void TextPropertyComponent::setText (const String& newText) { - textEditor->setText (newText, true); + textEditor->setText (newText, sendNotificationSync); } String TextPropertyComponent::getText() const @@ -123,7 +123,7 @@ void TextPropertyComponent::createEditor (const int maxNumChars, const bool isMu void TextPropertyComponent::refresh() { - textEditor->setText (getText(), false); + textEditor->setText (getText(), dontSendNotification); } void TextPropertyComponent::textWasEdited() diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 57115bba05..5999e7afe6 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -280,7 +280,7 @@ void ComboBox::setSelectedId (const int newItemId, const bool dontSendChangeMess if (! dontSendChangeMessage) triggerAsyncUpdate(); - label->setText (newItemText, false); + label->setText (newItemText, dontSendNotification); lastCurrentId = newItemId; currentId = newItemId; @@ -333,7 +333,7 @@ void ComboBox::setText (const String& newText, const bool dontSendChangeMessage) if (label->getText() != newText) { - label->setText (newText, false); + label->setText (newText, dontSendNotification); if (! dontSendChangeMessage) triggerAsyncUpdate(); @@ -417,7 +417,7 @@ void ComboBox::lookAndFeelChanged() newLabel->setEditable (label->isEditable()); newLabel->setJustificationType (label->getJustificationType()); newLabel->setTooltip (label->getTooltip()); - newLabel->setText (label->getText(), false); + newLabel->setText (label->getText(), dontSendNotification); } label = newLabel; diff --git a/modules/juce_gui_basics/widgets/juce_Label.cpp b/modules/juce_gui_basics/widgets/juce_Label.cpp index c081d562b1..b62220f6e3 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -56,7 +56,7 @@ Label::~Label() //============================================================================== void Label::setText (const String& newText, - const bool broadcastChangeMessage) + const NotificationType notification) { hideEditor (true); @@ -71,7 +71,7 @@ void Label::setText (const String& newText, if (ownerComponent != nullptr) componentMovedOrResized (*ownerComponent, true, true); - if (broadcastChangeMessage) + if (notification != dontSendNotification) callChangeListeners(); } } @@ -86,7 +86,7 @@ String Label::getText (const bool returnActiveEditorContents) const void Label::valueChanged (Value&) { if (lastTextValue != textValue.toString()) - setText (textValue.toString(), true); + setText (textValue.toString(), sendNotification); } //============================================================================== @@ -359,16 +359,13 @@ class LabelKeyboardFocusTraverser : public KeyboardFocusTraverser public: LabelKeyboardFocusTraverser() {} - Component* getNextComponent (Component* current) - { - return KeyboardFocusTraverser::getNextComponent (dynamic_cast (current) != nullptr - ? current->getParentComponent() : current); - } + Component* getNextComponent (Component* c) { return KeyboardFocusTraverser::getNextComponent (getComp (c)); } + Component* getPreviousComponent (Component* c) { return KeyboardFocusTraverser::getPreviousComponent (getComp (c)); } - Component* getPreviousComponent (Component* current) + static Component* getComp (Component* current) { - return KeyboardFocusTraverser::getPreviousComponent (dynamic_cast (current) != nullptr - ? current->getParentComponent() : current); + return dynamic_cast (current) != nullptr + ? current->getParentComponent() : current; } }; diff --git a/modules/juce_gui_basics/widgets/juce_Label.h b/modules/juce_gui_basics/widgets/juce_Label.h index cf968a4f16..ccf648c659 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.h +++ b/modules/juce_gui_basics/widgets/juce_Label.h @@ -56,11 +56,11 @@ public: //============================================================================== /** Changes the label text. - If broadcastChangeMessage is true and the new text is different to the current - text, then the class will broadcast a change message to any Label::Listener objects - that are registered. + The NotificationType parameter indicates whether to send a change message to + any Label::Listener objects if the new text is different. */ - void setText (const String& newText, bool broadcastChangeMessage); + void setText (const String& newText, + NotificationType notification); /** Returns the label's current text. @@ -185,8 +185,7 @@ public: /** Destructor. */ virtual ~Listener() {} - /** Called when a Label's text has changed. - */ + /** Called when a Label's text has changed. */ virtual void labelTextChanged (Label* labelThatHasChanged) = 0; }; @@ -269,10 +268,10 @@ protected: virtual void textWasChanged(); /** Called when the text editor has just appeared, due to a user click or other focus change. */ - virtual void editorShown (TextEditor* editorComponent); + virtual void editorShown (TextEditor*); /** Called when the text editor is going to be deleted, after editing has finished. */ - virtual void editorAboutToBeHidden (TextEditor* editorComponent); + virtual void editorAboutToBeHidden (TextEditor*); //============================================================================== /** @internal */ @@ -309,6 +308,8 @@ protected: void colourChanged(); /** @internal */ void valueChanged (Value&); + /** @internal */ + void callChangeListeners(); private: //============================================================================== @@ -327,7 +328,6 @@ private: bool leftOfOwnerComp : 1; bool updateFromTextEditorContents (TextEditor&); - void callChangeListeners(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Label) }; diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 57c9499f83..cdc1ef6664 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -401,7 +401,7 @@ public: void updateText() { if (valueBox != nullptr) - valueBox->setText (owner.getTextFromValue (currentValue.getValue()), false); + valueBox->setText (owner.getTextFromValue (currentValue.getValue()), dontSendNotification); } double constrainedValue (double value) const @@ -564,7 +564,7 @@ public: owner.addAndMakeVisible (valueBox = lf.createSliderTextBox (owner)); valueBox->setWantsKeyboardFocus (false); - valueBox->setText (previousTextBoxContent, false); + valueBox->setText (previousTextBoxContent, dontSendNotification); if (valueBox->isEditable() != editableText) // (avoid overriding the single/double click flags unless we have to) valueBox->setEditable (editableText && owner.isEnabled()); diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 18142be1ec..08fa287ff8 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1113,6 +1113,7 @@ void TextEditor::lookAndFeelChanged() { setCaretVisible (false); setCaretVisible (true); + updateCaretPosition(); } }