14class Size :
public Node {
17 :
Node(unpack(std::move(child))),
18 direction_(direction),
19 constraint_(constraint),
22 void ComputeRequirement()
override {
28 switch (constraint_) {
30 value = std::min(value, value_);
36 value = std::max(value, value_);
40 if (direction_ ==
WIDTH) {
49 void SetBox(Box box)
override {
52 if (direction_ ==
WIDTH) {
53 switch (constraint_) {
56 box.x_max = std::min(box.x_min + value_ + 1, box.x_max);
62 switch (constraint_) {
65 box.y_max = std::min(box.y_min + value_ + 1, box.y_max);
88 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.