FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
gauge_direction.cpp
Go to the documentation of this file.
1// 版權所有 2022 Arthur Sonzogni. 保留所有權利。
2// 此原始碼的使用受 MIT 授權條款約束,詳情請參閱
3// LICENSE 檔案。
4#include <chrono> // 用於 operator""s, chrono_literals
5#include <ftxui/dom/elements.hpp> // 用於 filler, operator|, separator, text, border, Element, vbox, vtext, hbox, center, gaugeDown, gaugeLeft, gaugeRight, gaugeUp
6#include <ftxui/screen/screen.hpp> // 用於 Screen
7#include <iostream> // 用於 cout, endl, ostream
8#include <string> // 用於 allocator, operator+, operator<<, string, to_string
9#include <thread> // 用於 sleep_for
10
11#include "ftxui/dom/node.hpp" // 用於 Render
12#include "ftxui/screen/color.hpp" // 用於 ftxui
13
14int 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}
int main()
void Render(Screen &screen, const Element &element)
在 ftxui::Screen 上顯示元素。
Definition node.cpp:82
像素的矩形網格。
Definition screen.hpp:26
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10