mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-18 09:08:08 +08:00
Add mouse implementation of most components.
This commit is contained in:
42
src/ftxui/dom/reflect.cpp
Normal file
42
src/ftxui/dom/reflect.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <memory>
|
||||
#include "ftxui/dom/elements.hpp"
|
||||
#include "ftxui/dom/node.hpp"
|
||||
#include "ftxui/dom/node_decorator.hpp"
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
Box box;
|
||||
|
||||
// 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.
|
Reference in New Issue
Block a user