2021-05-15 04:00:49 +08:00
|
|
|
#include <memory> // for make_shared, __shared_ptr_access
|
|
|
|
#include <utility> // for move
|
|
|
|
#include <vector> // for __alloc_traits<>::value_type, vector
|
2021-05-10 02:32:27 +08:00
|
|
|
|
|
|
|
#include "ftxui/dom/elements.hpp" // for Element, unpack, Decorator, reflect
|
|
|
|
#include "ftxui/dom/node.hpp" // for Node
|
|
|
|
#include "ftxui/dom/requirement.hpp" // for Requirement
|
|
|
|
#include "ftxui/screen/box.hpp" // for Box
|
2021-04-19 04:33:41 +08:00
|
|
|
|
|
|
|
namespace ftxui {
|
|
|
|
|
|
|
|
// Helper class.
|
|
|
|
class Reflect : public Node {
|
|
|
|
public:
|
|
|
|
Reflect(Element child, Box& box)
|
2021-05-16 23:18:11 +08:00
|
|
|
: Node(unpack(std::move(child))), reflected_box_(box) {}
|
2021-04-19 04:33:41 +08:00
|
|
|
~Reflect() override {}
|
|
|
|
|
|
|
|
void ComputeRequirement() final {
|
|
|
|
Node::ComputeRequirement();
|
2021-05-16 23:18:11 +08:00
|
|
|
requirement_ = children_[0]->requirement();
|
2021-04-19 04:33:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetBox(Box box) final {
|
2021-05-16 23:18:11 +08:00
|
|
|
reflected_box_ = box;
|
|
|
|
Node::SetBox(reflected_box_);
|
|
|
|
children_[0]->SetBox(reflected_box_);
|
2021-04-19 04:33:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2021-05-16 23:18:11 +08:00
|
|
|
Box& reflected_box_;
|
2021-04-19 04:33:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Decorator reflect(Box& box) {
|
|
|
|
return [&](Element child) -> Element {
|
|
|
|
return std::make_shared<Reflect>(std::move(child), box);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ftxui
|
|
|
|
|
|
|
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
|
|
// the LICENSE file.
|