Axmol Engine 2.4.0-258ceca
Loading...
Searching...
No Matches
LayoutComponent Class Reference

A component class used for layout. More...

#include <UILayoutComponent.h>

Public Types

enum class  HorizontalEdge
 Horizontal dock position type.
 
enum class  VerticalEdge
 Vertical dock position type.
 

Public Member Functions

 LayoutComponent ()
 Default constructor.
 
 ~LayoutComponent ()
 Default destructor.
 
 CREATE_FUNC (LayoutComponent)
 Create a LayoutComponent instance with default settings.
 
void setUsingPercentContentSize (bool isUsed)
 Percent content size is used to adapt node's content size based on parent's content size.
 
bool getUsingPercentContentSize () const
 Query whether use percent content size or not.
 
void setPercentContentSize (const Vec2 &percent)
 Set percent content size.
 
Vec2 getPercentContentSize () const
 Query the percent content size value.
 
const PointgetAnchorPosition () const
 Query the anchor position.
 
void setAnchorPosition (const Point &point)
 Change the anchor position to it's parent.
 
const PointgetPosition () const
 Query the owner's position.
 
void setPosition (const Point &position)
 Change the position of component owner.
 
bool isPositionPercentXEnabled () const
 Whether position percentX is enabled or not.
 
void setPositionPercentXEnabled (bool isUsed)
 Toggle position percentX enabled.
 
float getPositionPercentX () const
 Query the position percent X value.
 
void setPositionPercentX (float percentMargin)
 Change position percent X value.
 
bool isPositionPercentYEnabled () const
 Whether position percentY is enabled or not.
 
void setPositionPercentYEnabled (bool isUsed)
 Toggle position percentY enabled.
 
float getPositionPercentY () const
 Query the position percentY Y value.
 
void setPositionPercentY (float percentMargin)
 Change position percentY value.
 
HorizontalEdge getHorizontalEdge () const
 Query element horizontal dock type.
 
void setHorizontalEdge (HorizontalEdge hEage)
 Change element's horizontal dock type.
 
VerticalEdge getVerticalEdge () const
 Query element vertical dock type.
 
void setVerticalEdge (VerticalEdge vEage)
 Change element's vertical dock type.
 
float getLeftMargin () const
 Query left margin of owner relative to its parent.
 
void setLeftMargin (float margin)
 Change left margin of owner relative to its parent.
 
float getRightMargin () const
 Query the right margin of owner relative to its parent.
 
void setRightMargin (float margin)
 Change right margin of owner relative to its parent.
 
float getTopMargin () const
 Query the top margin of owner relative to its parent.
 
void setTopMargin (float margin)
 Change the top margin of owner relative to its parent.
 
float getBottomMargin () const
 Query the bottom margin of owner relative to its parent.
 
void setBottomMargin (float margin)
 Change the bottom margin of owner relative to its parent.
 
const Vec2getSize () const
 Query owner's content size.
 
void setSize (const Vec2 &size)
 Change the content size of owner.
 
bool isPercentWidthEnabled () const
 Query whether percent width is enabled or not.
 
void setPercentWidthEnabled (bool isUsed)
 Toggle enable percent width.
 
float getSizeWidth () const
 Query content size width of owner.
 
void setSizeWidth (float width)
 Change content size width of owner.
 
float getPercentWidth () const
 Query percent width of owner.
 
void setPercentWidth (float percentWidth)
 Change percent width of owner.
 
bool isPercentHeightEnabled () const
 Query whether percent height is enabled or not.
 
void setPercentHeightEnabled (bool isUsed)
 Toggle enable percent height.
 
float getSizeHeight () const
 Query size height of owner.
 
void setSizeHeight (float height)
 Change size height of owner.
 
float getPercentHeight () const
 Query percent height of owner.
 
void setPercentHeight (float percentHeight)
 Change percent height value of owner.
 
bool isStretchWidthEnabled () const
 Query whether stretch width is enabled or not.
 
void setStretchWidthEnabled (bool isUsed)
 Toggle enable stretch width.
 
bool isStretchHeightEnabled () const
 Query whether stretch height is enabled or not.
 
void setStretchHeightEnabled (bool isUsed)
 Toggle enable stretch height.
 
void setPercentOnlyEnabled (bool enable)
 Toggle enable percent only.
 
void setActiveEnabled (bool enable)
 Toggle active enabled of LayoutComponent's owner.
 
