FTXUI  3.0.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
dbox.cpp
Go to the documentation of this file.
1#include <algorithm> // for max
2#include <memory> // for __shared_ptr_access, shared_ptr, make_shared
3#include <utility> // for move
4#include <vector> // for vector
5
6#include "ftxui/dom/elements.hpp" // for Element, Elements, dbox
7#include "ftxui/dom/node.hpp" // for Node, Elements
8#include "ftxui/dom/requirement.hpp" // for Requirement
9#include "ftxui/screen/box.hpp" // for Box
10
11namespace ftxui {
12
13class DBox : public Node {
14 public:
15 explicit DBox(Elements children) : Node(std::move(children)) {}
16
17 void ComputeRequirement() override {
24 for (auto& child : children_) {
25 child->ComputeRequirement();
27 std::max(requirement_.min_x, child->requirement().min_x);
29 std::max(requirement_.min_y, child->requirement().min_y);
30
31 if (requirement_.selection < child->requirement().selection) {
32 requirement_.selection = child->requirement().selection;
33 requirement_.selected_box = child->requirement().selected_box;
34 }
35 }
36 }
37
38 void SetBox(Box box) override {
39 Node::SetBox(box);
40
41 for (auto& child : children_) {
42 child->SetBox(box);
43 }
44 }
45};
46
47/// @brief Stack several element on top of each other.
48/// @param children_ The input element.
49/// @return The right aligned element.
50/// @ingroup dom
51Element dbox(Elements children_) {
52 return std::make_shared<DBox>(std::move(children_));
53}
54
55} // namespace ftxui
56
57// Copyright 2020 Arthur Sonzogni. All rights reserved.
58// Use of this source code is governed by the MIT license that can be found in
59// the LICENSE file.
Elements children_
Definition node.hpp:53
virtual void SetBox(Box box)
Assign a position and a dimension to an element for drawing.
Definition node.cpp:22
Requirement requirement_
Definition node.hpp:54
std::shared_ptr< Node > Element
Definition elements.hpp:18
std::vector< Element > Elements
Definition elements.hpp:19
Element dbox(Elements)
Stack several element on top of each other.
Definition dbox.cpp:51