FTXUI/examples/component/checkbox.cpp

38 lines
1.2 KiB
C++
Raw Normal View History

2019-01-13 05:25:49 +08:00
#include "ftxui/component/checkbox.hpp"
2021-05-10 02:32:27 +08:00
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Checkbox, Make
#include "ftxui/component/container.hpp" // for Container
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive, Component
2019-01-13 05:25:49 +08:00
using namespace ftxui;
2021-05-10 02:32:27 +08:00
class MyComponent : public ComponentBase {
2020-03-23 05:32:44 +08:00
private:
2021-05-10 02:32:27 +08:00
std::wstring build_examples_label = L"Build examples";
std::wstring build_tests_label = L"Build tests";
std::wstring use_webassembly_label = L"Use WebAssembly";
bool build_examples_state = false;
bool build_tests_state = false;
bool use_webassembly_state = true;
Component container = Container::Vertical({
Checkbox(&build_examples_label, &build_examples_state),
Checkbox(&build_tests_label, &build_tests_state),
Checkbox(&use_webassembly_label, &use_webassembly_state),
});
2020-03-23 05:32:44 +08:00
public:
2021-05-10 02:32:27 +08:00
MyComponent() { Add(container); }
2019-01-13 05:25:49 +08:00
};
2020-03-23 05:32:44 +08:00
int main(int argc, const char* argv[]) {
2019-01-20 05:06:05 +08:00
auto screen = ScreenInteractive::TerminalOutput();
2021-05-10 02:32:27 +08:00
screen.Loop(Make<MyComponent>());
2019-01-13 05:25:49 +08:00
return 0;
}
2020-09-06 19:46:56 +08:00
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.