Class AxisLayout

#include <Geode/cocos/base_nodes/Layout.hpp>
classAxisLayout:publiccocos2d::Layout{ ... }

A multi-purpose dynamic layout for arranging nodes along an axis. Can be used to arrange nodes in a single line, a grid, or a flex layout. The RowLayout and ColumnLayout classes function as simple thin wrappers over AxisLayout. The positioning of individual nodes in the layout can be further controlled using AxisLayoutOptions

⚠️ Calculating layouts can get increasingly expensive for large amounts of child nodes being fit into a small space - while this should never prove a real performance concern as most layouts only have a few hundred children at the very most, be aware that you probably shouldn't call CCNode::updateLayout every frame for a menu with thousands of children

Examples1
auto menu = CCMenu::create();
// The menu's children will be arranged horizontally, unless they overflow 
// the content size width in which case a new line will be inserted and 
// aligned to the left. The menu automatically will automatically grow in 
// height to fit all the rows
menu->setLayout(
    RowLayout::create()
        ->setGap(10.f)
        ->setGrowCrossAxis(true)
        ->setAxisAlignment(AxisAlignment::Start)
);
menu->setContentSize({ 200.f, 0.f });
menu->addChild(...);
menu->updateLayout();
Public static methods1
staticcocos2d::AxisLayout*create()

Create a new AxisLayout. Note that this class is not automatically managed by default, so you must assign it to a CCNode or manually manage the memory yourself. See the chainable setters on AxisLayout for what options you can customize for the layout

Parameters

axis

The direction of the layout
Return value
Created AxisLayout

ℹ For convenience, you can use the RowLayout and ColumnLayout classes, which are just thin wrappers over AxisLayout

Public member functions27
virtualvoidapply()
No description provided
virtualcocos2d::CCSizegetSizeHint()const
No description provided
cocos2d::AxisgetAxis()const
No description provided
cocos2d::AxisAlignmentgetAxisAlignment()const
No description provided
cocos2d::AxisAlignmentgetCrossAxisAlignment()const
No description provided
cocos2d::AxisAlignmentgetCrossAxisLineAlignment()const
No description provided
floatgetGap()const
No description provided
boolgetAxisReverse()const
No description provided
boolgetCrossAxisReverse()const
No description provided
boolgetAutoScale()const
No description provided
boolgetGrowCrossAxis()const
No description provided
boolgetCrossAxisOverflow()const
No description provided
std::optional<float>getAutoGrowAxis()const
No description provided
floatgetDefaultMinScale()const
No description provided
floatgetDefaultMaxScale()const
No description provided
cocos2d::AxisLayout*setAxis()
No description provided
cocos2d::AxisLayout*setAxisAlignment()

Sets where to align the target node’s children on the main axis (X-axis for Row, Y-axis for Column)

cocos2d::AxisLayout*setCrossAxisAlignment()

Sets where to align the target node’s children on the cross-axis (Y-axis for Row, X-axis for Column)

cocos2d::AxisLayout*setCrossAxisLineAlignment()

Sets where to align the target node’s children on the cross-axis for each row (Y-axis for Row, X-axis for Column)

cocos2d::AxisLayout*setGap()

The spacing between the children of the node this layout applies to. Measured as the space between their edges, not centres. Does not apply on the main / cross axis if their alignment is AxisAlignment::Even

cocos2d::AxisLayout*setAxisReverse(
boolreverse
)

Whether to reverse the direction of the children in this layout or not

cocos2d::AxisLayout*setCrossAxisReverse(
boolreverse
)

Whether to reverse the direction of the rows on the cross-axis or not

cocos2d::AxisLayout*setAutoScale(
boolenable
)

If enabled, then the layout may scale the target’s children if they are about to overflow. Assumes that all the childrens’ intended scale is 1

cocos2d::AxisLayout*setGrowCrossAxis(
boolexpand
)

If true, if the main axis overflows extra nodes will be placed on new rows/columns on the cross-axis

cocos2d::AxisLayout*setCrossAxisOverflow(
boolallow
)

If true, the cross-axis content size of the target node will be automatically adjusted to fit the children

cocos2d::AxisLayout*setAutoGrowAxis(
std::optional<float>allowAndMinLength
)

If not std::nullopt, then the axis will be automatically extended to fit all items in a single row whose minimum length is the specified. Useful for scrollable list layer contents

cocos2d::AxisLayout*setDefaultScaleLimits(,)

Set the default minimum/maximum scales for nodes in the layout

Fields0
Protected member functions0
Protected fields1
;
No description provided