2018-10-10 01:06:03 +08:00
|
|
|
#ifndef FTXUI_DOM_ELEMENTS_HPP
|
|
|
|
#define FTXUI_DOM_ELEMENTS_HPP
|
2018-09-18 14:48:40 +08:00
|
|
|
|
2018-10-12 15:23:37 +08:00
|
|
|
#include "ftxui/color.hpp"
|
2018-10-10 01:06:03 +08:00
|
|
|
#include "ftxui/dom/node.hpp"
|
2018-09-18 14:48:40 +08:00
|
|
|
|
|
|
|
namespace ftxui {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-09-20 03:52:25 +08:00
|
|
|
using Element = std::unique_ptr<Node>;
|
2018-09-22 15:49:43 +08:00
|
|
|
using Child = std::unique_ptr<Node>;
|
2018-10-10 01:06:03 +08:00
|
|
|
using Children = std::vector<Child>;
|
2018-09-20 03:52:25 +08:00
|
|
|
|
|
|
|
// --- Layout ----
|
2018-09-22 15:49:43 +08:00
|
|
|
Element vbox(Children);
|
|
|
|
Element hbox(Children);
|
|
|
|
Element flex();
|
2018-09-20 03:52:25 +08:00
|
|
|
|
|
|
|
// --- Widget --
|
2018-09-22 15:49:43 +08:00
|
|
|
Element text(std::wstring text);
|
|
|
|
Element separator();
|
|
|
|
Element gauge(float ratio);
|
|
|
|
Element frame(Child);
|
2018-10-10 01:06:03 +08:00
|
|
|
Element frame(Child title, Child content);
|
|
|
|
|
|
|
|
// -- Decorator (Style) ---
|
|
|
|
Element bold(Element);
|
|
|
|
Element dim(Element);
|
|
|
|
Element inverted(Element);
|
|
|
|
Element underlined(Element);
|
2018-10-12 15:23:37 +08:00
|
|
|
Element color(Color, Element);
|
|
|
|
Element bgcolor(Color, Element);
|
2018-09-20 03:52:25 +08:00
|
|
|
|
|
|
|
// --- Decorator ---
|
2018-09-22 15:49:43 +08:00
|
|
|
Element hcenter(Element);
|
|
|
|
Element vcenter(Element);
|
|
|
|
Element center(Element);
|
|
|
|
Element flex(Element);
|
2018-09-18 14:48:40 +08:00
|
|
|
|
|
|
|
template <class... Args>
|
2018-10-10 01:06:03 +08:00
|
|
|
Children unpack(Args... args) {
|
|
|
|
Children vec;
|
2018-09-18 14:48:40 +08:00
|
|
|
(vec.push_back(std::forward<Args>(args)), ...);
|
|
|
|
return vec;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class... Args>
|
2018-10-10 01:06:03 +08:00
|
|
|
Element vbox(Args... children) {
|
2018-09-18 14:48:40 +08:00
|
|
|
return vbox(unpack(std::forward<Args>(children)...));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class... Args>
|
2018-10-10 01:06:03 +08:00
|
|
|
Element hbox(Args... children) {
|
2018-09-18 14:48:40 +08:00
|
|
|
return hbox(unpack(std::forward<Args>(children)...));
|
|
|
|
}
|
|
|
|
|
|
|
|
}; // namespace dom
|
|
|
|
}; // namespace ftxui
|
|
|
|
|
2018-10-10 01:06:03 +08:00
|
|
|
#endif /* end of include guard: FTXUI_DOM_ELEMENTS_HPP */
|