5#ifndef MALENA_TEXTINPUT_H
6#define MALENA_TEXTINPUT_H
21#include <SFML/Graphics.hpp>
31 enum class Flag { DISABLED, READONLY };
100 static_assert(std::is_base_of_v<TextInputSettings, S>,
101 "applySettings() requires a type derived from TextInputSettings");
111 static_assert(std::is_base_of_v<TextInputTheme, T>,
112 "applyTheme() requires a type derived from TextInputTheme");
117 template<
typename St>
120 static_assert(std::is_base_of_v<TextInputSettings, St> &&
121 std::is_base_of_v<TextInputTheme, St>,
122 "applyStyle() requires TextInputSettings and TextInputTheme");
174 void onChange(std::function<
void(
const std::string&)> callback);
175 void onSubmit(std::function<
void(
const std::string&)> callback);
184 template<
typename MANIFEST>
static const sf::Font & getDefault()
Return the built-in Arial font.
Base class for all Malena manifests.
Pure data layer for rich text editing.
Rendering layer for RichTextBuffer.
void setSelectionFont(const sf::Font &font)
std::string getValue() const
void applyStyle(const St &s)
virtual void onRebuildComplete()
void setError(bool error)
void setSelection(std::size_t start, std::size_t end)
void setSelectionBold(bool bold)
void handleChar(const sf::Event::TextEntered &te)
std::function< void(const std::string &)> _onSubmit
void setReadOnly(bool readonly)
void setSelectionItalic(bool italic)
sf::Vector2f getSize() const
void onSubmit(std::function< void(const std::string &)> callback)
void setValue(const std::string &value)
void applyTheme(const T &t)
virtual void rebuildAndScroll()
RichTextRenderer _renderer
void onChange(std::function< void(const std::string &)> callback)
void setSelectionColor(const sf::Color &color)
virtual void setFont(const sf::Font &font)
std::string getPlaceholder() const
std::function< void(const std::string &)> _onChange
virtual void handleKey(const sf::Event::KeyPressed &kp)
sf::Vector2f getPosition() const override
virtual void setSize(const sf::Vector2f &size)
void setFont(const sf::Font &&)=delete
sf::RectangleShape _background
TextInputManifest::State State
void setPlaceholder(const std::string &text)
void onThemeApplied(const Theme &theme) override
Called by ThemeManager when the active theme changes.
TextInputManifest::Flag Flag
sf::RenderTexture _canvas
virtual void setPosition(const sf::Vector2f &position) override
TextInput(const sf::Font &font=FontManager<>::getDefault())
virtual void syncPlaceholder()
std::string getSelectedText() const
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
unsigned int getCharacterSize() const
void setSelectionCharSize(unsigned int size)
void applySettings(const S &s)
virtual void setCharacterSize(unsigned int size)
void setEnabled(bool enabled)
sf::FloatRect getGlobalBounds() const override
virtual std::size_t hitTest(const sf::Vector2f &worldPos) const
void setSelectionUnderline(bool underline)
Shared manifest for TextInput and TextArea.
TextInput(const sf::Font &font=FontManager<>::getDefault())
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
@ FOCUSED
Component has keyboard focus (set by ClickableDispatcher).
Vector2< float > Vector2f
Layout and behaviour settings for TextInput and TextArea.
Color tokens for TextInput and TextArea.
Universal design token set applied across all Themeable components.