13class Size :
public Node {
16 :
Node(unpack(std::move(child))),
17 direction_(direction),
18 constraint_(constraint),
21 void ComputeRequirement()
override {
27 switch (constraint_) {
29 value = std::min(value, value_);
35 value = std::max(value, value_);
39 if (direction_ ==
WIDTH) {
48 void SetBox(Box box)
override {
51 if (direction_ ==
WIDTH) {
52 switch (constraint_) {
55 box.x_max = std::min(box.x_min + value_ + 1, box.x_max);
61 switch (constraint_) {
64 box.y_max = std::min(box.y_min + value_ + 1, box.y_max);
87 return std::make_shared<Size>(std::move(e), direction, constraint, value);
virtual void SetBox(Box box)
Assign a position and a dimension to an element for drawing.
virtual void ComputeRequirement()
Compute how much space an elements needs.
std::function< Element(Element)> Decorator
std::shared_ptr< Node > Element
Decorator size(Direction, Constraint, int value)
Apply a constraint on the size of an element.