2019-01-13 05:25:49 +08:00
|
|
|
#include "ftxui/component/container.hpp"
|
|
|
|
#include "ftxui/component/input.hpp"
|
|
|
|
#include "ftxui/component/menu.hpp"
|
2019-01-19 05:58:32 +08:00
|
|
|
#include "ftxui/component/radiobox.hpp"
|
|
|
|
#include "ftxui/component/checkbox.hpp"
|
2019-01-13 05:25:49 +08:00
|
|
|
#include "ftxui/component/screen_interactive.hpp"
|
|
|
|
#include "ftxui/component/toggle.hpp"
|
|
|
|
|
|
|
|
using namespace ftxui;
|
|
|
|
|
|
|
|
class MyComponent : public Component {
|
|
|
|
Container container = Container::Vertical();
|
|
|
|
Menu menu;
|
|
|
|
Toggle toggle;
|
2019-01-19 05:58:32 +08:00
|
|
|
Container checkbox_container = Container::Vertical();
|
|
|
|
CheckBox checkbox1;
|
|
|
|
CheckBox checkbox2;
|
|
|
|
RadioBox radiobox;
|
|
|
|
Input input;
|
2019-01-13 05:25:49 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
MyComponent() {
|
|
|
|
Add(&container);
|
|
|
|
menu.entries = {
|
2019-01-19 07:20:29 +08:00
|
|
|
L"Menu 1",
|
|
|
|
L"Menu 2",
|
|
|
|
L"Menu 3",
|
|
|
|
L"Menu 4",
|
2019-01-13 05:25:49 +08:00
|
|
|
};
|
|
|
|
container.Add(&menu);
|
|
|
|
|
|
|
|
toggle.entries = {
|
2019-01-19 07:20:29 +08:00
|
|
|
L"Toggle_1",
|
|
|
|
L"Toggle_2",
|
2019-01-13 05:25:49 +08:00
|
|
|
};
|
|
|
|
container.Add(&toggle);
|
|
|
|
|
2019-01-19 05:58:32 +08:00
|
|
|
container.Add(&checkbox_container);
|
|
|
|
checkbox1.label = L"checkbox1";
|
|
|
|
checkbox_container.Add(&checkbox1);
|
|
|
|
checkbox2.label = L"checkbox2";
|
|
|
|
checkbox_container.Add(&checkbox2);
|
|
|
|
|
|
|
|
radiobox.entries = {
|
2019-01-19 07:20:29 +08:00
|
|
|
L"Radiobox 1",
|
|
|
|
L"Radiobox 2",
|
|
|
|
L"Radiobox 3",
|
|
|
|
L"Radiobox 4",
|
2019-01-19 05:58:32 +08:00
|
|
|
};
|
|
|
|
container.Add(&radiobox);
|
|
|
|
|
2019-01-13 05:25:49 +08:00
|
|
|
input.placeholder = L"Input placeholder";
|
|
|
|
container.Add(&input);
|
|
|
|
}
|
|
|
|
|
2019-01-19 05:58:32 +08:00
|
|
|
Element Render(std::wstring name, Component& component) {
|
2019-01-19 07:20:29 +08:00
|
|
|
return hbox(text(name) | size(8,1), separator(), component.Render());
|
2019-01-19 05:58:32 +08:00
|
|
|
}
|
|
|
|
|
2019-01-13 05:25:49 +08:00
|
|
|
Element Render() override {
|
|
|
|
return
|
|
|
|
vbox(
|
2019-01-19 05:58:32 +08:00
|
|
|
Render(L"menu", menu),
|
|
|
|
separator(),
|
|
|
|
Render(L"toggle", toggle),
|
|
|
|
separator(),
|
|
|
|
Render(L"checkbox", checkbox_container),
|
2019-01-13 05:25:49 +08:00
|
|
|
separator(),
|
2019-01-19 05:58:32 +08:00
|
|
|
Render(L"radiobox", radiobox),
|
2019-01-13 05:25:49 +08:00
|
|
|
separator(),
|
2019-01-19 05:58:32 +08:00
|
|
|
Render(L"input", input)
|
2019-01-13 05:25:49 +08:00
|
|
|
) | frame;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, const char* argv[]) {
|
2019-01-19 07:20:29 +08:00
|
|
|
auto screen = ScreenInteractive::FitComponent();
|
2019-01-13 05:25:49 +08:00
|
|
|
MyComponent component;
|
|
|
|
screen.Loop(&component);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|