hbox.cpp
algorithm
cstddef
memory
utility
vector
ftxui/dom/box_helper.hpp
ftxui/dom/elements.hpp
ftxui/dom/node.hpp
ftxui/dom/requirement.hpp
ftxui/dom/selection.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
ftxui/dom/box_helper.hpp
src/ftxui/dom/hbox.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>//formax
    #include<cstddef>//forsize_t
    #include<memory>//for__shared_ptr_access,shared_ptr,make_shared,allocator_traits<>::value_type
    #include<utility>//formove
    #include<vector>//forvector,__alloc_traits<>::value_type

    #include"ftxui/dom/box_helper.hpp"//forElement,Compute
    #include"ftxui/dom/elements.hpp"//forElement,Elements,hbox
    #include"ftxui/dom/node.hpp"//forNode,Elements
    #include"ftxui/dom/requirement.hpp"//forRequirement
    #include"ftxui/dom/selection.hpp"//forSelection
    #include"ftxui/screen/box.hpp"//forBox
    namespaceftxui{

    namespace{
    classHBox:publicNode{
    public:
    explicitHBox(Elementschildren):Node(std::move(children)){}

    private:
    voidComputeRequirement()override{
    requirement_=Requirement{};

    for(auto&child:children_){
    child->ComputeRequirement();

    //Propagatethefocusedrequirement.
    if(requirement_.focused.Prefer(child->requirement().focused)){
    requirement_.focused=child->requirement().focused;
    requirement_.focused.box.Shift(requirement_.min_x,0);
    }

    //Extendthemin_xandmin_ytocontainallthechildren
    requirement_.min_x+=child->requirement().min_x;
    requirement_.min_y=
    std::max(requirement_.min_y,child->requirement().min_y);
    }
    }

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

    std::vector<box_helper::Element>elements(children_.size());
    for(size_ti=0;i<children_.size();++i){
    auto&element=elements[i];
    constauto&requirement=children_[i]->requirement();
    element.min_size=requirement.min_x;
    element.flex_grow=requirement.flex_grow_x;
    element.flex_shrink=requirement.flex_shrink_x;
    }
    constinttarget_size=box.x_max-box.x_min+1;
    box_helper::Compute(&elements,target_size);

    intx=box.x_min;
    for(size_ti=0;i<children_.size();++i){
    box.x_min=x;
    box.x_max=x+elements[i].size-1;
    children_[i]->SetBox(box);
    x=box.x_max+1;
    }
    }

    voidSelect(Selection&selection)override{
    //IfthisNodebox_doesn'tintersectwiththeselection,thenno
    //selection.
    if(Box::Intersection(selection.GetBox(),box_).IsEmpty()){
    return;
    }

    Selectionselection_saturated=selection.SaturateHorizontal(box_);
    for(auto&child:children_){
    child->Select(selection_saturated);
    }
    }
    };

    }//namespace

    ///@briefAcontainerdisplayingelementshorizontallyonebyone.
    ///@paramchildrenTheelementsinthecontainer
    ///@returnThecontainer.
    ///
    ///####Example
    ///
    ///```cpp
    ///hbox({
    ///text("Left"),
    ///text("Right"),
    ///});
    ///```
    Elementhbox(Elementschildren){
    returnstd::make_shared<HBox>(std::move(children));
    }

    }//namespaceftxui