optimize layout

This commit is contained in:
CaiWenzhi 2013-11-08 23:26:44 +08:00
parent 8a5084effa
commit a0f794b7df
3 changed files with 13 additions and 3 deletions

View File

@ -129,7 +129,17 @@ void UILayout::setClippingEnabled(bool able)
void UILayout::onSizeChanged()
{
DYNAMIC_CAST_CLIPPINGLAYER->setClippingSize(_size);
doLayout();
if (strcmp(getDescription(), "Layout") == 0)
{
cocos2d::ccArray* arrayChildren = _children->data;
int length = arrayChildren->num;
for (int i=0; i<length; ++i)
{
UIWidget* child = (UIWidget*)arrayChildren->arr[i];
child->updateSizeAndPosition();
}
doLayout();
}
if (_backGroundImage)
{
_backGroundImage->setPosition(cocos2d::Point(_size.width/2.0f, _size.height/2.0f));

View File

@ -381,7 +381,6 @@ void UIListView::refreshView()
remedyLayoutParameter(item);
}
updateInnerContainerSize();
doLayout();
}
void UIListView::addEventListenerListView(cocos2d::Object *target, SEL_ListViewEvent selector)

View File

@ -881,6 +881,8 @@ public:
virtual void onEnter();
virtual void onExit();
void updateSizeAndPosition();
virtual Object* getUserObject() { return _userObject; }
/**
* @js NA
@ -926,7 +928,6 @@ protected:
void cancelUpEvent();
void longClickEvent();
void updateAnchorPoint();
void updateSizeAndPosition();
void copyProperties(UIWidget* model);
virtual UIWidget* createCloneInstance();
virtual void copySpecialProperties(UIWidget* model);