#include <memory>
#include <string>
#include <vector>
int main() {
int depth = 0;
std::string rating = "3/5 stars";
auto button_rate_ftxui =
Button(
"Rate FTXUI", [&] { depth = 1; });
auto button_quit =
Button(
"Quit", screen.ExitLoopClosure());
button_rate_ftxui,
button_quit,
});
auto depth_0_renderer =
Renderer(depth_0_container, [&] {
text(
"Modal dialog example"),
text(
"☆☆☆ FTXUI:" + rating +
" ☆☆☆") |
bold,
button_rate_ftxui->Render(),
button_quit->Render(),
}),
}) |
});
std::vector<std::string> rating_labels = {
"1/5 stars", "2/5 stars", "3/5 stars", "4/5 stars", "5/5 stars",
};
auto on_rating = [&](std::string new_rating) {
rating = new_rating;
depth = 0;
};
Button(&rating_labels[0], [&] { on_rating(rating_labels[0]); }),
Button(&rating_labels[1], [&] { on_rating(rating_labels[1]); }),
Button(&rating_labels[2], [&] { on_rating(rating_labels[2]); }),
Button(&rating_labels[3], [&] { on_rating(rating_labels[3]); }),
Button(&rating_labels[4], [&] { on_rating(rating_labels[4]); }),
});
auto depth_1_renderer =
Renderer(depth_1_container, [&] {
text(
"Do you like FTXUI?"),
hbox(depth_1_container->Render()),
}) |
});
{
depth_0_renderer,
depth_1_renderer,
},
&depth);
auto main_renderer =
Renderer(main_container, [&] {
Element document = depth_0_renderer->Render();
if (depth == 1) {
document,
});
}
return document;
});
screen.Loop(main_renderer);
return 0;
}
static ScreenInteractive TerminalOutput()
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Component Tab(Components children, int *selector)
A list of components, where only one is drawn and interacted with at a time. The |selector| gives the...
Element clear_under(Element element)
Before drawing |child|, clear the pixels below. This is useful in.
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
std::shared_ptr< Node > Element
Element bold(Element)
Use a bold font, for elements with more emphasis.
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.
Element hbox(Elements)
A container displaying elements horizontally one by one.
Element center(Element)
Center an element horizontally and vertically.
Element text(std::wstring text)
Display a piece of unicode text.
Element dbox(Elements)
Stack several element on top of each other.
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 border(Element)
Draw a border around the element.
Element vbox(Elements)
A container displaying elements vertically one by one.