#include <functional>
#include <memory>
Component MainComponent(std::function<
void()> show_modal,
std::function<void()> exit) {
Button(
"Show modal", show_modal, button_style),
Button(
"Quit", exit, button_style),
});
inner,
})
});
return component;
}
Component ModalComponent(std::function<
void()> do_nothing,
std::function<void()> hide_modal) {
Button(
"Do nothing", do_nothing, button_style),
Button(
"Quit modal", hide_modal, button_style),
});
text(
"Modal component "),
inner,
})
});
return component;
}
int main(int argc, const char* argv[]) {
bool modal_shown = false;
auto show_modal = [&] { modal_shown = true; };
auto hide_modal = [&] { modal_shown = false; };
auto exit = screen.ExitLoopClosure();
auto do_nothing = [&] {};
auto main_component = MainComponent(show_modal, exit);
auto modal_component = ModalComponent(do_nothing, hide_modal);
main_component |=
Modal(modal_component, &modal_shown);
screen.Loop(main_component);
return 0;
}
static ScreenInteractive TerminalOutput()
Component Vertical(Components children)
A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or...
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
std::shared_ptr< Node > Element
std::shared_ptr< ComponentBase > Component
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked.
Component Modal(Component main, Component modal, const bool *show_modal)
Component Renderer(Component child, std::function< Element()>)
Return a new Component, similar to |child|, but using |render| as the Component::Render() event.
Element center(Element)
Center an element horizontally and vertically.
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.