2019-01-20 05:06:05 +08:00
|
|
|
#include "ftxui/component/checkbox.hpp"
|
|
|
|
#include "ftxui/component/container.hpp"
|
|
|
|
#include "ftxui/component/input.hpp"
|
|
|
|
#include "ftxui/component/menu.hpp"
|
|
|
|
#include "ftxui/component/screen_interactive.hpp"
|
|
|
|
#include "ftxui/component/toggle.hpp"
|
|
|
|
#include "ftxui/screen/string.hpp"
|
|
|
|
|
|
|
|
using namespace ftxui;
|
|
|
|
|
|
|
|
class MyComponent : public Component {
|
|
|
|
public:
|
|
|
|
MyComponent() {
|
|
|
|
Add(&container);
|
|
|
|
checkbox.resize(30);
|
2020-03-23 05:32:44 +08:00
|
|
|
for (int i = 0; i < checkbox.size(); ++i) {
|
2019-01-20 05:06:05 +08:00
|
|
|
checkbox[i].label = (L"CheckBox " + to_wstring(i));
|
|
|
|
container.Add(&checkbox[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-23 05:32:44 +08:00
|
|
|
// clang-format off
|
2019-01-20 05:06:05 +08:00
|
|
|
Element Render() override {
|
|
|
|
Elements content;
|
2020-03-23 05:32:44 +08:00
|
|
|
for (auto& it : checkbox) {
|
2019-01-20 05:06:05 +08:00
|
|
|
content.push_back(it.Render());
|
|
|
|
}
|
2019-01-21 06:04:10 +08:00
|
|
|
return vbox(std::move(content))
|
|
|
|
| frame
|
|
|
|
| size(HEIGHT, LESS_THAN, 10)
|
|
|
|
| border;
|
2019-01-20 05:06:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<CheckBox> checkbox;
|
|
|
|
Container container = Container::Vertical();
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, const char* argv[]) {
|
|
|
|
auto screen = ScreenInteractive::FitComponent();
|
|
|
|
MyComponent component;
|
|
|
|
screen.Loop(&component);
|
|
|
|
|
|
|
|
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.
|