FTXUI/examples/component/checkbox_in_frame.cpp

35 lines
1.2 KiB
C++
Raw Normal View History

2023-08-19 19:56:36 +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.
2022-03-14 01:51:46 +08:00
#include <array> // for array
2022-03-31 08:17:43 +08:00
#include <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for operator+, to_string
2021-05-10 02:32:27 +08:00
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Checkbox, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
2022-03-31 08:17:43 +08:00
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
2019-01-20 05:06:05 +08:00
using namespace ftxui;
int main() {
2022-03-14 01:51:46 +08:00
std::array<bool, 30> states;
2021-05-13 17:44:47 +08:00
auto container = Container::Vertical({});
2021-09-08 15:36:37 +08:00
for (int i = 0; i < 30; ++i) {
2022-03-14 01:51:46 +08:00
states[i] = false;
container->Add(Checkbox("Checkbox" + std::to_string(i), &states[i]));
2019-01-20 05:06:05 +08:00
}
2021-09-08 15:36:37 +08:00
auto renderer = Renderer(container, [&] {
2021-09-26 23:30:41 +08:00
return container->Render() | vscroll_indicator | frame |
size(HEIGHT, LESS_THAN, 10) | border;
2021-05-13 17:44:47 +08:00
});
2019-01-20 05:06:05 +08:00
auto screen = ScreenInteractive::FitComponent();
2021-09-08 15:36:37 +08:00
screen.Loop(renderer);
2019-01-20 05:06:05 +08:00
return 0;
}