FTXUI 7.0.3
C++ functional terminal UI.
Loading...
Searching...
No Matches
elements.hpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef FTXUI_DOM_ELEMENTS_HPP
5#define FTXUI_DOM_ELEMENTS_HPP
6
7#include <cstdint>
8#include <functional>
9#include <memory>
10
11#include <string_view>
12#include "ftxui/dom/canvas.hpp"
16#include "ftxui/dom/node.hpp"
17#include "ftxui/screen/box.hpp"
20#include "ftxui/util/export.hpp"
21#include "ftxui/util/ref.hpp"
22
23namespace ftxui {
24class Node;
25using Element = std::shared_ptr<Node>;
26using Elements = std::vector<Element>;
27using Decorator = std::function<Element(Element)>;
28using GraphFunction = std::function<std::vector<int>(int, int)>;
29
30/// @brief BorderStyleは、ターミナルUIの要素に適用できる様々なボーダースタイルを表す列挙型です。
31///
32/// BorderStyleは、ターミナルUIの要素に適用できる様々なボーダースタイルを表す列挙型です。
33/// ウィンドウ、フレーム、セパレータなどの要素の周囲の境界線の視覚的な外観を定義するために使用されます。
34/// @ingroup dom
43
44// デコレータと共に要素をパイプします。
45// 例えば、次の行は同等です:
46// -> text("ftxui") | bold | underlined
47// -> underlined(bold(text("FTXUI")))
52
53// --- ウィジェット ---
54FTXUI_EXPORT(DOM) Element text(std::string_view text);
55FTXUI_EXPORT(DOM) Element vtext(std::string_view text);
56FTXUI_EXPORT(DOM) Element separator();
57FTXUI_EXPORT(DOM) Element separatorLight();
59FTXUI_EXPORT(DOM) Element separatorHeavy();
63FTXUI_EXPORT(DOM) Element separator(Cell);
64FTXUI_EXPORT(DOM) Element separatorCharacter(std::string_view);
65FTXUI_EXPORT(DOM)
66Element separatorHSelector(float left,
67 float right,
68 Color unselected_color,
69 Color selected_color);
70FTXUI_EXPORT(DOM)
71Element separatorVSelector(float up,
72 float down,
73 Color unselected_color,
74 Color selected_color);
75FTXUI_EXPORT(DOM) Element gauge(float progress);
76FTXUI_EXPORT(DOM) Element gaugeLeft(float progress);
77FTXUI_EXPORT(DOM) Element gaugeRight(float progress);
78FTXUI_EXPORT(DOM) Element gaugeUp(float progress);
79FTXUI_EXPORT(DOM) Element gaugeDown(float progress);
80FTXUI_EXPORT(DOM) Element gaugeDirection(float progress, Direction direction);
81
82// charset[0]は"空"のグリフで、charset.back()は"満杯"です。間にある
83// エントリは境界セルを陰影付けします。
84FTXUI_EXPORT(DOM)
85Element gaugeCharset(float progress,
86 std::vector<std::string> charset,
88FTXUI_EXPORT(DOM) Element border(Element);
89FTXUI_EXPORT(DOM) Element borderLight(Element);
90FTXUI_EXPORT(DOM) Element borderDashed(Element);
91FTXUI_EXPORT(DOM) Element borderHeavy(Element);
92FTXUI_EXPORT(DOM) Element borderDouble(Element);
93FTXUI_EXPORT(DOM) Element borderRounded(Element);
94FTXUI_EXPORT(DOM) Element borderEmpty(Element);
95FTXUI_EXPORT(DOM) Decorator borderStyled(BorderStyle);
96FTXUI_EXPORT(DOM) Decorator borderStyled(BorderStyle, Color);
97FTXUI_EXPORT(DOM) Decorator borderStyled(Color);
98FTXUI_EXPORT(DOM) Decorator borderWith(const Cell&);
99FTXUI_EXPORT(DOM)
100Element window(Element title, Element content, BorderStyle border = ROUNDED);
101FTXUI_EXPORT(DOM) Element spinner(int charset_index, size_t image_index);
102FTXUI_EXPORT(DOM) Element paragraph(std::string_view text);
103FTXUI_EXPORT(DOM) Element paragraphAlignLeft(std::string_view text);
104FTXUI_EXPORT(DOM) Element paragraphAlignRight(std::string_view text);
105FTXUI_EXPORT(DOM) Element paragraphAlignCenter(std::string_view text);
106FTXUI_EXPORT(DOM) Element paragraphAlignJustify(std::string_view text);
108FTXUI_EXPORT(DOM) Element emptyElement();
109FTXUI_EXPORT(DOM) Element canvas(ConstRef<Canvas>);
110FTXUI_EXPORT(DOM)
111Element canvas(int width, int height, std::function<void(Canvas&)>);
112FTXUI_EXPORT(DOM) Element canvas(std::function<void(Canvas&)>);
113
114// -- デコレータ ---
115FTXUI_EXPORT(DOM) Element bold(Element);
117FTXUI_EXPORT(DOM) Element italic(Element);
118FTXUI_EXPORT(DOM) Element inverted(Element);
119FTXUI_EXPORT(DOM) Element underlined(Element);
120FTXUI_EXPORT(DOM) Element underlinedDouble(Element);
121FTXUI_EXPORT(DOM) Element blink(Element);
122FTXUI_EXPORT(DOM) Element strikethrough(Element);
123FTXUI_EXPORT(DOM) Decorator color(Color);
124FTXUI_EXPORT(DOM) Decorator bgcolor(Color);
125FTXUI_EXPORT(DOM) Decorator color(const LinearGradient&);
126FTXUI_EXPORT(DOM) Decorator bgcolor(const LinearGradient&);
127FTXUI_EXPORT(DOM) Element color(Color, Element);
128FTXUI_EXPORT(DOM) Element bgcolor(Color, Element);
129FTXUI_EXPORT(DOM) Element color(const LinearGradient&, Element);
130FTXUI_EXPORT(DOM) Element bgcolor(const LinearGradient&, Element);
131FTXUI_EXPORT(DOM) Decorator focusPosition(int x, int y);
132FTXUI_EXPORT(DOM) Decorator focusPositionRelative(float x, float y);
133FTXUI_EXPORT(DOM) Element automerge(Element child);
134FTXUI_EXPORT(DOM) Decorator hyperlink(std::string_view link);
135FTXUI_EXPORT(DOM) Element hyperlink(std::string_view link, Element child);
136FTXUI_EXPORT(DOM) Element selectionStyleReset(Element);
137FTXUI_EXPORT(DOM) Decorator selectionColor(Color foreground);
138FTXUI_EXPORT(DOM) Decorator selectionBackgroundColor(Color foreground);
139FTXUI_EXPORT(DOM) Decorator selectionForegroundColor(Color foreground);
140FTXUI_EXPORT(DOM) Decorator selectionStyle(std::function<void(Cell&)> style);
141
142// --- レイアウトは
143// 水平、垂直、またはスタックされた要素のセットです。
144FTXUI_EXPORT(DOM) Element hbox(Elements);
145FTXUI_EXPORT(DOM) Element vbox(Elements);
146FTXUI_EXPORT(DOM) Element dbox(Elements);
147FTXUI_EXPORT(DOM)
148Element flexbox(Elements, FlexboxConfig config = FlexboxConfig());
149FTXUI_EXPORT(DOM) Element gridbox(std::vector<Elements> lines);
150
151FTXUI_EXPORT(DOM)
152Element hflow(Elements); // ヘルパー: 行方向のデフォルトflexbox。
153FTXUI_EXPORT(DOM)
154Element vflow(Elements); // ヘルパー: 列方向のデフォルトflexbox。
155
156// -- 柔軟性 ---
157// コンテナ内ですべてが使用されていない残りのスペースを
158// どのように共有するかを定義します。
159FTXUI_EXPORT(DOM) Element flex(Element); // 可能/必要な場合に拡大/最小化します。
160FTXUI_EXPORT(DOM) Element flex_grow(Element); // 可能な場合に要素を拡大します。
161FTXUI_EXPORT(DOM) Element flex_shrink(Element); // 必要な場合に要素を最小化します。
165
166FTXUI_EXPORT(DOM)
167Element xflex(Element); // X軸で可能/必要な場合に拡大/最小化します。
168FTXUI_EXPORT(DOM)
169Element xflex_grow(Element); // X軸で可能な場合に要素を拡大します。
170FTXUI_EXPORT(DOM)
171Element xflex_shrink(Element); // X軸で必要な場合に要素を最小化します。
172FTXUI_EXPORT(DOM) Decorator xflex_factor(int grow, int shrink);
175
176FTXUI_EXPORT(DOM)
177Element yflex(Element); // Y軸で可能/必要な場合に拡大/最小化します。
178FTXUI_EXPORT(DOM)
179Element yflex_grow(Element); // Y軸で可能な場合に要素を拡大します。
180FTXUI_EXPORT(DOM)
181Element yflex_shrink(Element); // Y軸で必要な場合に要素を最小化します。
182FTXUI_EXPORT(DOM) Decorator yflex_factor(int grow, int shrink);
185
186FTXUI_EXPORT(DOM) Element notflex(Element); // flex属性をリセットします。
187FTXUI_EXPORT(DOM) Element filler(); // 空白の拡大可能な要素。
188
189// -- サイズのオーバーライド;
190enum WidthOrHeight : uint8_t { WIDTH, HEIGHT };
193
194// --- フレーム ---
195// フレームはスクロール可能な領域です。内部領域は外部領域よりも
196// 大きい可能性があります。内部領域は、フォーカスされた要素を
197// 表示させるためにスクロールされます。
202FTXUI_EXPORT(DOM) Element select(Element e); // 非推奨 - focusのエイリアス。
203
204// --- カーソル ---
205// これらは`focus`に似ていますが、カーソルの形状も変更します。
212
213// --- その他 ---
216FTXUI_EXPORT(DOM) Decorator reflect(Box& box);
217// |element|を描画する前に、下のピクセルをクリアします。これはdboxと
218// 組み合わせて使用すると便利です。
220
221// --- ユーティリティ --------------------------------------------------------------------
227
228namespace Dimension {
229FTXUI_EXPORT(DOM) Dimensions Fit(Element&, bool extend_beyond_screen = false);
230} // namespace Dimension
231
232} // namespace ftxui
233
234// コンテナが入力として任意の数の子を取れるようにします。
235#include "ftxui/dom/take_any_args.hpp"
236
237// wstringを使用した古い定義を含めます。
239#endif // FTXUI_DOM_ELEMENTS_HPP
アダプター。不変オブジェクトを所有または参照します。
Definition ref.hpp:20
#define FTXUI_EXPORT(component)
Definition export.hpp:25
Element text(std::string_view text)
UTF8エンコードされたユニコードテキストを表示します。
Element focusCursorBarBlinking(Element child)
focus と同じですが、カーソル形状を点滅バーに設定します。
Definition frame.cpp:188
Element separatorStyled(BorderStyle style)
他の2つの要素の間に垂直または水平の区切り線を描画します。
Element clear_under(Element element)
|child|を描画する前に、その下のセルをクリアする。これは dboxとの組み合わせで有用。
Element separatorEmpty()
他の2つの要素の間にEMPTYスタイルで垂直または水平の区切り線を描画します。
Element vscroll_indicator(Element child)
右側に垂直スクロールバーを表示します。 色はコンテンツに従います。
Element nothing(Element element)
何も行わないデコレーションです。
Definition dom/util.cpp:28
Decorator size(WidthOrHeight direction, Constraint constraint, int value)
要素のサイズに制約を適用する。
Element focusCursorUnderlineBlinking(Element child)
focus と同じですが、カーソル形状を点滅下線に設定します。
Definition frame.cpp:216
Element focusCursorBar(Element child)
focus と同じですが、カーソル形状を静止ブロックに設定します。
Definition frame.cpp:174
Element focusCursorBlock(Element child)
focus と同じですが、カーソル形状を静止ブロックに設定します。
Definition frame.cpp:146
Element vtext(std::string_view text)
ユニコードテキストを垂直に表示します。
BorderStyle
BorderStyleは、ターミナルUIの要素に適用できる様々なボーダースタイルを表す列挙型です。
Definition elements.hpp:35
Element center(Element child)
要素を水平方向および垂直方向に中央揃えします。
Direction
Directionは、東西南北の4つの基本方向を表す列挙型です。
Definition direction.hpp:14
Element focusCursorUnderline(Element child)
focus と同じですが、カーソル形状を静止下線に設定します。
Definition frame.cpp:202
Element gaugeCharset(float progress, std::vector< std::string > charset, Direction direction=Direction::Right)
カスタム文字セットを使って高精細なプログレスバーを描画する。
Element align_right(Element child)
要素を右側に揃えます。
Element hscroll_indicator(Element child)
下部に水平スクロールバーを表示します。 色はコンテンツに従います。
Element separatorDashed()
他の2つの要素の間にLIGHTスタイルで垂直または水平の区切り線を描画します。
Element focus(Element child)
子要素を兄弟要素の中でフォーカスされたものとして設定します。
Definition frame.cpp:101
Element vcenter(Element child)
要素を垂直方向に中央揃えします。
Element separatorDouble()
他の2つの要素の間にHEAVYスタイルで垂直または水平の区切り線を描画します。
Element focusCursorBlockBlinking(Element child)
focus と同じですが、カーソル形状を点滅ブロックに設定します。
Definition frame.cpp:160
Element hcenter(Element child)
要素を水平方向に中央揃えします。
@ EMPTY
Definition elements.hpp:41
@ DOUBLE
Definition elements.hpp:39
@ HEAVY
Definition elements.hpp:38
@ ROUNDED
Definition elements.hpp:40
@ DASHED
Definition elements.hpp:37
@ LIGHT
Definition elements.hpp:36
FTXUI ftxui::Dimension::名前空間
bool extend_beyond_screen
Definition elements.hpp:229
FTXUI ftxui::名前空間
Definition animation.hpp:11
@ LESS_THAN
Definition elements.hpp:191
@ GREATER_THAN
Definition elements.hpp:191
Decorator yflex_shrink_factor(int shrink)
Definition flex.cpp:199
size_t image_index
Definition elements.hpp:101
std::shared_ptr< Node > Element
Definition elements.hpp:25
Element xframe(Element child)
frame と同じですが、x軸のみに適用されます。
Definition frame.cpp:125
Decorator xflex_grow_factor(int grow)
Definition flex.cpp:175
Decorator yflex_grow_factor(int grow)
Definition flex.cpp:193
Direction direction
Definition elements.hpp:80
std::vector< Element > Elements
Definition elements.hpp:26
Decorator yflex_factor(int grow, int shrink)
Definition flex.cpp:187
WidthOrHeight
Definition elements.hpp:190
Component operator|(Component component, ComponentDecorator decorator)
std::function< Element(Element)> Decorator
Definition elements.hpp:27
Decorator flex_shrink_factor(int shrink)
Definition flex.cpp:163
Element yframe(Element child)
frame と同じですが、y軸のみに適用されます。
Definition frame.cpp:133
Decorator flex_grow_factor(int grow)
Definition flex.cpp:157
int shrink
Definition elements.hpp:162
int y
Definition elements.hpp:131
const Element & element
Definition node.hpp:94
Decorator reflect(Box &box)
Definition reflect.cpp:43
std::function< std::vector< int >(int, int)> GraphFunction
Definition elements.hpp:28
Decorator xflex_shrink_factor(int shrink)
Definition flex.cpp:181
Decorator xflex_factor(int grow, int shrink)
Definition flex.cpp:169
Decorator flex_factor(int grow, int shrink)
Definition flex.cpp:151
int value
Definition elements.hpp:192
Element frame(Element child)
要素を「仮想」領域内に表示できるようにします。そのサイズはコンテナよりも大きくすることができます。 この場合、より小さい部分のみが表示されます。フォーカスされた要素を表示するためにビューはスクロール可能...
Definition frame.cpp:117
Component & operator|=(Component &component, ComponentDecorator decorator)
Element select(Element e)
childをその兄弟の中でフォーカスされた要素に設定する。
Definition frame.cpp:108
std::uint8_t left
Definition screen.cpp:147
std::uint8_t down
Definition screen.cpp:150
std::uint8_t right
Definition screen.cpp:149