FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
examples/component/window.cpp
Go to the documentation of this file.
1// Copyright 2023 Arthur Sonzogni. All rights reserved.
2// このソースコードの使用は、LICENSE ファイルにある MIT ライセンスによって管理されています。
5#include <string>
6
7using namespace ftxui;
8
10 class Impl : public ComponentBase {
11 private:
12 bool checked[3] = {false, false, false};
13 float slider = 50;
14
15 public:
16 Impl() {
17 Add(Container::Vertical({
18 Checkbox("私をチェック", &checked[0]),
19 Checkbox("私をチェック", &checked[1]),
20 Checkbox("私をチェック", &checked[2]),
21 Slider("スライダー", &slider, 0.f, 100.f),
22 }));
23 }
24 };
25 return Make<Impl>();
26}
27
28int main() {
29 int window_1_left = 20;
30 int window_1_top = 10;
31 int window_1_width = 40;
32 int window_1_height = 20;
33
34 auto window_1 = Window({
35 .inner = DummyWindowContent(),
36 .title = "最初のウィンドウ",
37 .left = &window_1_left,
38 .top = &window_1_top,
39 .width = &window_1_width,
40 .height = &window_1_height,
41 });
42
43 auto window_2 = Window({
44 .inner = DummyWindowContent(),
45 .title = "私のウィンドウ",
46 .left = 40,
47 .top = 20,
48 });
49
50 auto window_3 = Window({
51 .inner = DummyWindowContent(),
52 .title = "私のウィンドウ",
53 .left = 60,
54 .top = 30,
55 });
56
57 auto window_4 = Window({
58 .inner = DummyWindowContent(),
59 });
60
61 auto window_5 = Window({});
62
63 auto window_container = Container::Stacked({
64 window_1,
65 window_2,
66 window_3,
67 window_4,
68 window_5,
69 });
70
71 auto display_win_1 = Renderer([&] {
72 return text("ウィンドウ1: " + //
73 std::to_string(window_1_width) + "x" +
74 std::to_string(window_1_height) + " + " +
75 std::to_string(window_1_left) + "," +
76 std::to_string(window_1_top));
77 });
78
79 auto layout = Container::Vertical({
80 display_win_1,
81 window_container,
82 });
83
84 auto screen = ScreenInteractive::Fullscreen();
85 screen.Loop(layout);
86
87 return EXIT_SUCCESS;
88}
Component DummyWindowContent()
void Add(Component children)
子を追加します。 @param child 添付する子。
Definition component.cpp:69
static ScreenInteractive Fullscreen()
ftxui::Elementとして自身のレンダリングを実装します。ftxui::Eventに応答してキーボードナビゲーションを実装します。
Component Renderer(Component child, std::function< Element()>)
|child|に似ていますが、|render|をComponentRender()イベントとして使用する新しいコンポーネントを返します。
Component Window(WindowOptions option)
ドラッグ可能/サイズ変更可能なウィンドウ。複数のウィンドウを使用するには、それらを Container::Stacked({...})コンポーネントを使用してスタックする必要があります。
Component Checkbox(CheckboxOption options)
チェック可能な要素を描画します。
Element text(std::wstring text)
ユニコードテキストを表示します。
Definition text.cpp:160
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
std::shared_ptr< T > Make(Args &&... args)
Definition component.hpp:26
Component Slider(SliderOption< T > options)
どの方向にも対応するスライダー。
std::shared_ptr< ComponentBase > Component