mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-29 16:39:34 +08:00
Implement a lot of new features.
This commit deserve to be cut into at least 8 sub commit. Sorry, I acknowledge this is bad... Here are the new features: * dom decorator: bold, dim, underlined, inverted. * component mechanism * components * menu * toogle
This commit is contained in:
44
ftxui/include/ftxui/dom/node.hpp
Normal file
44
ftxui/include/ftxui/dom/node.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef DOM_NODE_HPP
|
||||
#define DOM_NODE_HPP
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "ftxui/requirement.hpp"
|
||||
#include "ftxui/screen.hpp"
|
||||
#include "ftxui/box.hpp"
|
||||
|
||||
namespace ftxui {
|
||||
namespace dom {
|
||||
|
||||
class Node {
|
||||
public:
|
||||
Node();
|
||||
Node(std::vector<std::unique_ptr<Node>> children);
|
||||
virtual ~Node();
|
||||
|
||||
// Step 1: Direction parent <= children.
|
||||
// Compute layout requirement. Tell parent what dimensions this
|
||||
// element wants to be.
|
||||
virtual void ComputeRequirement();
|
||||
Requirement requirement() { return requirement_; }
|
||||
|
||||
// Step 2: Direction parent => children.
|
||||
// Assign this element its final dimensions.
|
||||
virtual void SetBox(Box box);
|
||||
|
||||
// Step 3: Draw this element.
|
||||
virtual void Render(Screen& screen);
|
||||
|
||||
std::vector<std::unique_ptr<Node>> children;
|
||||
protected:
|
||||
Requirement requirement_;
|
||||
Box box_;
|
||||
};
|
||||
|
||||
void Render(Screen& screen, Node* node);
|
||||
|
||||
}; // namespace dom
|
||||
}; // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: DOM_NODE_HPP */
|
Reference in New Issue
Block a user