axmol/cocos/ui/UILayoutComponent.cpp

609 lines
18 KiB
C++
Raw Normal View History

2014-10-09 18:28:09 +08:00
/****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc.
2014-12-22 11:20:03 +08:00
2014-10-09 18:28:09 +08:00
http://www.cocos2d-x.org
2014-12-22 11:20:03 +08:00
2014-10-09 18:28:09 +08:00
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
2014-12-22 11:20:03 +08:00
2014-10-09 18:28:09 +08:00
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
2014-12-22 11:20:03 +08:00
2014-10-09 18:28:09 +08:00
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "UILayoutComponent.h"
#include "2d/CCNode.h"
#include "GUIDefine.h"
2014-12-22 11:20:03 +08:00
#include "UIHelper.h"
2014-10-09 18:28:09 +08:00
NS_CC_BEGIN
namespace ui {
LayoutComponent::LayoutComponent()
2014-12-22 11:20:03 +08:00
:_horizontalEage(HorizontalEage::None)
, _verticalEage(VerticalEage::None)
, _leftMargin(0)
, _rightMargin(0)
, _usingPositionPercentX(false)
, _positionPercentX(0)
, _buttomMargin(0)
, _topMargin(0)
, _usingPositionPercentY(false)
, _positionPercentY(0)
, _percentWidth(0)
, _usingPercentWidth(false)
, _percentHeight(0)
, _usingPercentHeight(false)
, _actived(true)
,_usingStretchWidth(false)
, _usingStretchHeight(false)
2014-10-09 18:28:09 +08:00
{
_name = __LAYOUT_COMPONENT_NAME;
}
2014-12-22 11:20:03 +08:00
2014-10-09 18:28:09 +08:00
LayoutComponent::~LayoutComponent()
{
2014-12-22 11:20:03 +08:00
2014-10-09 18:28:09 +08:00
}
2014-12-22 11:20:03 +08:00
2014-12-22 14:51:50 +08:00
LayoutComponent* LayoutComponent::boundingLayoutForNode(Node* node)
{
LayoutComponent * layout = (LayoutComponent*)node->getComponent(__LAYOUT_COMPONENT_NAME);
if (layout != nullptr)
return layout;
layout = new (std::nothrow) LayoutComponent();
if (layout && layout->init())
{
layout->autorelease();
node->addComponent(layout);
return layout;
}
CC_SAFE_DELETE(layout);
return nullptr;
}
2014-10-09 18:28:09 +08:00
bool LayoutComponent::init()
{
bool ret = true;
do
{
if (!Component::init())
{
ret = false;
break;
}
2014-12-22 11:20:03 +08:00
2014-10-09 18:28:09 +08:00
//put layout component initalized code here
2014-12-22 11:20:03 +08:00
2014-10-09 18:28:09 +08:00
} while (0);
return ret;
}
2014-12-22 11:20:03 +08:00
Node* LayoutComponent::getOwnerParent()
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
Node* parent = _owner->getParent();
return parent;
2014-10-09 18:28:09 +08:00
}
2014-12-22 11:20:03 +08:00
void LayoutComponent::refreshHorizontalMargin()
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
Node* parent = this->getOwnerParent();
if (parent == nullptr)
return;
2014-12-22 19:05:31 +08:00
const Point& ownerPoint = _owner->getPosition();
const Point& ownerAnchor = _owner->getAnchorPoint();
const Size& ownerSize = _owner->getContentSize();
const Size& parentSize = parent->getContentSize();
2014-10-17 19:13:37 +08:00
2014-12-22 11:20:03 +08:00
_leftMargin = ownerPoint.x - ownerAnchor.x * ownerSize.width;
_rightMargin = parentSize.width - (ownerPoint.x + (1 - ownerAnchor.x) * ownerSize.width);
}
void LayoutComponent::refreshVerticalMargin()
{
Node* parent = this->getOwnerParent();
if (parent == nullptr)
return;
2014-12-22 19:05:31 +08:00
const Point& ownerPoint = _owner->getPosition();
const Point& ownerAnchor = _owner->getAnchorPoint();
const Size& ownerSize = _owner->getContentSize();
const Size& parentSize = parent->getContentSize();
2014-12-22 11:20:03 +08:00
_buttomMargin = ownerPoint.y - ownerAnchor.y * ownerSize.height;
_topMargin = parentSize.height - (ownerPoint.y + (1 - ownerAnchor.y) * ownerSize.height);
}
2014-12-22 18:39:44 +08:00
//OldVersion
2014-12-22 11:20:03 +08:00
void LayoutComponent::setUsingPercentContentSize(bool isUsed)
{
_usingPercentWidth = _usingPercentHeight = isUsed;
}
2014-12-22 19:05:31 +08:00
bool LayoutComponent::getUsingPercentContentSize()const
2014-12-22 11:20:03 +08:00
{
return _usingPercentWidth && _usingPercentHeight;
}
void LayoutComponent::setPercentContentSize(const Vec2 &percent)
{
this->setPercentWidth(percent.x);
this->setPercentHeight(percent.y);
}
2014-12-22 19:05:31 +08:00
Vec2 LayoutComponent::getPercentContentSize()const
2014-12-22 11:20:03 +08:00
{
Vec2 vec2=Vec2(_percentWidth,_percentHeight);
return vec2;
}
2014-12-22 18:39:44 +08:00
//Position & Margin
2014-12-22 19:05:31 +08:00
const Point& LayoutComponent::getAnchorPosition()const
2014-12-22 11:20:03 +08:00
{
return _owner->getAnchorPoint();
}
2014-12-22 19:05:31 +08:00
void LayoutComponent::setAnchorPosition(const Point& point)
2014-12-22 11:20:03 +08:00
{
Rect oldRect = _owner->getBoundingBox();
_owner->setAnchorPoint(point);
Rect newRect = _owner->getBoundingBox();
float offSetX = oldRect.origin.x - newRect.origin.x;
float offSetY = oldRect.origin.y - newRect.origin.y;
Point ownerPosition = _owner->getPosition();
ownerPosition.x += offSetX;
ownerPosition.y += offSetY;
this->setPosition(ownerPosition);
}
2014-12-22 19:05:31 +08:00
const Point& LayoutComponent::getPosition()const
2014-12-22 11:20:03 +08:00
{
return _owner->getPosition();
}
2014-12-22 19:05:31 +08:00
void LayoutComponent::setPosition(const Point& position)
2014-12-22 11:20:03 +08:00
{
_owner->setPosition(position);
Node* parent = this->getOwnerParent();
if (parent != nullptr)
2014-10-17 19:13:37 +08:00
{
2014-12-22 19:05:31 +08:00
const Point& ownerPoint = _owner->getPosition();
const Size& parentSize = parent->getContentSize();
2014-10-17 19:13:37 +08:00
2014-12-22 11:20:03 +08:00
if (parentSize.width != 0)
_positionPercentX = ownerPoint.x / parentSize.width;
2014-10-17 19:13:37 +08:00
else
2014-12-22 11:20:03 +08:00
_positionPercentX = 0;
if (parentSize.height != 0)
_positionPercentY = ownerPoint.y / parentSize.height;
else
_positionPercentY = 0;
this->refreshHorizontalMargin();
this->refreshVerticalMargin();
2014-10-17 19:13:37 +08:00
}
2014-10-09 18:28:09 +08:00
}
2014-12-22 19:05:31 +08:00
bool LayoutComponent::isUsingPositionPercentX()const
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
return _usingPositionPercentX;
2014-10-09 18:28:09 +08:00
}
2014-12-22 11:20:03 +08:00
void LayoutComponent::setPositionPercentXEnabled(bool isUsed)
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
_usingPositionPercentX = isUsed;
if (_usingPositionPercentX)
{
_horizontalEage = HorizontalEage::None;
}
}
2014-12-22 19:05:31 +08:00
float LayoutComponent::getPositionPercentX()const
2014-12-22 11:20:03 +08:00
{
return _positionPercentX;
}
void LayoutComponent::setPositionPercentX(float percentMargin)
{
_positionPercentX = percentMargin;
2014-10-17 19:13:37 +08:00
2014-12-22 11:20:03 +08:00
Node* parent = this->getOwnerParent();
if (parent != nullptr)
2014-10-17 19:13:37 +08:00
{
2014-12-22 11:20:03 +08:00
_owner->setPositionX(parent->getContentSize().width * _positionPercentX);
this->refreshHorizontalMargin();
2014-10-17 19:13:37 +08:00
}
2014-10-09 18:28:09 +08:00
}
2014-12-22 11:20:03 +08:00
2014-12-22 19:05:31 +08:00
bool LayoutComponent::isUsingPositionPercentY()const
2014-12-22 11:20:03 +08:00
{
return _usingPositionPercentY;
}
void LayoutComponent::setPositionPercentYEnabled(bool isUsed)
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
_usingPositionPercentY = isUsed;
if (_usingPositionPercentY)
{
_verticalEage = VerticalEage::None;
}
2014-10-09 18:28:09 +08:00
}
2014-12-22 19:05:31 +08:00
float LayoutComponent::getPositionPercentY()const
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
return _positionPercentY;
}
void LayoutComponent::setPositionPercentY(float percentMargin)
{
_positionPercentY = percentMargin;
2014-10-09 18:28:09 +08:00
2014-12-22 11:20:03 +08:00
Node* parent = this->getOwnerParent();
if (parent != nullptr)
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
_owner->setPositionY(parent->getContentSize().height * _positionPercentY);
this->refreshVerticalMargin();
2014-10-09 18:28:09 +08:00
}
}
2014-12-22 19:05:31 +08:00
LayoutComponent::HorizontalEage LayoutComponent::getHorizontalEage()const
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
return _horizontalEage;
2014-10-09 18:28:09 +08:00
}
2014-12-22 11:20:03 +08:00
void LayoutComponent::setHorizontalEage(HorizontalEage hEage)
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
_horizontalEage = hEage;
if (_horizontalEage != HorizontalEage::None)
2014-10-17 19:13:37 +08:00
{
2014-12-22 11:20:03 +08:00
_usingPositionPercentX = false;
}
2014-10-17 19:13:37 +08:00
2014-12-22 11:20:03 +08:00
Node* parent = this->getOwnerParent();
if (parent != nullptr)
{
2014-12-22 19:05:31 +08:00
const Size& parentSize = parent->getContentSize();
2014-12-22 11:20:03 +08:00
if (parentSize.width != 0)
_positionPercentX = _owner->getPosition().x / parentSize.width;
else
_positionPercentX = 0;
2014-10-17 19:13:37 +08:00
2014-12-22 11:20:03 +08:00
this->refreshHorizontalMargin();
2014-10-17 19:13:37 +08:00
}
2014-10-09 18:28:09 +08:00
}
2014-12-22 19:05:31 +08:00
LayoutComponent::VerticalEage LayoutComponent::getVerticalEage()const
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
return _verticalEage;
2014-10-09 18:28:09 +08:00
}
2014-12-22 11:20:03 +08:00
void LayoutComponent::setVerticalEage(VerticalEage vEage)
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
_verticalEage = vEage;
if (_verticalEage != VerticalEage::None)
{
_usingPositionPercentY = false;
}
2014-10-17 19:13:37 +08:00
2014-12-22 11:20:03 +08:00
Node* parent = this->getOwnerParent();
if (parent != nullptr)
2014-10-17 19:13:37 +08:00
{
2014-12-22 19:05:31 +08:00
const Size& parentSize = parent->getContentSize();
2014-12-22 11:20:03 +08:00
if (parentSize.height != 0)
_positionPercentY = _owner->getPosition().y / parentSize.height;
else
_positionPercentY = 0;
this->refreshVerticalMargin();
2014-10-17 19:13:37 +08:00
}
2014-10-09 18:28:09 +08:00
}
2014-12-22 19:05:31 +08:00
float LayoutComponent::getLeftMargin()const
2014-12-22 11:20:03 +08:00
{
return _leftMargin;
}
void LayoutComponent::setLeftMargin(float margin)
{
_leftMargin = margin;
}
2014-12-22 19:05:31 +08:00
float LayoutComponent::getRightMargin()const
2014-12-22 11:20:03 +08:00
{
return _rightMargin;
}
void LayoutComponent::setRightMargin(float margin)
{
_rightMargin = margin;
}
2014-12-22 19:05:31 +08:00
float LayoutComponent::getTopMargin()const
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
return _topMargin;
}
void LayoutComponent::setTopMargin(float margin)
{
_topMargin = margin;
}
2014-12-22 19:05:31 +08:00
float LayoutComponent::getButtomMargin()const
2014-12-22 11:20:03 +08:00
{
return _buttomMargin;
}
void LayoutComponent::setButtomMargin(float margin)
{
_buttomMargin = margin;
}
2014-12-22 18:39:44 +08:00
//Size & Percent
2014-12-22 19:05:31 +08:00
const Size& LayoutComponent::getSize()const
2014-12-22 11:20:03 +08:00
{
return this->getOwner()->getContentSize();
2014-10-09 18:28:09 +08:00
}
2014-12-22 19:05:31 +08:00
void LayoutComponent::setSize(const Size& _size)
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
_owner->setContentSize(_size);
Node* parent = this->getOwnerParent();
if (parent != nullptr)
2014-10-17 19:13:37 +08:00
{
2014-12-22 19:05:31 +08:00
const Size& ownerSize = _owner->getContentSize();
const Size& parentSize = parent->getContentSize();
2014-10-17 19:13:37 +08:00
2014-12-22 11:20:03 +08:00
if (parentSize.width != 0)
_percentWidth = ownerSize.width / parentSize.width;
2014-10-17 19:13:37 +08:00
else
2014-12-22 11:20:03 +08:00
_percentWidth = 0;
if (parentSize.height != 0)
_percentHeight = ownerSize.height / parentSize.height;
else
_percentHeight = 0;
this->refreshHorizontalMargin();
this->refreshVerticalMargin();
2014-10-17 19:13:37 +08:00
}
2014-12-22 11:20:03 +08:00
}
2014-12-22 19:05:31 +08:00
bool LayoutComponent::isUsingPercentWidth()const
2014-12-22 11:20:03 +08:00
{
return _usingPercentWidth;
}
void LayoutComponent::setPercentWidthEnabled(bool isUsed)
{
_usingPercentWidth = isUsed;
if (_usingPercentWidth)
2014-10-17 19:13:37 +08:00
{
2014-12-22 11:20:03 +08:00
_usingStretchWidth = false;
2014-10-17 19:13:37 +08:00
}
2014-12-22 11:20:03 +08:00
}
2014-12-22 19:05:31 +08:00
float LayoutComponent::getSizeWidth()const
2014-12-22 11:20:03 +08:00
{
return _owner->getContentSize().width;
}
void LayoutComponent::setSizeWidth(float width)
{
Size ownerSize = _owner->getContentSize();
ownerSize.width = width;
_owner->setContentSize(ownerSize);
Node* parent = this->getOwnerParent();
if (parent != nullptr)
{
2014-12-22 19:05:31 +08:00
const Size& parentSize = parent->getContentSize();
2014-12-22 11:20:03 +08:00
if (parentSize.width != 0)
_percentWidth = ownerSize.width / parentSize.width;
else
_percentWidth = 0;
2014-10-17 19:13:37 +08:00
2014-12-22 11:20:03 +08:00
this->refreshHorizontalMargin();
}
2014-10-09 18:28:09 +08:00
}
2014-12-22 19:05:31 +08:00
float LayoutComponent::getPercentWidth()const
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
return _percentWidth;
2014-10-09 18:28:09 +08:00
}
2014-12-22 11:20:03 +08:00
void LayoutComponent::setPercentWidth(float percentWidth)
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
_percentWidth = percentWidth;
2014-10-09 18:28:09 +08:00
2014-12-22 11:20:03 +08:00
Node* parent = this->getOwnerParent();
if (parent != nullptr)
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
Size ownerSize = _owner->getContentSize();
ownerSize.width = parent->getContentSize().width * _percentWidth;
_owner->setContentSize(ownerSize);
2014-10-09 18:28:09 +08:00
2014-12-22 11:20:03 +08:00
this->refreshHorizontalMargin();
}
}
2014-12-22 19:05:31 +08:00
bool LayoutComponent::isUsingPercentHeight()const
2014-12-22 11:20:03 +08:00
{
return _usingPercentHeight;
}
void LayoutComponent::setPercentHeightEnabled(bool isUsed)
{
_usingPercentHeight = isUsed;
if (_usingPercentHeight)
{
_usingStretchHeight = false;
}
}
2014-12-22 19:05:31 +08:00
float LayoutComponent::getSizeHeight()const
2014-12-22 11:20:03 +08:00
{
return _owner->getContentSize().height;
}
void LayoutComponent::setSizeHeight(float height)
{
Size ownerSize = _owner->getContentSize();
ownerSize.height = height;
_owner->setContentSize(ownerSize);
Node* parent = this->getOwnerParent();
if (parent != nullptr)
{
2014-12-22 19:05:31 +08:00
const Size& parentSize = parent->getContentSize();
2014-12-22 11:20:03 +08:00
if (parentSize.height != 0)
_percentHeight = ownerSize.height / parentSize.height;
2014-10-17 19:13:37 +08:00
else
2014-12-22 11:20:03 +08:00
_percentHeight = 0;
this->refreshVerticalMargin();
2014-10-09 18:28:09 +08:00
}
}
2014-12-22 19:05:31 +08:00
float LayoutComponent::getPercentHeight()const
2014-10-17 19:13:37 +08:00
{
2014-12-22 11:20:03 +08:00
return _percentHeight;
2014-10-17 19:13:37 +08:00
}
2014-12-22 11:20:03 +08:00
void LayoutComponent::setPercentHeight(float percentHeight)
2014-10-17 19:13:37 +08:00
{
2014-12-22 11:20:03 +08:00
_percentHeight = percentHeight;
Node* parent = this->getOwnerParent();
if (parent != nullptr)
{
Size ownerSize = _owner->getContentSize();
ownerSize.height = parent->getContentSize().height * _percentHeight;
_owner->setContentSize(ownerSize);
this->refreshVerticalMargin();
}
2014-10-17 19:13:37 +08:00
}
2014-12-22 19:05:31 +08:00
bool LayoutComponent::isUsingStretchWidth()const
2014-10-09 18:28:09 +08:00
{
2014-12-22 11:20:03 +08:00
return _usingStretchWidth;
}
void LayoutComponent::setStretchWidthEnabled(bool isUsed)
{
_usingStretchWidth = isUsed;
if (_usingStretchWidth)
{
_usingPercentWidth = false;
}
}
2014-12-22 19:05:31 +08:00
bool LayoutComponent::isUsingStretchHeight()const
2014-12-22 11:20:03 +08:00
{
return _usingStretchHeight;
}
void LayoutComponent::setStretchHeightEnabled(bool isUsed)
{
_usingStretchHeight = isUsed;
if (_usingStretchHeight)
{
_usingPercentHeight = false;
}
2014-10-09 18:28:09 +08:00
}
2014-10-17 19:13:37 +08:00
2014-12-22 11:20:03 +08:00
void LayoutComponent::refreshLayout()
2014-10-17 19:13:37 +08:00
{
2014-12-22 11:20:03 +08:00
Node* parent = this->getOwnerParent();
if (parent == nullptr)
return;
2014-12-22 19:05:31 +08:00
const Size& parentSize = parent->getContentSize();
const Point& ownerAnchor = _owner->getAnchorPoint();
2014-12-22 11:20:03 +08:00
Size ownerSize = _owner->getContentSize();
Point ownerPosition = _owner->getPosition();
switch (this->_horizontalEage)
{
case HorizontalEage::None:
if (_usingStretchWidth)
{
ownerSize.width = parentSize.width * _percentWidth;
ownerPosition.x = _leftMargin + ownerAnchor.x * ownerSize.width;
}
else
{
if (_usingPositionPercentX)
ownerPosition.x = parentSize.width * _positionPercentX;
if (_usingPercentWidth)
ownerSize.width = parentSize.width * _percentWidth;
}
break;
case HorizontalEage::Left:
if (_usingPercentWidth || _usingStretchWidth)
ownerSize.width = parentSize.width * _percentWidth;
ownerPosition.x = _leftMargin + ownerAnchor.x * ownerSize.width;
break;
case HorizontalEage::Right:
if (_usingPercentWidth || _usingStretchWidth)
ownerSize.width = parentSize.width * _percentWidth;
ownerPosition.x = parentSize.width - (_rightMargin + (1 - ownerAnchor.x) * ownerSize.width);
break;
case HorizontalEage::Center:
if (_usingPercentWidth || _usingStretchWidth)
{
ownerSize.width = parentSize.width - _leftMargin - _rightMargin;
ownerPosition.x = _leftMargin + ownerAnchor.x * ownerSize.width;
}
else
ownerPosition.x = parentSize.width * _positionPercentX;
break;
default:
break;
}
switch (this->_verticalEage)
2014-10-17 19:13:37 +08:00
{
2014-12-22 11:20:03 +08:00
case VerticalEage::None:
if (_usingStretchHeight)
{
ownerSize.height = parentSize.height * _percentHeight;
ownerPosition.y = _buttomMargin + ownerAnchor.y * ownerSize.height;
}
else
{
if (_usingPositionPercentY)
ownerPosition.y = parentSize.height * _positionPercentY;
if (_usingPercentHeight)
ownerSize.height = parentSize.height * _percentHeight;
}
break;
2014-12-22 14:51:50 +08:00
case VerticalEage::Bottom:
2014-12-22 11:20:03 +08:00
if (_usingPercentHeight || _usingStretchHeight)
ownerSize.height = parentSize.height * _percentHeight;
ownerPosition.y = _buttomMargin + ownerAnchor.y * ownerSize.height;
2014-10-17 19:13:37 +08:00
break;
2014-12-22 11:20:03 +08:00
case VerticalEage::Top:
if (_usingPercentHeight || _usingStretchHeight)
ownerSize.height = parentSize.height * _percentHeight;
ownerPosition.y = parentSize.height - (_topMargin + (1 - ownerAnchor.y) * ownerSize.height);
2014-10-17 19:13:37 +08:00
break;
2014-12-22 11:20:03 +08:00
case VerticalEage::Center:
if (_usingPercentHeight || _usingStretchHeight)
{
ownerSize.height = parentSize.height - _topMargin - _buttomMargin;
ownerPosition.y = _buttomMargin + ownerAnchor.y * ownerSize.height;
}
else
ownerPosition.y = parentSize.height* _positionPercentY;
2014-10-17 19:13:37 +08:00
break;
default:
break;
}
2014-12-22 11:20:03 +08:00
_owner->setPosition(ownerPosition);
_owner->setContentSize(ownerSize);
ui::Helper::doLayout(_owner);
}
void LayoutComponent::setActiveEnable(bool enable)
{
_actived = enable;
2014-10-17 19:13:37 +08:00
}
2014-10-09 18:28:09 +08:00
}
NS_CC_END