FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
node.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_NODE_HPP
5#define FTXUI_DOM_NODE_HPP
6
7#include <memory> // for shared_ptr
8#include <vector> // for vector
9
10#include "ftxui/dom/requirement.hpp" // for Requirement
11#include "ftxui/dom/selection.hpp" // for Selection
12#include "ftxui/screen/box.hpp" // for Box
14
15namespace ftxui {
16
17class Node;
18class Screen;
19
20using Element = std::shared_ptr<Node>;
21using Elements = std::vector<Element>;
22
23/// @brief NodeはDOMツリー内のすべての要素の基底クラスです。
24///
25/// DOM(Document Object Model)内の単一のノードを表し、レイアウトとレンダリングのための
26/// 基本的な構造を提供します。
27/// レイアウト要件の計算、ボックスの寸法の設定、コンテンツの選択、画面へのレンダリング、
28/// およびレイアウトステータスの確認のためのメソッドが含まれています。
29/// 通常、子要素もNodeのインスタンスです。
30///
31/// ユーザーはカスタム要素を作成するためにこのクラスから派生することが期待されます。
32///
33/// 組み込み要素のリストは `elements.hpp` ファイルにあります。
34///
35/// @ingroup dom
36class Node {
37 public:
39 explicit Node(Elements children);
40 Node(const Node&) = delete;
41 Node(const Node&&) = delete;
42 Node& operator=(const Node&) = delete;
43 Node& operator=(const Node&&) = delete;
44
45 virtual ~Node();
46
47 // ステップ1: レイアウト要件を計算します。この要素がどの寸法になりたいかを親に伝えます。
48 // 子から親へ伝播されます。
49 virtual void ComputeRequirement();
51
52 // ステップ2: この要素に最終的な寸法を割り当てます。
53 // 親から子へ伝播されます。
54 virtual void SetBox(Box box);
55
56 // ステップ3: (オプション) 選択
57 // 親から子へ伝播されます。
58 virtual void Select(Selection& selection);
59
60 // ステップ4: この要素を描画します。
61 virtual void Render(Screen& screen);
62
63 virtual std::string GetSelectedContent(Selection& selection);
64
65 // 一部の要素では、単一のイテレーションでレイアウトが解決しない場合があります。
66 // これにより、追加のイテレーションを要求できます。このシグナルは少なくとも一度は子に転送する必要があります。
67 struct Status {
68 int iteration = 0;
69 bool need_iteration = false;
70 };
71 virtual void Check(Status* status);
72
73 friend void Render(Screen& screen, Node* node, Selection& selection);
74
75 protected:
79};
80
81void Render(Screen& screen, const Element& element);
82void Render(Screen& screen, Node* node);
83void Render(Screen& screen, Node* node, Selection& selection);
84std::string GetNodeSelectedContent(Screen& screen,
85 Node* node,
86 Selection& selection);
87
88} // namespace ftxui
89
90#endif // FTXUI_DOM_NODE_HPP
virtual void Select(Selection &selection)
要素の選択を計算します。
Definition node.cpp:46
Elements children_
Definition node.hpp:76
virtual std::string GetSelectedContent(Selection &selection)
Definition node.cpp:72
virtual void SetBox(Box box)
描画のために要素に位置と次元を割り当てます。
Definition node.cpp:41
Requirement requirement_
Definition node.hpp:77
Requirement requirement()
Definition node.hpp:50
virtual void ComputeRequirement()
要素が必要とするスペースを計算します。
Definition node.cpp:20
virtual void Check(Status *status)
Definition node.cpp:65
virtual ~Node()
Node & operator=(const Node &)=delete
Node(const Node &)=delete
Box box_
Definition node.hpp:78
friend void Render(Screen &screen, Node *node, Selection &selection)
Definition node.cpp:96
Node & operator=(const Node &&)=delete
Node(const Node &&)=delete
NodeはDOMツリー内のすべての要素の基底クラスです。
Definition node.hpp:36
ターミナルユーザーインターフェースにおける選択範囲を表します。
Definition selection.hpp:20
void Render(Screen &screen, const Element &element)
要素をftxui::Screenに表示します。
Definition node.cpp:84
Requirementは、ターミナルユーザーインターフェースにおけるNodeのレイアウト要件を定義する構造体です。
ピクセルの長方形グリッド。
Definition screen.hpp:25
Boxは、2D空間における矩形領域を表す構造体です。
Definition box.hpp:14
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
std::string GetNodeSelectedContent(Screen &screen, Node *node, Selection &selection)
Definition node.cpp:167
std::shared_ptr< Node > Element
Definition elements.hpp:21
std::vector< Element > Elements
Definition elements.hpp:22