examples/component/menu_underline_animated_gallery.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<chrono>//foroperator""ms,literals
    #include<memory>//forallocator,shared_ptr,__shared_ptr_access
    #include<string>//forstring,operator+,to_string,basic_string
    #include<vector>//forvector

    #include"ftxui/component/animation.hpp"//forBackOut,Duration
    #include"ftxui/component/component.hpp"//forMenu,Renderer,Vertical
    #include"ftxui/component/component_base.hpp"//forComponentBase
    #include"ftxui/component/component_options.hpp"//forMenuOption,UnderlineOption
    #include"ftxui/component/mouse.hpp"//forftxui
    #include"ftxui/component/screen_interactive.hpp"//forComponent,ScreenInteractive
    #include"ftxui/dom/elements.hpp"//fortext,Element,operator|,borderEmpty,inverted
    #include"ftxui/screen/color.hpp"//forColor,Color::Blue,Color::Red

    usingnamespaceftxui;

    ComponentDummyComponent(intid){
    returnRenderer([id](boolfocused){
    autot=text("component"+std::to_string(id));
    if(focused)
    t=t|inverted;
    returnt;
    });
    }

    ComponentText(conststd::string&t){
    returnRenderer([t]{returntext(t)|borderEmpty;});
    }

    intmain(){
    usingnamespacestd::literals;
    std::vector<std::string>tab_values{
    "Tab1","Tab2","Tab3","Averyverylongtab","탭",
    };
    inttab_selected=0;

    autocontainer=Container::Vertical({});

    intframe_count=0;
    container->Add(Renderer(
    [&]{returntext("Framecount:"+std::to_string(frame_count++));}));

    {
    autooption=MenuOption::HorizontalAnimated();
    container->Add(Text("ThisdemonstratetheMenucomponent"));
    container->Add(Menu(&tab_values,&tab_selected,option));
    }

    {
    container->Add(Text("Setunderlinecolortoblue"));
    autooption=MenuOption::HorizontalAnimated();
    option.underline.color_inactive=Color::Blue;
    container->Add(Menu(&tab_values,&tab_selected,option));
    }

    {
    container->Add(Text("Setunderlineactivecolortored"));
    autooption=MenuOption::HorizontalAnimated();
    option.underline.color_active=Color::Red;
    container->Add(Menu(&tab_values,&tab_selected,option));
    }

    {
    container->Add(Text("Setanimationdurationto0ms"));
    autooption=MenuOption::HorizontalAnimated();
    option.underline.SetAnimationDuration(0ms);
    container->Add(Menu(&tab_values,&tab_selected,option));
    }

    {
    container->Add(Text("Setanimationeasingfunctiontoback-out"));
    autooption=MenuOption::HorizontalAnimated();
    option.underline.SetAnimationFunction(animation::easing::BackOut);
    option.underline.SetAnimationDuration(350ms);
    container->Add(Menu(&tab_values,&tab_selected,option));
    }

    //option.underline_animation_follower_delay=250ms
    {
    container->Add(Text("Adddelaytodesynchronizeanimation"));
    autooption=MenuOption::HorizontalAnimated();
    option.underline.follower_delay=250ms;
    container->Add(Menu(&tab_values,&tab_selected,option));
    }

    container->SetActiveChild(container->ChildAt(2));

    autoscreen=ScreenInteractive::TerminalOutput();
    screen.Loop(container);
    }