5#ifndef MALENA_TEXTINPUTBASE_H
6#define MALENA_TEXTINPUTBASE_H
39 enum class Flag { DISABLED, READONLY };
235 void onChange(std::function<
void(
const std::string&)> callback);
static const sf::Font & getDefault()
Return the built-in Arial font.
void setBorderColor(const sf::Color &color)
Set the border color in the idle state.
sf::Color _borderFocusedColor
void setBorderFocusedColor(const sf::Color &color)
Set the border color when focused.
void applyBackgroundState()
std::function< void(const std::string &)> _onChange
bool hasError() const
Return true if the field is currently in error state.
void updatePlaceholderPosition()
unsigned int getCharacterSize() const
Return the current character size in points.
sf::Vector2f getPosition() const override
virtual void setSize(const sf::Vector2f &size)
Set the width and height of the input field.
TextInputManifest::State State
Convenience alias for TextInputManifest::State.
sf::Color _borderDisabledColor
void setEnabled(bool enabled)
Enable or disable the input field.
void setReadOnly(bool readonly)
Set the field to read-only mode.
sf::Color _placeholderColor
void setTextColor(const sf::Color &color)
Set the text color.
sf::Color _disabledTextColor
void setFont(const sf::Font &&)=delete
Deleted — rvalue font references are not supported.
void setBackgroundColor(const sf::Color &color)
Set the background fill color in the idle state.
float getPadding() const
Return the current padding in pixels.
sf::Color _borderErrorColor
void setBorderErrorColor(const sf::Color &color)
Set the border color in the error state.
void setError(bool error)
Put the field into or out of the error visual state.
virtual void setFont(const sf::Font &font)
Set the font used for text and placeholder.
virtual void setCharacterSize(unsigned int size)
Set the character size in points.
void setBorderThickness(float thickness)
Set the border outline thickness in pixels.
void onChange(std::function< void(const std::string &)> callback)
Register a callback invoked whenever the text content changes.
void setPlaceholderColor(const sf::Color &color)
Set the placeholder text color.
sf::Vector2f getSize() const
Return the current size of the input field.
void setBackgroundFocusedColor(const sf::Color &color)
Set the background fill color when focused.
sf::RectangleShape _background
bool isReadOnly() const
Return true if the field is read-only.
std::string getPlaceholder() const
Return the current placeholder string.
sf::Color _bgDisabledColor
TextInputBase(const sf::Font &font=FontManager<>::getDefault())
Construct a text input base with an optional font.
void setPadding(float padding)
Set the padding between the border and the text.
bool isEnabled() const
Return true if the field is currently enabled.
sf::Color _bgFocusedColor
void setPosition(const sf::Vector2f &position) override
void setPlaceholder(const std::string &text)
Set the placeholder text shown when the field is empty.
sf::FloatRect getGlobalBounds() const override
TextInputManifest::Flag Flag
Convenience alias for TextInputManifest::Flag.
Shared manifest for TextInput and TextArea.
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
@ FOCUSED
Component has keyboard focus (set by ClickableDispatcher).
Vector2< float > Vector2f