2018-10-09 19:06:03 +02:00
|
|
|
#ifndef FTXUI_DOM_ELEMENTS_HPP
|
|
|
|
|
#define FTXUI_DOM_ELEMENTS_HPP
|
2018-09-18 08:48:40 +02:00
|
|
|
|
2019-01-03 00:35:59 +01:00
|
|
|
#include <functional>
|
|
|
|
|
|
2018-10-09 19:06:03 +02:00
|
|
|
#include "ftxui/dom/node.hpp"
|
2019-01-06 17:10:35 +01:00
|
|
|
#include "ftxui/screen/color.hpp"
|
2018-09-18 08:48:40 +02:00
|
|
|
|
2019-01-12 15:00:08 +01:00
|
|
|
namespace ftxui {
|
2018-09-18 08:48:40 +02:00
|
|
|
|
2018-09-19 21:52:25 +02:00
|
|
|
using Element = std::unique_ptr<Node>;
|
2019-01-12 18:24:46 +01:00
|
|
|
using Elements = std::vector<Element>;
|
2019-01-03 00:35:59 +01:00
|
|
|
using Decorator = std::function<Element(Element)>;
|
2018-09-19 21:52:25 +02:00
|
|
|
|
|
|
|
|
// --- Layout ----
|
2019-01-12 18:24:46 +01:00
|
|
|
Element vbox(Elements);
|
|
|
|
|
Element hbox(Elements);
|
|
|
|
|
Element dbox(Elements);
|
2019-01-06 19:17:27 +01:00
|
|
|
|
|
|
|
|
// -- Flexibility --
|
2019-01-05 02:03:49 +01:00
|
|
|
Element filler();
|
2019-01-02 22:33:59 +01:00
|
|
|
Element flex(Element);
|
2019-01-06 19:17:27 +01:00
|
|
|
Decorator size(size_t width, size_t height);
|
2018-09-19 21:52:25 +02:00
|
|
|
|
|
|
|
|
// --- Widget --
|
2018-09-22 09:49:43 +02:00
|
|
|
Element text(std::wstring text);
|
|
|
|
|
Element separator();
|
|
|
|
|
Element gauge(float ratio);
|
2019-01-05 02:03:49 +01:00
|
|
|
Element frame(Element);
|
2019-01-12 18:24:46 +01:00
|
|
|
Element window(Element title, Element content);
|
2019-01-06 22:28:15 +01:00
|
|
|
Element spinner(int charset_index, size_t image_index);
|
2018-10-09 19:06:03 +02:00
|
|
|
|
2019-01-05 02:03:49 +01:00
|
|
|
// -- Decorator ---
|
2018-10-09 19:06:03 +02:00
|
|
|
Element bold(Element);
|
|
|
|
|
Element dim(Element);
|
|
|
|
|
Element inverted(Element);
|
|
|
|
|
Element underlined(Element);
|
2018-10-21 14:18:11 +02:00
|
|
|
Element blink(Element);
|
2019-01-06 22:28:15 +01:00
|
|
|
|
2019-01-03 00:35:59 +01:00
|
|
|
Decorator color(Color);
|
|
|
|
|
Decorator bgcolor(Color);
|
2019-01-06 22:28:15 +01:00
|
|
|
Element color(Color, Element);
|
|
|
|
|
Element bgcolor(Color, Element);
|
2018-09-19 21:52:25 +02:00
|
|
|
|
2019-01-02 22:33:59 +01:00
|
|
|
// --- Util ---
|
2018-09-22 09:49:43 +02:00
|
|
|
Element hcenter(Element);
|
|
|
|
|
Element vcenter(Element);
|
|
|
|
|
Element center(Element);
|
2019-01-06 18:53:02 +01:00
|
|
|
Element align_right(Element);
|
2018-09-18 08:48:40 +02:00
|
|
|
|
2018-10-21 14:18:11 +02:00
|
|
|
// --- Util ---
|
|
|
|
|
Element nothing(Element element);
|
|
|
|
|
|
2019-01-05 02:03:49 +01:00
|
|
|
// Pipe elements into decorator togethers.
|
|
|
|
|
// Examples: text("ftxui") | bold | underlined;
|
|
|
|
|
Element operator|(Element, Decorator);
|
|
|
|
|
Decorator operator|(Decorator, Decorator);
|
|
|
|
|
|
2019-01-06 16:10:57 +01:00
|
|
|
// Make container able to take any number of children as input.
|
|
|
|
|
#include "take_any_args.hpp"
|
2019-01-05 02:03:49 +01:00
|
|
|
TAKE_ANY_ARGS(vbox)
|
|
|
|
|
TAKE_ANY_ARGS(hbox)
|
|
|
|
|
TAKE_ANY_ARGS(dbox)
|
2019-01-03 00:35:59 +01:00
|
|
|
|
2019-01-12 15:00:08 +01:00
|
|
|
}; // namespace ftxui
|
2018-09-18 08:48:40 +02:00
|
|
|
|
2018-10-09 19:06:03 +02:00
|
|
|
#endif /* end of include guard: FTXUI_DOM_ELEMENTS_HPP */
|