NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::tui::component< P > 模板类 参考

组件模板 更多...

#include <component.hpp>

类 neforce::tui::component< P > 继承关系图:
[图例]

Protected 成员函数

const props_type & props () const noexcept
 获取父组件传入的属性
template<typename T>
state< T > & create_state (T initial)
 创建响应式状态变量
void set_props (props_type p)
 注入属性

额外继承的成员函数

Public 成员函数 继承自 neforce::tui::component_base
virtual element render ()=0
 声明式渲染
virtual bool on_key (const key_event &e)
 键盘事件处理
virtual bool on_mouse (const mouse_event &e)
 鼠标事件处理
virtual void on_mouse_leave ()
 鼠标离开回调
void set_pass_through (bool v) noexcept
 设置事件穿透
bool pass_through () const noexcept
 是否启用事件穿透
bool has_focus () const noexcept
 是否持有 Reconciler 键盘焦点
void set_has_focus (bool v) noexcept
 设置 Reconciler 焦点状态(由 Reconciler 调用)
virtual void on_animation (int64_t delta)
 动画帧回调
virtual void setup ()
 挂载回调
virtual void cleanup () noexcept
 卸载回调
virtual bool should_update ()
 是否需要更新
component_baseparent () const noexcept
 获取父组件
size_t child_count () const noexcept
 获取子组件数量
component_basechild_at (size_t i) const noexcept
 获取指定索引的子组件
int index () const noexcept
 获取自身在父组件中的索引
void add_child (unique_ptr< component_base > child)
 注册子组件
unique_ptr< component_baseremove_child (component_base *child)
 移除子组件
unique_ptr< component_basedetach ()
 从父组件中脱离自身
void detach_all_children ()
 移除所有子组件
virtual bool focusable () const
 是否可获取焦点
component_baseactive_child () noexcept
 获取当前激活的子组件
const component_baseactive_child () const noexcept
 获取当前激活的子组件
void set_active_child (component_base *child) noexcept
 设置激活的子组件
bool active () const noexcept
 是否处于激活状态
bool focused () const noexcept
 是否拥有焦点
virtual void take_focus ()
 请求焦点
void schedule_render ()
 调度重渲染
template<typename Ctx>
void provide_context (Ctx value)
 设置上下文值
template<typename Ctx>
const Ctx & context () const
 获取上下文值
Protected 属性 继承自 neforce::tui::component_base
component_baseparent_ = nullptr
 父组件指针
component_baseactive_child_ = nullptr
 当前激活的子组件
bool has_focus_ = false
 reconciler 焦点状态
bool pass_through_ = false
 事件穿透标志
strandstrand_ = nullptr
 串行执行器
io_contextctx_ = nullptr
 事件循环上下文
vector< unique_ptr< component_base > > children_
 子组件列表

详细描述

template<typename P = empty_props>
class neforce::tui::component< P >

组件模板

模板参数
P属性类型,父组件向子组件传递的只读参数

所有 TUI 组件应继承此类并实现 render()

在文件 component.hpp349 行定义.

成员函数说明

◆ create_state()

template<typename P = empty_props>
template<typename T>
state< T > & neforce::tui::component< P >::create_state ( T initial)
inlineprotected

创建响应式状态变量

模板参数
T值类型
参数
initial初始值
返回
状态变量引用

状态变量生命周期绑定到组件。

注解
必须在构造函数或 setup() 中调用,禁止在 render() 中动态创建。

在文件 component.hpp378 行定义.

引用了 neforce::make_shared(), neforce::move() , 以及 neforce::tui::component_base::strand_.

◆ props()

template<typename P = empty_props>
const props_type & neforce::tui::component< P >::props ( ) const
inlinenodiscardprotectednoexcept

获取父组件传入的属性

返回
属性常量引用

在文件 component.hpp365 行定义.

◆ set_props()

template<typename P = empty_props>
void neforce::tui::component< P >::set_props ( props_type p)
inlineprotected

注入属性

参数
p属性值

在文件 component.hpp388 行定义.

引用了 neforce::move().


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