Layout Wraps
PBWrapPanel
Opaque object handle:
This is a subclass of PBElement. You can safely cast from PBWrapPanel to PBElement. To cast from PBElement to PBWrapPanel, call PBWrapPanelCast; this performs a runtime assertion to check the cast is possible. This function is thread-safe.
This object maintains an internal reference count. When the reference count reaches zero, the object will be automatically deallocated. To increment the reference count, call PBElementRetain; to decrement the reference count, call PBElementRelease. These functions are thread-safe.
PBWrapPanelFlags
Enumeration/bitset of type uint32_t:
Constants
PBWrapPanel_ALIGN_START
PBWrapPanel_ALIGN_START = 0<<0
Align the set of items in each column/row at the start of the column/row.
PBWrapPanel_ALIGN_CENTER
PBWrapPanel_ALIGN_CENTER = 1<<0
Align the set of items in each column/row in the center of the column/row.
PBWrapPanel_ALIGN_END
PBWrapPanel_ALIGN_END = 2<<0
Align the set of items in each column/row at the end of the column/row.
PBWrapPanel_ALIGN_JUSTIFY
PBWrapPanel_ALIGN_JUSTIFY = 3<<0
Evenly distribute the set of items in each column/row throughout column/row. The minor gap is only used as a minimum in this case.
Or any of the values from PBElementFlags.
PBWrapPanelCreate
Function: Create a layout panel where the child elements are placed into rows or columns automatically as they will fit.
Syntax (C/C++)
PBWrapPanelPtr _Nullable PBWrapPanelCreate(PBElementRef parent,
PBWrapPanelFlags flags, int32_t minorGapDp, int32_t majorGapDp,
PBRectangle insetsDp);
Syntax (Python)
WrapPanelCreate(parent, flags, minorGapDp, majorGapDp, insetsDp) -> (panel)
Parameters and Return Values
[in] parent (referenced PBElement): The parent element.
[in] flags (PBWrapPanelFlags): The element flags. By default, elements are placed into rows arranged vertically. Pass PBElement_LAYOUT_HORIZONTAL for columns arranged horizontally.
[in] minorGapDp (int32_t
): The gap between two child elements in the same row or column, in dps.
[in] majorGapDp (int32_t
): The gap between two rows or columns, in dps.
[in] insetsDp (PBRectangle): The spacing between the edges of this element and the edges of the rectangle into which the children are placed, in dps.
[out] panel (nullable owned PBWrapPanel): The created panel element, or null on failure.
Discussion
The vertical layout algorithm of the wrap panel is as follows. The panel starts with one, empty row. Each child element is added to this row in turn, until a child will not fit; that is, when the row would become larger than the width of the panel. Then a new row is started, and child elements are added to it. Child elements that report a width greater than the panel's width will be placed alone in a row with no siblings.
If the panel is measured for its height without providing the available width, infinite width is assumed to be available.
Horizontal alignment flags (including "fill") on child elements are ignored.
The horizontal layout algorithm for the wrap panel is similar to the algorithm described above, but with the horizontal and vertical axes switched.
Child elements are measured without otherDimensionSize set to 0.