FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
button_animated.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. 全著作権所有。
2// このソースコードの使用は、LICENSE ファイルにある MIT ライセンスに従います。
3#include <memory> // for shared_ptr, __shared_ptr_access
4#include <string> // for operator+, to_string
5
6#include "ftxui/component/captured_mouse.hpp" // for ftxui
7#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer
8#include "ftxui/component/component_base.hpp" // for ComponentBase
9#include "ftxui/component/component_options.hpp" // for ButtonOption
10#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
11#include "ftxui/dom/elements.hpp" // for gauge, separator, text, vbox, operator|, Element, border
12#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Green, Color::Red
13
14using namespace ftxui;
15
16int main() {
17 int value = 50;
18
19 // コンポーネントのツリー。これは、キーボードを使用してナビゲートする方法を定義します。
20 auto buttons = Container::Horizontal({
21 Button(
22 "Decrease", [&] { value--; }, ButtonOption::Animated(Color::Red)),
23 Button(
24 "Reset", [&] { value = 50; }, ButtonOption::Animated(Color::Green)),
25 Button(
26 "Increase", [&] { value++; }, ButtonOption::Animated(Color::Blue)),
27 });
28
29 // 画面上でのレンダリング方法を変更します。
30 auto component = Renderer(buttons, [&] {
31 return vbox({
32 vbox({
33 text("value = " + std::to_string(value)),
34 separator(),
35 gauge(value * 0.01f),
36 }) | border,
37 buttons->Render(),
38 });
39 });
40
41 auto screen = ScreenInteractive::FitComponent();
42 screen.Loop(component);
43 return 0;
44}
int main()
static ButtonOption Animated()
アニメーションカラーを使用するButtonOptionを作成します。
static ScreenInteractive FitComponent()
描画されるコンポーネントの幅と高さに一致するScreenInteractiveを作成します。
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked. (ja: ボタンを描画します。クリックされたときに機能を実行します。)
Component Renderer(Component child, std::function< Element()>)
|child|に似ていますが、|render|をComponentRender()イベントとして使用する新しいコンポーネントを返します。
virtual void Render(Screen &screen)
要素をftxui::Screenに表示します。
Definition node.cpp:59
Element text(std::wstring text)
ユニコードテキストを表示します。
Definition text.cpp:160
Element gauge(float progress)
高精細プログレスバーを描画します。
Element vbox(Elements)
要素を縦に一つずつ表示するコンテナ。
Definition vbox.cpp:94
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
Element separator()