5#include <SDL3/SDL_rect.h>
33 virtual void setText(
const std::string& text);
73 void onRender(
const SDL_FRect& screenRect)
override = 0;
98 SHIT_META(({.displayName =
"Text", .tooltip =
"文本内容"}))
100 SHIT_META(({.displayName =
"Placeholder", .tooltip =
"占位符文字"}))
102 SHIT_META(({.displayName =
"Font Path", .tooltip =
"字体文件路径"}))
104 SHIT_META(({.displayName =
"Font Size", .tooltip =
"字号", .range = {1, 300}}))
108 SHIT_META(({.displayName =
"Text Color", .tooltip =
"文字颜色"}))
110 SHIT_META(({.displayName =
"Placeholder Color", .tooltip =
"占位符颜色"}))
112 SHIT_META(({.displayName =
"Cursor Color", .tooltip =
"光标颜色"}))
114 SHIT_META(({.displayName =
"Selection Color", .tooltip =
"选区颜色"}))
140 static
size_t charToByte(const std::
string& s,
size_t charIdx);
141 static
size_t byteToChar(const std::
string& s,
size_t byteOff);
145 void onDetach() override;
146 void onDestroy() override;
#define SHIT_API
定义 Core.h:14
#define SHIT_REFLECT_BODY(Type)
定义 Macros.h:62
#define SHIT_REFLECT(Mode)
定义 Macros.h:59
#define SHIT_META(...)
定义 Macros.h:68
float getFontSize() const
定义 UITextInput.h:43
float m_fontHeight
定义 UITextInput.h:107
const Color & getCursorColor() const
定义 UITextInput.h:54
Color m_textColor
定义 UITextInput.h:109
bool isMultiline() const
定义 UITextInput.h:62
bool m_isMultiline
定义 UITextInput.h:97
const Color & getTextColor() const
定义 UITextInput.h:48
Color m_cursorColor
定义 UITextInput.h:113
const std::string & getText() const
定义 UITextInput.h:32
void setTextColor(const Color &color)
定义 UITextInput.h:49
virtual bool onKeyDown(KeyCode key, bool shift, bool ctrl)
子类可覆写:处理键盘控制键(方向键、退格、删除、Home/End、回车)
void onTextEditing(const char *utf8Text, int start, int length)
void markDirty()
标记脏位(下一帧重建纹理/布局)
定义 UITextInput.h:89
bool isFocused() const
定义 UITextInput.h:61
void setPlaceholderColor(const Color &color)
定义 UITextInput.h:52
size_t m_selectionAnchor
定义 UITextInput.h:123
static size_t charToByte(const std::string &s, size_t charIdx)
const std::string & getFontPath() const
定义 UITextInput.h:40
virtual void insertText(const std::string &utf8)
子类可覆写:向缓冲插入一段 UTF-8 文本
int m_preeditLength
定义 UITextInput.h:131
const Color & getSelectionColor() const
定义 UITextInput.h:57
void onRender(const SDL_FRect &screenRect) override=0
子类实现:在给定屏幕矩形内绘制自身(通过 Renderer 静态 API 绘制)
void onTextInput(const char *utf8Text)
virtual void insertNewline()
子类可覆写:当前选区是否被替换为换行(UITextBox 拒绝)
static size_t byteToChar(const std::string &s, size_t byteOff)
void setFontPath(const std::string &fontPath)
定义 UITextInput.h:41
void setSelectionColor(const Color &color)
定义 UITextInput.h:58
Color m_selectionColor
定义 UITextInput.h:115
std::string m_preedit
定义 UITextInput.h:127
float m_fontSize
定义 UITextInput.h:105
void moveCursor(int deltaChars, bool selecting)
std::string m_text
定义 UITextInput.h:99
size_t m_cursor
定义 UITextInput.h:121
void setFocused(bool focused)
由 UIRenderSystem 在命中时调用,切换聚焦
void setCursorColor(const Color &color)
定义 UITextInput.h:55
const Color & getPlaceholderColor() const
定义 UITextInput.h:51
void setFontSize(float fontSize)
定义 UITextInput.h:44
float getFontHeight() const
定义 UITextInput.h:46
TTF_Font * acquireFont()
获取或加载字体(进程级缓存,跨 UITextInput/UITextBox/UITextArea 共享)
const std::string & getPlaceholder() const
定义 UITextInput.h:36
void setPlaceholder(const std::string &placeholder)
定义 UITextInput.h:37
virtual void setText(const std::string &text)
int m_preeditStart
定义 UITextInput.h:129
bool m_isFocused
定义 UITextInput.h:95
friend class TextInputGate
定义 UITextInput.h:144
void moveCursorToBoundary(bool toStart, bool selecting)
std::string m_placeholder
定义 UITextInput.h:101
Color m_placeholderColor
定义 UITextInput.h:111
std::string m_fontPath
定义 UITextInput.h:103
size_t getCharacterCount() const
以"字符"计算文本长度
bool m_isDirty
定义 UITextInput.h:117
RGBA 颜色(每通道 8 位)
定义 Core.h:26