39 std::vector<std::string> entries{
40 "Monkey",
"Dog",
"Cat",
"Bird",
"Elephant",
"Cat",
42 std::array<int, 12> selected = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
44 auto vmenu_1_ =
VMenu1(&entries, &selected[0]);
45 auto vmenu_2_ =
VMenu2(&entries, &selected[1]);
46 auto vmenu_3_ =
VMenu3(&entries, &selected[2]);
47 auto vmenu_4_ =
VMenu4(&entries, &selected[3]);
48 auto vmenu_5_ =
VMenu5(&entries, &selected[4]);
49 auto vmenu_6_ =
VMenu6(&entries, &selected[5]);
50 auto vmenu_7_ =
VMenu7(&entries, &selected[6]);
51 auto vmenu_8_ =
VMenu8(&entries, &selected[7]);
53 auto hmenu_1_ =
HMenu1(&entries, &selected[8]);
54 auto hmenu_2_ =
HMenu2(&entries, &selected[9]);
55 auto hmenu_3_ =
HMenu3(&entries, &selected[10]);
56 auto hmenu_4_ =
HMenu4(&entries, &selected[11]);
57 auto hmenu_5_ =
HMenu5(&entries, &selected[12]);
77 auto renderer =
Renderer(container, [&] {
111 screen.Loop(renderer);
116 option.entries_option.transform = [](
EntryState state) {
117 state.label = (state.active ?
"> " :
" ") + state.label;
125 return Menu(entries, selected, option);
130 option.entries_option.transform = [](
EntryState state) {
131 state.label += (state.active ?
" <" :
" ");
139 return Menu(entries, selected, option);
144 option.entries_option.transform = [](
EntryState state) {
145 Element e = state.active ?
text(
"[" + state.label +
"]")
146 :
text(
" " + state.label +
" ");
156 return Menu(entries, selected, option);
161 option.entries_option.transform = [](
EntryState state) {
162 if (state.active && state.focused) {
176 return Menu(entries, selected, option);
181 option.entries_option.transform = [](
EntryState state) {
182 auto element =
text(state.label);
183 if (state.active && state.focused) {
190 return element |
bold;
194 return Menu(entries, selected, option);
201 option.underline.SetAnimationFunction(animation::easing::Linear);
202 return Menu(entries, selected, option);
207 option.entries_option.animated_colors.foreground.enabled =
true;
208 option.entries_option.animated_colors.background.enabled =
true;
209 option.entries_option.animated_colors.background.active =
Color::Red;
210 option.entries_option.animated_colors.background.inactive =
Color::Black;
211 option.entries_option.animated_colors.foreground.active =
Color::White;
212 option.entries_option.animated_colors.foreground.inactive =
Color::Red;
213 return Menu(entries, selected, option);
218 option.entries_option.animated_colors.foreground.Set(
220 return Menu(entries, selected, option);
233 option.elements_infix = [] {
return text(
" 🮣🮠"); };
235 return Menu(entries, selected, option);
244 option.underline.SetAnimation(std::chrono::milliseconds(1500),
245 animation::easing::ElasticOut);
246 option.entries_option.transform = [](
EntryState state) {
248 if (state.active && state.focused)
250 if (!state.focused && !state.active)
256 return Menu(entries, selected, option);
static ScreenInteractive TerminalOutput()
static MenuOption Toggle()
Standard options for a horizontal menu with some separator. This can be useful to implement a tab bar...
static MenuOption Horizontal()
Standard options for a horizontal menu. This can be useful to implement a tab bar.
static MenuOption VerticalAnimated()
Standard options for an animated vertical menu. This can be useful to implement a list of selectable ...
static MenuOption Vertical()
Standard options for a vertical menu. This can be useful to implement a list of selectable items.
static MenuOption HorizontalAnimated()
Standard options for an animated horizontal menu. This can be useful to implement a tab bar.
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Component Menu(MenuOption options)
A list of text. The focused element is selected.
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
Decorator bgcolor(Color)
Decorate using a background color.
Element borderDouble(Element)
Draw a double border around the element.
Element flex(Element)
Make a child element to expand proportionally to the space left in a container.
Element bold(Element)
Use a bold font, for elements with more emphasis.
Element text(std::wstring text)
Display a piece of unicode text.
Element separator()
Draw a vertical or horizontal separation in between two other elements.
Element filler()
An element that will take expand proportionally to the space left in a container.
Element dim(Element)
Use a light font, for elements with less emphasis.
Element border(Element)
Draw a border around the element.
Decorator color(Color)
Decorate using a foreground color.
Element vbox(Elements)
A container displaying elements vertically one by one.
The FTXUI ftxui:: namespace.
std::shared_ptr< Node > Element
Element hbox(Elements)
A container displaying elements horizontally one by one.
std::shared_ptr< ComponentBase > Component
arguments for transform from |ButtonOption|, |CheckboxOption|, |RadioboxOption|, |MenuEntryOption|,...