size.cpp
algorithm
memory
utility
ftxui/dom/elements.hpp
ftxui/dom/node.hpp
ftxui/dom/requirement.hpp
ftxui/screen/box.hpp
ftxui/dom/canvas.hpp
ftxui/dom/deprecated.hpp
ftxui/dom/direction.hpp
ftxui/dom/elements.hpp
ftxui/dom/flexbox_config.hpp
ftxui/dom/linear_gradient.hpp
ftxui/dom/node.hpp
ftxui/dom/requirement.hpp
ftxui/dom/selection.hpp
ftxui/screen/box.hpp
ftxui/screen/color.hpp
ftxui/screen/image.hpp
ftxui/screen/pixel.hpp
ftxui/screen/screen.hpp
ftxui/screen/string.hpp
ftxui/screen/terminal.hpp
ftxui/util/autoreset.hpp
ftxui/util/ref.hpp
src/ftxui/dom/size.cpp
algorithm
cstddef
cstdint
ftxui/dom/take_any_args.hpp
functional
memory
optional
sstream
string
unordered_map
utility
variant
vector
ftxui

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<algorithm>//formin,max
    #include<memory>//formake_shared,__shared_ptr_access
    #include<utility>//formove

    #include"ftxui/dom/elements.hpp"//forConstraint,WidthOrHeight,EQUAL,GREATER_THAN,LESS_THAN,WIDTH,unpack,Decorator,Element,size
    #include"ftxui/dom/node.hpp"//forNode,Elements
    #include"ftxui/dom/requirement.hpp"//forRequirement
    #include"ftxui/screen/box.hpp"//forBox

    namespaceftxui{

    namespace{
    classSize:publicNode{
    public:
    Size(Elementchild,WidthOrHeightdirection,Constraintconstraint,intvalue)
    :Node(unpack(std::move(child))),
    direction_(direction),
    constraint_(constraint),
    value_(std::max(0,value)){}

    voidComputeRequirement()override{
    Node::ComputeRequirement();
    requirement_=children_[0]->requirement();

    auto&value=direction_==WIDTH?requirement_.min_x:requirement_.min_y;

    switch(constraint_){
    caseLESS_THAN:
    value=std::min(value,value_);
    break;
    caseEQUAL:
    value=value_;
    break;
    caseGREATER_THAN:
    value=std::max(value,value_);
    break;
    }

    if(direction_==WIDTH){
    requirement_.flex_grow_x=0;
    requirement_.flex_shrink_x=0;
    }else{
    requirement_.flex_grow_y=0;
    requirement_.flex_shrink_y=0;
    }
    }

    voidSetBox(Boxbox)override{
    Node::SetBox(box);

    if(direction_==WIDTH){
    switch(constraint_){
    caseLESS_THAN:
    caseEQUAL:
    box.x_max=std::min(box.x_min+value_+1,box.x_max);
    break;
    caseGREATER_THAN:
    break;
    }
    }else{
    switch(constraint_){
    caseLESS_THAN:
    caseEQUAL:
    box.y_max=std::min(box.y_min+value_+1,box.y_max);
    break;
    caseGREATER_THAN:
    break;
    }
    }
    children_[0]->SetBox(box);
    }

    private:
    WidthOrHeightdirection_;
    Constraintconstraint_;
    intvalue_;
    };
    }//namespace

    ///@briefApplyaconstraintonthesizeofanelement.
    ///@paramdirectionWhethertheWIDTHoftheHEIGHToftheelementmustbe
    ///constrained.
    ///@paramconstraintThetypeofconstaint.
    ///@paramvalueThevalue.
    ///@ingroupdom
    Decoratorsize(WidthOrHeightdirection,Constraintconstraint,intvalue){
    return[=](Elemente){
    returnstd::make_shared<Size>(std::move(e),direction,constraint,value);
    };
    }

    }//namespaceftxui