From 8d8215b148e9fd7bba7769390a3dd6ec19d93ca2 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 22 Dec 2014 09:55:29 +0800 Subject: [PATCH] override function for listview --- cocos/ui/UILayout.h | 2 +- cocos/ui/UIListView.cpp | 11 +++++++++++ cocos/ui/UIListView.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index 0ce92d964b..ab21dff859 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -270,7 +270,7 @@ public: /** * force refresh widget layout */ - void forceDoLayout(); + virtual void forceDoLayout(); /** * request to refresh widget layout diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index 23e7d9a610..eb95f64907 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -453,6 +453,17 @@ void ListView::refreshView() updateInnerContainerSize(); } +void ListView::forceDoLayout() +{ + if (_refreshViewDirty) + { + refreshView(); + _refreshViewDirty = false; + } + + this->_innerContainer->forceDoLayout(); +} + void ListView::doLayout() { Layout::doLayout(); diff --git a/cocos/ui/UIListView.h b/cocos/ui/UIListView.h index 65856ff1f7..109c6ef973 100644 --- a/cocos/ui/UIListView.h +++ b/cocos/ui/UIListView.h @@ -162,6 +162,8 @@ public: float getItemsMargin()const; + virtual void forceDoLayout()override; + virtual void doLayout() override; virtual void addChild(Node* child)override;