MCPcopy Create free account
hub / github.com/axmolengine/axmol / setPosition

Method setPosition

core/ui/UILayoutComponent.cpp:175–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173 return _owner->getPosition();
174}
175void LayoutComponent::setPosition(const Point& position)
176{
177 Node* parent = this->getOwnerParent();
178 if (parent != nullptr)
179 {
180 Point ownerPoint = position;
181 const Vec2& parentSize = parent->getContentSize();
182
183 if (parentSize.width != 0)
184 _positionPercentX = ownerPoint.x / parentSize.width;
185 else
186 {
187 _positionPercentX = 0;
188 if (_usingPositionPercentX || _horizontalEdge == HorizontalEdge::Center)
189 ownerPoint.x = 0;
190 }
191
192 if (parentSize.height != 0)
193 _positionPercentY = ownerPoint.y / parentSize.height;
194 else
195 {
196 _positionPercentY = 0;
197 if (_usingPositionPercentY || _verticalEdge == VerticalEdge::Center)
198 ownerPoint.y = 0;
199 }
200
201 _owner->setPosition(ownerPoint);
202
203 this->refreshHorizontalMargin();
204 this->refreshVerticalMargin();
205 }
206 else
207 _owner->setPosition(position);
208}
209
210bool LayoutComponent::isPositionPercentXEnabled() const
211{

Callers 2

setAnchorPositionMethod · 0.95
refreshLayoutMethod · 0.45

Calls 4

getOwnerParentMethod · 0.95
refreshVerticalMarginMethod · 0.95
getContentSizeMethod · 0.45

Tested by

no test coverage detected