#include <functional>
#include <memory>
std::function<void()> exit) {
auto component = Container::Vertical({
});
component |= Renderer([&](
Element inner) {
return vbox({
text("Main component"),
separator(),
inner,
})
| size(WIDTH, GREATER_THAN, 15)
| size(HEIGHT, GREATER_THAN, 15)
| border
| center;
});
return component;
}
std::function<void()> hide_modal) {
auto component = Container::Vertical({
});
component |= Renderer([&](
Element inner) {
return vbox({
text("Modal component "),
separator(),
inner,
})
| size(WIDTH, GREATER_THAN, 30)
| border;
});
return component;
}
int main(
int argc,
const char* argv[]) {
auto screen = ScreenInteractive::TerminalOutput();
bool modal_shown = false;
auto show_modal = [&] { modal_shown = true; };
auto hide_modal = [&] { modal_shown = false; };
auto exit = screen.ExitLoopClosure();
auto do_nothing = [&] {};
main_component |= Modal(modal_component, &modal_shown);
screen.Loop(main_component);
return 0;
}
Component ModalComponent(std::function< void()> do_nothing, std::function< void()> hide_modal)
Component MainComponent(std::function< void()> show_modal, std::function< void()> exit)
The FTXUI ftxui:: namespace.
std::shared_ptr< Node > Element
std::shared_ptr< ComponentBase > Component