| @@ -191,6 +191,12 @@ void Label::editorShown (TextEditor* textEditor) | |||||
| { | { | ||||
| Component::BailOutChecker checker (this); | Component::BailOutChecker checker (this); | ||||
| listeners.callChecked (checker, [this, textEditor] (Label::Listener& l) { l.editorShown (this, *textEditor); }); | listeners.callChecked (checker, [this, textEditor] (Label::Listener& l) { l.editorShown (this, *textEditor); }); | ||||
| if (checker.shouldBailOut()) | |||||
| return; | |||||
| if (onEditorShow != nullptr) | |||||
| onEditorShow(); | |||||
| } | } | ||||
| void Label::editorAboutToBeHidden (TextEditor* textEditor) | void Label::editorAboutToBeHidden (TextEditor* textEditor) | ||||
| @@ -200,6 +206,12 @@ void Label::editorAboutToBeHidden (TextEditor* textEditor) | |||||
| Component::BailOutChecker checker (this); | Component::BailOutChecker checker (this); | ||||
| listeners.callChecked (checker, [this, textEditor] (Label::Listener& l) { l.editorHidden (this, *textEditor); }); | listeners.callChecked (checker, [this, textEditor] (Label::Listener& l) { l.editorHidden (this, *textEditor); }); | ||||
| if (checker.shouldBailOut()) | |||||
| return; | |||||
| if (onEditorHide != nullptr) | |||||
| onEditorHide(); | |||||
| } | } | ||||
| void Label::showEditor() | void Label::showEditor() | ||||
| @@ -404,6 +416,12 @@ void Label::callChangeListeners() | |||||
| { | { | ||||
| Component::BailOutChecker checker (this); | Component::BailOutChecker checker (this); | ||||
| listeners.callChecked (checker, [this] (Listener& l) { l.labelTextChanged (this); }); | listeners.callChecked (checker, [this] (Listener& l) { l.labelTextChanged (this); }); | ||||
| if (checker.shouldBailOut()) | |||||
| return; | |||||
| if (onTextChange != nullptr) | |||||
| onTextChange(); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -200,6 +200,16 @@ public: | |||||
| /** Deregisters a previously-registered listener. */ | /** Deregisters a previously-registered listener. */ | ||||
| void removeListener (Listener* listener); | void removeListener (Listener* listener); | ||||
| //============================================================================== | |||||
| /** You can assign a lambda to this callback object to have it called when the label text is changed. */ | |||||
| std::function<void()> onTextChange; | |||||
| /** You can assign a lambda to this callback object to have it called when the label's editor is shown. */ | |||||
| std::function<void()> onEditorShow; | |||||
| /** You can assign a lambda to this callback object to have it called when the label's editor is hidden. */ | |||||
| std::function<void()> onEditorHide; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Makes the label turn into a TextEditor when clicked. | /** Makes the label turn into a TextEditor when clicked. | ||||
| @@ -320,6 +320,12 @@ public: | |||||
| Component::BailOutChecker checker (&owner); | Component::BailOutChecker checker (&owner); | ||||
| listeners.callChecked (checker, [&] (Slider::Listener& l) { l.sliderValueChanged (&owner); }); | listeners.callChecked (checker, [&] (Slider::Listener& l) { l.sliderValueChanged (&owner); }); | ||||
| if (checker.shouldBailOut()) | |||||
| return; | |||||
| if (owner.onValueChange != nullptr) | |||||
| owner.onValueChange(); | |||||
| } | } | ||||
| void sendDragStart() | void sendDragStart() | ||||
| @@ -328,6 +334,12 @@ public: | |||||
| Component::BailOutChecker checker (&owner); | Component::BailOutChecker checker (&owner); | ||||
| listeners.callChecked (checker, [&] (Slider::Listener& l) { l.sliderDragStarted (&owner); }); | listeners.callChecked (checker, [&] (Slider::Listener& l) { l.sliderDragStarted (&owner); }); | ||||
| if (checker.shouldBailOut()) | |||||
| return; | |||||
| if (owner.onDragStart != nullptr) | |||||
| owner.onDragStart(); | |||||
| } | } | ||||
| void sendDragEnd() | void sendDragEnd() | ||||
| @@ -337,6 +349,12 @@ public: | |||||
| Component::BailOutChecker checker (&owner); | Component::BailOutChecker checker (&owner); | ||||
| listeners.callChecked (checker, [&] (Slider::Listener& l) { l.sliderDragEnded (&owner); }); | listeners.callChecked (checker, [&] (Slider::Listener& l) { l.sliderDragEnded (&owner); }); | ||||
| if (checker.shouldBailOut()) | |||||
| return; | |||||
| if (owner.onDragEnd != nullptr) | |||||
| owner.onDragEnd(); | |||||
| } | } | ||||
| struct DragInProgress | struct DragInProgress | ||||
| @@ -586,6 +586,16 @@ public: | |||||
| /** Removes a previously-registered listener. */ | /** Removes a previously-registered listener. */ | ||||
| void removeListener (Listener* listener); | void removeListener (Listener* listener); | ||||
| //============================================================================== | |||||
| /** You can assign a lambda to this callback object to have it called when the slider value is changed. */ | |||||
| std::function<void()> onValueChange; | |||||
| /** You can assign a lambda to this callback object to have it called when the slider's drag begins. */ | |||||
| std::function<void()> onDragStart; | |||||
| /** You can assign a lambda to this callback object to have it called when the slider's drag ends. */ | |||||
| std::function<void()> onDragEnd; | |||||
| //============================================================================== | //============================================================================== | ||||
| /** This lets you choose whether double-clicking moves the slider to a given position. | /** This lets you choose whether double-clicking moves the slider to a given position. | ||||