examples/component/button_animated.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<memory>//forshared_ptr,__shared_ptr_access
    #include<string>//foroperator+,to_string

    #include"ftxui/component/captured_mouse.hpp"//forftxui
    #include"ftxui/component/component.hpp"//forButton,Horizontal,Renderer
    #include"ftxui/component/component_base.hpp"//forComponentBase
    #include"ftxui/component/component_options.hpp"//forButtonOption
    #include"ftxui/component/screen_interactive.hpp"//forScreenInteractive
    #include"ftxui/dom/elements.hpp"//forgauge,separator,text,vbox,operator|,Element,border
    #include"ftxui/screen/color.hpp"//forColor,Color::Blue,Color::Green,Color::Red

    usingnamespaceftxui;

    intmain(){
    intvalue=50;

    //Thetreeofcomponents.Thisdefineshowtonavigateusingthekeyboard.
    autobuttons=Container::Horizontal({
    Button(
    "Decrease",[&]{value--;},ButtonOption::Animated(Color::Red)),
    Button(
    "Reset",[&]{value=50;},ButtonOption::Animated(Color::Green)),
    Button(
    "Increase",[&]{value++;},ButtonOption::Animated(Color::Blue)),
    });

    //Modifythewaytorenderthemonscreen:
    autocomponent=Renderer(buttons,[&]{
    returnvbox({
    vbox({
    text("value="+std::to_string(value)),
    separator(),
    gauge(value*0.01f),
    })|border,
    buttons->Render(),
    });
    });

    autoscreen=ScreenInteractive::FitComponent();
    screen.Loop(component);
    return0;
    }