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// このソースコードの使用は、LICENSE ファイルにある MIT ライセンスによって管理されています。
3// (Use of this source code is governed by the MIT license that can be found in the LICENSE file.)
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()
ピクセルの長方形グリッド。
Definition screen.hpp:25
FTXUI ftxui:: 名前空間
Definition animation.hpp:9