FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
reflect.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// このソースコードの使用は、LICENSE ファイルにある MIT ライセンスに従います。
3#include <memory> // for make_shared, __shared_ptr_access
4#include <utility> // for move
5
6#include "ftxui/dom/elements.hpp" // for Element, unpack, Decorator, reflect
7#include "ftxui/dom/node.hpp" // for Node, Elements
8#include "ftxui/dom/requirement.hpp" // for Requirement
9#include "ftxui/screen/box.hpp" // for Box
10#include "ftxui/screen/screen.hpp" // for Screen
11
12namespace ftxui {
13namespace {
14
15// ヘルパークラス。
16class Reflect : public Node {
17 public:
18 Reflect(Element child, Box& box)
19 : Node(unpack(std::move(child))), reflected_box_(box) {}
20
21 void ComputeRequirement() final {
23 requirement_ = children_[0]->requirement();
24 }
25
26 void SetBox(Box box) final {
27 reflected_box_ = box;
28 Node::SetBox(box);
29 children_[0]->SetBox(box);
30 }
31
32 void Render(Screen& screen) final {
33 reflected_box_ = Box::Intersection(screen.stencil, reflected_box_);
34 Node::Render(screen);
35 }
36
37 private:
38 Box& reflected_box_;
39};
40} // namespace
41
43 return [&](Element child) -> Element {
44 return std::make_shared<Reflect>(std::move(child), box);
45 };
46}
47
48} // namespace ftxui
virtual void SetBox(Box box)
描画のために要素に位置と次元を割り当てます。
Definition node.cpp:41
virtual void ComputeRequirement()
要素が必要とするスペースを計算します。
Definition node.cpp:20
friend void Render(Screen &screen, Node *node, Selection &selection)
Definition node.cpp:96
void Render(Screen &screen, const Element &element)
要素をftxui::Screenに表示します。
Definition node.cpp:84
static auto Intersection(Box a, Box b) -> Box
Definition box.cpp:10
Boxは、2D空間における矩形領域を表す構造体です。
Definition box.hpp:14
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
std::function< Element(Element)> Decorator
Definition elements.hpp:23
std::shared_ptr< Node > Element
Definition elements.hpp:21
Decorator reflect(Box &box)
Definition reflect.cpp:42