2019-01-07 00:10:35 +08:00
|
|
|
#ifndef FTXUI_DOM_NODE_HPP
|
|
|
|
#define FTXUI_DOM_NODE_HPP
|
2018-09-18 14:48:40 +08:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-01-07 00:10:35 +08:00
|
|
|
#include "ftxui/dom/requirement.hpp"
|
2019-01-20 05:06:05 +08:00
|
|
|
#include "ftxui/screen/box.hpp"
|
2019-01-07 00:10:35 +08:00
|
|
|
#include "ftxui/screen/screen.hpp"
|
2018-09-18 14:48:40 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
namespace ftxui {
|
2018-09-18 14:48:40 +08:00
|
|
|
|
|
|
|
class Node {
|
|
|
|
public:
|
|
|
|
Node();
|
|
|
|
Node(std::vector<std::unique_ptr<Node>> children);
|
|
|
|
virtual ~Node();
|
|
|
|
|
2019-01-03 05:33:59 +08:00
|
|
|
// Step 1: Compute layout requirement. Tell parent what dimensions this
|
2018-09-18 14:48:40 +08:00
|
|
|
// element wants to be.
|
2019-01-03 05:33:59 +08:00
|
|
|
// Propagated from Children to Parents.
|
2018-09-18 14:48:40 +08:00
|
|
|
virtual void ComputeRequirement();
|
|
|
|
Requirement requirement() { return requirement_; }
|
|
|
|
|
2019-01-03 05:33:59 +08:00
|
|
|
// Step 2: Assign this element its final dimensions.
|
|
|
|
// Propagated from Parents to Children.
|
2018-09-18 14:48:40 +08:00
|
|
|
virtual void SetBox(Box box);
|
|
|
|
|
|
|
|
// Step 3: Draw this element.
|
2019-01-12 22:00:08 +08:00
|
|
|
virtual void Render(Screen& screen);
|
2018-09-18 14:48:40 +08:00
|
|
|
|
|
|
|
std::vector<std::unique_ptr<Node>> children;
|
|
|
|
protected:
|
|
|
|
Requirement requirement_;
|
|
|
|
Box box_;
|
|
|
|
};
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
void Render(Screen& screen, Node* node);
|
2018-09-18 14:48:40 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
}; // namespace ftxui
|
2018-09-18 14:48:40 +08:00
|
|
|
|
2019-01-07 00:10:35 +08:00
|
|
|
#endif /* end of include guard: FTXUI_DOM_NODE_HPP */
|