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
17 using namespace ftxui;
18
19 int main() {
20 auto screen = ScreenInteractive::TerminalOutput();
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}
captured_mouse.hpp
component.hpp
component_base.hpp
component_options.hpp
direction.hpp
elements.hpp
ftxui::ScreenInteractive::TerminalOutput
static ScreenInteractive TerminalOutput()
Definition screen_interactive.cpp:410
ftxui::Container::Horizontal
Component Horizontal(Components children)
A list of components, drawn one by one horizontally and navigated horizontally using left/right arrow...
Definition container.cpp:360
ftxui::size
Decorator size(WidthOrHeight, Constraint, int value)
Apply a constraint on the size of an element.
Definition src/ftxui/dom/size.cpp:89
ftxui::Direction::Up
@ Up
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
ftxui::HEIGHT
@ HEIGHT
Definition elements.hpp:161
ftxui::GREATER_THAN
@ GREATER_THAN
Definition elements.hpp:162
ref.hpp
screen_interactive.hpp
main
int main()
Definition slider_direction.cpp:19
ftxui::SliderOption
Definition component_options.hpp:224
ftxui::SliderOption::direction
Direction direction
Definition component_options.hpp:229
ftxui::SliderOption::increment
ConstRef< T > increment
Definition component_options.hpp:228
ftxui::SliderOption::value
Ref< T > value
Definition component_options.hpp:225
ftxui::SliderOption::max
ConstRef< T > max
Definition component_options.hpp:227