flex.cpp
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/flex.cpp
cstddef
cstdint
ftxui/dom/take_any_args.hpp
functional
memory
optional
sstream
string
unordered_map
utility
variant
vector
ftxui

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

    #include"ftxui/dom/elements.hpp"//forElement,unpack,filler,flex,flex_grow,flex_shrink,notflex,xflex,xflex_grow,xflex_shrink,yflex,yflex_grow,yflex_shrink
    #include"ftxui/dom/node.hpp"//forElements,Node
    #include"ftxui/dom/requirement.hpp"//forRequirement
    #include"ftxui/screen/box.hpp"//forBox

    namespaceftxui{

    namespace{

    usingFlexFunction=void(*)(Requirement&);

    voidfunction_flex_grow(Requirement&r){
    r.flex_grow_x=1;
    r.flex_grow_y=1;
    }

    voidfunction_xflex_grow(Requirement&r){
    r.flex_grow_x=1;
    }

    voidfunction_yflex_grow(Requirement&r){
    r.flex_grow_y=1;
    }

    voidfunction_flex_shrink(Requirement&r){
    r.flex_shrink_x=1;
    r.flex_shrink_y=1;
    }

    voidfunction_xflex_shrink(Requirement&r){
    r.flex_shrink_x=1;
    }

    voidfunction_yflex_shrink(Requirement&r){
    r.flex_shrink_y=1;
    }

    voidfunction_flex(Requirement&r){
    r.flex_grow_x=1;
    r.flex_grow_y=1;
    r.flex_shrink_x=1;
    r.flex_shrink_y=1;
    }

    voidfunction_xflex(Requirement&r){
    r.flex_grow_x=1;
    r.flex_shrink_x=1;
    }

    voidfunction_yflex(Requirement&r){
    r.flex_grow_y=1;
    r.flex_shrink_y=1;
    }

    voidfunction_not_flex(Requirement&r){
    r.flex_grow_x=0;
    r.flex_grow_y=0;
    r.flex_shrink_x=0;
    r.flex_shrink_y=0;
    }

    classFlex:publicNode{
    public:
    explicitFlex(FlexFunctionf):f_(f){}
    Flex(FlexFunctionf,Elementchild):Node(unpack(std::move(child))),f_(f){}
    voidComputeRequirement()override{
    requirement_.min_x=0;
    requirement_.min_y=0;
    if(!children_.empty()){
    children_[0]->ComputeRequirement();
    requirement_=children_[0]->requirement();
    }
    f_(requirement_);
    }

    voidSetBox(Boxbox)override{
    Node::SetBox(box);
    if(children_.empty()){
    return;
    }
    children_[0]->SetBox(box);
    }

    FlexFunctionf_;
    };

    }//namespace

    ///@briefAnelementthatwilltakeexpandproportionallytothespaceleftin
    ///acontainer.
    ///@ingroupdom
    Elementfiller(){
    returnstd::make_shared<Flex>(function_flex);
    }

    ///@briefMakeachildelementtoexpandproportionallytothespaceleftina
    ///container.
    ///@ingroupdom
    ///
    ///####Examples:
    ///
    ///~~~cpp
    ///hbox({
    ///text("left")|border,
    ///text("middle")|border|flex,
    ///text("right") |border,
    ///});
    ///~~~
    ///
    ///####Output:
    ///
    ///~~~bash
    ///┌────┐┌─────────────────────────────────────────────────────────┐┌─────┐
    ///│left││middle││right│
    ///└────┘└─────────────────────────────────────────────────────────┘└─────┘
    ///~~~
    Elementflex(Elementchild){
    returnstd::make_shared<Flex>(function_flex,std::move(child));
    }

    ///@briefExpand/Minimizeifpossible/neededontheXaxis.
    ///@ingroupdom
    Elementxflex(Elementchild){
    returnstd::make_shared<Flex>(function_xflex,std::move(child));
    }

    ///@briefExpand/Minimizeifpossible/neededontheYaxis.
    ///@ingroupdom
    Elementyflex(Elementchild){
    returnstd::make_shared<Flex>(function_yflex,std::move(child));
    }

    ///@briefExpandifpossible.
    ///@ingroupdom
    Elementflex_grow(Elementchild){
    returnstd::make_shared<Flex>(function_flex_grow,std::move(child));
    }

    ///@briefExpandifpossibleontheXaxis.
    ///@ingroupdom
    Elementxflex_grow(Elementchild){
    returnstd::make_shared<Flex>(function_xflex_grow,std::move(child));
    }

    ///@briefExpandifpossibleontheYaxis.
    ///@ingroupdom
    Elementyflex_grow(Elementchild){
    returnstd::make_shared<Flex>(function_yflex_grow,std::move(child));
    }

    ///@briefMinimizeifneeded.
    ///@ingroupdom
    Elementflex_shrink(Elementchild){
    returnstd::make_shared<Flex>(function_flex_shrink,std::move(child));
    }

    ///@briefMinimizeifneededontheXaxis.
    ///@ingroupdom
    Elementxflex_shrink(Elementchild){
    returnstd::make_shared<Flex>(function_xflex_shrink,std::move(child));
    }

    ///@briefMinimizeifneededontheYaxis.
    ///@ingroupdom
    Elementyflex_shrink(Elementchild){
    returnstd::make_shared<Flex>(function_yflex_shrink,std::move(child));
    }

    ///@briefMaketheelementnotflexible.
    ///@ingroupdom
    Elementnotflex(Elementchild){
    returnstd::make_shared<Flex>(function_not_flex,std::move(child));
    }

    }//namespaceftxui