2021-05-01 20:40:35 +02:00
|
|
|
#include <algorithm> // for max
|
|
|
|
|
#include <memory> // for __shared_ptr_access, shared_ptr, make_shared
|
|
|
|
|
#include <utility> // for move
|
2022-05-08 08:44:38 +02:00
|
|
|
#include <vector> // for vector
|
2020-03-23 21:26:00 +01:00
|
|
|
|
2021-05-01 20:40:35 +02:00
|
|
|
#include "ftxui/dom/elements.hpp" // for Element, Elements, dbox
|
2022-04-28 10:43:31 +02:00
|
|
|
#include "ftxui/dom/node.hpp" // for Node, Elements
|
2021-05-01 20:40:35 +02:00
|
|
|
#include "ftxui/dom/requirement.hpp" // for Requirement
|
|
|
|
|
#include "ftxui/screen/box.hpp" // for Box
|
2019-01-03 00:35:59 +01:00
|
|
|
|
2019-01-12 15:00:08 +01:00
|
|
|
namespace ftxui {
|
2019-01-03 00:35:59 +01:00
|
|
|
|
|
|
|
|
class DBox : public Node {
|
|
|
|
|
public:
|
2022-03-31 02:17:43 +02:00
|
|
|
explicit DBox(Elements children) : Node(std::move(children)) {}
|
2019-01-03 00:35:59 +01:00
|
|
|
|
|
|
|
|
void ComputeRequirement() override {
|
2020-06-01 16:13:29 +02:00
|
|
|
requirement_.min_x = 0;
|
|
|
|
|
requirement_.min_y = 0;
|
2020-06-01 23:40:32 +02:00
|
|
|
requirement_.flex_grow_x = 0;
|
|
|
|
|
requirement_.flex_grow_y = 0;
|
|
|
|
|
requirement_.flex_shrink_x = 0;
|
|
|
|
|
requirement_.flex_shrink_y = 0;
|
2021-05-16 17:18:11 +02:00
|
|
|
for (auto& child : children_) {
|
2019-01-03 00:35:59 +01:00
|
|
|
child->ComputeRequirement();
|
2020-06-01 16:13:29 +02:00
|
|
|
requirement_.min_x =
|
|
|
|
|
std::max(requirement_.min_x, child->requirement().min_x);
|
|
|
|
|
requirement_.min_y =
|
|
|
|
|
std::max(requirement_.min_y, child->requirement().min_y);
|
2019-01-19 22:06:05 +01:00
|
|
|
|
|
|
|
|
if (requirement_.selection < child->requirement().selection) {
|
|
|
|
|
requirement_.selection = child->requirement().selection;
|
|
|
|
|
requirement_.selected_box = child->requirement().selected_box;
|
|
|
|
|
}
|
2019-01-03 00:35:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetBox(Box box) override {
|
|
|
|
|
Node::SetBox(box);
|
|
|
|
|
|
2022-03-31 02:17:43 +02:00
|
|
|
for (auto& child : children_) {
|
2019-01-03 00:35:59 +01:00
|
|
|
child->SetBox(box);
|
2022-03-31 02:17:43 +02:00
|
|
|
}
|
2019-01-03 00:35:59 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-05-25 01:34:13 +02:00
|
|
|
/// @brief Stack several element on top of each other.
|
2021-05-16 17:18:11 +02:00
|
|
|
/// @param children_ The input element.
|
2020-05-25 01:34:13 +02:00
|
|
|
/// @return The right aligned element.
|
|
|
|
|
/// @ingroup dom
|
2021-05-16 17:18:11 +02:00
|
|
|
Element dbox(Elements children_) {
|
|
|
|
|
return std::make_shared<DBox>(std::move(children_));
|
2019-01-03 00:35:59 +01:00
|
|
|
}
|
|
|
|
|
|
2020-02-11 21:44:55 +01:00
|
|
|
} // namespace ftxui
|
2020-08-16 00:24:18 +02:00
|
|
|
|
|
|
|
|
// 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.
|