void refreshLayout ()
 Refresh layout of the owner.
 

Static Public Member Functions

static LayoutComponentbindLayoutComponent (Node *node)
 Bind a LayoutComponent to a specified node.
 

Detailed Description

A component class used for layout.

The LayoutComponent holds all the data for layouting.

Constructor & Destructor Documentation

◆ LayoutComponent()

Default constructor.

@lua new

◆ ~LayoutComponent()

Default destructor.

@lua NA

Member Function Documentation

◆ bindLayoutComponent()

static LayoutComponent * bindLayoutComponent ( Node * node)
static

Bind a LayoutComponent to a specified node.

If the node has already binded a LayoutComponent named __LAYOUT_COMPONENT_NAME, just return the LayoutComponent. Otherwise, create a new LayoutComponent and bind the LayoutComponent to the node.

Parameters
nodeA Node* instance pointer.
Returns
The binded LayoutComponent instance pointer.

◆ setUsingPercentContentSize()

void setUsingPercentContentSize ( bool isUsed)

Percent content size is used to adapt node's content size based on parent's content size.

If set to true then node's content size will be changed based on the value set by

See also
setPercentContentSize
Parameters
isUsedTrue to enable percent content size, false otherwise.

◆ getUsingPercentContentSize()

bool getUsingPercentContentSize ( ) const

Query whether use percent content size or not.

Returns
True if using percent content size, false otherwise.

◆ setPercentContentSize()

void setPercentContentSize ( const Vec2 & percent)

Set percent content size.

The value should be [0-1], 0 means the child's content size will be 0 and 1 means the child's content size is the same as its parents.

Parameters
percentThe percent (x,y) of the node in [0-1] scope.

◆ getPercentContentSize()

Vec2 getPercentContentSize ( ) const

Query the percent content size value.

Returns
Percent (x,y) in Vec2.

◆ getAnchorPosition()

const Point & getAnchorPosition ( ) const

Query the anchor position.

Returns
Anchor position to it's parent

◆ setAnchorPosition()

void setAnchorPosition ( const Point & point)

Change the anchor position to it's parent.

Parameters
pointA value in (x,y) format.

◆ getPosition()

const Point & getPosition ( ) const

Query the owner's position.

Returns
The owner's position.

◆ setPosition()

void setPosition ( const Point & position)

Change the position of component owner.

Parameters
positionA position in (x,y)

◆ isPositionPercentXEnabled()

bool isPositionPercentXEnabled ( ) const

Whether position percentX is enabled or not.

Returns
True if position percentX is enable, false otherwise.

◆ setPositionPercentXEnabled()

void setPositionPercentXEnabled ( bool isUsed)

Toggle position percentX enabled.

Parameters
isUsedTrue if enable position percentX, false otherwise.

◆ getPositionPercentX()

float getPositionPercentX ( ) const

Query the position percent X value.

Returns
Position percent X value in float.

◆ setPositionPercentX()

void setPositionPercentX ( float percentMargin)

Change position percent X value.

Parameters
percentMarginMargin in float.

◆ isPositionPercentYEnabled()

bool isPositionPercentYEnabled ( ) const

Whether position percentY is enabled or not.

See also
setPositionPercentYEnabled
Returns
True if position percentY is enabled, false otherwise.

◆ setPositionPercentYEnabled()

void setPositionPercentYEnabled ( bool isUsed)

Toggle position percentY enabled.

Parameters
isUsedTrue if position percentY is enabled, false otherwise.

◆ getPositionPercentY()

float getPositionPercentY ( ) const

Query the position percentY Y value.

Returns
Position percent Y value in float.

◆ setPositionPercentY()

void setPositionPercentY ( float percentMargin)

Change position percentY value.

Parameters
percentMarginMargin in float.

◆ getHorizontalEdge()

HorizontalEdge getHorizontalEdge ( ) const

Query element horizontal dock type.

Returns
Horizontal dock type.

◆ setHorizontalEdge()

void setHorizontalEdge ( HorizontalEdge hEage)

Change element's horizontal dock type.

Parameters
hEageHorizontal dock type
See also
HorizontalEdge

◆ getVerticalEdge()

VerticalEdge getVerticalEdge ( ) const

Query element vertical dock type.

Returns
Vertical dock type.

◆ setVerticalEdge()

void setVerticalEdge ( VerticalEdge vEage)

Change element's vertical dock type.

