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()
|
void ListView::updateInnerContainerSize()
|
||||||
{
|
{
|
||||||
switch (_direction)
|
switch (_direction)
|
||||||
|
@ -263,7 +268,7 @@ void ListView::addChild(cocos2d::Node *child, int zOrder, int tag)
|
||||||
if (nullptr != widget)
|
if (nullptr != widget)
|
||||||
{
|
{
|
||||||
_items.pushBack(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)
|
if (nullptr != widget)
|
||||||
{
|
{
|
||||||
_items.pushBack(widget);
|
_items.pushBack(widget);
|
||||||
_outOfBoundaryAmountDirty = true;
|
onItemListChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +312,7 @@ void ListView::removeChild(cocos2d::Node *child, bool cleaup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_items.eraseObject(widget);
|
_items.eraseObject(widget);
|
||||||
_outOfBoundaryAmountDirty = true;
|
onItemListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollView::removeChild(child, cleaup);
|
ScrollView::removeChild(child, cleaup);
|
||||||
|
@ -321,9 +326,9 @@ void ListView::removeAllChildren()
|
||||||
void ListView::removeAllChildrenWithCleanup(bool cleanup)
|
void ListView::removeAllChildrenWithCleanup(bool cleanup)
|
||||||
{
|
{
|
||||||
ScrollView::removeAllChildrenWithCleanup(cleanup);
|
ScrollView::removeAllChildrenWithCleanup(cleanup);
|
||||||
_items.clear();
|
|
||||||
_curSelectedIndex = -1;
|
_curSelectedIndex = -1;
|
||||||
_outOfBoundaryAmountDirty = true;
|
_items.clear();
|
||||||
|
onItemListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListView::insertCustomItem(Widget* item, ssize_t index)
|
void ListView::insertCustomItem(Widget* item, ssize_t index)
|
||||||
|
@ -336,7 +341,7 @@ void ListView::insertCustomItem(Widget* item, ssize_t index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_items.insert(index, item);
|
_items.insert(index, item);
|
||||||
_outOfBoundaryAmountDirty = true;
|
onItemListChanged();
|
||||||
|
|
||||||
ScrollView::addChild(item);
|
ScrollView::addChild(item);
|
||||||
|
|
||||||
|
|
|
@ -388,6 +388,8 @@ CC_CONSTRUCTOR_ACCESS:
|
||||||
protected:
|
protected:
|
||||||
virtual void handleReleaseLogic(Touch *touch) override;
|
virtual void handleReleaseLogic(Touch *touch) override;
|
||||||
|
|
||||||
|
virtual void onItemListChanged();
|
||||||
|
|
||||||
void updateInnerContainerSize();
|
void updateInnerContainerSize();
|
||||||
void remedyLayoutParameter(Widget* item);
|
void remedyLayoutParameter(Widget* item);
|
||||||
void remedyVerticalLayoutParameter(LinearLayoutParameter* layoutParameter, ssize_t itemIndex);
|
void remedyVerticalLayoutParameter(LinearLayoutParameter* layoutParameter, ssize_t itemIndex);
|
||||||
|
|
|
@ -137,6 +137,13 @@ bool PageView::isUsingCustomScrollThreshold()const
|
||||||
return _usingCustomScrollThreshold;
|
return _usingCustomScrollThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PageView::onItemListChanged()
|
||||||
|
{
|
||||||
|
ListView::onItemListChanged();
|
||||||
|
ssize_t index = getIndex(getCenterItemInCurrentView());
|
||||||
|
_indicator->reset(_items.size(), index);
|
||||||
|
}
|
||||||
|
|
||||||
void PageView::onSizeChanged()
|
void PageView::onSizeChanged()
|
||||||
{
|
{
|
||||||
ListView::onSizeChanged();
|
ListView::onSizeChanged();
|
||||||
|
|
|
@ -256,6 +256,7 @@ CC_CONSTRUCTOR_ACCESS:
|
||||||
protected:
|
protected:
|
||||||
void pageTurningEvent();
|
void pageTurningEvent();
|
||||||
|
|
||||||
|
virtual void onItemListChanged() override;
|
||||||
virtual void onSizeChanged() override;
|
virtual void onSizeChanged() override;
|
||||||
virtual void handleReleaseLogic(Touch *touch) override;
|
virtual void handleReleaseLogic(Touch *touch) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue