|
3 | 3 |
|
4 | 4 | using namespace geode::prelude; |
5 | 5 |
|
| 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 | + |
6 | 15 | void PageMenu::checkChildren(float dt) { |
7 | 16 | auto fields = m_fields.self(); |
8 | 17 | if (!fields->m_paged) return; |
9 | 18 | if (fields->m_lastChildrenCount != getChildrenCount()) { |
10 | 19 | setPaged(fields->m_elementCount, fields->m_orientation, fields->m_max, fields->m_padding); |
11 | 20 | } |
12 | 21 | if (fields->m_paged && fields->m_arrowsMenu) { |
13 | | - fields->m_arrowsMenu->setPosition(getPosition()); |
| 22 | + fields->m_arrowsMenu->setPosition(getNodeCenter(this)); |
14 | 23 | fields->m_arrowsMenu->setVisible(isVisible()); |
15 | 24 | fields->m_arrowsMenu->ignoreAnchorPointForPosition(false); |
16 | | - fields->m_arrowsMenu->setAnchorPoint(getAnchorPoint()); |
| 25 | + fields->m_arrowsMenu->setZOrder(getZOrder()); |
17 | 26 | } |
18 | 27 | } |
19 | 28 |
|
@@ -119,6 +128,9 @@ void PageMenu::setPaged(int count, PageOrientation orientation, float max, float |
119 | 128 |
|
120 | 129 | setPage(fields->m_currentPage); |
121 | 130 | if (Layout* layout = getLayout()) { |
| 131 | + if (AxisLayout* axisLayout = typeinfo_cast<AxisLayout*>(layout)) { |
| 132 | + axisLayout->setCrossAxisOverflow(false); |
| 133 | + } |
122 | 134 | layout->ignoreInvisibleChildren(true); |
123 | 135 | } |
124 | 136 | updateLayout(); |
@@ -152,9 +164,8 @@ void PageMenu::addArrowButtons() { |
152 | 164 |
|
153 | 165 | fields->m_arrowsMenu->setID(fmt::format("{}-navigation-menu", getID())); |
154 | 166 | fields->m_arrowsMenu->ignoreAnchorPointForPosition(false); |
155 | | - fields->m_arrowsMenu->setPosition(getPosition()); |
| 167 | + fields->m_arrowsMenu->setPosition(getNodeCenter(this)); |
156 | 168 | fields->m_arrowsMenu->setScale(getScale()); |
157 | | - fields->m_arrowsMenu->setAnchorPoint(getAnchorPoint()); |
158 | 169 | fields->m_arrowsMenu->addChild(nextButton); |
159 | 170 | fields->m_arrowsMenu->addChild(prevButton); |
160 | 171 |
|
|
0 commit comments