ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
UIRendererComponent类 参考abstract

UI 渲染控件基类(对应游戏世界的 RendererComponent) 更多...

#include <UIRendererComponent.h>

类 UIRendererComponent 继承关系图:
Component UIButton UIImage UIText UITextInput UITextArea UITextBox

Public 成员函数

 UIRendererComponent ()
 ~UIRendererComponent () override=default
void onAttach () override
void onDetach () override
void onDestroy () override
virtual void onRender (const SDL_FRect &screenRect)=0
 子类实现:在给定屏幕矩形内绘制自身(通过 Renderer 静态 API 绘制)
virtual bool containsPoint (const SDL_FRect &screenRect, const Vector2 &point) const
 点击命中检测:默认矩形内即命中,子类可覆写为更精确的形状
int getZIndex () const
void setZIndex (int zIndex)
bool isVisible () const
void setVisible (bool visible)
Public 成员函数 继承自 Component
 Component ()
virtual ~Component ()=default
virtual void onCreate ()
virtual void onAfterDeserialize ()
 反序列化完成后回调(Prefab::apply 逐组件调用一次,字段已写入)。 用于重建"直写字段绕过了 setter、无法自动触发的引擎状态"(如精灵纹理加载)。
 Component (const Component &)=delete
Componentoperator= (const Component &)=delete
 Component (Component &&)=delete
Componentoperator= (Component &&)=delete
GameObjectgetOwner () const
bool isRegistered () const

Protected 成员函数

void requestSort ()
 components变更后通知系统重排(实例:zIndex 变化)
Protected 成员函数 继承自 Component
void setRegistered (bool registered)

静态 Protected 成员函数

static SDL_Color toSDLColor (const Color &color)
 Color → SDL_Color 边界转换(供 UIText / UITextInput 系列传给 SDL_ttf 用)

Protected 属性

int m_zIndex = 0
 渲染层级(值越大越靠上)
bool m_isVisible = true
 是否参与渲染与命中
Protected 属性 继承自 Component
GameObjectm_owner = nullptr
bool m_isRegistered = false

详细描述

UI 渲染控件基类(对应游戏世界的 RendererComponent)

所有可渲染的 UI 控件(UIImage / UIText / UIButton 等)继承此类。 onAttach / onDetach 自动向 UIRenderSystem 注册 / 注销。 由 UIRenderSystem 每帧按 zIndex 排序后统一调用 onRender,屏幕矩形由 UITransform 计算。

构造及析构函数说明

◆ UIRendererComponent()

UIRendererComponent ( )

◆ ~UIRendererComponent()

~UIRendererComponent ( )
overridedefault

成员函数说明

◆ containsPoint()

virtual bool containsPoint ( const SDL_FRect & screenRect,
const Vector2 & point ) const
virtual

点击命中检测:默认矩形内即命中,子类可覆写为更精确的形状

◆ getZIndex()

int getZIndex ( ) const
inline

◆ isVisible()

bool isVisible ( ) const
inline

◆ onAttach()

void onAttach ( )
overridevirtual

重载 Component .

◆ onDestroy()

void onDestroy ( )
overridevirtual

重载 Component .

UIText 重载.

◆ onDetach()

void onDetach ( )
overridevirtual

重载 Component .

◆ onRender()

virtual void onRender ( const SDL_FRect & screenRect)
pure virtual

子类实现:在给定屏幕矩形内绘制自身(通过 Renderer 静态 API 绘制)

UIButton, UIImage, UIText, UITextArea, UITextBox , 以及 UITextInput 内被实现.

◆ requestSort()

void requestSort ( )
protected

components变更后通知系统重排(实例:zIndex 变化)

◆ setVisible()

void setVisible ( bool visible)
inline

◆ setZIndex()

void setZIndex ( int zIndex)
inline

◆ toSDLColor()

SDL_Color toSDLColor ( const Color & color)
inlinestaticprotected

Color → SDL_Color 边界转换(供 UIText / UITextInput 系列传给 SDL_ttf 用)

类成员变量说明

◆ m_isVisible

bool m_isVisible = true
protected

是否参与渲染与命中

◆ m_zIndex

int m_zIndex = 0
protected

渲染层级(值越大越靠上)


该类的文档由以下文件生成: