#include <string>
private:
bool checked[3] = {false, false, false};
float slider = 50;
public:
Impl() {
Add(Container::Vertical({
Checkbox("Check me", &checked[0]),
Checkbox("Check me", &checked[1]),
Checkbox("Check me", &checked[2]),
Slider("Slider", &slider, 0.f, 100.f),
}));
}
};
return Make<Impl>();
}
int window_1_left = 20;
int window_1_top = 10;
int window_1_width = 40;
int window_1_height = 20;
.title = "First window",
.left = &window_1_left,
.top = &window_1_top,
.width = &window_1_width,
.height = &window_1_height,
});
.title = "My window",
.left = 40,
.top = 20,
});
.title = "My window",
.left = 60,
.top = 30,
});
});
auto window_container = Container::Stacked({
window_1,
window_2,
window_3,
window_4,
window_5,
});
auto display_win_1 = Renderer([&] {
return text("window_1: " +
std::to_string(window_1_width) + "x" +
std::to_string(window_1_height) + " + " +
std::to_string(window_1_left) + "," +
std::to_string(window_1_top));
});
auto layout = Container::Vertical({
display_win_1,
window_container,
});
auto screen = ScreenInteractive::Fullscreen();
}
它将自身实现为 ftxui::Element。它通过响应 ftxui::Event 来实现键盘导航。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::shared_ptr< ComponentBase > Component