diff --git a/cocos/scripting/js-bindings/script/ccui/jsb_ccui_deprecated.js b/cocos/scripting/js-bindings/script/ccui/jsb_ccui_deprecated.js index 5144d54931..67356c4d60 100644 --- a/cocos/scripting/js-bindings/script/ccui/jsb_ccui_deprecated.js +++ b/cocos/scripting/js-bindings/script/ccui/jsb_ccui_deprecated.js @@ -1,3 +1,5 @@ +/*global ccui */ + /* * Copyright (c) 2013-2014 Chukong Technologies Inc. * @@ -25,15 +27,69 @@ var cc = cc || {}; (function() { + var logW = function(oldName, newName) { + cc.log("\n********** \n"+oldName +" was deprecated, please use "+ newName +" instead.\n**********"); + }; - ccui.Text.prototype.setText = function(text){ + ccui.Text.prototype.setText = function(text) { logW("ccui.Text.setText", "ccui.Text.setString"); this.setString(text); }; - ccui.Text.prototype.getStringValue = function(){ + ccui.Text.prototype.getStringValue = function() { logW("ccui.Text.getStringValue", "ccui.Text.getString"); return this.getString(); }; + ccui.PageView.prototype.getCurPageIndex = function() { + logW("ccui.PageView.getCurPageIndex", "ccui.PageView.getCurrentPageIndex"); + return this.getCurrentPageIndex(); + }; + + ccui.PageView.prototype.addWidgetToPage = function(widget, pageIndx) { + logW("ccui.PageView.addWidgetToPage", "ccui.PageView.insertPage"); + return this.insertPage(widget, pageIndx); + }; + + ccui.PageView.prototype.setCurPageIndex = function(index) { + logW("ccui.PageView.setCurPageIndex", "ccui.PageView.setCurrentPageIndex"); + return this.setCurrentPageIndex(index); + }; + + ccui.PageView.prototype.getPages = function() { + logW("ccui.PageView.getPages", "ccui.PageView.getItems"); + return this.getItems(); + }; + + ccui.PageView.prototype.getPage = function(index) { + logW("ccui.PageView.getPage", "ccui.PageView.getItem"); + return this.getItem(index); + }; + + ccui.PageView.prototype.setCustomScrollThreshold = function() { + cc.log("Since v3.9, this method has no effect."); + }; + + ccui.PageView.prototype.getCustomScrollThreshold = function() { + cc.log("Since v3.9, this method has no effect."); + }; + + ccui.PageView.prototype.setUsingCustomScrollThreshold = function() { + cc.log("Since v3.9, this method has no effect."); + }; + + ccui.PageView.prototype.isUsingCustomScrollThreshold = function() { + cc.log("Since v3.9, this method has no effect."); + }; + + ccui.ListView.prototype.requestRefreshView = function() { + logW("ccui.ListView.requestRefreshView", "ccui.ListView.forceDoLayout"); + this.forceDoLayout(); + }; + + ccui.ListView.prototype.refreshView = function() { + logW("ccui.ListView.refreshView", "ccui.ListView.forceDoLayout"); + this.forceDoLayout(); + }; + })(); diff --git a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp index af0771301b..9c7e005281 100644 --- a/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_ui_manual.cpp @@ -62,16 +62,16 @@ static int lua_cocos2dx_Widget_addTouchEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Widget_addTouchEventListener'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Widget_addTouchEventListener'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; @@ -183,16 +183,16 @@ static int lua_cocos2dx_CheckBox_addEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_CheckBox_addEventListener'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_CheckBox_addEventListener'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; if (1 == argc) @@ -379,16 +379,16 @@ static int lua_cocos2dx_Slider_addEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Slider_addEventListener'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Slider_addEventListener'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; if (1 == argc) @@ -441,16 +441,16 @@ static int lua_cocos2dx_TextField_addEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TextField_addEventListener'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TextField_addEventListener'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; if (1 == argc) @@ -503,16 +503,16 @@ static int lua_cocos2dx_PageView_addEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_PageView_addEventListener'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_PageView_addEventListener'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; if (1 == argc) @@ -524,10 +524,10 @@ static int lua_cocos2dx_PageView_addEventListener(lua_State* L) } #endif LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - self->addEventListener([=](cocos2d::Ref* ref,PageView::EventType eventType){ + auto pageViewHandler = [=](cocos2d::Ref* ref,PageView::EventType eventType){ handleUIEvent(handler, ref, (int)eventType); - }); + }; + self->addEventListener((PageView::ccPageViewCallback)pageViewHandler); ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler); return 0; @@ -565,16 +565,16 @@ static int lua_cocos2dx_ScrollView_addEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ScrollView_addEventListener'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ScrollView_addEventListener'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; if (1 == argc) @@ -627,16 +627,16 @@ static int lua_cocos2dx_ListView_addEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ListView_addEventListener'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ListView_addEventListener'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; if (1 == argc) @@ -679,16 +679,16 @@ static int lua_cocos2dx_ListView_addScrollViewEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ListView_addScrollViewEventListener'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ListView_addScrollViewEventListener'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; if (1 == argc) @@ -743,16 +743,16 @@ static int lua_cocos2dx_LayoutParameter_setMargin(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_setMargin'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_setMargin'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; @@ -811,16 +811,16 @@ static int lua_cocos2dx_LayoutParameter_getMargin(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_getMargin'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_getMargin'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; @@ -883,16 +883,16 @@ static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.EditBox",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.EditBox",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_EditBox_registerScriptEditBoxHandler'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; @@ -932,16 +932,16 @@ static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.EditBox",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.EditBox",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'\n", NULL); - return 0; - } + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler'\n", NULL); + return 0; + } #endif argc = lua_gettop(L) - 1; @@ -1072,9 +1072,9 @@ static int tolua_cocos2dx_EventListenerFocus_clone(lua_State* L) self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'tolua_cocos2dx_EventListenerFocus_clone'\n", nullptr); - return 0; - } + tolua_error(L,"invalid 'self' in function 'tolua_cocos2dx_EventListenerFocus_clone'\n", nullptr); + return 0; + } #endif argc = lua_gettop(L) - 1; @@ -1120,9 +1120,9 @@ static int tolua_cocos2dx_EventListenerFocus_registerScriptHandler(lua_State* L) self = static_cast(tolua_tousertype(L,1,0)); #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'tolua_cocos2dx_EventListenerFocus_registerScriptHandler'\n", nullptr); - return 0; - } + tolua_error(L,"invalid 'self' in function 'tolua_cocos2dx_EventListenerFocus_registerScriptHandler'\n", nullptr); + return 0; + } #endif argc = lua_gettop(L) - 1; @@ -1183,8 +1183,8 @@ int register_ui_moudle(lua_State* L) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) register_all_cocos2dx_experimental_video(L); register_all_cocos2dx_experimental_video_manual(L); - register_all_cocos2dx_experimental_webview(L); - register_all_cocos2dx_experimental_webview_manual(L); + register_all_cocos2dx_experimental_webview(L); + register_all_cocos2dx_experimental_webview_manual(L); #endif extendEventListenerFocusEvent(L); } diff --git a/cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua b/cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua index 52c5e2e851..97b1445812 100644 --- a/cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua +++ b/cocos/scripting/lua-bindings/script/ui/DeprecatedUIFunc.lua @@ -162,6 +162,56 @@ function UIPageViewDeprecated.addEventListenerPageView(self,handler) return self:addEventListener(handler) end ccui.PageView.addEventListenerPageView = UIPageViewDeprecated.addEventListenerPageView + +function UIPageViewDeprecated.addWidgetToPage(self, widget, pageIdx) + deprecatedTip("ccui.PageView:addWidgetToPage","ccui.PageView:insertPage") + return self:insertPage(widget, pageIdx) +end +ccui.PageView.addWidgetToPage = UIPageViewDeprecated.addWidgetToPage + +function UIPageViewDeprecated.getCurPageIndex(self) + deprecatedTip("ccui.PageView:getCurPageIndex","ccui.PageView:getCurrentPageIndex") + return self:getCurrentPageIndex() +end +ccui.PageView.getCurPageIndex = UIPageViewDeprecated.getCurPageIndex + +function UIPageViewDeprecated.setCurPageIndex(self, index) + deprecatedTip("ccui.PageView:setCurPageIndex","ccui.PageView:setCurrentPageIndex") + return self:setCurrentPageIndex(index) +end +ccui.PageView.setCurPageIndex = UIPageViewDeprecated.setCurPageIndex + +function UIPageViewDeprecated.getPages(self) + deprecatedTip("ccui.PageView:getPages","ccui.PageView:getItems") + return self:getItems() +end +ccui.PageView.getPages = UIPageViewDeprecated.getPages + +function UIPageViewDeprecated.getPage(self, index) + deprecatedTip("ccui.PageView:getPage","ccui.PageView:getItem") + return self:getItem(index) +end +ccui.PageView.getPage = UIPageViewDeprecated.getPage + +function UIPageViewDeprecated.setCustomScrollThreshold(self) + print("Since v3.9, this method has no effect.") +end +ccui.PageView.setCustomScrollThreshold = UIPageViewDeprecated.setCustomScrollThreshold + +function UIPageViewDeprecated.getCustomScrollThreshold(self) + print("Since v3.9, this method has no effect.") +end +ccui.PageView.getCustomScrollThreshold = UIPageViewDeprecated.getCustomScrollThreshold + +function UIPageViewDeprecated.isUsingCustomScrollThreshold(self) + print("Since v3.9, this method has no effect.") +end +ccui.PageView.isUsingCustomScrollThreshold = UIPageViewDeprecated.isUsingCustomScrollThreshold + +function UIPageViewDeprecated.setUsingCustomScrollThreshold(self) + print("Since v3.9, this method has no effect.") +end +ccui.PageView.setUsingCustomScrollThreshold = UIPageViewDeprecated.setUsingCustomScrollThreshold --functions of ccui.PageView will be deprecated end --functions of ccui.ScrollView will be deprecated begin @@ -180,4 +230,16 @@ function UIListViewDeprecated.addEventListenerListView(self,handler) return self:addEventListener(handler) end ccui.ListView.addEventListenerListView = UIListViewDeprecated.addEventListenerListView + +function UIListViewDeprecated.requestRefreshView(self) + deprecatedTip("ccui.ListView:requestRefreshView","ccui.ListView:forceDoLayout") + return self:forceDoLayout() +end +ccui.ListView.requestRefreshView = UIListViewDeprecated.requestRefreshView + +function UIListViewDeprecated.refreshView(self) + deprecatedTip("ccui.ListView:refreshView","ccui.ListView:refreshView") + return self:forceDoLayout() +end +ccui.ListView.refreshView = UIListViewDeprecated.refreshView --functions of ccui.ListView will be deprecated end diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 3fb95e8093..183c6354b1 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013-2014 Chukong Technologies Inc. +Copyright (c) 2013-2016 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -254,7 +254,7 @@ void PageView::handleReleaseLogic(Touch *touch) { --_currentPageIndex; } - _currentPageIndex = MIN(_currentPageIndex, _items.size()); + _currentPageIndex = MIN(_currentPageIndex, _items.size() - 1); _currentPageIndex = MAX(_currentPageIndex, 0); scrollToItem(_currentPageIndex); } @@ -288,6 +288,12 @@ void PageView::addEventListenerPageView(Ref *target, SEL_PageViewEvent selector) void PageView::addEventListener(const ccPageViewCallback& callback) { _eventCallback = callback; + ccScrollViewCallback scrollViewCallback = [=](Ref* ref, ScrollView::EventType type) -> void{ + if (type == ScrollView::EventType::AUTOSCROLL_ENDED) { + callback(ref, PageView::EventType::TURNING); + } + }; + this->addEventListener(scrollViewCallback); } ssize_t PageView::getCurPageIndex() const diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 49d0906c6a..246f99100c 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013-2014 Chukong Technologies Inc. +Copyright (c) 2013-2016 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -238,7 +238,7 @@ public: * @param callback A page turning callback. */ void addEventListener(const ccPageViewCallback& callback); - + using ScrollView::addEventListener; //override methods virtual std::string getDescription() const override; diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 7a248e739c..13faed712c 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -535,6 +535,7 @@ void ScrollView::processAutoScrolling(float deltaTime) if(reachedEnd) { _autoScrolling = false; + dispatchEvent(SCROLLVIEW_EVENT_AUTOSCROLL_ENDED, EventType::AUTOSCROLL_ENDED); } moveInnerContainer(newPosition - getInnerContainerPosition(), reachedEnd); diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 2858f36fa3..16f3b55572 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -55,7 +55,8 @@ typedef enum SCROLLVIEW_EVENT_BOUNCE_TOP, SCROLLVIEW_EVENT_BOUNCE_BOTTOM, SCROLLVIEW_EVENT_BOUNCE_LEFT, - SCROLLVIEW_EVENT_BOUNCE_RIGHT + SCROLLVIEW_EVENT_BOUNCE_RIGHT, + SCROLLVIEW_EVENT_AUTOSCROLL_ENDED }ScrollviewEventType; /** @@ -100,7 +101,8 @@ public: BOUNCE_BOTTOM, BOUNCE_LEFT, BOUNCE_RIGHT, - CONTAINER_MOVED + CONTAINER_MOVED, + AUTOSCROLL_ENDED }; /** diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index 7306c0d9a8..f720f680fa 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -83,7 +83,7 @@ bool UIPageViewTest::init() pageView->removeItem(0); pageView->scrollToItem(pageCount - 2); - pageView->addEventListener(CC_CALLBACK_2(UIPageViewTest::pageViewEvent, this)); + pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewTest::pageViewEvent, this)); _uiLayer->addChild(pageView); @@ -187,7 +187,7 @@ bool UIPageViewButtonTest::init() pageView->removeItem(0); - pageView->addEventListener(CC_CALLBACK_2(UIPageViewButtonTest::pageViewEvent, this)); + pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewButtonTest::pageViewEvent, this)); _uiLayer->addChild(pageView); @@ -293,7 +293,7 @@ bool UIPageViewTouchPropagationTest::init() pageView->insertCustomItem(outerBox, i); } - pageView->addEventListener(CC_CALLBACK_2(UIPageViewTouchPropagationTest::pageViewEvent, this)); + pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewTouchPropagationTest::pageViewEvent, this)); pageView->setName("pageView"); pageView->addTouchEventListener([](Ref* sender, Widget::TouchEventType type){ if (type == Widget::TouchEventType::BEGAN) @@ -493,7 +493,7 @@ bool UIPageViewDynamicAddAndRemoveTest::init() pageView->insertCustomItem(outerBox, i); } - pageView->addEventListener(CC_CALLBACK_2(UIPageViewDynamicAddAndRemoveTest::pageViewEvent, this)); + pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewDynamicAddAndRemoveTest::pageViewEvent, this)); pageView->setName("pageView"); _uiLayer->addChild(pageView); @@ -777,7 +777,7 @@ bool UIPageViewVerticalTest::init() pageView->insertCustomItem(layout, i); } - pageView->addEventListener(CC_CALLBACK_2(UIPageViewVerticalTest::pageViewEvent, this)); + pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewVerticalTest::pageViewEvent, this)); _uiLayer->addChild(pageView); @@ -936,7 +936,7 @@ bool UIPageViewChildSizeTest::init() pageView->insertCustomItem(imageView, i); } - pageView->addEventListener(CC_CALLBACK_2(UIPageViewChildSizeTest::pageViewEvent, this)); + pageView->addEventListener((PageView::ccPageViewCallback)CC_CALLBACK_2(UIPageViewChildSizeTest::pageViewEvent, this)); _uiLayer->addChild(pageView); diff --git a/tests/js-tests/src/GUITest/UIListViewTest/UIListViewTest.js b/tests/js-tests/src/GUITest/UIListViewTest/UIListViewTest.js index d80f6cc9b1..363a36e1dc 100644 --- a/tests/js-tests/src/GUITest/UIListViewTest/UIListViewTest.js +++ b/tests/js-tests/src/GUITest/UIListViewTest/UIListViewTest.js @@ -136,6 +136,7 @@ var UIListViewTest_Vertical = UIMainLayer.extend({ // set all items layout gravity listView.setGravity(ccui.ListView.GRAVITY_CENTER_VERTICAL); + listView.requestRefreshView(); return true; } @@ -334,4 +335,4 @@ var UIListViewTest_TouchIntercept = UIMainLayer.extend({ } return false; } -}); \ No newline at end of file +}); diff --git a/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js b/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js index 7876a75fd7..c0bf09af1c 100644 --- a/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js +++ b/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js @@ -66,9 +66,14 @@ var UIPageViewTest = UIMainLayer.extend({ text.y = layoutRect.height / 2; layout.addChild(text); - pageView.addPage(layout); + pageView.addWidgetToPage(layout, i); } + pageView.setCurPageIndex(1); pageView.addEventListener(this.pageViewEvent, this); + + //for test purpose only + cc.log(pageView.getPages()); + cc.log(pageView.getPage(0)); this._mainNode.addChild(pageView); return true; @@ -580,4 +585,4 @@ var UIPageViewDisableTouchTest = UIMainLayer.extend({ } return false; } -}); \ No newline at end of file +}); diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua index 114cd78764..86f54144b6 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -1748,13 +1748,16 @@ add_new_testcase(function() label:setPosition(cc.p(layout:getContentSize().width / 2, layout:getContentSize().height / 2)) layout:addChild(label) - pageView:addPage(layout) + pageView:addWidgetToPage(layout, i-1) end + pageView:setCurPageIndex(1) local function pageViewEvent(sender, eventType) if eventType == ccui.PageViewEventType.turning then local pageInfo = string.format("page %d " , pageView:getCurPageIndex() + 1) + local pages = pageView:getPages() + print("total items " .. table.getn(pages)) self._displayValueLabel:setString(pageInfo) end end