FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
gauge_direction.cpp
Go to the documentation of this file.
1// Copyright 2022 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 <chrono> // for operator""s, chrono_literals
5#include <ftxui/dom/elements.hpp> // for filler, operator|, separator, text, border, Element, vbox, vtext, hbox, center, gaugeDown, gaugeLeft, gaugeRight, gaugeUp
6#include <ftxui/screen/screen.hpp> // for Screen
7#include <iostream> // for cout, endl, ostream
8#include <string> // for allocator, operator+, operator<<, string, to_string
9#include <thread> // for sleep_for
10
11#include "ftxui/dom/node.hpp" // for Render
12#include "ftxui/screen/color.hpp" // for ftxui
13
14 int main() {
15 using namespace ftxui;
16 using namespace std::chrono_literals;
17
18 std::string reset_position;
19 for (float percentage = 0.0f; percentage <= 1.0f; percentage += 0.002f) {
20 std::string data_downloaded =
21 std::to_string(int(percentage * 5000)) + "/5000";
22
23 auto gauge_up = //
24 hbox({
25 vtext("gauge vertical"),
26 separator(),
27 gaugeUp(percentage),
28 }) |
29 border;
30
31 auto gauge_down = //
32 hbox({
33 vtext("gauge vertical"),
34 separator(),
35 gaugeDown(percentage),
36 }) |
37 border;
38
39 auto gauge_right = //
40 vbox({
41 text("gauge horizontal"),
42 separator(),
43 gaugeRight(percentage),
44 }) |
45 border;
46
47 auto gauge_left = //
48 vbox({
49 text("gauge horizontal"),
50 separator(),
51 gaugeLeft(percentage),
52 }) |
53 border;
54
55 auto document = hbox({
56 gauge_up,
57 filler(),
58 vbox({
59 gauge_right,
60 filler(),
61 text(data_downloaded) | border | center,
62 filler(),
63 gauge_left,
64 }),
65 filler(),
66 gauge_down,
67 });
68
69 auto screen = Screen(32, 16);
70 Render(screen, document);
71 std::cout << reset_position;
72 screen.Print();
73 reset_position = screen.ResetPosition();
74
75 std::this_thread::sleep_for(0.01s);
76 }
77 std::cout << std::endl;
78}
color.hpp
elements.hpp
main
int main()
Definition gauge_direction.cpp:14
ftxui::Screen
A rectangular grid of Pixel.
Definition screen.hpp:27
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
node.hpp
screen.hpp