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

Method setSizeWidth

core/ui/UILayoutComponent.cpp:393–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391 return _owner->getContentSize().width;
392}
393void LayoutComponent::setSizeWidth(float width)
394{
395 Vec2 ownerSize = _owner->getContentSize();
396 ownerSize.width = width;
397
398 Node* parent = this->getOwnerParent();
399 if (parent != nullptr)
400 {
401 const Vec2& parentSize = parent->getContentSize();
402 if (parentSize.width != 0)
403 _percentWidth = ownerSize.width / parentSize.width;
404 else
405 {
406 _percentWidth = 0;
407 if (_usingPercentWidth)
408 ownerSize.width = 0;
409 }
410 _owner->setContentSize(ownerSize);
411 this->refreshHorizontalMargin();
412 }
413 else
414 _owner->setContentSize(ownerSize);
415}
416
417float LayoutComponent::getPercentWidth() const
418{

Calls 4

getOwnerParentMethod · 0.95
getContentSizeMethod · 0.45
setContentSizeMethod · 0.45

Tested by

no test coverage detected