Layout
Inherited: None
Description
The Layout class is a base class used for managing the layout and positioning of widgets within a graphical user interface (GUI). It provides a structured way to organize UI elements, ensuring that they are placed efficiently and consistently on the screen. The Layout class is essential for developers who need to arrange multiple components (such as buttons, labels, text fields, etc.) in a clean and organized manner.
Public Methods
void |
addLayout (Layout * layout) |
void |
addTransform (RectTransform * transform) |
int |
count () const |
int |
direction () const |
int |
indexOf (const Layout * layout) const |
int |
indexOf (const RectTransform * transform) const |
void |
insertLayout (int index, Layout * layout) |
void |
insertTransform (int index, RectTransform * transform) |
void |
invalidate () |
void |
removeLayout (Layout * layout) |
void |
removeTransform (RectTransform * transform) |
void |
setDirection (int direction) |
void |
setSpacing (float spacing) |
sizeHint () |
|
float |
spacing () const |
Static Methods
None
Methods Description
void Layout::addLayout (Layout * layout)
Adds a child layout to the current layout.
void Layout::addTransform (RectTransform * transform)
Adds a transform to the current layout.
int Layout::count () const
Returns number of items in the layout.
int Layout::direction () const
Returns the layout direction (Vertical or Horizontal).
See also setDirection().
int Layout::indexOf (Layout * layout) const
Returns the index of the specified child layout.
int Layout::indexOf (RectTransform * transform) const
Returns the index of the specified transform.
void Layout::insertLayout (int index, Layout * layout)
Inserts a child layout at the specified index. If -1, the layout is appended to the end.
void Layout::insertTransform (int index, RectTransform * transform)
Inserts a transform at the specified index. If -1, the layout is appended to the end.
void Layout::invalidate ()
Marks the layout as dirty, indicating that it needs to be recomputed.
RectTransform * Layout::rectTransform ()
Returns the parent rect transform of this layout, or nullptr if this layout is not installed on any rect transform. If the layout is a sub-layout, this function returns the parent rect transform of the parent layout.
void Layout::removeLayout (Layout * layout)
Removes a child layout from the current layout.
void Layout::removeTransform (RectTransform * transform)
Removes a transform from the current layout.
void Layout::setDirection (int direction)
Sets the layout direction.
See also *direction*().
void Layout::setSpacing (float spacing)
Sets the spacing between items in the layout.
See also *spacing*().
Vector2 Layout::sizeHint ()
Returns the size hint for the layout.
float Layout::spacing () const
Returns the spacing between items in the layout.
See also setSpacing().