mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Some checks failed
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, windows-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, ubuntu-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
Bug:https://github.com/eclipse-ecal/ecal/pull/2095
60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
// 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.
|
|
#include <algorithm> // for max
|
|
#include <cstddef> // for size_t
|
|
#include <memory> // for __shared_ptr_access, shared_ptr, make_shared
|
|
#include <utility> // for move
|
|
#include <vector>
|
|
|
|
#include "ftxui/dom/elements.hpp" // for Element, Elements, dbox
|
|
#include "ftxui/dom/node.hpp" // for Node, Elements
|
|
#include "ftxui/dom/requirement.hpp" // for Requirement
|
|
#include "ftxui/screen/box.hpp" // for Box
|
|
#include "ftxui/screen/pixel.hpp" // for Pixel
|
|
|
|
namespace ftxui {
|
|
|
|
namespace {
|
|
class DBox : public Node {
|
|
public:
|
|
explicit DBox(Elements children) : Node(std::move(children)) {}
|
|
|
|
void ComputeRequirement() override {
|
|
requirement_ = Requirement{};
|
|
for (auto& child : children_) {
|
|
child->ComputeRequirement();
|
|
|
|
// Propagate the focused requirement.
|
|
if (requirement_.focused.Prefer(child->requirement().focused)) {
|
|
requirement_.focused = child->requirement().focused;
|
|
}
|
|
|
|
// Extend the min_x and min_y to contain all the children
|
|
requirement_.min_x =
|
|
std::max(requirement_.min_x, child->requirement().min_x);
|
|
requirement_.min_y =
|
|
std::max(requirement_.min_y, child->requirement().min_y);
|
|
}
|
|
}
|
|
|
|
void SetBox(Box box) override {
|
|
Node::SetBox(box);
|
|
|
|
for (auto& child : children_) {
|
|
child->SetBox(box);
|
|
}
|
|
}
|
|
};
|
|
} // namespace
|
|
|
|
/// @brief Stack several element on top of each other.
|
|
/// @param children_ The input element.
|
|
/// @return The right aligned element.
|
|
/// @ingroup dom
|
|
Element dbox(Elements children_) {
|
|
return std::make_shared<DBox>(std::move(children_));
|
|
}
|
|
|
|
} // namespace ftxui
|