NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
renderer.hpp
浏览该文件的文档.
1#ifndef NEFORCE_TUI_RENDERER_HPP__
2#define NEFORCE_TUI_RENDERER_HPP__
3
11
15NEFORCE_BEGIN_NAMESPACE__
16NEFORCE_BEGIN_TUI__
17
22
24class component_base;
26
44
51class NEFORCE_API renderer {
52public:
60 renderer(screen& target, const theme& t, int term_w, int term_h);
61
68 void render(const element& tree, const vector<layout_rect>& layout, bool has_focus);
69
75 void set_term_size(int w, int h) {
76 term_w_ = w;
77 term_h_ = h;
78 }
79
84 NEFORCE_NODISCARD const vector<scrollbar_hit>& scrollbar_hits() const noexcept { return scrollbar_hits_; }
85
98 void render_text_block(int x, int y, int w, int h, const string& text, const tui::style& style, style::wrap_mode wm,
99 int* out_end_x = nullptr, int* out_end_y = nullptr);
100
110 void apply_border(int x, int y, int w, int h, enum style::border border, const _NEFORCE color& c);
111
118
130 void render_button(int x, int y, int w, int h, const string& label, const style& style, const tui::theme& theme,
132
143 void render_checkbox(int x, int y, int w, int h, const string& label, bool checked, const style& style);
144
151 void render_separator(int x, int y, int w);
152
160 void apply_clear(int x, int y, int w, int h);
161
169 void apply_text(int x, int y, const string& text, const style& style);
170
179 void apply_text(int x, int y, const string& text, const style& style, int max_x);
180
187 void clear_element_area(const element& el, const vector<layout_rect>& layout, int& idx);
188
189private:
190 struct clip_rect {
191 int x, y, w, h;
192 };
193
194 screen& screen_;
195 const theme& theme_;
196 int term_w_;
197 int term_h_;
198 vector<clip_rect> clip_stack_;
199 vector<scrollbar_hit> scrollbar_hits_;
200 bool has_focus_ = false;
201
202 void render_subtree(const element& el, const vector<layout_rect>& layout, int& idx);
203};
204
214NEFORCE_NODISCARD NEFORCE_API const element* find_element_at(const vector<layout_rect>& layout, const element& tree,
215 int mx, int my, int& idx);
216
229NEFORCE_NODISCARD NEFORCE_API component_base* hit_test_at(const vector<layout_rect>& layout, const element& tree,
230 int mx, int my, int& idx, component_base* fallback);
231 // TUI
233
234NEFORCE_END_TUI__
235NEFORCE_END_NAMESPACE__
236#endif // NEFORCE_TUI_RENDERER_HPP__
void set_term_size(int w, int h)
更新终端尺寸
void render_text_block(int x, int y, int w, int h, const string &text, const tui::style &style, style::wrap_mode wm, int *out_end_x=nullptr, int *out_end_y=nullptr)
渲染文本块
void render_checkbox(int x, int y, int w, int h, const string &label, bool checked, const style &style)
渲染复选框
void apply_text(int x, int y, const string &text, const style &style)
写入文本
void clear_element_area(const element &el, const vector< layout_rect > &layout, int &idx)
清除元素树中所有叶子元素区域
const vector< scrollbar_hit > & scrollbar_hits() const noexcept
获取本次渲染收集的滚动条命中信息
renderer(screen &target, const theme &t, int term_w, int term_h)
构造函数
void render(const element &tree, const vector< layout_rect > &layout, bool has_focus)
渲染元素树
void apply_text(int x, int y, const string &text, const style &style, int max_x)
写入文本
void apply_clear(int x, int y, int w, int h)
清除指定区域
void render_button(int x, int y, int w, int h, const string &label, const style &style, const tui::theme &theme, style::variant variant)
渲染按钮
void render_separator(int x, int y, int w)
渲染分隔线
void apply_style_to_cell(cell &cell, const style &style)
将样式字段应用到 cell
void apply_border(int x, int y, int w, int h, enum style::border border, const _NEFORCE color &c)
绘制边框
终端屏幕帧缓冲
动态大小数组容器
虚拟UI元素
decorator border(enum style::border b)
边框装饰器
const element * find_element_at(const vector< layout_rect > &layout, const element &tree, int mx, int my, int &idx)
在元素树中查找可点击元素
component_base * hit_test_at(const vector< layout_rect > &layout, const element &tree, int mx, int my, int &idx, component_base *fallback)
命中测试
decorator color(color c)
前景色装饰器
终端帧缓冲抽象
像素/字符单元
滚动条命中信息
variant
组件语义变体
wrap_mode
文本换行模式
变体类型主模板
TUI样式与主题系统