FTXUI  4.1.1
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 {
25 for (auto& child : children_) {
26 child->ComputeRequirement();
28 std::max(requirement_.min_x, child->requirement().min_x);
30 std::max(requirement_.min_y, child->requirement().min_y);
31
32 if (requirement_.selection < child->requirement().selection) {
33 requirement_.selection = child->requirement().selection;
34 requirement_.selected_box = child->requirement().selected_box;
35 }
36 }
37 }
38
39 void SetBox(Box box) override {
40 Node::SetBox(box);
41
42 for (auto& child : children_) {
43 child->SetBox(box);
44 }
45 }
46};
47
48/// @brief Stack several element on top of each other.
49/// @param children_ The input element.
50/// @return The right aligned element.
51/// @ingroup dom
52Element dbox(Elements children_) {
53 return std::make_shared<DBox>(std::move(children_));
54}
55
56} // namespace ftxui
57
58// Copyright 2020 Arthur Sonzogni. All rights reserved.
59// Use of this source code is governed by the MIT license that can be found in
60// 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:23
Requirement requirement_
Definition node.hpp:54
std::shared_ptr< Node > Element
Definition elements.hpp:19
std::vector< Element > Elements
Definition elements.hpp:20
Element dbox(Elements)
Stack several element on top of each other.
Definition dbox.cpp:52