38 isMultiline (multiline)
47 return interestedInFileDrag;
59 ed->setInputRestrictions (maxChars);
63 ed->setMultiLine (
true,
true);
64 ed->setReturnKeyStartsNewLine (
true);
72 owner.textWasEdited();
83 void setInterestedInFileDrag (
bool isInterested)
85 interestedInFileDrag = isInterested;
88 void setTextToDisplayWhenEmpty (
const String& text,
float alpha)
90 textToDisplayWhenEmpty = text;
91 alphaToUseForEmptyText = alpha;
100 auto labelFont =
lf.getLabelFont (*
this);
106 jmax (1, (
int) ((
float) textArea.getHeight() / labelFont.getHeight())),
116 bool interestedInFileDrag =
true;
118 String textToDisplayWhenEmpty;
119 float alphaToUseForEmptyText = 0.0f;
141 if (newValue.toString().
isEmpty())
163 isMultiLine (multiLine)
182 textEditor->setTextToDisplayWhenEmpty (value.
getDefault(), 0.5f);
186 textEditor->setTextToDisplayWhenEmpty (value.
getDefault(), 0.5f);
191TextPropertyComponent::~TextPropertyComponent() {}
200 return textEditor->getText();
205 return textEditor->getTextValue();
208void TextPropertyComponent::createEditor (
int maxNumChars,
bool isEditable)
210 textEditor.reset (
new LabelComp (*
this,
maxNumChars, isMultiLine, isEditable));
225void TextPropertyComponent::textWasEdited()
227 auto newText = textEditor->getText();
238void TextPropertyComponent::callListeners()
241 listenerList.callChecked (
checker, [
this] (Listener&
l) {
l.textPropertyComponentChanged (
this); });
247 textEditor->updateColours();
252 if (textEditor !=
nullptr)
253 textEditor->setInterestedInFileDrag (isInterested);
258 if (textEditor !=
nullptr)
259 textEditor->setEditable (isEditable, isEditable);
Rectangle< ValueType > subtractedFrom(const Rectangle< ValueType > &original) const noexcept
Returns a rectangle with these borders removed from it.
Colour withAlpha(uint8 newAlpha) const noexcept
Returns a colour that's the same colour as this one, but with a new alpha value.
A class to keep an eye on a component and check for it being deleted.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void repaint()
Marks the whole component as needing to be redrawn.
void setColour(int colourID, Colour newColour)
Registers a colour to be used for a particular purpose.
Colour findColour(int colourID, bool inheritFromParent=false) const
Looks for a colour that has been registered with the given colour ID number.
LookAndFeel & getLookAndFeel() const noexcept
Finds the appropriate look-and-feel to use for this component.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
virtual void colourChanged()
This method is called when a colour is changed by the setColour() method, or when the look-and-feel i...
Components derived from this class can have files dropped onto them by an external application.
A graphics context, used for drawing a component or image.
void drawFittedText(const String &text, int x, int y, int width, int height, Justification justificationFlags, int maximumNumberOfLines, float minimumHorizontalScale=0.0f) const
Tries to draw a text string inside a given space.
void setFont(const Font &newFont)
Changes the font to use for subsequent text-drawing functions.
void setColour(Colour newColour)
Changes the current drawing colour.
@ topLeft
Indicates that the item should be placed in the top-left corner.
A component that displays a text string, and can optionally become a text editor when clicked.
virtual TextEditor * createEditorComponent()
Creates the TextEditor component that will be used when the user has clicked on the label.
void setEditable(bool editOnSingleClick, bool editOnDoubleClick=false, bool lossOfFocusDiscardsChanges=false)
Makes the label turn into a TextEditor when clicked.
@ outlineColourId
An optional colour to use to draw a border around the label.
@ backgroundColourId
The background colour to fill the label with.
@ textColourId
The colour for the text.
Justification getJustificationType() const noexcept
Returns the type of justification, as set in setJustificationType().
bool isBeingEdited() const noexcept
Returns true if the editor is currently focused and active.
void showEditor()
Makes the editor appear as if the label had been clicked by the user.
float getMinimumHorizontalScale() const noexcept
Specifies the amount that the font can be squashed horizontally.
void setText(const String &newText, NotificationType notification)
Changes the label text.
A base class for a component that goes in a PropertyPanel and displays one of an item's properties.
int preferredHeight
Used by the PropertyPanel to determine how high this component needs to be.
A special array for holding a list of strings.
String joinIntoString(StringRef separatorString, int startIndex=0, int numberOfElements=-1) const
Joins the strings in the array together into one string.
bool isEmpty() const noexcept
Returns true if the string contains no characters.
void filesDropped(const StringArray &files, int, int) override
Callback to indicate that the user has dropped the files onto this component.
void paintOverChildren(Graphics &g) override
Components can override this method to draw over the top of their children.
bool isInterestedInFileDrag(const StringArray &) override
Callback to check whether this target is interested in the set of files being offered.
TextEditor * createEditorComponent() override
Creates the TextEditor component that will be used when the user has clicked on the label.
void textWasEdited() override
Called after the user changes the text.
Used to receive callbacks for text changes.
A PropertyComponent that shows its value as editable text.
void setInterestedInFileDrag(bool isInterested)
Sets whether the text property component can have files dropped onto it by an external application.
void refresh() override
Updates the property component if the item it refers to has changed.
void setEditable(bool isEditable)
Sets whether the text editor is editable.
void colourChanged() override
This method is called when a colour is changed by the setColour() method, or when the look-and-feel i...
virtual void setText(const String &newText)
Called when the user edits the text.
Value & getValue() const
Returns the text that should be shown in the text editor as a Value object.
virtual String getText() const
Returns the text that should be shown in the text editor.
void addListener(Listener *newListener)
Registers a listener to receive events when this button's state changes.
TextPropertyComponent(const String &propertyName, int maxNumChars, bool isMultiLine, bool isEditable=true)
Creates a text property component.
@ backgroundColourId
The colour to fill the background of the text area.
@ outlineColourId
The colour to use to draw an outline around the text area.
@ textColourId
The colour to use for the editable text.
void removeListener(Listener *listener)
Removes a previously-registered button listener.
var getValue() const override
Returns the current value of this object.
void setValue(const var &newValue) override
Changes the current value.
This class acts as a wrapper around a property inside a ValueTree.
bool isUsingDefault() const
Returns true if the property does not exist in the referenced ValueTree.
var getDefault() const
Returns the current default value.
std::function< void()> onDefaultChange
You can assign a lambda to this callback and it will called when the default value is changed.
void resetToDefault() noexcept
Removes the property from the referenced ValueTree.
var get() const noexcept
Returns the current value of the property.
Used internally by the Value class as the base class for its shared value objects.
Represents a shared variant value.
A variant class, that can be used to hold a range of primitive values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
@ sendNotificationSync
Requests a synchronous notification.
@ dontSendNotification
No notification message should be sent.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...