| 173 | return _owner->getPosition(); |
| 174 | } |
| 175 | void 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 | |
| 210 | bool LayoutComponent::isPositionPercentXEnabled() const |
| 211 | { |
no test coverage detected