Layout Management Overview
ProGUI's Layout Management system is responsible for arranging widgets within windows or other container widgets. It provides different layout engines to handle various arrangement scenarios automatically, adapting to window resizing and content changes.
Key concepts and functionalities include:
- Layout Objects: Layouts are created using CreateLayout() and act as containers. They manage a list of child items (which can be widgets or other layouts).
- Layout Types: ProGUI supports multiple layout types, selectable via LayoutSetType():
#PG_Layout_Type_Basic: Simple layout where widgets are placed at explicit coordinates relative to the layout container.#PG_Layout_Type_Flex: Implements a CSS Flexbox-like model for arranging items in rows or columns, with wrapping, justification, and alignment options.#PG_Layout_Type_Grid: Implements a CSS Grid-like model for arranging items in a two-dimensional grid defined by rows and columns.
- Layout Items: When a widget (CreateWidget()) or another layout is added to a parent layout, it's wrapped in a
LayoutItemstructure. This structure holds layout-specific properties for that child. - Widget Properties for Layout: Many layout item properties are conveniently set via `WidgetSet...` commands (e.g., WidgetSetWidth(), WidgetSetMargin(), WidgetSetAlign(), WidgetSetRowSpan()). These internally modify the widget's corresponding
LayoutItem. - Layout Properties: Specific layout containers have their own properties (e.g., padding, gaps, flow direction, justification, alignment) configurable via `LayoutSet...`, `LayoutFlexSet...`, and `LayoutGridSet...` commands.
- Layout Hierarchy: Layouts can be nested. LayoutPush() and LayoutPop() manage a stack to easily add widgets to the desired layout container. LayoutGetCurrent() and LayoutSetCurrent() directly access or set the active layout.
- Scrolling: Layouts automatically manage scroll offsets (LayoutGetScrollOffsetX(), LayoutGetScrollOffsetY()) when their content overflows the available space. Internal scrollbar widgets are managed automatically.
- Update Mechanism: Layouts recalculate positions and sizes when their container (window or parent layout widget) resizes or when properties affecting the layout are changed.
The layout system aims to simplify the process of creating responsive and adaptive user interfaces.