mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-27 21:58:29 +08:00
41 lines
885 B
C++
41 lines
885 B
C++
|
#include <memory>
|
||
|
#include "ftxui/dom/elements.hpp"
|
||
|
#include "ftxui/dom/node.hpp"
|
||
|
#include "ftxui/dom/node_decorator.hpp"
|
||
|
|
||
|
namespace ftxui {
|
||
|
|
||
|
// Helper class.
|
||
|
class Reflect : public Node {
|
||
|
public:
|
||
|
Reflect(Element child, Box& box)
|
||
|
: Node(unpack(std::move(child))), box_(box) {}
|
||
|
~Reflect() override {}
|
||
|
|
||
|
void ComputeRequirement() final {
|
||
|
Node::ComputeRequirement();
|
||
|
requirement_ = children[0]->requirement();
|
||
|
}
|
||
|
|
||
|
void SetBox(Box box) final {
|
||
|
box_ = box;
|
||
|
Node::SetBox(box_);
|
||
|
children[0]->SetBox(box_);
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
Box& box_;
|
||
|
};
|
||
|
|
||
|
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.
|