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 widgets.
- 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 widgets in rows or columns, with wrapping, justification, and alignment options.#PG_Layout_Type_Grid: Implements a CSS Grid-like model for arranging widgets in a two-dimensional grid defined by rows and columns.
- Widget Properties for Layout: Layout item properties are conveniently set via `WidgetSet...` commands (e.g., WidgetSetWidth(), WidgetSetMargin(), WidgetSetAlign(), WidgetSetRowSpan()).
- 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.