component_options.cpp
ftxui/component/component_options.hpp
ftxui/screen/color.hpp
memory
utility
ftxui/component/animation.hpp
ftxui/dom/direction.hpp
ftxui/dom/elements.hpp
ftxui/component/animation.hpp
ftxui/component/captured_mouse.hpp
ftxui/component/component_base.hpp
ftxui/component/component_options.hpp
ftxui/dom/canvas.hpp
ftxui/dom/deprecated.hpp
ftxui/dom/direction.hpp
ftxui/dom/elements.hpp
ftxui/dom/flexbox_config.hpp
ftxui/dom/linear_gradient.hpp
ftxui/dom/node.hpp
ftxui/dom/requirement.hpp
ftxui/dom/selection.hpp
ftxui/screen/box.hpp
ftxui/screen/color.hpp
ftxui/screen/image.hpp
ftxui/screen/pixel.hpp
ftxui/screen/screen.hpp
ftxui/screen/string.hpp
ftxui/screen/terminal.hpp
ftxui/util/autoreset.hpp
ftxui/util/ref.hpp
src/ftxui/component/component_options.cpp
chrono
cstddef
cstdint
ftxui/dom/take_any_args.hpp
functional
memory
optional
sstream
string
unordered_map
utility
variant
vector
ftxui

    //Copyright2022ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include"ftxui/component/component_options.hpp"

    #include<ftxui/screen/color.hpp>//forColor,Color::White,Color::Black,Color::GrayDark,Color::Blue,Color::GrayLight,Color::Red
    #include<memory>//forshared_ptr
    #include<utility>//formove
    #include"ftxui/component/animation.hpp"//forFunction,Duration
    #include"ftxui/dom/direction.hpp"
    #include"ftxui/dom/elements.hpp"//foroperator|=,Element,text,bgcolor,inverted,bold,dim,operator|,color,borderEmpty,hbox,automerge,border,borderLight

    namespaceftxui{

    ///@briefAcoloroptionthatcanbeanimated.
    ///@params_inactiveThecolorwhenthecomponentisinactive.
    ///@params_activeThecolorwhenthecomponentisactive.
    ///@params_durationThedurationoftheanimation.
    ///@params_functionTheeasingfunctionoftheanimation.
    ///@ingroupcomponent
    voidAnimatedColorOption::Set(Color_inactive,
    Color_active,
    animation::Duration_duration,
    animation::easing::Function_function){
    enabled=true;
    inactive=_inactive;
    active=_active;
    duration=_duration;
    function=std::move(_function);
    }

    ///@briefSethowtheunderlineshouldanimate.
    ///@paramdThedurationoftheanimation.
    ///@paramfTheeasingfunctionoftheanimation.
    ///@ingroupcomponent
    voidUnderlineOption::SetAnimation(animation::Durationd,
    animation::easing::Functionf){
    SetAnimationDuration(d);
    SetAnimationFunction(std::move(f));
    }

    ///@briefSethowtheunderlineshouldanimate.
    ///@paramdThedurationoftheanimation.
    ///@ingroupcomponent
    voidUnderlineOption::SetAnimationDuration(animation::Durationd){
    leader_duration=d;
    follower_duration=d;
    }

    ///@briefSethowtheunderlineshouldanimate.
    ///@paramfTheeasingfunctionoftheanimation.
    ///@ingroupcomponent
    voidUnderlineOption::SetAnimationFunction(animation::easing::Functionf){
    leader_function=f;
    follower_function=std::move(f);
    }

    ///@briefSethowtheunderlineshouldanimate.
    ///Thisisusefultodesynchronizetheanimationoftheleaderandthe
    ///follower.
    ///@paramf_leaderThedurationoftheanimationfortheleader.
    ///@paramf_followerThedurationoftheanimationforthefollower.
    ///@ingroupcomponent
    voidUnderlineOption::SetAnimationFunction(
    animation::easing::Functionf_leader,
    animation::easing::Functionf_follower){
    leader_function=std::move(f_leader);
    follower_function=std::move(f_follower);
    }

    ///@briefStandardoptionsforanhorizontalmenu.
    ///Thiscanbeusefultoimplementatabbar.
    ///@ingroupcomponent
    //static
    MenuOptionMenuOption::Horizontal(){
    MenuOptionoption;
    option.direction=Direction::Right;
    option.entries_option.transform=[](constEntryState&state){
    Elemente=text(state.label);
    if(state.focused){
    e|=inverted;
    }
    if(state.active){
    e|=bold;
    }
    if(!state.focused&&!state.active){
    e|=dim;
    }
    returne;
    };
    option.elements_infix=[]{returntext("");};

    returnoption;
    }

    ///@briefStandardoptionsforananimatedhorizontalmenu.
    ///Thiscanbeusefultoimplementatabbar.
    ///@ingroupcomponent
    //static
    MenuOptionMenuOption::HorizontalAnimated(){
    autooption=Horizontal();
    option.underline.enabled=true;
    returnoption;
    }

    ///@briefStandardoptionsforaverticalmenu.
    ///Thiscanbeusefultoimplementalistofselectableitems.
    ///@ingroupcomponent
    //static
    MenuOptionMenuOption::Vertical(){
    MenuOptionoption;
    option.entries_option.transform=[](constEntryState&state){
    Elemente=text((state.active?">":"")+state.label);//NOLINT
    if(state.focused){
    e|=inverted;
    }
    if(state.active){
    e|=bold;
    }
    if(!state.focused&&!state.active){
    e|=dim;
    }
    returne;
    };
    returnoption;
    }

    ///@briefStandardoptionsforananimatedverticalmenu.
    ///Thiscanbeusefultoimplementalistofselectableitems.
    ///@ingroupcomponent
    //static
    MenuOptionMenuOption::VerticalAnimated(){
    autooption=MenuOption::Vertical();
    option.entries_option.transform=[](constEntryState&state){
    Elemente=text(state.label);
    if(state.focused){
    e|=inverted;
    }
    if(state.active){
    e|=bold;
    }
    if(!state.focused&&!state.active){
    e|=dim;
    }
    returne;
    };
    option.underline.enabled=true;
    returnoption;
    }

    ///@briefStandardoptionsforahoritontalmenuwithsomeseparator.
    ///Thiscanbeusefultoimplementatabbar.
    ///@ingroupcomponent
    //static
    MenuOptionMenuOption::Toggle(){
    autooption=MenuOption::Horizontal();
    option.elements_infix=[]{returntext("│")|automerge;};
    returnoption;
    }

    ///@briefCreateaButtonOption,highlightedusing[]characters.
    ///@ingroupcomponent
    //static
    ButtonOptionButtonOption::Ascii(){
    ButtonOptionoption;
    option.transform=[](constEntryState&s){
    conststd::stringt=s.focused?"["+s.label+"]"//
    :""+s.label+"";
    returntext(t);
    };
    returnoption;
    }

    ///@briefCreateaButtonOption,invertedwhenfocused.
    ///@ingroupcomponent
    //static
    ButtonOptionButtonOption::Simple(){
    ButtonOptionoption;
    option.transform=[](constEntryState&s){
    autoelement=text(s.label)|borderLight;
    if(s.focused){
    element|=inverted;
    }
    returnelement;
    };
    returnoption;
    }

    ///@briefCreateaButtonOption.Thebuttonisshownusingaborder,inverted
    ///whenfocused.Thisisthecurrentdefault.
    ///@ingroupcomponent
    ButtonOptionButtonOption::Border(){
    ButtonOptionoption;
    option.transform=[](constEntryState&s){
    autoelement=text(s.label)|border;
    if(s.active){
    element|=bold;
    }
    if(s.focused){
    element|=inverted;
    }
    returnelement;
    };
    returnoption;
    }

    ///@briefCreateaButtonOption,usinganimatedcolors.
    ///@ingroupcomponent
    //static
    ButtonOptionButtonOption::Animated(){
    returnAnimated(Color::Black,Color::GrayLight,//
    Color::GrayDark,Color::White);
    }

    ///@briefCreateaButtonOption,usinganimatedcolors.
    ///@ingroupcomponent
    //static
    ButtonOptionButtonOption::Animated(Colorcolor){
    returnButtonOption::Animated(
    Color::Interpolate(0.85F,color,Color::Black),//NOLINT
    Color::Interpolate(0.10F,color,Color::White),//NOLINT
    Color::Interpolate(0.10F,color,Color::Black),//NOLINT
    Color::Interpolate(0.85F,color,Color::White));//NOLINT
    }

    ///@briefCreateaButtonOption,usinganimatedcolors.
    ///@ingroupcomponent
    //static
    ButtonOptionButtonOption::Animated(Colorbackground,Colorforeground){
    //NOLINTBEGIN
    returnButtonOption::Animated(
    /*bakground=*/background,
    /*foreground=*/foreground,
    /*background_active=*/foreground,
    /*foreground_active=*/background);
    //NOLINTEND
    }

    ///@briefCreateaButtonOption,usinganimatedcolors.
    ///@ingroupcomponent
    //static
    ButtonOptionButtonOption::Animated(Colorbackground,
    Colorforeground,
    Colorbackground_active,
    Colorforeground_active){
    ButtonOptionoption;
    option.transform=[](constEntryState&s){
    autoelement=text(s.label)|borderEmpty;
    if(s.focused){
    element|=bold;
    }
    returnelement;
    };
    option.animated_colors.foreground.Set(foreground,foreground_active);
    option.animated_colors.background.Set(background,background_active);
    returnoption;
    }

    ///@briefOptionforstandardCheckbox.
    ///@ingroupcomponent
    //static
    CheckboxOptionCheckboxOption::Simple(){
    autooption=CheckboxOption();
    option.transform=[](constEntryState&s){
    #ifdefined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
    //Microsoftterminaldonotusefontsabletorenderproperlythedefault
    //radioboxglyph.
    autoprefix=text(s.state?"[X]":"[]");//NOLINT
    #else
    autoprefix=text(s.state?"▣":"☐");//NOLINT
    #endif
    autot=text(s.label);
    if(s.active){
    t|=bold;
    }
    if(s.focused){
    t|=inverted;
    }
    returnhbox({prefix,t});
    };
    returnoption;
    }

    ///@briefOptionforstandardRadiobox
    ///@ingroupcomponent
    //static
    RadioboxOptionRadioboxOption::Simple(){
    autooption=RadioboxOption();
    option.transform=[](constEntryState&s){
    #ifdefined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
    //Microsoftterminaldonotusefontsabletorenderproperlythedefault
    //radioboxglyph.
    autoprefix=text(s.state?"(*)":"()");//NOLINT
    #else
    autoprefix=text(s.state?"◉":"○");//NOLINT
    #endif
    autot=text(s.label);
    if(s.active){
    t|=bold;
    }
    if(s.focused){
    t|=inverted;
    }
    returnhbox({prefix,t});
    };
    returnoption;
    }

    ///@briefStandardoptionsfortheinputcomponent.
    ///@ingroupcomponent
    //static
    InputOptionInputOption::Default(){
    InputOptionoption;
    option.transform=[](InputStatestate){
    state.element|=color(Color::White);

    if(state.is_placeholder){
    state.element|=dim;
    }

    if(state.focused){
    state.element|=inverted;
    }elseif(state.hovered){
    state.element|=bgcolor(Color::GrayDark);
    }

    returnstate.element;
    };
    returnoption;
    }

    ///@briefStandardoptionsforamorebeautifulinputcomponent.
    ///@ingroupcomponent
    //static
    InputOptionInputOption::Spacious(){
    InputOptionoption;
    option.transform=[](InputStatestate){
    state.element|=borderEmpty;
    state.element|=color(Color::White);

    if(state.is_placeholder){
    state.element|=dim;
    }

    if(state.focused){
    state.element|=bgcolor(Color::Black);
    }

    if(state.hovered){
    state.element|=bgcolor(Color::GrayDark);
    }

    returnstate.element;
    };
    returnoption;
    }

    }//namespaceftxui