37 auto screen = App::TerminalOutput();
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]);
59 auto container = Container::Vertical({
60 Container::Horizontal({
77 auto renderer =
Renderer(container, [&] {
111 screen.Loop(renderer);
115 auto option = MenuOption::Vertical();
116 option.entries_option.transform = [](EntryState state) {
117 state.label = (state.active ?
"> " :
" ") + state.label;
127 return Menu(entries, selected, option);
131 auto option = MenuOption::Vertical();
132 option.entries_option.transform = [](EntryState state) {
133 state.label += (state.active ?
" <" :
" ");
143 return Menu(entries, selected, option);
147 auto option = MenuOption::Vertical();
148 option.entries_option.transform = [](EntryState state) {
149 Element e = state.active ?
text(
"[" + state.label +
"]")
150 :
text(
" " + state.label +
" ");
156 e = e |
color(Color::Blue);
163 return Menu(entries, selected, option);
167 auto option = MenuOption::Vertical();
168 option.entries_option.transform = [](EntryState state) {
169 if (state.active && state.focused) {
183 return Menu(entries, selected, option);
187 auto option = MenuOption::Vertical();
188 option.entries_option.transform = [](EntryState state) {
190 if (state.active && state.focused) {
201 return Menu(entries, selected, option);
205 auto option = MenuOption::VerticalAnimated();
206 option.underline.color_inactive = Color::Default;
207 option.underline.color_active = Color::Red;
208 option.underline.SetAnimationFunction(animation::easing::Linear);
209 return Menu(entries, selected, option);
213 auto option = MenuOption::Vertical();
214 option.entries_option.animated_colors.foreground.enabled =
true;
215 option.entries_option.animated_colors.background.enabled =
true;
216 option.entries_option.animated_colors.background.active = Color::Red;
217 option.entries_option.animated_colors.background.inactive = Color::Black;
218 option.entries_option.animated_colors.foreground.active = Color::White;
219 option.entries_option.animated_colors.foreground.inactive = Color::Red;
220 return Menu(entries, selected, option);
224 auto option = MenuOption::Vertical();
225 option.entries_option.animated_colors.foreground.Set(
226 Color::Red, Color::White, std::chrono::milliseconds(500));
227 return Menu(entries, selected, option);
231 return Menu(entries, selected, MenuOption::Horizontal());
235 return Menu(entries, selected, MenuOption::Toggle());
239 auto option = MenuOption::Toggle();
240 option.elements_infix = [] {
return text(
" 🮣🮠"); };
242 return Menu(entries, selected, option);
246 return Menu(entries, selected, MenuOption::HorizontalAnimated());
250 auto option = MenuOption::HorizontalAnimated();
251 option.underline.SetAnimation(std::chrono::milliseconds(1500),
252 animation::easing::ElasticOut);
253 option.entries_option.transform = [](EntryState state) {
255 if (state.active && state.focused) {
258 if (!state.focused && !state.active) {
263 option.underline.color_inactive = Color::Default;
264 option.underline.color_active = Color::Red;
265 return Menu(entries, selected, option);
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Component Menu(ConstStringListRef entries, int *selected_, MenuOption options=MenuOption::Vertical())
A list of text. The focused element is selected.
Element borderDouble(Element child)
Draw a double border around the element.
Element text(std::string_view text)
Display a piece of UTF8 encoded unicode text.
Element flex(Element child)
Make a child element to expand proportionally to the space left in a container.
Element bold(Element child)
Use a bold font, for elements with more emphasis.
Element bgcolor(Color color, Element child)
Set the background color of an element.
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 child)
Use a light font, for elements with less emphasis.
Element color(Color color, Element child)
Set the foreground color of an element.
Element border(Element child)
Draw a border around the element.
Element vbox(Elements children)
A container displaying elements vertically one by one.
The FTXUI ftxui:: namespace.
std::shared_ptr< Node > Element
Element hbox(Elements children)
A container displaying elements horizontally one by one.
std::shared_ptr< ComponentBase > Component