mirror of https://github.com/axmolengine/axmol.git
Add `onItemListChanged()`method.
This commit is contained in:
parent
0ee09fcfce
commit
4dbfb79110
|
@ -100,6 +100,11 @@ void ListView::handleReleaseLogic(Touch *touch)
|
|||
}
|
||||
}
|
||||
|
||||
void ListView::onItemListChanged()
|
||||
{
|
||||
_outOfBoundaryAmountDirty = true;
|
||||
}
|
||||
|
||||
void ListView::updateInnerContainerSize()
|
||||
{
|
||||
switch (_direction)
|
||||
|
@ -263,7 +268,7 @@ void ListView::addChild(cocos2d::Node *child, int zOrder, int tag)
|
|||
if (nullptr != widget)
|
||||
{
|
||||
_items.pushBack(widget);
|
||||
_outOfBoundaryAmountDirty = true;
|
||||
onItemListChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,7 +290,7 @@ void ListView::addChild(Node* child, int zOrder, const std::string &name)
|
|||
if (nullptr != widget)
|
||||
{
|
||||
_items.pushBack(widget);
|
||||
_outOfBoundaryAmountDirty = true;
|
||||
onItemListChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,7 +312,7 @@ void ListView::removeChild(cocos2d::Node *child, bool cleaup)
|
|||
}
|
||||
}
|
||||
_items.eraseObject(widget);
|
||||
_outOfBoundaryAmountDirty = true;
|
||||
onItemListChanged();
|
||||
}
|
||||
|
||||
ScrollView::removeChild(child, cleaup);
|
||||
|
@ -321,9 +326,9 @@ void ListView::removeAllChildren()
|
|||
void ListView::removeAllChildrenWithCleanup(bool cleanup)
|
||||
{
|
||||
ScrollView::removeAllChildrenWithCleanup(cleanup);
|
||||
_items.clear();
|
||||
_curSelectedIndex = -1;
|
||||
_outOfBoundaryAmountDirty = true;
|
||||
_items.clear();
|
||||
onItemListChanged();
|
||||
}
|
||||
|
||||
void ListView::insertCustomItem(Widget* item, ssize_t index)
|
||||
|
@ -336,8 +341,8 @@ void ListView::insertCustomItem(Widget* item, ssize_t index)
|
|||
}
|
||||
}
|
||||
_items.insert(index, item);
|
||||
_outOfBoundaryAmountDirty = true;
|
||||
|
||||
onItemListChanged();
|
||||
|
||||
ScrollView::addChild(item);
|
||||
|
||||
remedyLayoutParameter(item);
|
||||
|
|
|
@ -387,7 +387,9 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
|
||||
protected:
|
||||
virtual void handleReleaseLogic(Touch *touch) override;
|
||||
|
||||
|
||||
virtual void onItemListChanged();
|
||||
|
||||
void updateInnerContainerSize();
|
||||
void remedyLayoutParameter(Widget* item);
|
||||
void remedyVerticalLayoutParameter(LinearLayoutParameter* layoutParameter, ssize_t itemIndex);
|
||||
|
|
|
@ -137,6 +137,13 @@ bool PageView::isUsingCustomScrollThreshold()const
|
|||
return _usingCustomScrollThreshold;
|
||||
}
|
||||
|
||||
void PageView::onItemListChanged()
|
||||
{
|
||||
ListView::onItemListChanged();
|
||||
ssize_t index = getIndex(getCenterItemInCurrentView());
|
||||
_indicator->reset(_items.size(), index);
|
||||
}
|
||||
|
||||
void PageView::onSizeChanged()
|
||||
{
|
||||
ListView::onSizeChanged();
|
||||
|
|
|
@ -256,6 +256,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
protected:
|
||||
void pageTurningEvent();
|
||||
|
||||
virtual void onItemListChanged() override;
|
||||
virtual void onSizeChanged() override;
|
||||
virtual void handleReleaseLogic(Touch *touch) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue