#include "ftxui/dom/node.hpp" #include "ftxui/dom/elements.hpp" namespace ftxui { class Flex : public Node { public: Flex() {} Flex(Element child) : Node(unpack(std::move(child))) {} ~Flex() override {} void ComputeRequirement() override { requirement_.min.x = 0; requirement_.min.y = 0; if (!children.empty()) { children[0]->ComputeRequirement(); requirement_ = children[0]->requirement(); } requirement_.flex.x = 1; requirement_.flex.y = 1; } void SetBox(Box box) override { if (children.empty()) return; children[0]->SetBox(box); } }; class NotFlex : public Flex { public: NotFlex() {} NotFlex(Element child) : Flex(std::move(child)) {} ~NotFlex() override {} void ComputeRequirement() override { requirement_.min.x = 0; requirement_.min.y = 0; if (!children.empty()) { children[0]->ComputeRequirement(); requirement_ = children[0]->requirement(); } requirement_.flex.x = 0; requirement_.flex.y = 0; } }; std::unique_ptr filler() { return std::make_unique(); } std::unique_ptr flex(Element child) { return std::make_unique(std::move(child)); } std::unique_ptr notflex(Element child) { return std::make_unique(std::move(child)); } }; // namespace ftxui