2018-10-10 01:06:03 +08:00
|
|
|
#include <chrono>
|
|
|
|
#include <iostream>
|
|
|
|
#include <thread>
|
|
|
|
|
2019-01-13 01:24:46 +08:00
|
|
|
#include "ftxui/component/container.hpp"
|
2019-01-07 00:10:35 +08:00
|
|
|
#include "ftxui/component/screen_interactive.hpp"
|
|
|
|
#include "ftxui/component/toggle.hpp"
|
2019-01-13 01:24:46 +08:00
|
|
|
#include "ftxui/screen/string.hpp"
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
using namespace ftxui;
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-13 01:24:46 +08:00
|
|
|
class MyComponent : public Component {
|
2018-10-10 01:06:03 +08:00
|
|
|
public:
|
2019-01-13 01:24:46 +08:00
|
|
|
MyComponent() {
|
|
|
|
Add(&container);
|
|
|
|
container.Add(&toggle_1);
|
|
|
|
container.Add(&toggle_2);
|
|
|
|
container.Add(&toggle_3);
|
|
|
|
container.Add(&toggle_4);
|
|
|
|
|
2019-01-03 07:35:59 +08:00
|
|
|
toggle_1.options = {L"On", L"Off"};
|
|
|
|
toggle_2.options = {L"Enabled", L"Disabled"};
|
|
|
|
toggle_3.options = {L"10€", L"0€"};
|
|
|
|
toggle_4.options = {L"Nothing", L"One element", L"Several elements"};
|
2018-10-10 01:06:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::function<void()> on_enter = []() {};
|
|
|
|
|
|
|
|
private:
|
2019-01-13 01:24:46 +08:00
|
|
|
Container container = Container::Vertical();
|
2018-10-10 01:06:03 +08:00
|
|
|
Toggle toggle_1;
|
|
|
|
Toggle toggle_2;
|
|
|
|
Toggle toggle_3;
|
2019-01-03 07:35:59 +08:00
|
|
|
Toggle toggle_4;
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
Element Render() override {
|
|
|
|
return
|
|
|
|
vbox(
|
|
|
|
text(L"Choose your options:"),
|
|
|
|
text(L""),
|
|
|
|
hbox(text(L" * Poweroff on startup : "), toggle_1.Render()),
|
|
|
|
hbox(text(L" * Out of process : "), toggle_2.Render()),
|
2019-01-03 07:35:59 +08:00
|
|
|
hbox(text(L" * Price of the information : "), toggle_3.Render()),
|
|
|
|
hbox(text(L" * Number of elements : "), toggle_4.Render())
|
2018-10-10 01:06:03 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, const char* argv[]) {
|
2019-01-07 00:10:35 +08:00
|
|
|
auto screen = ScreenInteractive::TerminalOutput();
|
2019-01-13 01:24:46 +08:00
|
|
|
MyComponent component;
|
2018-10-10 01:06:03 +08:00
|
|
|
component.on_enter = screen.ExitLoopClosure();
|
2019-01-13 01:24:46 +08:00
|
|
|
screen.Loop(&component);
|
2018-10-10 01:06:03 +08:00
|
|
|
}
|