add AxisLayout::create

This commit is contained in:
HJfod 2023-02-11 17:50:14 +02:00
parent ba0851e4fa
commit f5ce865b55
2 changed files with 22 additions and 0 deletions

View file

@ -101,6 +101,18 @@ protected:
AxisLayout(Axis);
public:
/**
* 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
* @param axis The direction of the layout
* @note For convenience, you can use the RowLayout and ColumnLayout
* classes, which are just thin wrappers over AxisLayout
* @returns Created AxisLayout
*/
static AxisLayout* create(Axis axis = Axis::Row);
void apply(CCNode* on) override;
Axis getAxis() const;
@ -113,6 +125,7 @@ public:
bool getGrowCrossAxis() const;
bool getCrossAxisOverflow() const;
AxisLayout* setAxis(Axis axis);
/**
* Sets where to align the target node's children on the main axis (X for
* Row, Y for Column)

View file

@ -373,6 +373,11 @@ bool AxisLayout::getCrossAxisOverflow() const {
return m_allowCrossAxisOverflow;
}
AxisLayout* AxisLayout::setAxis(Axis axis) {
m_axis = axis;
return this;
}
AxisLayout* AxisLayout::setCrossAxisAlignment(AxisAlignment align) {
m_crossAlignment = align;
return this;
@ -413,6 +418,10 @@ AxisLayout* AxisLayout::setGrowCrossAxis(bool shrink) {
return this;
}
AxisLayout* AxisLayout::create(Axis axis) {
return new AxisLayout(axis);
}
RowLayout::RowLayout() : AxisLayout(Axis::Row) {}
RowLayout* RowLayout::create() {