mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-27 13:48:51 +08:00
a574a6c3ee
Requested from: https://github.com/robinlinden/hastur/pull/12
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#include <memory> // for make_shared, __shared_ptr_access
|
|
#include <utility> // for move
|
|
#include <vector> // for __alloc_traits<>::value_type, vector
|
|
|
|
#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
|
|
|
|
namespace ftxui {
|
|
|
|
// Helper class.
|
|
class Reflect : public Node {
|
|
public:
|
|
Reflect(Element child, Box& box)
|
|
: Node(unpack(std::move(child))), reflected_box_(box) {}
|
|
~Reflect() override {}
|
|
|
|
void ComputeRequirement() final {
|
|
Node::ComputeRequirement();
|
|
requirement_ = children_[0]->requirement();
|
|
}
|
|
|
|
void SetBox(Box box) final {
|
|
reflected_box_ = box;
|
|
Node::SetBox(reflected_box_);
|
|
children_[0]->SetBox(reflected_box_);
|
|
}
|
|
|
|
private:
|
|
Box& reflected_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.
|