19 std::function<
void()> exit) {
20 auto component = Container::Vertical({
27 text(
"Main component"),
41 std::function<
void()> hide_modal) {
42 auto component = Container::Vertical({
49 text(
"Modal component "),
59int main(
int argc,
const char* argv[]) {
60 auto screen = App::TerminalOutput();
63 bool modal_shown =
false;
66 auto show_modal = [&] { modal_shown =
true; };
67 auto hide_modal = [&] { modal_shown =
false; };
68 auto exit = screen.ExitLoopClosure();
69 auto do_nothing = [&] {};
77 main_component |=
Modal(modal_component, &modal_shown);
79 screen.Loop(main_component);
Component Button(ConstStringRef label, std::function< void()> on_click, ButtonOption options=ButtonOption::Simple())
繪製一個按鈕。點擊時執行一個函式。
FTXUI_EXPORT(COMPONENT) ComponentDecorator Maybe(std Component Modal(Component main, Component modal, const bool *show_modal)
Component Renderer(Component child, std::function< Element()>)
回傳一個新的 Component,類似 |child|,但使用 |render| 作為 Component::Render() 事件。
Element text(std::string_view text)
顯示一段 UTF8 編碼的 Unicode 文字。
Decorator size(WidthOrHeight direction, Constraint constraint, int value)
對元素的大小套用限制。
Element center(Element child)
水平與垂直置中一個元素。
Element separator()
在兩個元素之間繪製垂直或水平分隔線。
Element border(Element child)
在元素周圍繪製邊框。
Element vbox(Elements children)
一個垂直一個接一個顯示元素的容器。
Component ModalComponent(std::function< void()> do_nothing, std::function< void()> hide_modal)
Component MainComponent(std::function< void()> show_modal, std::function< void()> exit)
std::shared_ptr< Node > Element
std::shared_ptr< ComponentBase > Component