Axmol 3.0.0-89d6d9a
Loading...
Searching...
No Matches
Helper Class Reference

Helper class for traversing children in widget tree. More...

#include <UIHelper.h>

Classes

class  VisibleRect
 CLASS VisibleRect. More...

Public Types

enum  AlignType
 align type defination

Static Public Member Functions

static Widget * seekWidgetByTag (Widget *root, int tag)
 Find a widget with a specific tag from root widget.
static Widget * seekWidgetByName (Widget *root, std::string_view name)
 Find a widget with a specific name from root widget.
static Widget * seekActionWidgetByActionTag (Widget *root, int tag)
 Find a widget with a specific action tag from root widget This search will be recursive through all child widgets.
static std::string getSubStringOfUTF8String (std::string_view str, std::string::size_type start, std::string::size_type length)
 Get a UTF8 substring from a std::string with a given start position and length Sample: std::string str = "中国中国中国"; substr = getSubStringOfUTF8String(str,0,2) will = "中国".
static void doLayout (Node *rootNode)
 Refresh object and it's children layout state.
static void changeLayoutSystemActiveState (bool active)
 Change the active property of Layout's.
static Rect restrictCapInsetRect (const Rect &capInsets, const Vec2 &textureSize)
 restrict capInsetSize, when the capInsets's width is larger than the textureSize, it will restrict to 0, the height goes the same way as width.
static Rect getNodeNativeWindowRect (Node *node)
 Returns the node bounding rectangle in OS native window coordinates.
static void setDesignSizeFixedEdge (const Vec2 &designSize)
 adatpe design size with fixed edge, normally, use this function for screen adatpe
static void setDesignSizeNoBorder (const Vec2 &designSize)
 adapte design size with no border
static Vec2 getNodeGroupSize (std::span< Node *const > nodes)
 Get node group size.
static void setNodeGroupSize (std::span< Node *const > nodes, const Vec2 &newSize)
 Set nodes group size.
static float getNodeGroupLeft (std::span< Node *const > nodes)
 Get Node group left.
static float getNodeGroupTop (std::span< Node *const > nodes)
 Get node group top.
static float getNodeGroupRight (std::span< Node *const > nodes)
 Get node group right.
static float getNodeGroupBottom (std::span< Node *const > nodes)
 Get node group bottom.
static void centerHorizontally (std::span< Node *const > nodes)
 Center horiz to parent.
static void centerVertically (std::span< Node *const > nodes)
 Center vertical to parent.
static void centerToParent (std::span< Node *const > nodes)
 Center to parent.
static void alignLefts (std::span< Node *const > nodes)
 Align lefts.
static void alignRights (std::span< Node *const > nodes)
 Align rights.
static void alignTops (std::span< Node *const > nodes)
 Align tops.
static void alignBottoms (std::span< Node *const > nodes)
 Align bottoms.
static void alignHorizontals (std::span< Node *const > nodes)
 Align horiz.
static void alignVerticals (std::span< Node *const > nodes)
 Align vertical.
static void alignCenters (std::span< Node *const > nodes)
 Align centers.
static void makeSameWidth (std::span< Node *const > nodes)
 Make same width.
static void makeSameHeight (std::span< Node *const > nodes)
 Make same height.
static void makeSameSize (std::span< Node *const > nodes)
 Make same size.
static void makeHorizontalSpacingEqual (std::vector< ax::Node * > &nodes)
 Make horiz spacing equal.
static void makeVerticalSpacingEqual (std::vector< ax::Node * > &nodes)
 Make vertical spacing equal.
static void increaseHorizontalSpacing (std::vector< ax::Node * > &nodes, float theSpacing)
 Increease horiz spacing.
static void increaseVerticalSpacing (std::vector< ax::Node * > &nodes, float theSpacing)
 Increase vertical spacing.
static void decreaseHorizontalSpacing (std::vector< ax::Node * > &nodes, float theSpacing)
 Decrease horiz spacing.
static void decreaseVerticalSpacing (std::vector< ax::Node * > &nodes, float theSpacing)
 Decrease vertical spacing.
static void removeHorizontalSpacing (std::span< Node *const > nodes)
 Remove horiz spacing.
static void removeVerticalSpacing (std::span< Node *const > nodes)
 Remove Vertical spacing.
static void makeHorizontalSpacingEqual (std::span< Node *const > nodes, float theSpacing)
 maybe for internal use
static void makeVerticalSpacingEqual (std::span< Node *const > nodes, float theSpacing)
 maybe for internal use

Detailed Description

Helper class for traversing children in widget tree.

It also provides some helper functions for layout.

Member Function Documentation

◆ seekWidgetByTag()

Widget * seekWidgetByTag ( Widget * root,
int tag )
static

Find a widget with a specific tag from root widget.

This search will be recursive through all child widgets.

Parameters
rootThe be searched root widget.
tagThe widget tag.
Returns
Widget instance pointer.

◆ seekWidgetByName()

Widget * seekWidgetByName ( Widget * root,
std::string_view name )
static

Find a widget with a specific name from root widget.

This search will be recursive through all child widgets.

Parameters
rootThe be searched root widget.
nameThe widget name.
Returns
Widget instance pointer.

◆ seekActionWidgetByActionTag()

Widget * seekActionWidgetByActionTag ( Widget * root,
int tag )
static

Find a widget with a specific action tag from root widget This search will be recursive through all child widgets.

Parameters
rootThe be searched root widget.
tagThe widget action's tag.
Returns
Widget instance pointer.

◆ getSubStringOfUTF8String()

std::string getSubStringOfUTF8String ( std::string_view str,
std::string::size_type start,
std::string::size_type length )
static

