2020-03-24 04:26:00 +08:00
|
|
|
#include <algorithm>
|
|
|
|
|
2019-01-03 07:35:59 +08:00
|
|
|
#include "ftxui/dom/elements.hpp"
|
2020-03-23 05:32:44 +08:00
|
|
|
#include "ftxui/dom/node.hpp"
|
2019-01-03 07:35:59 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
namespace ftxui {
|
2019-01-03 07:35:59 +08:00
|
|
|
|
|
|
|
class DBox : public Node {
|
|
|
|
public:
|
2019-01-13 01:24:46 +08:00
|
|
|
DBox(Elements children) : Node(std::move(children)) {}
|
2019-01-03 07:35:59 +08:00
|
|
|
~DBox() {}
|
|
|
|
|
|
|
|
void ComputeRequirement() override {
|
2020-06-01 22:13:29 +08:00
|
|
|
requirement_.min_x = 0;
|
|
|
|
requirement_.min_y = 0;
|
2020-06-02 05:40:32 +08:00
|
|
|
requirement_.flex_grow_x = 0;
|
|
|
|
requirement_.flex_grow_y = 0;
|
|
|
|
requirement_.flex_shrink_x = 0;
|
|
|
|
requirement_.flex_shrink_y = 0;
|
2019-01-03 07:35:59 +08:00
|
|
|
for (auto& child : children) {
|
|
|
|
child->ComputeRequirement();
|
2020-06-01 22:13:29 +08: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-20 05:06:05 +08:00
|
|
|
|
|
|
|
if (requirement_.selection < child->requirement().selection) {
|
|
|
|
requirement_.selection = child->requirement().selection;
|
|
|
|
requirement_.selected_box = child->requirement().selected_box;
|
|
|
|
}
|
2019-01-03 07:35:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBox(Box box) override {
|
|
|
|
Node::SetBox(box);
|
|
|
|
|
|
|
|
for (auto& child : children)
|
|
|
|
child->SetBox(box);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-05-25 07:34:13 +08:00
|
|
|
/// @brief Stack several element on top of each other.
|
|
|
|
/// @param The input element.
|
|
|
|
/// @return The right aligned element.
|
|
|
|
/// @ingroup dom
|
2020-05-21 02:36:47 +08:00
|
|
|
Element dbox(Elements children) {
|
|
|
|
return std::make_shared<DBox>(std::move(children));
|
2019-01-03 07:35:59 +08:00
|
|
|
}
|
|
|
|
|
2020-02-12 04:44:55 +08:00
|
|
|
} // namespace ftxui
|
2020-08-16 06:24:18 +08: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.
|