mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-05-06 07:33:07 +08:00
39 lines
795 B
C++
39 lines
795 B
C++
#include "ftxui/core/dom/node.hpp"
|
|
|
|
namespace ftxui {
|
|
namespace dom {
|
|
|
|
Node::Node() {}
|
|
Node::Node(std::vector<std::unique_ptr<Node>> children)
|
|
: children(std::move(children)) {}
|
|
Node::~Node() {}
|
|
|
|
void Node::ComputeRequirement() {}
|
|
void Node::SetBox(Box box) {
|
|
box_ = box;
|
|
}
|
|
void Node::Render(Screen& screen) {
|
|
for(auto& child : children)
|
|
child->Render(screen);
|
|
}
|
|
|
|
void Render(Screen& screen, Node* node) {
|
|
// Step 1: Find what dimension this elements wants to be.
|
|
node->ComputeRequirement();
|
|
|
|
Box box;
|
|
box.left = 0;
|
|
box.top = 0;
|
|
box.right = screen.dimx() - 1;
|
|
box.bottom = screen.dimy() - 1;
|
|
|
|
// Step 2: Assign a dimension to the element.
|
|
node->SetBox(box);
|
|
|
|
// Step 3: Draw the element.
|
|
node->Render(screen);
|
|
}
|
|
|
|
}; // namespace dom
|
|
}; // namespace ftxui
|