Get a UTF8 substring from a std::string with a given start position and length Sample: std::string str = "中国中国中国"; substr = getSubStringOfUTF8String(str,0,2) will = "中国".

Parameters
strThe source string.
startThe start position of the substring.
lengthThe length of the substring in UTF8 count
Returns
a UTF8 substring

◆ doLayout()

void doLayout ( Node * rootNode)
static

Refresh object and it's children layout state.

Parameters
rootNodeA Node* or Node* descendant instance pointer.

◆ changeLayoutSystemActiveState()

void changeLayoutSystemActiveState ( bool active)
static

Change the active property of Layout's.

See also
LayoutComponent
Parameters
activeA boolean value.

◆ restrictCapInsetRect()

Rect restrictCapInsetRect ( const Rect & capInsets,
const Vec2 & textureSize )
static

restrict capInsetSize, when the capInsets's width is larger than the textureSize, it will restrict to 0, the height goes the same way as width.

Parameters
capInsetsA user defined capInsets.
textureSizeThe size of a scale9enabled texture
Returns
a restricted capInset.

◆ getNodeNativeWindowRect()

Rect getNodeNativeWindowRect ( Node * node)
static

Returns the node bounding rectangle in OS native window coordinates.

Coordinates origin is top-left. Units are OS native pixels/points (NOT engine logical screen units). The returned rect is suitable for native windowing APIs, platform UI integration, and system-level hit testing.

Note: This function returns screen rect after converting engine screen units by dividing by _inputScale.

◆ setDesignSizeFixedEdge()

void setDesignSizeFixedEdge ( const Vec2 & designSize)
static

adatpe design size with fixed edge, normally, use this function for screen adatpe

Parameters
designSize

◆ setDesignSizeNoBorder()

void setDesignSizeNoBorder ( const Vec2 & designSize)
static

adapte design size with no border

Parameters
designSize

◆ centerHorizontally()

void centerHorizontally ( std::span< Node *const > nodes)
static

Center horiz to parent.

Parameters
nodes

◆ centerVertically()

void centerVertically ( std::span< Node *const > nodes)
static

Center vertical to parent.

Parameters
nodes

◆ centerToParent()

void centerToParent ( std::span< Node *const > nodes)
static

Center to parent.

Parameters
nodes

◆ alignLefts()

void alignLefts ( std::span< Node *const > nodes)
static

Align lefts.

Parameters
nodes

◆ alignRights()

void alignRights ( std::span< Node *const > nodes)
static

Align rights.

Parameters
nodes

◆ alignTops()

void alignTops ( std::span< Node *const > nodes)
static

Align tops.

Parameters
nodes

◆ alignBottoms()

void alignBottoms ( std::span< Node *const > nodes)
static

Align bottoms.

Parameters
nodes

◆ alignHorizontals()

void alignHorizontals ( std::span< Node *const > nodes)
static

Align horiz.

Parameters
nodes

◆ alignVerticals()

void alignVerticals ( std::span< Node *const > nodes)
static

Align vertical.

Parameters
nodes

◆ alignCenters()

void alignCenters ( std::span< Node *const > nodes)
static

Align centers.

Parameters
nodes

◆ makeSameWidth()

void makeSameWidth ( std::span< Node *const > nodes)
static

Make same width.

Parameters
nodes

◆ makeSameHeight()

void makeSameHeight ( std::span< Node *const > nodes)
static

Make same height.

Parameters
nodes

◆ makeSameSize()

void makeSameSize ( std::span< Node *const > nodes)
static

Make same size.

Parameters
nodes

◆ makeHorizontalSpacingEqual() [1/2]

void makeHorizontalSpacingEqual ( std::vector< ax::Node * > & nodes)
static

Make horiz spacing equal.

Parameters
nodes

◆ makeVerticalSpacingEqual() [1/2]

void makeVerticalSpacingEqual ( std::vector< ax::Node * > & nodes)
static

Make vertical spacing equal.

Parameters
nodes

◆ increaseHorizontalSpacing()

void increaseHorizontalSpacing ( std::vector< ax::Node * > & nodes,
float theSpacing )
static

Increease horiz spacing.

Parameters
nodes

◆ increaseVerticalSpacing()

void increaseVerticalSpacing ( std::vector< ax::Node * > & nodes,
float theSpacing )
static

Increase vertical spacing.

Parameters
nodes

◆ decreaseHorizontalSpacing()

void decreaseHorizontalSpacing ( std::vector< ax::Node * > & nodes,
float theSpacing )
static

Decrease horiz spacing.

Parameters
nodes

◆ decreaseVerticalSpacing()

void decreaseVerticalSpacing ( std::vector< ax::Node * > & nodes,
float theSpacing )
static

Decrease vertical spacing.

Parameters
nodes

◆ removeHorizontalSpacing()

void removeHorizontalSpacing ( std::span< Node *const > nodes)
static

Remove horiz spacing.

Parameters
nodes

◆ removeVerticalSpacing()

void removeVerticalSpacing ( std::span< Node *const > nodes)
static

Remove Vertical spacing.

Parameters
nodes

◆ makeHorizontalSpacingEqual() [2/2]

void makeHorizontalSpacingEqual ( std::span< Node *const > nodes,
float theSpacing )
static

maybe for internal use

Parameters
nodes

◆ makeVerticalSpacingEqual() [2/2]

void makeVerticalSpacingEqual ( std::span< Node *const > nodes,
float theSpacing )
static

maybe for internal use

Parameters
nodes

The documentation for this class was generated from the following file:
  • UIHelper.h