From 4bd38dc619b256374ef3aba1dc67319aa026a7a1 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 23 May 2014 22:08:19 +0100 Subject: [PATCH] Added callback Label::Listener::editorShown --- modules/juce_gui_basics/widgets/juce_Label.cpp | 9 ++++++++- modules/juce_gui_basics/widgets/juce_Label.h | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/juce_gui_basics/widgets/juce_Label.cpp b/modules/juce_gui_basics/widgets/juce_Label.cpp index 682c209ba6..727aacfb8e 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -189,7 +189,12 @@ void Label::componentVisibilityChanged (Component& component) //============================================================================== void Label::textWasEdited() {} void Label::textWasChanged() {} -void Label::editorShown (TextEditor*) {} + +void Label::editorShown (TextEditor* textEditor) +{ + Component::BailOutChecker checker (this); + listeners.callChecked (checker, &LabelListener::editorShown, this, *textEditor); +} void Label::editorAboutToBeHidden (TextEditor*) { @@ -444,3 +449,5 @@ void Label::textEditorFocusLost (TextEditor& ed) { textEditorTextChanged (ed); } + +void Label::Listener::editorShown (Label*, TextEditor&) {} diff --git a/modules/juce_gui_basics/widgets/juce_Label.h b/modules/juce_gui_basics/widgets/juce_Label.h index 7e7fcb21b5..a0e2f80c39 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.h +++ b/modules/juce_gui_basics/widgets/juce_Label.h @@ -74,7 +74,7 @@ public: You can call Value::referTo() on this object to make the label read and control a Value object that you supply. */ - Value& getTextValue() { return textValue; } + Value& getTextValue() noexcept { return textValue; } //============================================================================== /** Changes the font to use to draw the text. @@ -109,13 +109,12 @@ public: //============================================================================== /** Sets the style of justification to be used for positioning the text. - (The default is Justification::centredLeft) */ void setJustificationType (Justification justification); /** Returns the type of justification, as set in setJustificationType(). */ - Justification getJustificationType() const noexcept { return justification; } + Justification getJustificationType() const noexcept { return justification; } /** Changes the border that is left between the edge of the component and the text. By default there's a small gap left at the sides of the component to allow for @@ -124,7 +123,7 @@ public: void setBorderSize (BorderSize newBorderSize); /** Returns the size of the border to be left around the text. */ - BorderSize getBorderSize() const noexcept { return border; } + BorderSize getBorderSize() const noexcept { return border; } /** Makes this label "stick to" another component. @@ -149,16 +148,17 @@ public: Returns false if the label is above the other component. This is only relevent if attachToComponent() has been called. */ - bool isAttachedOnLeft() const noexcept { return leftOfOwnerComp; } + bool isAttachedOnLeft() const noexcept { return leftOfOwnerComp; } - /** Specifies the minimum amount that the font can be squashed horizantally before it starts + /** Specifies the minimum amount that the font can be squashed horizontally before it starts using ellipsis. @see Graphics::drawFittedText */ void setMinimumHorizontalScale (float newScale); - float getMinimumHorizontalScale() const noexcept { return minimumHorizontalScale; } + /** Specifies the amount that the font can be squashed horizontally. */ + float getMinimumHorizontalScale() const noexcept { return minimumHorizontalScale; } //============================================================================== /** @@ -179,6 +179,9 @@ public: /** Called when a Label's text has changed. */ virtual void labelTextChanged (Label* labelThatHasChanged) = 0; + + /** Called when a Label goes into editing mode and displays a TextEditor. */ + virtual void editorShown (Label*, TextEditor& textEditorShown); }; /** Registers a listener that will be called when the label's text changes. */ @@ -225,7 +228,6 @@ public: bool isEditable() const noexcept { return editSingleClick || editDoubleClick; } /** Makes the editor appear as if the label had been clicked by the user. - @see textWasEdited, setEditable */ void showEditor();