examples/component/menu2.cpp

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

    #include"ftxui/component/captured_mouse.hpp"//forftxui
    #include"ftxui/component/component.hpp"//forMenu,Horizontal,Renderer
    #include"ftxui/component/component_base.hpp"//forComponentBase
    #include"ftxui/component/component_options.hpp"//forMenuOption
    #include"ftxui/component/screen_interactive.hpp"//forComponent,ScreenInteractive
    #include"ftxui/dom/elements.hpp"//fortext,separator,bold,hcenter,vbox,hbox,gauge,Element,operator|,border

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

    std::vector<std::string>left_menu_entries={
    "0%","10%","20%","30%","40%","50%","60%","70%","80%","90%",
    };
    std::vector<std::string>right_menu_entries={
    "0%","1%","2%","3%","4%","5%","6%","7%","8%","9%","10%",
    };

    automenu_option=MenuOption();
    menu_option.on_enter=screen.ExitLoopClosure();

    intleft_menu_selected=0;
    intright_menu_selected=0;
    Componentleft_menu_=
    Menu(&left_menu_entries,&left_menu_selected,menu_option);
    Componentright_menu_=
    Menu(&right_menu_entries,&right_menu_selected,menu_option);

    Componentcontainer=Container::Horizontal({
    left_menu_,
    right_menu_,
    });

    autorenderer=Renderer(container,[&]{
    intsum=left_menu_selected*10+right_menu_selected;
    returnvbox({
    //--------Toppanel--------------
    hbox({
    //--------LeftMenu--------------
    vbox({
    hcenter(bold(text("Percentageby10%"))),
    separator(),
    left_menu_->Render(),
    }),
    separator(),
    //--------RightMenu--------------
    vbox({
    hcenter(bold(text("Percentageby1%"))),
    separator(),
    right_menu_->Render(),
    }),
    separator(),
    }),
    separator(),
    //--------Bottompanel--------------
    vbox({
    hbox({
    text("gauge:"),
    gauge(sum/100.0),
    }),
    hbox({
    text("text:"),
    text(std::to_string(sum)+"%"),
    }),
    }),
    })|
    border;
    });

    screen.Loop(renderer);
    }