16Elements Split(std::string_view the_text) {
19 size_t end = the_text.find(
' ');
20 while (end != std::string_view::npos) {
21 output.push_back(
text(the_text.substr(start, end - start)));
23 end = the_text.find(
' ', start);
25 output.push_back(
text(the_text.substr(start)));
29Element Split(std::string_view paragraph,
30 const std::function<
Element(std::string_view)>& f) {
33 size_t end = paragraph.find(
'\n');
34 while (end != std::string_view::npos) {
35 output.push_back(f(paragraph.substr(start, end - start)));
37 end = paragraph.find(
'\n', start);
39 output.push_back(f(paragraph.substr(start)));
40 return vbox(std::move(output));
56 return Split(the_text, [](std::string_view line) {
57 static const auto config = FlexboxConfig().SetGap(1, 0);
58 return flexbox(Split(line), config);
66 return Split(the_text, [](std::string_view line) {
67 static const auto config = FlexboxConfig().SetGap(1, 0).Set(
68 FlexboxConfig::JustifyContent::FlexEnd);
69 return flexbox(Split(line), config);
77 return Split(the_text, [](std::string_view line) {
78 static const auto config =
79 FlexboxConfig().SetGap(1, 0).Set(FlexboxConfig::JustifyContent::Center);
80 return flexbox(Split(line), config);
88 return Split(the_text, [](std::string_view line) {
89 static const auto config = FlexboxConfig().SetGap(1, 0).Set(
90 FlexboxConfig::JustifyContent::SpaceBetween);
92 words.push_back(
text(
"") | xflex);
93 return flexbox(std::move(words), config);
Element text(std::string_view text)
顯示一段 UTF8 編碼的 Unicode 文字。
Element paragraphAlignLeft(std::string_view the_text)
回傳一個在多行上繪製段落並靠左對齊的元素。
Element paragraphAlignJustify(std::string_view the_text)
回傳一個在多行上繪製段落並使用左右對齊的元素。
Element paragraphAlignCenter(std::string_view the_text)
回傳一個在多行上繪製段落並置中對齊的元素。
Element paragraph(std::string_view the_text)
回傳一個在多行上繪製段落的元素。
Element paragraphAlignRight(std::string_view the_text)
回傳一個在多行上繪製段落並靠右對齊的元素。
Element vbox(Elements children)
一個垂直一個接一個顯示元素的容器。
Element flexbox(Elements, FlexboxConfig config=FlexboxConfig())
一個容器,用於在行/列中顯示元素,並在滿時能夠換行到下一列/行。
std::shared_ptr< Node > Element
std::vector< Element > Elements