FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1// Copyright 2021 Arthur Sonzogni. All rights reserved.
2// このソースコードの使用は、LICENSE ファイルにあるMITライセンスに従います。
3#ifndef FTXUI_COMPONENT_HPP
4#define FTXUI_COMPONENT_HPP
5
6#include <functional> // for function
7#include <memory> // for make_shared, shared_ptr
8#include <utility> // for forward
9
11#include "ftxui/component/component_base.hpp" // for Component, Components
12#include "ftxui/component/component_options.hpp" // for ButtonOption, CheckboxOption, MenuOption
13#include "ftxui/dom/elements.hpp" // for Element
14#include "ftxui/util/ref.hpp" // for ConstRef, Ref, ConstStringRef, ConstStringListRef, StringRef
15
16namespace ftxui {
17struct ButtonOption;
18struct CheckboxOption;
19struct Event;
20struct InputOption;
21struct MenuOption;
22struct RadioboxOption;
23struct MenuEntryOption;
24
25template <class T, class... Args>
26std::shared_ptr<T> Make(Args&&... args) {
27 return std::make_shared<T>(std::forward<Args>(args)...);
28}
29
30Component operator|(Component component, ElementDecorator decorator);
31Component& operator|=(Component& component, ComponentDecorator decorator);
32Component& operator|=(Component& component, ElementDecorator decorator);
33
34// コンポーネントを装飾するためのパイプ演算子。
35
36namespace Container {
38Component Vertical(Components children, int* selector);
40Component Horizontal(Components children, int* selector);
41Component Tab(Components children, int* selector);
43} // namespace Container
44
47 std::function<void()> on_click,
49
52 bool* checked,
54
56Component Input(StringRef content, InputOption options = {});
58 StringRef placeholder,
59 InputOption options = {});
60
61Component Menu(MenuOption options);
62Component Menu(ConstStringListRef entries,
63 int* selected_,
64 MenuOption options = MenuOption::Vertical());
65Component MenuEntry(MenuEntryOption options);
66Component MenuEntry(ConstStringRef label, MenuEntryOption options = {});
67
68Component Radiobox(RadioboxOption options);
69Component Radiobox(ConstStringListRef entries,
70 int* selected_,
71 RadioboxOption options = {});
72
73Component Dropdown(ConstStringListRef entries, int* selected);
74Component Dropdown(DropdownOption options);
75
76Component Toggle(ConstStringListRef entries, int* selected);
77
78// 一般的なスライダーコンストラクタ:
79template <typename T>
80Component Slider(SliderOption<T> options);
81
82// `SliderOption`コンストラクタを使用しない短縮形:
83Component Slider(ConstStringRef label,
84 Ref<int> value,
85 ConstRef<int> min = 0,
86 ConstRef<int> max = 100,
87 ConstRef<int> increment = 5);
88Component Slider(ConstStringRef label,
89 Ref<float> value,
90 ConstRef<float> min = 0.f,
91 ConstRef<float> max = 100.f,
92 ConstRef<float> increment = 5.f);
93Component Slider(ConstStringRef label,
94 Ref<long> value,
95 ConstRef<long> min = 0L,
96 ConstRef<long> max = 100L,
97 ConstRef<long> increment = 5L);
98
99Component ResizableSplit(ResizableSplitOption options);
102Component ResizableSplitTop(Component main, Component back, int* main_size);
104
105Component Renderer(Component child, std::function<Element()>);
106Component Renderer(std::function<Element()>);
107Component Renderer(std::function<Element(bool /* focused */)>);
108ComponentDecorator Renderer(ElementDecorator);
109
110Component CatchEvent(Component child, std::function<bool(Event)>);
111ComponentDecorator CatchEvent(std::function<bool(Event)> on_event);
112
113Component Maybe(Component, const bool* show);
114Component Maybe(Component, std::function<bool()>);
115ComponentDecorator Maybe(const bool* show);
116ComponentDecorator Maybe(std::function<bool()>);
117
118Component Modal(Component main, Component modal, const bool* show_modal);
119ComponentDecorator Modal(Component modal, const bool* show_modal);
120
122 Component child,
123 Ref<bool> show = false);
124
125Component Hoverable(Component component, bool* hover);
127 std::function<void()> on_enter,
128 std::function<void()> on_leave);
129Component Hoverable(Component component, //
130 std::function<void(bool)> on_change);
131ComponentDecorator Hoverable(bool* hover);
132ComponentDecorator Hoverable(std::function<void()> on_enter,
133 std::function<void()> on_leave);
134ComponentDecorator Hoverable(std::function<void(bool)> on_change);
135
137
138} // namespace ftxui
139
140#endif /* end of include guard: FTXUI_COMPONENT_HPP */
アダプター。定数文字列を所有または参照します。便宜上、このクラスは複数の不変文字列を共有表現に変換します。
Definition ref.hpp:91
アダプター。可変オブジェクトを所有または参照します。
Definition ref.hpp:45
アダプター。定数文字列を所有または参照します。便宜上、このクラスは複数の可変文字列を共有表現に変換します。
Definition ref.hpp:80
static CheckboxOption Simple()
標準チェックボックスのオプション。
static ButtonOption Simple()
フォーカス時に反転するButtonOptionを作成します。
static MenuOption Vertical()
垂直メニューの標準オプション。 これは選択可能なアイテムのリストを実装するのに役立ちます。
Component Horizontal(Components children)
コンポーネントのリスト。水平方向に1つずつ描画され、左右の矢印キーまたは'h'/'l'キーを使用して水平方向にナビゲートされます。
Component Maybe(Component, const bool *show)
コンポーネント|child|を装飾します。|show|がtrueの場合にのみ表示されます。
Component ResizableSplitTop(Component main, Component back, int *main_size)
2つのコンポーネント間の垂直分割。マウスで設定可能。
Component Menu(MenuOption options)
テキストのリスト。フォーカスされた要素が選択されます。
Component MenuEntry(MenuEntryOption options)
特定のメニューエントリ。これらはContainer::Verticalに入れてメニューを形成できます。
Component Toggle(ConstStringListRef entries, int *selected)
要素の水平リスト。ユーザーはこれらを操作できます。
Component Radiobox(RadioboxOption options)
1つだけ選択できる要素のリスト。
Component Button(ButtonOption options)
Draw a button. Execute a function when clicked. (ja: ボタンを描画します。クリックされたときに機能を実行します。)
Component Modal(Component main, Component modal, const bool *show_modal)
Definition modal.cpp:17
Component Renderer(Component child, std::function< Element()>)
|child|に似ていますが、|render|をComponentRender()イベントとして使用する新しいコンポーネントを返します。
Component Hoverable(Component component, bool *hover)
コンポーネントをラップします。マウスでホバーされているかどうかを知る機能を提供します。
Definition hoverable.cpp:42
Component Window(WindowOptions option)
ドラッグ可能/サイズ変更可能なウィンドウ。複数のウィンドウを使用するには、それらを Container::Stacked({...})コンポーネントを使用してスタックする必要があります。
Component Vertical(Components children)
コンポーネントのリスト。垂直方向に1つずつ描画され、上下の矢印キーまたは'j'/'k'キーを使用して垂直方向にナビゲートされます。
Component ResizableSplitRight(Component main, Component back, int *main_size)
2つのコンポーネント間の水平分割。マウスで設定可能。
Component Dropdown(ConstStringListRef entries, int *selected)
ドロップダウンメニュー。
Component Stacked(Components children)
互いの上にスタックされるコンポーネントのリスト。 イベントは、最初のコンポーネントに伝播され、処理されない場合は2番目のコンポーネントに伝播されます。 コンポーネントは与えられた順序とは逆の順序で描画さ...
Component ResizableSplitBottom(Component main, Component back, int *main_size)
2つのコンポーネント間の垂直分割。マウスで設定可能。
Component Checkbox(CheckboxOption options)
チェック可能な要素を描画します。
Component ResizableSplitLeft(Component main, Component back, int *main_size)
2つのコンポーネント間の水平分割。マウスで設定可能。
Component Tab(Components children, int *selector)
コンポーネントのリスト。一度に1つだけ描画され、操作されます。|selector|は選択されたコンポーネントのインデックスを提供します。これはタブを実装するのに便利です。
AnimatedButtonコンポーネントのオプション。
Checkboxコンポーネントのオプション。
イベントを表します。キープレスイベント、ターミナルのリサイズなど、さまざまなイベントがあります。
Definition event.hpp:28
Inputコンポーネントのオプション。
FTXUIのftxui::Container::名前空間
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
std::shared_ptr< T > Make(Args &&... args)
Definition component.hpp:26
std::shared_ptr< Node > Element
Definition elements.hpp:21
std::vector< Component > Components
Component ResizableSplit(ResizableSplitOption options)
2つのコンポーネント間の分割。
Component Collapsible(ConstStringRef label, Component child, Ref< bool > show=false)
折りたたみ可能なコンポーネント。矢印付きのチェックボックスを表示します。アクティブ化されると、子が 表示されます。
Component Input(InputOption options={})
Component operator|(Component component, ElementDecorator decorator)
Component Slider(SliderOption< T > options)
どの方向にも対応するスライダー。
Component & operator|=(Component &component, ComponentDecorator decorator)
std::shared_ptr< ComponentBase > Component
Component CatchEvent(Component child, std::function< bool(Event)>)