FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
button_in_frame.cpp
Go to the documentation of this file.
1// Copyright 2022 Arthur Sonzogni. All rights reserved.
2// このソースコードの使用は、LICENSEファイルに記載されているMITライセンスに準拠しています。
3#include <memory> // for allocator, __shared_ptr_access, shared_ptr
4#include <string> // for to_string, operator+
5
6#include "ftxui/component/captured_mouse.hpp" // for ftxui
7#include "ftxui/component/component.hpp" // for Button, Renderer, Vertical
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 operator|, text, Element, hbox, separator, size, vbox, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
12#include "ftxui/screen/color.hpp" // for Color, Color::Default, Color::GrayDark, Color::White
13
14using namespace ftxui;
15
16int main() {
17 int counter = 0;
18 auto on_click = [&] { counter++; };
19
22
23 auto container = Container::Vertical({});
24 for (int i = 0; i < 30; ++i) {
25 auto button = Button("Button " + std::to_string(i), on_click, style);
26 container->Add(button);
27 }
28
29 auto renderer = Renderer(container, [&] {
30 return vbox({
31 hbox({
32 text("Counter:"),
33 text(std::to_string(counter)),
34 }),
35 separator(),
36 container->Render() | vscroll_indicator | frame |
37 size(HEIGHT, LESS_THAN, 20),
38 }) |
39 border;
40 });
41
42 auto screen = ScreenInteractive::FitComponent();
43 screen.Loop(renderer);
44
45 return 0;
46}
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 vbox(Elements)
要素を縦に一つずつ表示するコンテナ。
Definition vbox.cpp:94
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
Element hbox(Elements)
要素を水平方向に1つずつ表示するコンテナ。
Definition hbox.cpp:93
Element separator()
@ LESS_THAN
Definition elements.hpp:157
return size
Definition string.cpp:1516