27class CaptureMouseImpl :
public CapturedMouseInterface {};
54 if (parent_ ==
nullptr) {
59 if (child.get() ==
this) {
71 child->parent_ =
this;
79 if (parent_ ==
nullptr) {
82 auto it = std::find_if(std::begin(parent_->
children_),
85 return this == that.get();
112 class Wrapper :
public Node {
114 bool active_ =
false;
116 Wrapper(
Element child,
bool active)
117 :
Node({std::move(child)}), active_(active) {}
119 void SetBox(
Box box)
override {
121 children_[0]->SetBox(box);
124 void ComputeRequirement()
override {
125 Node::ComputeRequirement();
126 requirement_.focused.component_active = active_;
130 return std::make_shared<Wrapper>(std::move(element),
Active());
140 return text(
"Not implemented component");
149 if (child->OnEvent(event)) {
161 child->OnAnimation(params);
169 if (child->Focusable()) {
180 if (child->Focusable()) {
189 return parent_ ==
nullptr || parent_->
ActiveChild().get() ==
this;
195 const auto* current =
this;
196 while (current && current->Active()) {
197 current = current->parent_;
215 parent->SetActiveChild(child);
224 return event.screen_->CaptureMouse();
226 return std::make_unique<CaptureMouseImpl>();
virtual bool Focusable() const
コンポーネントがフォーカス可能な要素を含んでいる場合にtrueを返します。 フォーカス不可能なコンポーネントは、キーボードでナビゲートする際にスキップされます。
bool Focused() const
要素がユーザーによってフォーカスされているかどうかを返します。 ComponentBaseがユーザーによってフォーカスされている場合にtrueを返します。要素は、そのすべての子孫が親のActiveChi...
CapturedMouse CaptureMouse(const Event &event)
利用可能であればCapturedMouseを取得します。コンポーネントは1つしかありません。これは他のコンポーネントよりも優先されるコンポーネントを表します。
void Add(Component children)
子を追加します。 @param child 添付する子。
Element Render()
コンポーネントを描画します。 このftxui::ComponentBaseを表すftxui::Screen上に描画されるftxui::Elementを構築します。レンダリングを変更するにはOnRende...
void TakeFocus()
このコンポーネントにフォーカスを与えるように、すべての祖先を設定します。
bool Active() const
要素が現在親のアクティブな子であるかどうかを返します。
ScreenInteractive * screen_
virtual Component ActiveChild()
現在アクティブな子を返します。
void DetachAllChildren()
すべての子を削除します。
int Index() const
親におけるコンポーネントのインデックスを返します。親がない場合は-1を返します。
size_t ChildCount() const
子の数を返します。
ComponentBase * Parent() const
親のComponentBaseを返します。存在しない場合はnullを返します。
virtual void SetActiveChild(ComponentBase *child)
virtual Element OnRender()
コンポーネントを描画します。 このftxui::ComponentBaseを表すftxui::Screen上に描画されるftxui::Elementを構築します。この関数はオーバーライドされることを意図...
virtual bool OnEvent(Event)
イベントに応じて呼び出されます。
void Detach()
この子を親からデタッチします。
Component & ChildAt(size_t i)
インデックスiの子にアクセスします。
virtual void OnAnimation(animation::Params ¶ms)
アニメーションイベントに応じて呼び出されます。
ftxui::Elementとして自身のレンダリングを実装します。ftxui::Eventに応答してキーボードナビゲーションを実装します。
イベントを表します。キープレスイベント、ターミナルのリサイズなど、さまざまなイベントがあります。
NodeはDOMツリー内のすべての要素の基底クラスです。
Element text(std::wstring text)
ユニコードテキストを表示します。
Boxは、2D空間における矩形領域を表す構造体です。
FTXUIのftxui::animation::名前空間。
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::shared_ptr< Node > Element
std::shared_ptr< ComponentBase > Component