FTXUI/src/ftxui/dom/dbox.cpp

41 lines
1.0 KiB
C++
Raw Normal View History

2019-01-03 07:35:59 +08:00
#include "ftxui/dom/node.hpp"
#include "ftxui/dom/elements.hpp"
namespace ftxui {
2019-01-03 07:35:59 +08:00
class DBox : public Node {
public:
2019-01-13 01:24:46 +08:00
DBox(Elements children) : Node(std::move(children)) {}
2019-01-03 07:35:59 +08:00
~DBox() {}
void ComputeRequirement() override {
requirement_.min.x = 0;
requirement_.min.y = 0;
requirement_.flex.x = 1;
requirement_.flex.y = 0;
for (auto& child : children) {
child->ComputeRequirement();
requirement_.min.x = std::max(requirement_.min.x, child->requirement().min.x);
requirement_.min.y = std::max(requirement_.min.y, child->requirement().min.y);
2019-01-20 05:06:05 +08:00
if (requirement_.selection < child->requirement().selection) {
requirement_.selection = child->requirement().selection;
requirement_.selected_box = child->requirement().selected_box;
}
2019-01-03 07:35:59 +08:00
}
}
void SetBox(Box box) override {
Node::SetBox(box);
for (auto& child : children)
child->SetBox(box);
}
};
2019-01-13 01:24:46 +08:00
std::unique_ptr<Node> dbox(Elements children) {
2019-01-03 07:35:59 +08:00
return std::make_unique<DBox>(std::move(children));
}
2020-02-12 04:44:55 +08:00
} // namespace ftxui