FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
slider_direction.cpp
Go to the documentation of this file.
1// 版權所有 2020 Arthur Sonzogni. 保留所有權利。
2// 本原始碼的使用受 MIT 授權約束,可在 LICENSE 檔案中找到。
3#include <array> // for array
4#include <cmath> // for sin
5#include <ftxui/component/component_base.hpp> // for ComponentBase
6#include <ftxui/component/component_options.hpp> // for SliderOption
7#include <ftxui/dom/direction.hpp> // for Direction, Direction::Up
8#include <ftxui/dom/elements.hpp> // for size, GREATER_THAN, HEIGHT
9#include <ftxui/util/ref.hpp> // for ConstRef, Ref
10#include <memory> // for shared_ptr, __shared_ptr_access
11
12#include "ftxui/component/captured_mouse.hpp" // for ftxui
13#include "ftxui/component/component.hpp" // for Horizontal, Slider, operator|=
14#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
15
16using namespace ftxui;
17
18int main() {
20 std::array<int, 30> values;
21 for (size_t i = 0; i < values.size(); ++i) {
22 values[i] = 50 + 20 * std::sin(i * 0.3);
23 }
24
25 auto layout_horizontal = Container::Horizontal({});
26 for (auto& value : values) {
27 // 在 C++17 中:
28 SliderOption<int> option;
29 option.value = &value;
30 option.max = 100;
31 option.increment = 5;
32 option.direction = Direction::Up;
33 layout_horizontal->Add(Slider<int>(option));
34
35 /* 在 C++20 中:
36 layout_horizontal->Add(Slider<int>({
37 .value = &values[i],
38 .max = 100,
39 .increment = 5,
40 .direction = Direction::Up,
41 }));
42 */
43 }
44
45 layout_horizontal |= size(HEIGHT, GREATER_THAN, 20);
46
47 screen.Loop(layout_horizontal);
48}
static ScreenInteractive TerminalOutput()
Decorator size(WidthOrHeight, Constraint, int value)
限制元素的大小。
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10
@ GREATER_THAN
Definition elements.hpp:159
int main()