Files
FTXUI/examples/component/checkbox_in_frame.cpp

35 lines
1.2 KiB
C++
Raw Normal View History

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