MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / alignItemsHorizontally

Method alignItemsHorizontally

Source/GameToolbox/nodes.cpp:174–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174void GameToolbox::alignItemsHorizontally(ax::Vector<Node*> children, float padding, Point location)
175{
176 auto totalWidth = -padding;
177
178 if (children.size())
179 {
180 for (Node* child : children)
181 {
182 totalWidth += padding + (child->getContentSize().width * child->getScaleX());
183 }
184
185 float xPos = -(float)(totalWidth * 0.5);
186 for (Node* child : children)
187 {
188 auto width = child->getContentSize().width;
189 auto scale = child->getScaleX();
190
191 child->setPosition({ xPos + (width * scale) * 0.5f, 0 });
192 child->setPosition(child->getPosition() + location);
193
194 xPos = xPos + (float)(padding + (float)(width * child->getScaleX()));
195 }
196 }
197}
198
199void GameToolbox::alignItemsHorizontallyWithPadding(ax::Vector<ax::Node*> _children, float padding) {
200 float width = -padding;

Callers 1

searchButtonFunction · 0.80

Calls 2

sizeMethod · 0.80
setPositionMethod · 0.80

Tested by

no test coverage detected