box.cpp
ftxui/screen/box.hpp
algorithm
ftxui/screen/box.hpp
src/ftxui/screen/box.cpp
algorithm
ftxui

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include"ftxui/screen/box.hpp"

    #include<algorithm>

    namespaceftxui{
    ///@returnthebiggestBoxcontainedinboth|a|and|b|.
    ///@ingroupscreen
    //static
    BoxBox::Intersection(Boxa,Boxb){
    returnBox{
    std::max(a.x_min,b.x_min),
    std::min(a.x_max,b.x_max),
    std::max(a.y_min,b.y_min),
    std::min(a.y_max,b.y_max),
    };
    }

    ///@returnthesmallestBoxcontainingboth|a|and|b|.
    ///@ingroupscreen
    //static
    BoxBox::Union(Boxa,Boxb){
    returnBox{
    std::min(a.x_min,b.x_min),
    std::max(a.x_max,b.x_max),
    std::min(a.y_min,b.y_min),
    std::max(a.y_max,b.y_max),
    };
    }

    ///Shifttheboxby(x,y).
    ///@paramxhorizontalshift.
    ///@paramyverticalshift.
    ///@ingroupscreen
    voidBox::Shift(intx,inty){
    x_min+=x;
    x_max+=x;
    y_min+=y;
    y_max+=y;
    }

    ///@returnwhether(x,y)iscontainedinsidethebox.
    ///@ingroupscreen
    boolBox::Contain(intx,inty)const{
    returnx_min<=x&&//
    x_max>=x&&//
    y_min<=y&&//
    y_max>=y;
    }

    ///@returnwhethertheboxisempty.
    ///@ingroupscreen
    boolBox::IsEmpty()const{
    returnx_min>x_max||y_min>y_max;
    }

    ///@returnwhether|other|isthesameas|this|
    ///@ingroupscreen
    boolBox::operator==(constBox&other)const{
    return(x_min==other.x_min)&&(x_max==other.x_max)&&
    (y_min==other.y_min)&&(y_max==other.y_max);
    }

    ///@returnwhether|other|and|this|aredifferent.
    ///@ingroupscreen
    boolBox::operator!=(constBox&other)const{
    return!operator==(other);
    }

    }//namespaceftxui