examples/component/menu_entries_animated.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<iostream>//forbasic_ostream::operator<<,operator<<,endl,basic_ostream,basic_ostream<>::__ostream_type,cout,ostream
    #include<memory>//forshared_ptr,__shared_ptr_access
    #include<string>//forto_string,allocator

    #include"ftxui/component/captured_mouse.hpp"//forftxui
    #include"ftxui/component/component.hpp"//forMenuEntryAnimated,Renderer,Vertical
    #include"ftxui/component/component_base.hpp"//forComponentBase
    #include"ftxui/component/component_options.hpp"//forMenuEntryAnimated
    #include"ftxui/component/screen_interactive.hpp"//forScreenInteractive
    #include"ftxui/dom/elements.hpp"//foroperator|,separator,Element,Decorator,color,text,hbox,size,bold,frame,inverted,vbox,HEIGHT,LESS_THAN,border
    #include"ftxui/screen/color.hpp"//forColor,Color::Blue,Color::Cyan,Color::Green,Color::Red,Color::Yellow

    usingnamespaceftxui;

    //Defineaspecialstyleforsomemenuentry.
    MenuEntryOptionColored(ftxui::Colorc){
    MenuEntryOptionoption;
    option.animated_colors.foreground.enabled=true;
    option.animated_colors.background.enabled=true;
    option.animated_colors.background.active=c;
    option.animated_colors.background.inactive=Color::Black;
    option.animated_colors.foreground.active=Color::White;
    option.animated_colors.foreground.inactive=c;
    returnoption;
    }

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

    intselected=0;
    automenu=Container::Vertical(
    {
    MenuEntry("1.rear",Colored(Color::Red)),
    MenuEntry("2.drown",Colored(Color::Yellow)),
    MenuEntry("3.nail",Colored(Color::Green)),
    MenuEntry("4.quit",Colored(Color::Cyan)),
    MenuEntry("5.decorative",Colored(Color::Blue)),
    MenuEntry("7.costume"),
    MenuEntry("8.pick"),
    MenuEntry("9.oral"),
    MenuEntry("11.minister"),
    MenuEntry("12.football"),
    MenuEntry("13.welcome"),
    MenuEntry("14.copper"),
    MenuEntry("15.inhabitant"),
    },
    &selected);

    //Displaytogetherthemenuwithaborder
    autorenderer=Renderer(menu,[&]{
    returnvbox({
    hbox(text("selected="),text(std::to_string(selected))),
    separator(),
    menu->Render()|frame,
    })|
    border|bgcolor(Color::Black);
    });

    screen.Loop(renderer);

    std::cout<<"Selectedelement="<<selected<<std::endl;
    }