FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
slider_direction.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <array> // for array
5#include <cmath> // for sin
6#include <ftxui/component/component_base.hpp> // for ComponentBase
7#include <ftxui/component/component_options.hpp> // for SliderOption
8#include <ftxui/dom/direction.hpp> // for Direction, Direction::Up
9#include <ftxui/dom/elements.hpp> // for size, GREATER_THAN, HEIGHT
10#include <ftxui/util/ref.hpp> // for ConstRef, Ref
11#include <memory> // for shared_ptr, __shared_ptr_access
12
13#include "ftxui/component/captured_mouse.hpp" // for ftxui
14#include "ftxui/component/component.hpp" // for Horizontal, Slider, operator|=
15#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
16
17using namespace ftxui;
18
19int main() {
21 std::array<int, 30> values;
22 for (size_t i = 0; i < values.size(); ++i) {
23 values[i] = 50 + 20 * std::sin(i * 0.3);
24 }
25
26 auto layout_horizontal = Container::Horizontal({});
27 for (auto& value : values) {
28 // In C++17:
29 SliderOption<int> option;
30 option.value = &value;
31 option.max = 100;
32 option.increment = 5;
33 option.direction = Direction::Up;
34 layout_horizontal->Add(Slider<int>(option));
35
36 /* In C++20:
37 layout_horizontal->Add(Slider<int>({
38 .value = &values[i],
39 .max = 100,
40 .increment = 5,
41 .direction = Direction::Up,
42 }));
43 */
44 }
45
46 layout_horizontal |= size(HEIGHT, GREATER_THAN, 20);
47
48 screen.Loop(layout_horizontal);
49}
static ScreenInteractive TerminalOutput()
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
@ GREATER_THAN
Definition elements.hpp:162
int main()