/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/ThirdParty/RmlUi/Source/Core/Layout/ContainerBox.h
139 строк
5 KB
C-Core
Updated RmlUi to 6.2 and added some improvements (#1813)
10 фев 2026, 01:19
Не верифицирован
10 фев 2026, 01:19
58e2d41
Код
Авторство
О чём код?
#pragma once #include "../../../Include/RmlUi/Core/Box.h" #include "../../../Include/RmlUi/Core/StyleTypes.h" #include "../../../Include/RmlUi/Core/Types.h" #include "LayoutBox.h" namespace Rml { /** Abstraction for layout boxes that can act as a containing block. Implements functionality for catching overflow, and for handling positioned boxes that the box acts as a containing block for. */ class ContainerBox : public LayoutBox { public: // Enable or disable scrollbars for the element we represent, preparing it for the first round of layouting, according to our properties. void ResetScrollbars(const Box& box); // Adds an absolutely positioned element, to be formatted and positioned when closing this container, see 'ClosePositionedElements'. void AddAbsoluteElement(Element* element, Vector2f static_position, Element* static_relative_offset_parent); // Adds a relatively positioned element which we act as a containing block for. void AddRelativeElement(Element* element); ContainerBox* GetParent() { return parent_container; } Element* GetElement() { return element; } bool IsScrollContainer() const; // Returns true if this box acts as a containing block for absolutely positioned descendants. bool IsAbsolutePositioningContainingBlock() const { return is_absolute_positioning_containing_block; } protected: ContainerBox(Type type, Element* element, ContainerBox* parent_container); /// Checks if we have a new overflow on an auto-scrolling element. If so, our vertical scrollbar will be enabled and /// our block boxes will be destroyed. All content will need to be re-formatted. /// @param[in] content_overflow_size The size of the visible content, relative to our content area. /// @param[in] box The box built for the element, possibly with a non-determinate height. /// @param[in] max_height Maximum height of the content area, if any. /// @returns True if no overflow occured, false if it did. bool CatchOverflow(const Vector2f content_overflow_size, const Box& box, const float max_height) const; /// Set the box and scrollable area on our element, possibly catching any overflow. /// @param[in] content_overflow_size The size of the visible content, relative to our content area. /// @param[in] box The box to be set on the element. /// @param[in] max_height Maximum height of the content area, if any. /// @returns True if no overflow occured, false if it did. bool SubmitBox(const Vector2f content_overflow_size, const Box& box, const float max_height); /// Formats, sizes, and positions all absolute elements whose containing block is this, and offsets relative elements. void ClosePositionedElements(); // Set the element's baseline (proxy for private access to Element). void SetElementBaseline(float element_baseline); // Calls Element::OnLayout (proxy for private access to Element). void SubmitElementLayout(); // The element this box represents, if any. Element* const element; private: struct AbsoluteElement { Vector2f static_position; // The hypothetical position of the element as if it was placed in normal flow. Element* static_position_offset_parent; // The element for which the static position is offset from. }; using AbsoluteElementMap = SmallUnorderedMap<Element*, AbsoluteElement>; AbsoluteElementMap absolute_elements; // List of absolutely positioned elements that we act as a containing block for. ElementList relative_elements; // List of relatively positioned elements that we act as a containing block for. Style::Overflow overflow_x = Style::Overflow::Visible; Style::Overflow overflow_y = Style::Overflow::Visible; bool is_absolute_positioning_containing_block = false; ContainerBox* parent_container = nullptr; }; /** The root of a tree of layout boxes, usually represents the root element or viewport. */ class RootBox final : public ContainerBox { public: RootBox(Vector2f containing_block) : ContainerBox(Type::Root, nullptr, nullptr), box(containing_block) {} RootBox(const Box& box) : ContainerBox(Type::Root, nullptr, nullptr), box(box) {} const Box* GetIfBox() const override { return &box; } String DebugDumpTree(int depth) const override; private: Box box; }; /** A box where flexbox layout occurs. */ class FlexContainer final : public ContainerBox { public: FlexContainer(Element* element, ContainerBox* parent_container); // Submits the formatted box to the flex container element, and propagates any uncaught overflow to this box. // @returns True if it succeeds, otherwise false if it needs to be formatted again because scrollbars were enabled. bool Close(const Vector2f content_overflow_size, const Box& box, float element_baseline); float GetShrinkToFitWidth() const override; const Box* GetIfBox() const override { return &box; } String DebugDumpTree(int depth) const override; Box& GetBox() { return box; } private: Box box; }; /** A box where table formatting occurs. As opposed to a flex container, the table wrapper cannot contain overflow or produce scrollbars. */ class TableWrapper final : public ContainerBox { public: TableWrapper(Element* element, ContainerBox* parent_container); // Submits the formatted box to the table element, and propagates any uncaught overflow to this box. void Close(const Vector2f content_overflow_size, const Box& box, float element_baseline); float GetShrinkToFitWidth() const override; const Box* GetIfBox() const override { return &box; } String DebugDumpTree(int depth) const override; Box& GetBox() { return box; } private: Box box; }; } // namespace Rml