22 int direction_index = 0;
24 int justify_content_index = 0;
25 int align_items_index = 0;
26 int align_content_index = 0;
28 std::vector<std::string> directions = {
35 std::vector<std::string> wraps = {
41 std::vector<std::string> justify_content = {
42 "FlexStart",
"FlexEnd",
"Center",
"Stretch",
43 "SpaceBetween",
"SpaceAround",
"SpaceEvenly",
46 std::vector<std::string> align_items = {
53 std::vector<std::string> align_content = {
54 "FlexStart",
"FlexEnd",
"Center",
"Stretch",
55 "SpaceBetween",
"SpaceAround",
"SpaceEvenly",
58 auto radiobox_direction =
Radiobox(&directions, &direction_index);
59 auto radiobox_wrap =
Radiobox(&wraps, &wrap_index);
60 auto radiobox_justify_content =
61 Radiobox(&justify_content, &justify_content_index);
62 auto radiobox_align_items =
Radiobox(&align_items, &align_items_index);
63 auto radiobox_align_content =
Radiobox(&align_content, &align_content_index);
65 bool element_xflex_grow =
false;
66 bool element_yflex_grow =
false;
67 bool group_xflex_grow =
true;
68 bool group_yflex_grow =
true;
69 auto checkbox_element_xflex_grow =
70 Checkbox(
"element |= xflex_grow", &element_xflex_grow);
71 auto checkbox_element_yflex_grow =
72 Checkbox(
"element |= yflex_grow", &element_yflex_grow);
73 auto checkbox_group_xflex_grow =
74 Checkbox(
"group |= xflex_grow", &group_xflex_grow);
75 auto checkbox_group_yflex_grow =
76 Checkbox(
"group |= yflex_grow", &group_yflex_grow);
78 auto make_box = [&](
size_t dimx,
size_t dimy,
size_t index) {
79 std::string title = std::to_string(dimx) +
"x" + std::to_string(dimy);
80 auto element =
window(
text(title) | hcenter | bold,
81 text(std::to_string(index)) | hcenter | dim) |
85 if (element_xflex_grow)
87 if (element_yflex_grow)
92 auto content_renderer =
Renderer([&] {
122 if (!group_xflex_grow)
124 if (!group_yflex_grow)
127 group = group |
flex;
134 int space_right = 10;
135 int space_bottom = 1;
138 content_renderer, &space_right);
141 content_renderer, &space_bottom);
148 checkbox_element_xflex_grow,
149 checkbox_element_yflex_grow,
150 checkbox_group_xflex_grow,
151 checkbox_group_yflex_grow,
154 Container::Horizontal({
155 radiobox_justify_content,
156 radiobox_align_items,
157 radiobox_align_content,
162 auto main_renderer =
Renderer(main_container, [&] {
166 radiobox_direction->
Render()),
170 checkbox_element_xflex_grow->Render(),
171 checkbox_element_yflex_grow->Render(),
172 checkbox_group_xflex_grow->Render(),
173 checkbox_group_yflex_grow->Render(),
178 radiobox_justify_content->
Render()),
180 radiobox_align_items->
Render()),
182 radiobox_align_content->
Render()),
184 content_renderer->Render() | flex |
border,
188 screen.Loop(main_renderer);
Element make_box(int x, int y)
static ScreenInteractive Fullscreen()
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Component Radiobox(RadioboxOption options)
A list of element, where only one can be selected.
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Component ResizableSplitRight(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Component ResizableSplitBottom(Component main, Component back, int *main_size)
An vertical split in between two components, configurable using the mouse.
Component Checkbox(CheckboxOption options)
Draw checkable element.
AlignContent align_content
@ Center
items are centered along the cross axis.
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
JustifyContent justify_content
@ Center
Items are centered along the line.
FlexboxConfig & Set(FlexboxConfig::Direction)
Set the flexbox direction.
Decorator bgcolor(Color)
Decorate using a background color.
Element window(Element title, Element content, BorderStyle border=ROUNDED)
Draw window with a title and a border around the element.
Element xflex_grow(Element)
Expand if possible on the X axis.
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Element flex(Element)
Make a child element to expand proportionally to the space left in a container.
Element center(Element)
Center an element horizontally and vertically.
Element text(std::wstring text)
Display a piece of unicode text.
Element yflex_grow(Element)
Expand if possible on the Y axis.
Element notflex(Element)
Make the element not flexible.
Element filler()
An element that will take expand proportionally to the space left in a container.
Element border(Element)
Draw a border around the element.
Decorator color(Color)
Decorate using a foreground color.
Element vbox(Elements)
A container displaying elements vertically one by one.
FlexboxConfig is a configuration structure that defines the layout properties for a flexbox container...
static Color HSV(uint8_t hue, uint8_t saturation, uint8_t value)
Build a Color from its HSV representation. https://en.wikipedia.org/wiki/HSL_and_HSV.
The FTXUI ftxui:: namespace.
Element flexbox(Elements, FlexboxConfig config=FlexboxConfig())
A container displaying elements on row/columns and capable of wrapping on the next column/row when fu...
Element hbox(Elements)
A container displaying elements horizontally one by one.