5#ifndef MALENA_TEXTINPUT_H
6#define MALENA_TEXTINPUT_H
21#include <SFML/Graphics.hpp>
31 enum class Flag { READONLY };
104 static_assert(std::is_base_of_v<TextInputSettings, S>,
105 "applySettings() requires a type derived from TextInputSettings");
115 static_assert(std::is_base_of_v<TextInputTheme, T>,
116 "applyTheme() requires a type derived from TextInputTheme");
121 template<
typename St>
124 static_assert(std::is_base_of_v<TextInputSettings, St> &&
125 std::is_base_of_v<TextInputTheme, St>,
126 "applyStyle() requires TextInputSettings and TextInputTheme");
223 void onChange(std::function<
void(
const std::string&)> callback);
224 void onSubmit(std::function<
void(
const std::string&)> callback);
233 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)
const sf::Font * _monoFont
unsigned int getCharSizeAt(std::size_t index) const
std::string getValue() const
void applyStyle(const St &s)
void changeSelectionIndent(int delta)
std::size_t getSelectionEnd() const
virtual void onRebuildComplete()
void setError(bool error)
void setSelection(std::size_t start, std::size_t end)
void setSelectionBold(bool bold)
std::size_t getCursor() const
void handleChar(const sf::Event::TextEntered &te)
std::function< void(const std::string &)> _onSubmit
void setSelectionAlign(int align)
TextAttribute getActiveStyle() const
The style that applies to text typed/selected at the caret right now — selection start if a selection...
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)
std::size_t getSelectionStart() const
sf::Vector2f getPosition() const override
virtual void setSize(const sf::Vector2f &size)
void setMonospaceFont(const sf::Font *font)
Register an alternate "monospace" font so it survives rich-text round-trips. Spans using this exact f...
void setFont(const sf::Font &&)=delete
sf::RectangleShape _background
TextInputManifest::State State
void onEnabledChanged(bool enabled) override
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())
sf::Color getColorAt(std::size_t index) const
virtual void syncPlaceholder()
void setRichText(const std::string &json)
void setClearSelectionOnBlur(bool enabled)
std::string getSelectedText() const
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
const sf::Font * getFontAt(std::size_t index) const
unsigned int getCharacterSize() const
void setSelectionCharSize(unsigned int size)
sf::Color getTextColor() const
void applySettings(const S &s)
virtual void setCharacterSize(unsigned int size)
void setSelectionListType(int listType)
sf::FloatRect getGlobalBounds() const override
std::string getRichText() const
bool _clearSelectionOnBlur
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...>.
nlohmann::json json
Alias for nlohmann::json.
@ FOCUSED
Component has keyboard focus (set by ClickableDispatcher).
Vector2< float > Vector2f
A styled attribute range applied to a span of characters.
Layout and behaviour settings for TextInput and TextArea.
Color tokens for TextInput and TextArea.
Universal design token set applied across all Themeable components.