Skip to content
This repository was archived by the owner on Apr 10, 2026. It is now read-only.

Commit bb1efc1

Browse files
committed
Fix anchor point issues
1 parent 79c27b4 commit bb1efc1

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"android": "2.2074",
66
"mac": "2.2074"
77
},
8-
"version": "v1.4.6",
8+
"version": "v1.4.7",
99
"id": "alphalaneous.pages_api",
1010
"name": "Pages API",
1111
"developer": "Alphalaneous",

src/PageMenu.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,26 @@
33

44
using namespace geode::prelude;
55

6+
CCPoint getNodeCenter(CCNode* node) {
7+
CCPoint pos = node->getPosition();
8+
CCSize size = node->getScaledContentSize();
9+
CCPoint anchor = node->getAnchorPoint();
10+
11+
return {pos.x + size.width * (0.5f - anchor.x),
12+
pos.y + size.height * (0.5f - anchor.y)};
13+
}
14+
615
void PageMenu::checkChildren(float dt) {
716
auto fields = m_fields.self();
817
if (!fields->m_paged) return;
918
if (fields->m_lastChildrenCount != getChildrenCount()) {
1019
setPaged(fields->m_elementCount, fields->m_orientation, fields->m_max, fields->m_padding);
1120
}
1221
if (fields->m_paged && fields->m_arrowsMenu) {
13-
fields->m_arrowsMenu->setPosition(getPosition());
22+
fields->m_arrowsMenu->setPosition(getNodeCenter(this));
1423
fields->m_arrowsMenu->setVisible(isVisible());
1524
fields->m_arrowsMenu->ignoreAnchorPointForPosition(false);
16-
fields->m_arrowsMenu->setAnchorPoint(getAnchorPoint());
25+
fields->m_arrowsMenu->setZOrder(getZOrder());
1726
}
1827
}
1928

@@ -119,6 +128,9 @@ void PageMenu::setPaged(int count, PageOrientation orientation, float max, float
119128

120129
setPage(fields->m_currentPage);
121130
if (Layout* layout = getLayout()) {
131+
if (AxisLayout* axisLayout = typeinfo_cast<AxisLayout*>(layout)) {
132+
axisLayout->setCrossAxisOverflow(false);
133+
}
122134
layout->ignoreInvisibleChildren(true);
123135
}
124136
updateLayout();
@@ -152,9 +164,8 @@ void PageMenu::addArrowButtons() {
152164

153165
fields->m_arrowsMenu->setID(fmt::format("{}-navigation-menu", getID()));
154166
fields->m_arrowsMenu->ignoreAnchorPointForPosition(false);
155-
fields->m_arrowsMenu->setPosition(getPosition());
167+
fields->m_arrowsMenu->setPosition(getNodeCenter(this));
156168
fields->m_arrowsMenu->setScale(getScale());
157-
fields->m_arrowsMenu->setAnchorPoint(getAnchorPoint());
158169
fields->m_arrowsMenu->addChild(nextButton);
159170
fields->m_arrowsMenu->addChild(prevButton);
160171

0 commit comments

Comments
 (0)