16 using FlexFunction = void (*)(Requirement&);
18 void function_flex_grow(Requirement& r) {
23 void function_xflex_grow(Requirement& r) {
27 void function_yflex_grow(Requirement& r) {
31 void function_flex_shrink(Requirement& r) {
36 void function_xflex_shrink(Requirement& r) {
40 void function_yflex_shrink(Requirement& r) {
44 void function_flex(Requirement& r) {
51 void function_xflex(Requirement& r) {
56 void function_yflex(Requirement& r) {
61 void function_not_flex(Requirement& r) {
68 class 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 {
83 if (children_.empty()) {
86 children_[0]->SetBox(box);
98 return std::make_shared<Flex>(function_flex);
123 return std::make_shared<Flex>(function_flex, std::move(child));
129 return std::make_shared<Flex>(function_xflex, std::move(child));
135 return std::make_shared<Flex>(function_yflex, std::move(child));
141 return std::make_shared<Flex>(function_flex_grow, std::move(child));
147 return std::make_shared<Flex>(function_xflex_grow, std::move(child));
153 return std::make_shared<Flex>(function_yflex_grow, std::move(child));
159 return std::make_shared<Flex>(function_flex_shrink, std::move(child));
165 return std::make_shared<Flex>(function_xflex_shrink, std::move(child));
171 return std::make_shared<Flex>(function_yflex_shrink, std::move(child));
177 return std::make_shared<Flex>(function_not_flex, std::move(child));
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.
std::shared_ptr< Node > Element
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.