mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 10:40:00 +08:00
8a2a9b0799
Fix all the diagnostics reported. Bug: https://github.com/ArthurSonzogni/FTXUI/issues/828
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
// the LICENSE file.
|
|
#ifndef FTXUI_DOM_NODE_HPP
|
|
#define FTXUI_DOM_NODE_HPP
|
|
|
|
#include <memory> // for shared_ptr
|
|
#include <vector> // for vector
|
|
|
|
#include "ftxui/dom/requirement.hpp" // for Requirement
|
|
#include "ftxui/screen/box.hpp" // for Box
|
|
#include "ftxui/screen/screen.hpp"
|
|
|
|
namespace ftxui {
|
|
|
|
class Node;
|
|
class Screen;
|
|
|
|
using Element = std::shared_ptr<Node>;
|
|
using Elements = std::vector<Element>;
|
|
|
|
class Node {
|
|
public:
|
|
Node();
|
|
explicit Node(Elements children);
|
|
Node(const Node&) = delete;
|
|
Node(const Node&&) = delete;
|
|
Node& operator=(const Node&) = delete;
|
|
Node& operator=(const Node&&) = delete;
|
|
|
|
virtual ~Node();
|
|
|
|
// Step 1: Compute layout requirement. Tell parent what dimensions this
|
|
// element wants to be.
|
|
// Propagated from Children to Parents.
|
|
virtual void ComputeRequirement();
|
|
Requirement requirement() { return requirement_; }
|
|
|
|
// Step 2: Assign this element its final dimensions.
|
|
// Propagated from Parents to Children.
|
|
virtual void SetBox(Box box);
|
|
|
|
// Step 3: Draw this element.
|
|
virtual void Render(Screen& screen);
|
|
|
|
// Layout may not resolve within a single iteration for some elements. This
|
|
// allows them to request additionnal iterations. This signal must be
|
|
// forwarded to children at least once.
|
|
struct Status {
|
|
int iteration = 0;
|
|
bool need_iteration = false;
|
|
};
|
|
virtual void Check(Status* status);
|
|
|
|
protected:
|
|
Elements children_;
|
|
Requirement requirement_;
|
|
Box box_;
|
|
};
|
|
|
|
void Render(Screen& screen, const Element& element);
|
|
void Render(Screen& screen, Node* node);
|
|
|
|
} // namespace ftxui
|
|
|
|
#endif // FTXUI_DOM_NODE_HPP
|