FTXUI  0.11.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
node.hpp
Go to the documentation of this file.
1#ifndef FTXUI_DOM_NODE_HPP
2#define FTXUI_DOM_NODE_HPP
3
4#include <memory> // for shared_ptr
5#include <vector> // for vector
6
7#include "ftxui/dom/requirement.hpp" // for Requirement
8#include "ftxui/screen/box.hpp" // for Box
10
11namespace ftxui {
12
13class Node;
14class Screen;
15
16using Element = std::shared_ptr<Node>;
17using Elements = std::vector<Element>;
18
19class Node {
20 public:
21 Node();
22 Node(Elements children);
23 virtual ~Node();
24
25 // Step 1: Compute layout requirement. Tell parent what dimensions this
26 // element wants to be.
27 // Propagated from Children to Parents.
28 virtual void ComputeRequirement();
30
31 // Step 2: Assign this element its final dimensions.
32 // Propagated from Parents to Children.
33 virtual void SetBox(Box box);
34
35 // Step 3: Draw this element.
36 virtual void Render(Screen& screen);
37
38 protected:
42};
43
44void Render(Screen& screen, const Element& node);
45void Render(Screen& screen, Node* node);
46
47} // namespace ftxui
48
49#endif /* end of include guard: FTXUI_DOM_NODE_HPP */
50
51// Copyright 2020 Arthur Sonzogni. All rights reserved.
52// Use of this source code is governed by the MIT license that can be found in
53// the LICENSE file.
Elements children_
Definition node.hpp:39
virtual void SetBox(Box box)
Assign a position and a dimension to an element for drawing.
Definition node.cpp:21
Requirement requirement_
Definition node.hpp:40
Requirement requirement()
Definition node.hpp:29
virtual void ComputeRequirement()
Compute how much space an elements needs.
Definition node.cpp:14
virtual ~Node()
Definition node.cpp:10
virtual void Render(Screen &screen)
Display an element on a ftxui::Screen.
Definition node.cpp:27
Box box_
Definition node.hpp:41
A rectangular grid of Pixel.
Definition screen.hpp:49
std::shared_ptr< Node > Element
Definition elements.hpp:15
std::vector< Element > Elements
Definition elements.hpp:16
void Render(Screen &screen, const Element &node)
Display an element on a ftxui::Screen.
Definition node.cpp:34