16using FlexFunction = void (*)(Requirement&);
18void function_flex_grow(Requirement& r) {
23void function_xflex_grow(Requirement& r) {
27void function_yflex_grow(Requirement& r) {
31void function_flex_shrink(Requirement& r) {
36void function_xflex_shrink(Requirement& r) {
40void function_yflex_shrink(Requirement& r) {
44void function_flex(Requirement& r) {
51void function_xflex(Requirement& r) {
56void function_yflex(Requirement& r) {
61void function_not_flex(Requirement& r) {
68class Flex :
public Node {
70 explicit Flex(FlexFunction f) :
f_(f) {}
71 Flex(FlexFunction f,
Element child) : Node(unpack(std::move(child))),
f_(f) {}
72 void ComputeRequirement()
override {
73 requirement_.min_x = 0;
74 requirement_.min_y = 0;
75 if (!children_.empty()) {
76 children_[0]->ComputeRequirement();
77 requirement_ = children_[0]->requirement();
82 void SetBox(Box box)
override {
84 if (children_.empty()) {
87 children_[0]->SetBox(box);
99 return std::make_shared<Flex>(function_flex);
124 return std::make_shared<Flex>(function_flex, std::move(child));
130 return std::make_shared<Flex>(function_xflex, std::move(child));
136 return std::make_shared<Flex>(function_yflex, std::move(child));
142 return std::make_shared<Flex>(function_flex_grow, std::move(child));
148 return std::make_shared<Flex>(function_xflex_grow, std::move(child));
154 return std::make_shared<Flex>(function_yflex_grow, std::move(child));
160 return std::make_shared<Flex>(function_flex_shrink, std::move(child));
166 return std::make_shared<Flex>(function_xflex_shrink, std::move(child));
172 return std::make_shared<Flex>(function_yflex_shrink, std::move(child));
178 return std::make_shared<Flex>(function_not_flex, std::move(child));
virtual void SetBox(Box box)
Assign a position and a dimension to an element for drawing.
Element xflex(Element)
Expand/Minimize if possible/needed on the X axis.
Element xflex_grow(Element)
Expand if possible on the X axis.
Element flex(Element)
Make a child element to expand proportionally to the space left in a container.
Element yflex(Element)
Expand/Minimize if possible/needed on the Y axis.
Element flex_shrink(Element)
Minimize if needed.
Element yflex_grow(Element)
Expand if possible on the Y axis.
Element flex_grow(Element)
Expand if possible.
Element notflex(Element)
Make the element not flexible.
Element xflex_shrink(Element)
Minimize if needed on the X axis.
Element filler()
An element that will take expand proportionally to the space left in a container.
Element yflex_shrink(Element)
Minimize if needed on the Y axis.
The FTXUI ftxui:: namespace.
std::shared_ptr< Node > Element