19 return Renderer(component, [name, component] {
34 const std::vector<std::string> menu_entries = {
40 int menu_selected = 0;
41 auto menu =
Menu(&menu_entries, &menu_selected);
42 menu =
Wrap(
"Menu", menu);
45 int toggle_selected = 0;
46 std::vector<std::string> toggle_entries = {
50 auto toggle =
Toggle(&toggle_entries, &toggle_selected);
51 toggle =
Wrap(
"Toggle", toggle);
54 bool checkbox_1_selected =
false;
55 bool checkbox_2_selected =
false;
56 bool checkbox_3_selected =
false;
57 bool checkbox_4_selected =
false;
60 Checkbox(
"checkbox1", &checkbox_1_selected),
61 Checkbox(
"checkbox2", &checkbox_2_selected),
62 Checkbox(
"checkbox3", &checkbox_3_selected),
63 Checkbox(
"checkbox4", &checkbox_4_selected),
65 checkboxes =
Wrap(
"Checkbox", checkboxes);
68 int radiobox_selected = 0;
69 std::vector<std::string> radiobox_entries = {
75 auto radiobox =
Radiobox(&radiobox_entries, &radiobox_selected);
76 radiobox =
Wrap(
"Radiobox", radiobox);
79 std::string input_label;
80 auto input =
Input(&input_label,
"placeholder");
81 input =
Wrap(
"Input", input);
84 std::string button_label =
"Quit";
85 std::function<void()> on_button_clicked_;
86 auto button =
Button(&button_label, screen.ExitLoopClosure());
87 button =
Wrap(
"Button", button);
90 int slider_value_1 = 12;
91 int slider_value_2 = 56;
92 int slider_value_3 = 128;
94 Slider(
"R:", &slider_value_1, 0, 256, 1),
95 Slider(
"G:", &slider_value_2, 0, 256, 1),
96 Slider(
"B:", &slider_value_3, 0, 256, 1),
98 sliders =
Wrap(
"Slider", sliders);
103 text(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. "),
104 text(
"Sed do eiusmod tempor incididunt ut labore et dolore magna "
106 text(
"Ut enim ad minim veniam, quis nostrud exercitation ullamco "
107 "laboris nisi ut aliquip ex ea commodo consequat. "),
108 text(
"Duis aute irure dolor in reprehenderit in voluptate velit esse "
109 "cillum dolore eu fugiat nulla pariatur. "),
110 text(
"Excepteur sint occaecat cupidatat non proident, sunt in culpa "
111 "qui officia deserunt mollit anim id est laborum. "),
115 lorel_ipsum =
Wrap(
"Lorel Ipsum", lorel_ipsum);
130 auto component =
Renderer(layout, [&] {
136 checkboxes->Render(),
146 lorel_ipsum->Render(),
151 screen.Loop(component);
Component Wrap(std::string name, Component component)
Element Render()
Draw the component. Build a ftxui::Element to be drawn on the ftxui::Screen representing this ftxui::...
static ScreenInteractive FitComponent()
Component Menu(MenuOption options)
A list of text. The focused element is selected.
Component Toggle(ConstStringListRef entries, int *selected)
An horizontal list of elements. The user can navigate through them.
Component Radiobox(RadioboxOption options)
A list of element, where only one can be selected.
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked.
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...
Component Input(InputOption options={})
An input box for editing text.
Component Checkbox(CheckboxOption options)
Draw checkable element.
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
Element xflex(Element)
Expand/Minimize if possible/needed on the X axis.
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
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 border(Element)
Draw a border around the element.
Element vbox(Elements)
A container displaying elements vertically one by one.
The FTXUI ftxui:: namespace.
Element hbox(Elements)
A container displaying elements horizontally one by one.
Component Slider(SliderOption< T > options)
A slider in any direction.
std::shared_ptr< ComponentBase > Component