#include <stddef.h>
#include <memory>
#include <string>
#include <vector>
int main() {
int direction_index = 0;
int wrap_index = 0;
int justify_content_index = 0;
int align_items_index = 0;
int align_content_index = 0;
std::vector<std::string> directions = {
"Row",
"RowInversed",
"Column",
"ColumnInversed",
};
std::vector<std::string> wraps = {
"NoWrap",
"Wrap",
"WrapInversed",
};
std::vector<std::string> justify_content = {
"FlexStart", "FlexEnd", "Center", "Stretch",
"SpaceBetween", "SpaceAround", "SpaceEvenly",
};
std::vector<std::string> align_items = {
"FlexStart",
"FlexEnd",
"Center",
"Stretch",
};
std::vector<std::string> align_content = {
"FlexStart", "FlexEnd", "Center", "Stretch",
"SpaceBetween", "SpaceAround", "SpaceEvenly",
};
auto radiobox_direction =
Radiobox(&directions, &direction_index);
auto radiobox_wrap =
Radiobox(&wraps, &wrap_index);
auto radiobox_justify_content =
Radiobox(&justify_content, &justify_content_index);
auto radiobox_align_items =
Radiobox(&align_items, &align_items_index);
auto radiobox_align_content =
Radiobox(&align_content, &align_content_index);
bool element_xflex_grow = false;
bool element_yflex_grow = false;
bool group_xflex_grow = true;
bool group_yflex_grow = true;
auto checkbox_element_xflex_grow =
Checkbox(
"element |= xflex_grow", &element_xflex_grow);
auto checkbox_element_yflex_grow =
Checkbox(
"element |= yflex_grow", &element_yflex_grow);
auto checkbox_group_xflex_grow =
Checkbox(
"group |= xflex_grow", &group_xflex_grow);
auto checkbox_group_yflex_grow =
Checkbox(
"group |= yflex_grow", &group_yflex_grow);
auto make_box = [&](size_t dimx, size_t dimy, size_t index) {
if (element_xflex_grow)
if (element_yflex_grow)
return element;
};
FlexboxConfig config;
config.justify_content =
config.align_items =
config.align_content =
{
make_box(8, 4, 0),
make_box(9, 6, 1),
make_box(11, 6, 2),
make_box(10, 4, 3),
make_box(13, 7, 4),
make_box(12, 4, 5),
make_box(12, 5, 6),
make_box(10, 4, 7),
make_box(12, 4, 8),
make_box(10, 5, 9),
},
config);
if (!group_xflex_grow)
if (!group_yflex_grow)
return group;
});
int space_right = 10;
int space_bottom = 1;
content_renderer, &space_right);
content_renderer, &space_bottom);
radiobox_direction,
radiobox_wrap,
checkbox_element_xflex_grow,
checkbox_element_yflex_grow,
checkbox_group_xflex_grow,
checkbox_group_yflex_grow,
}),
}),
radiobox_justify_content,
radiobox_align_items,
radiobox_align_content,
}),
content_renderer,
});
auto main_renderer =
Renderer(main_container, [&] {
radiobox_direction->Render()),
window(
text(
"FlexboxConfig::Wrap"), radiobox_wrap->Render()),
checkbox_element_xflex_grow->Render(),
checkbox_element_yflex_grow->Render(),
checkbox_group_xflex_grow->Render(),
checkbox_group_yflex_grow->Render(),
})),
}),
radiobox_justify_content->Render()),
radiobox_align_items->Render()),
radiobox_align_content->Render()),
})}),
});
});
screen.Loop(main_renderer);
return 0;
}
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.
static ScreenInteractive Fullscreen()
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
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 bold(Element)
Use a bold font, for elements with more emphasis.
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.
Element hbox(Elements)
A container displaying elements horizontally one by one.
Element center(Element)
Center an element horizontally and vertically.
std::string to_string(const std::wstring &s)
Convert a UTF8 std::string into a std::wstring.
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.
Component ResizableSplitRight(Component main, Component back, int *main_size)
An horizontal split in between two components, configurable using the mouse.
Element flexbox(Elements, FlexboxConfig config=FlexboxConfig())
Element filler()
An element that will take expand proportionally to the space left in a container.
Element dim(Element)
Use a light font, for elements with less emphasis.
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.
Element border(Element)
Draw a border around the element.
Decorator color(Color)
Decorate using a foreground color.
Element hcenter(Element)
Center an element horizontally.
Element vbox(Elements)
A container displaying elements vertically one by one.
@ Center
items are centered along the cross axis.
@ Center
Items are centered along the line.