Parameters
vEageVertical dock type
See also
VerticalEdge.

◆ getLeftMargin()

float getLeftMargin ( ) const

Query left margin of owner relative to its parent.

Returns
Left margin in float.

◆ setLeftMargin()

void setLeftMargin ( float margin)

Change left margin of owner relative to its parent.

Parameters
marginMargin in float.

◆ getRightMargin()

float getRightMargin ( ) const

Query the right margin of owner relative to its parent.

Returns
Right margin in float.

◆ setRightMargin()

void setRightMargin ( float margin)

Change right margin of owner relative to its parent.

Parameters
marginMargin in float.

◆ getTopMargin()

float getTopMargin ( ) const

Query the top margin of owner relative to its parent.

Returns
Top margin in float.

◆ setTopMargin()

void setTopMargin ( float margin)

Change the top margin of owner relative to its parent.

Parameters
marginMargin in float.

◆ getBottomMargin()

float getBottomMargin ( ) const

Query the bottom margin of owner relative to its parent.

Returns
Bottom margin in float.

◆ setBottomMargin()

void setBottomMargin ( float margin)

Change the bottom margin of owner relative to its parent.

Parameters
marginin float.

◆ getSize()

const Vec2 & getSize ( ) const

Query owner's content size.

Returns
Owner's content size.

◆ setSize()

void setSize ( const Vec2 & size)

Change the content size of owner.

Parameters
sizeContent size in
See also
Vec2.

◆ isPercentWidthEnabled()

bool isPercentWidthEnabled ( ) const

Query whether percent width is enabled or not.

Returns
True if percent width is enabled, false, otherwise.

◆ setPercentWidthEnabled()

void setPercentWidthEnabled ( bool isUsed)

Toggle enable percent width.

Parameters
isUsedTrue if percent width is enabled, false otherwise.

◆ getSizeWidth()

float getSizeWidth ( ) const

Query content size width of owner.

Returns
Content size width in float.

◆ setSizeWidth()

void setSizeWidth ( float width)

Change content size width of owner.

Parameters
widthContent size width in float.

◆ getPercentWidth()

float getPercentWidth ( ) const

Query percent width of owner.

Returns
percent width in float.

◆ setPercentWidth()

void setPercentWidth ( float percentWidth)

Change percent width of owner.

Parameters
percentWidthPercent Width in float.

◆ isPercentHeightEnabled()

bool isPercentHeightEnabled ( ) const

Query whether percent height is enabled or not.

Returns
True if percent height is enabled, false otherwise.

◆ setPercentHeightEnabled()

void setPercentHeightEnabled ( bool isUsed)

Toggle enable percent height.

Parameters
isUsedTrue if percent height is enabled, false otherwise.

◆ getSizeHeight()

float getSizeHeight ( ) const

Query size height of owner.

Returns
The size height in float.

◆ setSizeHeight()

void setSizeHeight ( float height)

Change size height of owner.

Parameters
heightThe size height in float.

◆ getPercentHeight()

float getPercentHeight ( ) const

Query percent height of owner.

Returns
Percent height in float.

◆ setPercentHeight()

void setPercentHeight ( float percentHeight)

Change percent height value of owner.

Parameters
percentHeightPercent height in float.

◆ isStretchWidthEnabled()

bool isStretchWidthEnabled ( ) const

Query whether stretch width is enabled or not.

Returns
True if stretch width is enabled, false otherwise.

◆ setStretchWidthEnabled()

void setStretchWidthEnabled ( bool isUsed)

Toggle enable stretch width.

Parameters
isUsedTrue if enable stretch width, false otherwise.

◆ isStretchHeightEnabled()

bool isStretchHeightEnabled ( ) const

Query whether stretch height is enabled or not.

Returns
True if stretch height is enabled, false otherwise.

◆ setStretchHeightEnabled()

void setStretchHeightEnabled ( bool isUsed)

Toggle enable stretch height.

Parameters
isUsedTrue if stretch height is enabled, false otherwise.

◆ setPercentOnlyEnabled()

void setPercentOnlyEnabled ( bool enable)

Toggle enable percent only.

Parameters
enableTrue if percent only is enabled, false otherwise.

◆ setActiveEnabled()

void setActiveEnabled ( bool enable)

Toggle active enabled of LayoutComponent's owner.

Parameters
enableTrue if active layout component, false otherwise.

The documentation for this class was generated from the following file: