|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
组件模板 更多...
#include <component.hpp>
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_base * | parent () const noexcept |
| 获取父组件 | |
| size_t | child_count () const noexcept |
| 获取子组件数量 | |
| component_base * | child_at (size_t i) const noexcept |
| 获取指定索引的子组件 | |
| int | index () const noexcept |
| 获取自身在父组件中的索引 | |
| void | add_child (unique_ptr< component_base > child) |
| 注册子组件 | |
| unique_ptr< component_base > | remove_child (component_base *child) |
| 移除子组件 | |
| unique_ptr< component_base > | detach () |
| 从父组件中脱离自身 | |
| void | detach_all_children () |
| 移除所有子组件 | |
| virtual bool | focusable () const |
| 是否可获取焦点 | |
| component_base * | active_child () noexcept |
| 获取当前激活的子组件 | |
| const component_base * | active_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_base * | parent_ = nullptr |
| 父组件指针 | |
| component_base * | active_child_ = nullptr |
| 当前激活的子组件 | |
| bool | has_focus_ = false |
| reconciler 焦点状态 | |
| bool | pass_through_ = false |
| 事件穿透标志 | |
| strand * | strand_ = nullptr |
| 串行执行器 | |
| io_context * | ctx_ = nullptr |
| 事件循环上下文 | |
| vector< unique_ptr< component_base > > | children_ |
| 子组件列表 | |
组件模板
| P | 属性类型,父组件向子组件传递的只读参数 |
所有 TUI 组件应继承此类并实现 render()。
在文件 component.hpp 第 349 行定义.
|
inlineprotected |
创建响应式状态变量
| T | 值类型 |
| initial | 初始值 |
状态变量生命周期绑定到组件。
在文件 component.hpp 第 378 行定义.
引用了 neforce::make_shared(), neforce::move() , 以及 neforce::tui::component_base::strand_.
|
inlinenodiscardprotectednoexcept |
|
inlineprotected |