16class Size :
public Node {
19 : Node(unpack(std::move(child))),
21 constraint_(constraint),
24 void ComputeRequirement()
override {
25 Node::ComputeRequirement();
26 requirement_ = children_[0]->requirement();
28 auto&
value = direction_ ==
WIDTH ? requirement_.min_x : requirement_.min_y;
30 switch (constraint_) {
42 if (direction_ ==
WIDTH) {
43 requirement_.flex_grow_x = 0;
44 requirement_.flex_shrink_x = 0;
46 requirement_.flex_grow_y = 0;
47 requirement_.flex_shrink_y = 0;
51 void SetBox(Box box)
override {
54 if (direction_ ==
WIDTH) {
55 switch (constraint_) {
58 box.x_max = std::min(box.x_min + value_ + 1, box.x_max);
64 switch (constraint_) {
67 box.y_max = std::min(box.y_min + value_ + 1, box.y_max);
73 children_[0]->SetBox(box);
91 return std::make_shared<Size>(std::move(e),
direction, constraint,
value);
Decorator size(WidthOrHeight direction, Constraint constraint, int value)
Apply a constraint on the size of an element.
The FTXUI ftxui:: namespace.
std::shared_ptr< Node > Element
std::function< Element(Element)> Decorator