examples/component/modal_dialog_custom.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<memory>//forallocator,shared_ptr,__shared_ptr_access
    #include<string>//forstring,basic_string,char_traits,operator+
    #include<vector>//forvector

    #include"ftxui/component/captured_mouse.hpp"//forftxui
    #include"ftxui/component/component.hpp"//forButton,Renderer,Horizontal,Tab
    #include"ftxui/component/component_base.hpp"//forComponentBase
    #include"ftxui/component/screen_interactive.hpp"//forScreenInteractive
    #include"ftxui/dom/elements.hpp"//foroperator|,Element,filler,text,hbox,separator,center,vbox,bold,border,clear_under,dbox,size,GREATER_THAN,HEIGHT

    intmain(){
    usingnamespaceftxui;
    autoscreen=ScreenInteractive::TerminalOutput();

    //Therearetwolayers.Oneatdepth=0andthemodalwindowatdepth=1;
    intdepth=0;

    //ThecurrentratingofFTXUI.
    std::stringrating="3/5stars";

    //Atdepth=0,twobuttons.OneforratingFTXUIandoneforquitting.
    autobutton_rate_ftxui=Button("RateFTXUI",[&]{depth=1;});
    autobutton_quit=Button("Quit",screen.ExitLoopClosure());

    autodepth_0_container=Container::Horizontal({
    button_rate_ftxui,
    button_quit,
    });
    autodepth_0_renderer=Renderer(depth_0_container,[&]{
    returnvbox({
    text("Modaldialogexample"),
    separator(),
    text("☆☆☆FTXUI:"+rating+"☆☆☆")|bold,
    filler(),
    hbox({
    button_rate_ftxui->Render(),
    filler(),
    button_quit->Render(),
    }),
    })|
    border|size(HEIGHT,GREATER_THAN,18)|center;
    });

    //Atdepth=1,The"modal"window.
    std::vector<std::string>rating_labels={
    "1/5stars","2/5stars","3/5stars","4/5stars","5/5stars",
    };
    autoon_rating=[&](std::stringnew_rating){
    rating=new_rating;
    depth=0;
    };
    autodepth_1_container=Container::Horizontal({
    Button(&rating_labels[0],[&]{on_rating(rating_labels[0]);}),
    Button(&rating_labels[1],[&]{on_rating(rating_labels[1]);}),
    Button(&rating_labels[2],[&]{on_rating(rating_labels[2]);}),
    Button(&rating_labels[3],[&]{on_rating(rating_labels[3]);}),
    Button(&rating_labels[4],[&]{on_rating(rating_labels[4]);}),
    });

    autodepth_1_renderer=Renderer(depth_1_container,[&]{
    returnvbox({
    text("DoyoulikeFTXUI?"),
    separator(),
    hbox(depth_1_container->Render()),
    })|
    border;
    });

    automain_container=Container::Tab(
    {
    depth_0_renderer,
    depth_1_renderer,
    },
    &depth);

    automain_renderer=Renderer(main_container,[&]{
    Elementdocument=depth_0_renderer->Render();

    if(depth==1){
    document=dbox({
    document,
    depth_1_renderer->Render()|clear_under|center,
    });
    }
    returndocument;
    });

    screen.Loop(main_renderer);
    return0;
    }