NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
style.hpp
浏览该文件的文档.
1#ifndef NEFORCE_TUI_DOM_STYLE_HPP__
2#define NEFORCE_TUI_DOM_STYLE_HPP__
3
10
13NEFORCE_BEGIN_NAMESPACE__
14NEFORCE_BEGIN_TUI__
15
21
25struct NEFORCE_API style {
29 struct padding {
30 int top = 0;
31 int right = 0;
32 int bottom = 0;
33 int left = 0;
34 };
35
39 struct margin {
40 int top = 0;
41 int right = 0;
42 int bottom = 0;
43 int left = 0;
44 };
45
49 enum class border : uint8_t {
51 single,
52 double_,
53 rounded,
54 };
55
59 enum class align : uint8_t {
60 start,
61 center,
63 stretch,
64 };
65
69 enum class justify : uint8_t {
70 start,
71 center,
73 space_between,
74 space_around,
75 };
76
80 enum class direction : uint8_t {
81 row,
82 column,
83 };
84
88 enum class variant : uint8_t {
89 default_,
90 primary,
91 secondary,
92 danger,
94 };
95
99 enum class wrap_mode : uint8_t {
101 word,
103 };
104
124
127
136
147
154 static style merge(const style& base, const style& over);
155};
156
176
180struct NEFORCE_API theme {
190
196 NEFORCE_NODISCARD style button_style(style::variant v) const;
197
202 NEFORCE_NODISCARD style text_style() const;
203
209 NEFORCE_NODISCARD style input_style(bool focused) const;
210};
211
215NEFORCE_INLINE17 constexpr theme dark_theme = {
216 /* .bg = */ .bg = color{16, 16, 16},
217 /* .fg = */ .fg = color{220, 220, 220},
218 /* .primary = */ .primary = color::cyan(),
219 /* .secondary = */ .secondary = color{100, 100, 220},
220 /* .danger = */ .danger = color::red(),
221 /* .success = */ .success = color::green(),
222 /* .warning = */ .warning = color::yellow(),
223 /* .muted = */ .muted = color{128, 128, 128},
224 /* .border = */ .border = color{64, 64, 64},
225};
226 // TUI
228
229NEFORCE_END_TUI__
230NEFORCE_END_NAMESPACE__
231#endif // NEFORCE_TUI_DOM_STYLE_HPP__
static constexpr color green() noexcept
绿色
static constexpr color red() noexcept
红色
static constexpr color yellow() noexcept
黄色
static constexpr color cyan() noexcept
青色
颜色类
unsigned char uint8_t
8位无符号整数类型
constexpr none_t none
默认空表示
constexpr theme dark_theme
预置暗色主题
decorator color(color c)
前景色装饰器
constexpr decltype(auto) end(Container &cont) noexcept(noexcept(cont.end()))
获取容器的结束迭代器
可选值类型
char类型包装类
布局容器属性
int cross_gap
换行时交叉轴间距
int gap
子元素间距
float flex_grow
弹性增长因子
style::size_hint height
高度约束
enum style::align align
交叉轴对齐
enum style::align align_content
多行/列时交叉轴内容对齐
style::justify justify
主轴对齐
bool wrap
是否允许换行
style::size_hint width
宽度约束
float flex_shrink
弹性收缩因子
style::direction dir
排列方向
size_mode mode
尺寸模式
@ auto_
由内容决定尺寸
@ fixed
固定字符数,由 value 指定
@ percent
父容器的百分比,value 为 0-100
int value
Fixed 字符数 / Percent 百分比 / Fill 弹性权重
optional< bool > underline
单下划线
optional< color > fg
前景色
direction
布局方向
optional< float > flex_grow
弹性增长权重
optional< bool > underlined_double
双下划线
justify
主轴对齐方式
variant
组件语义变体
optional< size_hint > width
宽度约束
optional< color > borderColor
边框颜色
optional< bool > blink
闪烁
optional< bool > dim
暗色
optional< bool > reverse
反色
wrap_mode
文本换行模式
optional< float > flex_shrink
弹性收缩权重
optional< wrap_mode > text_wrap
文本换行模式
optional< bool > strikethrough
删除线
static style merge(const style &base, const style &over)
合并两个样式
optional< bool > italic
斜体
optional< size_hint > height
高度约束
optional< color > bg
背景色
optional< bool > bold
粗体
style input_style(bool focused) const
获取输入框样式
color fg
默认前景色
style text_style() const
获取默认文本样式
style button_style(style::variant v) const
获取按钮样式
color border
边框色
color warning
警告色
color primary
主色调
color success
成功色
color bg
默认背景色
color muted
弱化/禁用色
color danger
危险/错误色
color secondary
次要色调