From 29615f7e26c5d010f5fc9a56e85d014b9a3ed153 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Fri, 11 Apr 2014 11:36:23 +0800 Subject: [PATCH 01/40] closed #4727, Support run sample projects with console. --- .gitignore | 6 ++++++ tools/cocos2d-console | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1a4ce31489..593d846023 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,9 @@ CMakeCache.txt CMakeFiles Makefile cmake_install.cmake + +# Ignore files generated by console +build/build/ +cocos/scripting/lua-bindings/proj.ios_mac/build/ +tests/*/runtime/ +tests/*/publish/ diff --git a/tools/cocos2d-console b/tools/cocos2d-console index ae27f3bafb..a16db09013 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit ae27f3bafbbdda9c32e5b89c79183183486e1299 +Subproject commit a16db09013d8eb92f2eee099b873f38167912375 From a9ccb812ed27a5b863c3054b9e9ca9ecb0c7d9c4 Mon Sep 17 00:00:00 2001 From: Anton Sokolchenko Date: Sat, 12 Apr 2014 18:47:00 +0300 Subject: [PATCH 02/40] Fix memory leak --- cocos/2d/platform/CCImage.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos/2d/platform/CCImage.cpp b/cocos/2d/platform/CCImage.cpp index a502a5b815..b9ef38f2d6 100644 --- a/cocos/2d/platform/CCImage.cpp +++ b/cocos/2d/platform/CCImage.cpp @@ -804,7 +804,14 @@ bool Image::initWithJpgData(const unsigned char * data, ssize_t dataLen) _dataLen = cinfo.output_width*cinfo.output_height*cinfo.output_components; _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); - CC_BREAK_IF(! _data); + if(!_data) + { + if (row_pointers != nullptr) + { + free(row_pointers); + } + break; + } /* now actually read the jpeg into the raw buffer */ /* read one scan line at a time */ From 65cf2e125676d0d4fd6991459cb9c253b99c5d01 Mon Sep 17 00:00:00 2001 From: Anton Sokolchenko Date: Sun, 13 Apr 2014 01:13:58 +0300 Subject: [PATCH 03/40] Update CCImage.cpp --- cocos/2d/platform/CCImage.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cocos/2d/platform/CCImage.cpp b/cocos/2d/platform/CCImage.cpp index b9ef38f2d6..0b6e21874e 100644 --- a/cocos/2d/platform/CCImage.cpp +++ b/cocos/2d/platform/CCImage.cpp @@ -804,14 +804,7 @@ bool Image::initWithJpgData(const unsigned char * data, ssize_t dataLen) _dataLen = cinfo.output_width*cinfo.output_height*cinfo.output_components; _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); - if(!_data) - { - if (row_pointers != nullptr) - { - free(row_pointers); - } - break; - } + CC_BREAK_IF(! _data); /* now actually read the jpeg into the raw buffer */ /* read one scan line at a time */ @@ -949,7 +942,14 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen) _dataLen = rowbytes * _height; _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); - CC_BREAK_IF(!_data); + if(!_data) + { + if (row_pointers != nullptr) + { + free(row_pointers); + } + break; + } for (unsigned short i = 0; i < _height; ++i) { @@ -964,7 +964,7 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen) if (row_pointers != nullptr) { free(row_pointers); - }; + } bRet = true; } while (0); @@ -2035,6 +2035,9 @@ bool Image::saveImageToPNG(const std::string& filePath, bool isToRGB) { fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); + + free(row_pointers); + row_pointers = nullptr; break; } From d361efacae0dde8f26aca96cc99f1cbe07b42eed Mon Sep 17 00:00:00 2001 From: cw Date: Tue, 15 Apr 2014 17:10:11 +0800 Subject: [PATCH 04/40] add update --- cocos/base/CCConsole.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index fc0c599990..8952aad09f 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -220,6 +220,7 @@ static void _log(const char *format, va_list args) OutputDebugStringW(wszBuf); WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), NULL, FALSE); printf("%s", buf); + fflush(stdout); #else // Linux, Mac, iOS, etc fprintf(stdout, "cocos2d: %s", buf); From 4af7e14dc8ed9113a992d636b064e34e9e875b44 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 16 Apr 2014 10:32:43 +0800 Subject: [PATCH 05/40] Update the reference of submodule cocos2d-console. --- tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 8a8f2439b5..f5768df8fd 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 8a8f2439b5d649579c8a112e27f606eb7f3c21a0 +Subproject commit f5768df8fdd5a5a0069b9634aede93ce13e0c9d6 From e5cd2adaadb7e34020dd718808440ab932b3c658 Mon Sep 17 00:00:00 2001 From: lm Date: Wed, 16 Apr 2014 11:05:27 +0800 Subject: [PATCH 06/40] [Jenkins][ci skip] Add [ci emptytest] command --- tools/jenkins-scripts/job-comment-trigger.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/jenkins-scripts/job-comment-trigger.py b/tools/jenkins-scripts/job-comment-trigger.py index f133d27f4e..86932aa0db 100644 --- a/tools/jenkins-scripts/job-comment-trigger.py +++ b/tools/jenkins-scripts/job-comment-trigger.py @@ -24,13 +24,13 @@ def main(): #get comment body comment_body = comment['body'] print comment_body - pattern = re.compile("\[ci(\s+)rebuild\]", re.I) - result = pattern.search(comment_body) + #will check 'ci' comment + searchCI = re.search("\[ci.*\]", comment_body) - # will check console/console create + #will check console/console create searchConsole = re.search('\[console.*\]', comment_body) - if result is None and searchConsole is None: + if searchCI is None and searchConsole is None: print 'skip build for pull request #' + str(pr_num) return(0) @@ -80,11 +80,15 @@ def main(): traceback.print_exc() job_trigger_url = '' - if result: - job_trigger_url = os.environ['JOB_TRIGGER_URL'] + if searchCI: + ciOper = searchCI.group() + if('build' in ciOper): + job_trigger_url = os.environ['JOB_PULL_REQUEST_BUILD_TRIGGER_URL'] + if('emptytest' in ciOper): + job_trigger_url = os.environ['JOB_EMPTYTEST_TRIGGER_URL'] if searchConsole: consoleOper = searchConsole.group() - job_trigger_url = os.environ['JOB_CONSOLE_TEST_URL'] + job_trigger_url = os.environ['JOB_CONSOLE_TEST_TRIGGER_URL'] payload_forword['console'] = consoleOper print 'job_trigger_url is: ', job_trigger_url From 4605fb6d56c33652395d201934c10dbcb58e728c Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 16 Apr 2014 11:08:01 +0800 Subject: [PATCH 07/40] closed #4847, Find ant path from system first when ANT_ROOT is not set. --- setup.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/setup.py b/setup.py index 32f45a0b48..f374b2bb2f 100755 --- a/setup.py +++ b/setup.py @@ -521,6 +521,27 @@ class SetEnvVar(object): ret = self._force_update_unix_env(var_name, value) return ret + def _get_ant_path(self): + print(" ->Find command ant in system...") + ret = None + if not self._isWindows(): + import commands + state, result = commands.getstatusoutput("which ant") + if state == 0: + ret = os.path.dirname(result) + + if ret is not None: + print(" ->Path \"%s\" was found\n" % ret) + else: + print(" ->Command ant not found\n") + return ret + + def _find_value_from_sys(self, var_name): + if var_name == ANT_ROOT: + return self._get_ant_path() + else: + return None + def set_variable(self, var_name, value): print("->Check environment variable %s" % var_name) find_value = self._find_environment_variable(var_name) @@ -538,6 +559,10 @@ class SetEnvVar(object): # do nothing need_action = action_none else: + if not value: + # find the command path in system + value = self._find_value_from_sys(var_name) + if not value: value = self._get_input_value(var_name) From 3cbe02771d410a2711a75452d8cf755f54e9ada1 Mon Sep 17 00:00:00 2001 From: lm Date: Wed, 16 Apr 2014 13:47:40 +0800 Subject: [PATCH 08/40] [Jenkins][ci skip] Fix ftp home in upload_apk.sh --- tools/jenkins-scripts/upload_apk.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/jenkins-scripts/upload_apk.sh b/tools/jenkins-scripts/upload_apk.sh index 8ede92b688..e4ec09e5cf 100644 --- a/tools/jenkins-scripts/upload_apk.sh +++ b/tools/jenkins-scripts/upload_apk.sh @@ -3,7 +3,7 @@ localfile=$1 remotefile=$2 -sftp redmine@10.10.11.15 << EOF +sftp $FTP_HOME << EOF put $localfile $remotefile bye EOF From b78c89d39b5e1a97cc24bdade1886a67ca17c711 Mon Sep 17 00:00:00 2001 From: lm Date: Wed, 16 Apr 2014 14:19:13 +0800 Subject: [PATCH 09/40] [Jenkins][ci skip] Fix ftp home in upload_apk.sh --- tools/jenkins-scripts/upload_apk.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/jenkins-scripts/upload_apk.sh b/tools/jenkins-scripts/upload_apk.sh index e4ec09e5cf..759e4d7cb2 100644 --- a/tools/jenkins-scripts/upload_apk.sh +++ b/tools/jenkins-scripts/upload_apk.sh @@ -1,10 +1,9 @@ -#!/bin/sh - -localfile=$1 +#!/bin/sh +calfile=$1 remotefile=$2 sftp $FTP_HOME << EOF put $localfile $remotefile bye EOF -echo "upload finished" \ No newline at end of file +echo "upload finished" From edc4dde15fc4063746c8794470465cc64cf47254 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 16 Apr 2014 15:31:44 +0800 Subject: [PATCH 10/40] =?UTF-8?q?fix=20the=20bug=20that=20`EditBox`=20can?= =?UTF-8?q?=E2=80=99t=20response=20that=20=E2=80=98changed=E2=80=99,`ended?= =?UTF-8?q?`=20and=20=E2=80=98return=E2=80=99=20event=20for=20lua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp | 49 ++++++++----------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp index 421296dce0..abc3fdea21 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp @@ -234,35 +234,6 @@ void EditBoxImplWin::visit(void) { } -static void editBoxCallbackFunc(const char* pText, void* ctx) -{ - EditBoxImplWin* thiz = (EditBoxImplWin*)ctx; - thiz->setText(pText); - - if (thiz->getDelegate() != NULL) - { - thiz->getDelegate()->editBoxTextChanged(thiz->getEditBox(), thiz->getText()); - thiz->getDelegate()->editBoxEditingDidEnd(thiz->getEditBox()); - thiz->getDelegate()->editBoxReturn(thiz->getEditBox()); - } - - EditBox* pEditBox = thiz->getEditBox(); - if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) - { - CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox); - ScriptEvent event(kCommonEvent,(void*)&data); - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - memset(data.eventName,0,64*sizeof(char)); - strncpy(data.eventName,"ended",64); - event.data = (void*)&data; - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - memset(data.eventName,0,64*sizeof(char)); - strncpy(data.eventName,"return",64); - event.data = (void*)&data; - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - } -} - void EditBoxImplWin::openKeyboard() { if (_delegate != NULL) @@ -300,6 +271,26 @@ void EditBoxImplWin::openKeyboard() _delegate->editBoxEditingDidEnd(_editBox); _delegate->editBoxReturn(_editBox); } + +#if CC_ENABLE_SCRIPT_BINDING + if (nullptr != _editBox && 0 != _editBox->getScriptEditBoxHandler()) + { + CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed",_editBox); + ScriptEvent event(kCommonEvent,(void*)&data); + if (didChange) + { + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + } + memset(data.eventName,0,64*sizeof(char)); + strncpy(data.eventName,"ended",64); + event.data = (void*)&data; + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + memset(data.eventName,0,64*sizeof(char)); + strncpy(data.eventName,"return",64); + event.data = (void*)&data; + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + } +#endif // #if CC_ENABLE_SCRIPT_BINDING } void EditBoxImplWin::closeKeyboard() From 4c9fb311da2f5890934b232425738c0df86df16f Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 16 Apr 2014 16:04:33 +0800 Subject: [PATCH 11/40] Remove hard codes --- extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp index abc3fdea21..a2b8b801a4 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp @@ -281,12 +281,12 @@ void EditBoxImplWin::openKeyboard() { ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } - memset(data.eventName,0,64*sizeof(char)); - strncpy(data.eventName,"ended",64); + memset(data.eventName,0,sizeof(data.eventName)); + strncpy(data.eventName,"ended",sizeof(data.eventName)); event.data = (void*)&data; ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - memset(data.eventName,0,64*sizeof(char)); - strncpy(data.eventName,"return",64); + memset(data.eventName,0,sizeof(data.eventName)); + strncpy(data.eventName,"return",sizeof(data.eventName)); event.data = (void*)&data; ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } From a9a1e7cb2feacda0a55d0ec46dd5aacd2cf83009 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 16 Apr 2014 16:08:26 +0800 Subject: [PATCH 12/40] Remove hard codes --- extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp | 8 ++++---- extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm | 4 ++-- extensions/GUI/CCEditBox/CCEditBoxImplMac.mm | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp index 173c32b994..2a19344c7e 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp @@ -264,12 +264,12 @@ static void editBoxCallbackFunc(const char* pText, void* ctx) CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox); ScriptEvent event(kCommonEvent,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - memset(data.eventName,0,64*sizeof(char)); - strncpy(data.eventName,"ended",64); + memset(data.eventName, 0, sizeof(data.eventName)); + strncpy(data.eventName, "ended", sizeof(data.eventName)); event.data = (void*)&data; ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - memset(data.eventName,0,64*sizeof(char)); - strncpy(data.eventName,"return",64); + memset(data.eventName, 0, sizeof(data.eventName)); + strncpy(data.eventName, "return", sizeof(data.eventName)); event.data = (void*)&data; ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm index 2befae216a..ecb9a46a02 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm +++ b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm @@ -196,8 +196,8 @@ static const int CC_EDIT_BOX_PADDING = 5; cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox); cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data); cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - memset(data.eventName,0,64*sizeof(char)); - strncpy(data.eventName,"return",64); + memset(data.eventName, 0, sizeof(data.eventName)); + strncpy(data.eventName, "return", sizeof(data.eventName)); event.data = (void*)&data; cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm b/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm index 3af3c7448f..aa7c2b5905 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm +++ b/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm @@ -187,8 +187,8 @@ cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox); cocos2d::ScriptEvent event(cocos2d::kCommonEvent,(void*)&data); cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); - memset(data.eventName,0,64*sizeof(char)); - strncpy(data.eventName,"return",64); + memset(data.eventName, 0, sizeof(data.eventName)); + strncpy(data.eventName, "return", sizeof(data.eventName)); event.data = (void*)&data; cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); } From 3b16a267fbb258016c14d0175179ad4865ff522d Mon Sep 17 00:00:00 2001 From: lm Date: Wed, 16 Apr 2014 16:26:50 +0800 Subject: [PATCH 13/40] [Jenkins][ci skip] Fix 'localfile' parameter --- tools/jenkins-scripts/upload_apk.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/jenkins-scripts/upload_apk.sh b/tools/jenkins-scripts/upload_apk.sh index 759e4d7cb2..8c0af6e9a7 100644 --- a/tools/jenkins-scripts/upload_apk.sh +++ b/tools/jenkins-scripts/upload_apk.sh @@ -1,5 +1,5 @@ #!/bin/sh -calfile=$1 +localfile=$1 remotefile=$2 sftp $FTP_HOME << EOF From 84b6981e2bd54c470841ba382e69e7763ddabbe4 Mon Sep 17 00:00:00 2001 From: lm Date: Wed, 16 Apr 2014 18:36:05 +0800 Subject: [PATCH 14/40] [Jenkins][ci skip] Comment result of emptytest --- tools/jenkins-scripts/emptytest-post-build.py | 32 +++++++++++++++++++ tools/jenkins-scripts/job-comment-trigger.py | 11 +++++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tools/jenkins-scripts/emptytest-post-build.py diff --git a/tools/jenkins-scripts/emptytest-post-build.py b/tools/jenkins-scripts/emptytest-post-build.py new file mode 100644 index 0000000000..c23ff9e06b --- /dev/null +++ b/tools/jenkins-scripts/emptytest-post-build.py @@ -0,0 +1,32 @@ +import os +import json +import requests +import jenkinsapi +from jenkinsapi.jenkins import Jenkins +from jenkinsapi.constants import STATUS_SUCCESS + +payload_str = os.environ['payload'] +payload_str = payload_str.decode('utf-8','ignore') +#parse to json obj +payload = json.loads(payload_str) +#pr = payload['pull_request'] +url = payload['html_url'] +print "build pr:" + url +#get statuses url +comments_url = payload['comments_url'] + +J = Jenkins(os.environ['JENKINS_URL']) +target_url = os.environ['BUILD_URL'] +build_number = int(os.environ['BUILD_NUMBER']) +data = {} +access_token = os.environ['GITHUB_ACCESS_TOKEN'] +Headers = {"Authorization":"token " + access_token} + +result = J[os.environ['JOB_NAME']].get_build(build_number).get_status() + +if(result == STATUS_SUCCESS): + data['body'] = "Emptytest run Success: " + target_url +else: + data['body'] = "Emptytest run Failure: " + target_url + +requests.post(statuses_url, data=json.dumps(data), headers=Headers) diff --git a/tools/jenkins-scripts/job-comment-trigger.py b/tools/jenkins-scripts/job-comment-trigger.py index 86932aa0db..9b3a802cd5 100644 --- a/tools/jenkins-scripts/job-comment-trigger.py +++ b/tools/jenkins-scripts/job-comment-trigger.py @@ -57,6 +57,10 @@ def main(): statuses_url = repository['statuses_url'] payload_forword['statuses_url'] = statuses_url print 'statuses_url: ' + statuses_url + #get comments url + comments_url = repository['comments_url'] + payload_forword['comments_url'] = comments_url + print 'comments_url: ' + comments_url #get pr target branch branch = repository['base']['ref'] @@ -75,14 +79,17 @@ def main(): Headers = {"Authorization":"token " + access_token} try: - requests.post(statuses_url, data=json.dumps(data), headers=Headers) + if searchCI: + ciOper = searchCI.group() + if('rebuild' in ciOper): + requests.post(statuses_url, data=json.dumps(data), headers=Headers) except: traceback.print_exc() job_trigger_url = '' if searchCI: ciOper = searchCI.group() - if('build' in ciOper): + if('rebuild' in ciOper): job_trigger_url = os.environ['JOB_PULL_REQUEST_BUILD_TRIGGER_URL'] if('emptytest' in ciOper): job_trigger_url = os.environ['JOB_EMPTYTEST_TRIGGER_URL'] From fb462b90b6e4f2cbb59f1a4893da39cb4c471fe1 Mon Sep 17 00:00:00 2001 From: lm Date: Wed, 16 Apr 2014 18:56:17 +0800 Subject: [PATCH 15/40] [Jenkins][ci skip] Fix 'comments_url' parameter --- tools/jenkins-scripts/emptytest-post-build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/jenkins-scripts/emptytest-post-build.py b/tools/jenkins-scripts/emptytest-post-build.py index c23ff9e06b..190f06b812 100644 --- a/tools/jenkins-scripts/emptytest-post-build.py +++ b/tools/jenkins-scripts/emptytest-post-build.py @@ -12,7 +12,7 @@ payload = json.loads(payload_str) #pr = payload['pull_request'] url = payload['html_url'] print "build pr:" + url -#get statuses url +#get comments url comments_url = payload['comments_url'] J = Jenkins(os.environ['JENKINS_URL']) @@ -29,4 +29,4 @@ if(result == STATUS_SUCCESS): else: data['body'] = "Emptytest run Failure: " + target_url -requests.post(statuses_url, data=json.dumps(data), headers=Headers) +requests.post(comments_url, data=json.dumps(data), headers=Headers) From 008bdba373ded0a1d29a6232210abb032c152210 Mon Sep 17 00:00:00 2001 From: lm Date: Thu, 17 Apr 2014 09:57:55 +0800 Subject: [PATCH 16/40] [Jenkins][ci skip] Change 'GITHUB_ACCESS_TOKEN' to 'GITHUB_COMMENT_ACCESS_TOKEN' --- tools/jenkins-scripts/emptytest-post-build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/jenkins-scripts/emptytest-post-build.py b/tools/jenkins-scripts/emptytest-post-build.py index 190f06b812..3fdbff6178 100644 --- a/tools/jenkins-scripts/emptytest-post-build.py +++ b/tools/jenkins-scripts/emptytest-post-build.py @@ -19,7 +19,7 @@ J = Jenkins(os.environ['JENKINS_URL']) target_url = os.environ['BUILD_URL'] build_number = int(os.environ['BUILD_NUMBER']) data = {} -access_token = os.environ['GITHUB_ACCESS_TOKEN'] +access_token = os.environ['GITHUB_COMMENT_ACCESS_TOKEN'] Headers = {"Authorization":"token " + access_token} result = J[os.environ['JOB_NAME']].get_build(build_number).get_status() From 63f54cb5f7d6fdf0833c51619d5bb6b2b0b362fa Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 17 Apr 2014 10:15:11 +0800 Subject: [PATCH 17/40] closed #4568: Application crashes on closing if CC_ENABLE_CACHE_TEXTURE_DATA is enabled. CC_SAFE_RELEASE(_eventDispatcher); should be after 'delete _renderer;' in Director's destructor. --- cocos/2d/CCDirector.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index e7ccbd72aa..296865cd6b 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -176,7 +176,7 @@ Director::~Director(void) CC_SAFE_RELEASE(_notificationNode); CC_SAFE_RELEASE(_scheduler); CC_SAFE_RELEASE(_actionManager); - CC_SAFE_RELEASE(_eventDispatcher); + delete _eventAfterUpdate; delete _eventAfterDraw; @@ -189,6 +189,8 @@ Director::~Director(void) delete _console; #endif + CC_SAFE_RELEASE(_eventDispatcher); + // clean auto release pool PoolManager::destroyInstance(); From a9ed075d5099a051af880d4fef3244c577fcf400 Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 17 Apr 2014 10:15:58 +0800 Subject: [PATCH 18/40] closed #4883. fixed slider hittest problem --- cocos/ui/UISlider.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index a50279cba2..20449b7083 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -381,7 +381,8 @@ void Slider::setPercent(int percent) bool Slider::hitTest(const cocos2d::Point &pt) { Point nsp = this->_slidBallNormalRenderer->convertToNodeSpace(pt); - Rect ballRect = this->_slidBallNormalRenderer->getTextureRect(); + Size ballSize = this->_slidBallNormalRenderer->getContentSize(); + Rect ballRect = Rect(0,0, ballSize.width, ballSize.height); if (ballRect.containsPoint(nsp)) { return true; } From 30e1d41dbf6bc59efe257be025f9d8819b74a53b Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 17 Apr 2014 10:16:37 +0800 Subject: [PATCH 19/40] Makes 'compareRenderCommand' as a static function instead of a global function --- cocos/2d/renderer/CCRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/renderer/CCRenderer.cpp b/cocos/2d/renderer/CCRenderer.cpp index 0a54dcbd72..e0b49f8aee 100644 --- a/cocos/2d/renderer/CCRenderer.cpp +++ b/cocos/2d/renderer/CCRenderer.cpp @@ -43,7 +43,7 @@ NS_CC_BEGIN // helper -bool compareRenderCommand(RenderCommand* a, RenderCommand* b) +static bool compareRenderCommand(RenderCommand* a, RenderCommand* b) { return a->getGlobalOrder() < b->getGlobalOrder(); } From 19f6526ef8554be54a2dc67e7eab9f63b7c90f00 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 17 Apr 2014 14:08:25 +0800 Subject: [PATCH 20/40] Widget supports contentsize --- .../cocostudio/CCSGUIReader.cpp | 4 + cocos/ui/UIButton.cpp | 57 ++++++++----- cocos/ui/UIButton.h | 12 +-- cocos/ui/UICheckBox.cpp | 80 ++++++++++++------- cocos/ui/UICheckBox.h | 13 ++- cocos/ui/UIImageView.cpp | 28 ++++--- cocos/ui/UIImageView.h | 7 +- cocos/ui/UILayout.cpp | 15 +--- cocos/ui/UILayout.h | 4 +- cocos/ui/UILoadingBar.cpp | 25 ++++-- cocos/ui/UILoadingBar.h | 6 +- cocos/ui/UIRichText.cpp | 9 ++- cocos/ui/UIRichText.h | 3 +- cocos/ui/UISlider.cpp | 40 +++++++--- cocos/ui/UISlider.h | 7 +- cocos/ui/UIText.cpp | 43 ++++++---- cocos/ui/UIText.h | 9 +-- cocos/ui/UITextAtlas.cpp | 34 +++++--- cocos/ui/UITextAtlas.h | 9 +-- cocos/ui/UITextBMFont.cpp | 30 ++++--- cocos/ui/UITextBMFont.h | 5 +- cocos/ui/UITextField.cpp | 43 ++++++---- cocos/ui/UITextField.h | 6 +- cocos/ui/UIWidget.cpp | 41 ++++++---- cocos/ui/UIWidget.h | 18 +++-- .../UIButtonTest/UIButtonTest.cpp | 4 +- .../UIImageViewTest/UIImageViewTest.cpp | 4 +- .../UILayoutTest/UILayoutTest.cpp | 14 ++-- .../UILoadingBarTest/UILoadingBarTest.cpp | 4 +- .../UIScrollViewTest/UIScrollViewTest.cpp | 4 +- 30 files changed, 350 insertions(+), 228 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 710297c001..cc0de45460 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1109,6 +1109,10 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va } else { + if (!dynamic_cast(widget)) + { + child->setPosition(Point(child->getPositionX() + widget->getSize().width / 2.0f, child->getPositionY() + widget->getSize().height / 2.0f)); + } widget->addChild(child); } } diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index cff34e84ec..75ba0e9256 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -63,7 +63,10 @@ _pressedTextureScaleXInSize(1.0f), _pressedTextureScaleYInSize(1.0f), _normalTextureLoaded(false), _pressedTextureLoaded(false), -_disabledTextureLoaded(false) +_disabledTextureLoaded(false), +_normalTextureAdaptDirty(true), +_pressedTextureAdaptDirty(true), +_disabledTextureAdaptDirty(true) { } @@ -253,12 +256,12 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) } } _normalTextureSize = _buttonNormalRenderer->getContentSize(); - normalTextureScaleChangedWithSize(); - updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_buttonNormalRenderer); + updateContentSizeWithTextureSize(_normalTextureSize); _normalTextureLoaded = true; + _normalTextureAdaptDirty = true; } void Button::loadTexturePressed(const std::string& selected,TextureResType texType) @@ -301,12 +304,11 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy } } _pressedTextureSize = _buttonClickedRenderer->getContentSize(); - pressedTextureScaleChangedWithSize(); - updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_buttonDisableRenderer); _pressedTextureLoaded = true; + _pressedTextureAdaptDirty = true; } void Button::loadTextureDisabled(const std::string& disabled,TextureResType texType) @@ -349,12 +351,11 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT } } _disabledTextureSize = _buttonDisableRenderer->getContentSize(); - disabledTextureScaleChangedWithSize(); - updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_buttonDisableRenderer); _disabledTextureLoaded = true; + _disabledTextureAdaptDirty = true; } void Button::setCapInsets(const Rect &capInsets) @@ -516,25 +517,41 @@ void Button::updateFlippedY() static_cast(_buttonDisableRenderer)->setFlippedY(_flippedY); } } - -void Button::setAnchorPoint(const Point &pt) + +void Button::updateTitleLocation() { - Widget::setAnchorPoint(pt); - _buttonNormalRenderer->setAnchorPoint(pt); - _buttonClickedRenderer->setAnchorPoint(pt); - _buttonDisableRenderer->setAnchorPoint(pt); - _titleRenderer->setPosition(Point(_size.width*(0.5f-_anchorPoint.x), _size.height*(0.5f-_anchorPoint.y))); + _titleRenderer->setPosition(Point(_contentSize.width * 0.5f, _contentSize.height * 0.5f)); } void Button::onSizeChanged() { Widget::onSizeChanged(); - normalTextureScaleChangedWithSize(); - pressedTextureScaleChangedWithSize(); - disabledTextureScaleChangedWithSize(); + updateTitleLocation(); + _normalTextureAdaptDirty = true; + _pressedTextureAdaptDirty = true; + _disabledTextureAdaptDirty = true; +} + +void Button::adaptRenderers() +{ + if (_normalTextureAdaptDirty) + { + normalTextureScaleChangedWithSize(); + _normalTextureAdaptDirty = false; + } + if (_pressedTextureAdaptDirty) + { + pressedTextureScaleChangedWithSize(); + _pressedTextureAdaptDirty = false; + } + if (_disabledTextureAdaptDirty) + { + disabledTextureScaleChangedWithSize(); + _disabledTextureAdaptDirty = false; + } } -const Size& Button::getContentSize() const +const Size& Button::getVirtualRendererSize() const { return _normalTextureSize; } @@ -567,7 +584,6 @@ void Button::normalTextureScaleChangedWithSize() { _buttonNormalRenderer->setScale(1.0f); _normalTextureScaleXInSize = _normalTextureScaleYInSize = 1.0f; - _size = _normalTextureSize; } } else @@ -593,6 +609,7 @@ void Button::normalTextureScaleChangedWithSize() _normalTextureScaleYInSize = scaleY; } } + _buttonNormalRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); } void Button::pressedTextureScaleChangedWithSize() @@ -628,6 +645,7 @@ void Button::pressedTextureScaleChangedWithSize() _pressedTextureScaleYInSize = scaleY; } } + _buttonClickedRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); } void Button::disabledTextureScaleChangedWithSize() @@ -659,6 +677,7 @@ void Button::disabledTextureScaleChangedWithSize() _buttonDisableRenderer->setScaleY(scaleY); } } + _buttonDisableRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); } void Button::setPressedActionEnabled(bool enabled) diff --git a/cocos/ui/UIButton.h b/cocos/ui/UIButton.h index 42d9c1d22d..a67cfdd064 100644 --- a/cocos/ui/UIButton.h +++ b/cocos/ui/UIButton.h @@ -146,9 +146,6 @@ public: const Rect& getCapInsetsDisabledRenderer(); - //override "setAnchorPoint" of widget. - virtual void setAnchorPoint(const Point &pt) override; - /** * Sets if button is using scale9 renderer. * @@ -168,8 +165,8 @@ public: //override "ignoreContentAdaptWithSize" method of widget. virtual void ignoreContentAdaptWithSize(bool ignore) override; - //override "getContentSize" method of widget. - virtual const Size& getContentSize() const override; + //override "getVirtualRendererSize" method of widget. + virtual const Size& getVirtualRendererSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; @@ -212,6 +209,8 @@ protected: void disabledTextureScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; + virtual void adaptRenderers() override; + void updateTitleLocation(); protected: Node* _buttonNormalRenderer; Node* _buttonClickedRenderer; @@ -240,6 +239,9 @@ protected: bool _normalTextureLoaded; bool _pressedTextureLoaded; bool _disabledTextureLoaded; + bool _normalTextureAdaptDirty; + bool _pressedTextureAdaptDirty; + bool _disabledTextureAdaptDirty; }; } diff --git a/cocos/ui/UICheckBox.cpp b/cocos/ui/UICheckBox.cpp index 1393d7fdb3..2da91ba8c1 100644 --- a/cocos/ui/UICheckBox.cpp +++ b/cocos/ui/UICheckBox.cpp @@ -54,7 +54,12 @@ _backGroundFileName(""), _backGroundSelectedFileName(""), _frontCrossFileName(""), _backGroundDisabledFileName(""), -_frontCrossDisabledFileName("") +_frontCrossDisabledFileName(""), +_backGroundBoxRendererAdaptDirty(true), +_backGroundSelectedBoxRendererAdaptDirty(true), +_frontCrossRendererAdaptDirty(true), +_backGroundBoxDisabledRendererAdaptDirty(true), +_frontCrossDisabledRendererAdaptDirty(true) { } @@ -178,11 +183,11 @@ void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResTyp default: break; } - backGroundTextureScaleChangedWithSize(); - updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_backGroundBoxRenderer); + updateContentSizeWithTextureSize(_backGroundBoxRenderer->getContentSize()); + _backGroundBoxRendererAdaptDirty = true; } void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType) @@ -204,11 +209,10 @@ void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelect default: break; } - backGroundSelectedTextureScaleChangedWithSize(); - updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_backGroundSelectedBoxRenderer); + _backGroundSelectedBoxRendererAdaptDirty = true; } void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType texType) @@ -230,11 +234,10 @@ void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType tex default: break; } - frontCrossTextureScaleChangedWithSize(); - updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_frontCrossRenderer); + _frontCrossRendererAdaptDirty = true; } void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType) @@ -256,11 +259,10 @@ void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabl default: break; } - backGroundDisabledTextureScaleChangedWithSize(); - updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_backGroundBoxDisabledRenderer); + _backGroundBoxDisabledRendererAdaptDirty = true; } void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType) @@ -282,11 +284,10 @@ void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabl default: break; } - frontCrossDisabledTextureScaleChangedWithSize(); - updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_frontCrossDisabledRenderer); + _frontCrossDisabledRendererAdaptDirty = true; } void CheckBox::onTouchEnded(Touch *touch, Event *unusedEvent) @@ -396,27 +397,46 @@ void CheckBox::updateFlippedY() _frontCrossDisabledRenderer->setFlippedY(_flippedY); } -void CheckBox::setAnchorPoint(const Point &pt) -{ - Widget::setAnchorPoint(pt); - _backGroundBoxRenderer->setAnchorPoint(pt); - _backGroundSelectedBoxRenderer->setAnchorPoint(pt); - _backGroundBoxDisabledRenderer->setAnchorPoint(pt); - _frontCrossRenderer->setAnchorPoint(pt); - _frontCrossDisabledRenderer->setAnchorPoint(pt); -} - void CheckBox::onSizeChanged() { Widget::onSizeChanged(); - backGroundTextureScaleChangedWithSize(); - backGroundSelectedTextureScaleChangedWithSize(); - frontCrossTextureScaleChangedWithSize(); - backGroundDisabledTextureScaleChangedWithSize(); - frontCrossDisabledTextureScaleChangedWithSize(); + _backGroundBoxRendererAdaptDirty = true; + _backGroundSelectedBoxRendererAdaptDirty = true; + _frontCrossRendererAdaptDirty = true; + _backGroundBoxDisabledRendererAdaptDirty = true; + _frontCrossDisabledRendererAdaptDirty = true; +} + +void CheckBox::adaptRenderers() +{ + if (_backGroundBoxRendererAdaptDirty) + { + backGroundTextureScaleChangedWithSize(); + _backGroundBoxRendererAdaptDirty = false; + } + if (_backGroundSelectedBoxRendererAdaptDirty) + { + backGroundSelectedTextureScaleChangedWithSize(); + _backGroundSelectedBoxRendererAdaptDirty = false; + } + if (_frontCrossRendererAdaptDirty) + { + frontCrossTextureScaleChangedWithSize(); + _frontCrossRendererAdaptDirty = false; + } + if (_backGroundBoxDisabledRendererAdaptDirty) + { + backGroundDisabledTextureScaleChangedWithSize(); + _backGroundBoxDisabledRendererAdaptDirty = false; + } + if (_frontCrossDisabledRendererAdaptDirty) + { + frontCrossDisabledTextureScaleChangedWithSize(); + _frontCrossDisabledRendererAdaptDirty = false; + } } -const Size& CheckBox::getContentSize() const +const Size& CheckBox::getVirtualRendererSize() const { return _backGroundBoxRenderer->getContentSize(); } @@ -431,7 +451,6 @@ void CheckBox::backGroundTextureScaleChangedWithSize() if (_ignoreSize) { _backGroundBoxRenderer->setScale(1.0f); - _size = _backGroundBoxRenderer->getContentSize(); } else { @@ -446,6 +465,7 @@ void CheckBox::backGroundTextureScaleChangedWithSize() _backGroundBoxRenderer->setScaleX(scaleX); _backGroundBoxRenderer->setScaleY(scaleY); } + _backGroundBoxRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2)); } void CheckBox::backGroundSelectedTextureScaleChangedWithSize() @@ -467,6 +487,7 @@ void CheckBox::backGroundSelectedTextureScaleChangedWithSize() _backGroundSelectedBoxRenderer->setScaleX(scaleX); _backGroundSelectedBoxRenderer->setScaleY(scaleY); } + _backGroundSelectedBoxRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2)); } void CheckBox::frontCrossTextureScaleChangedWithSize() @@ -488,6 +509,7 @@ void CheckBox::frontCrossTextureScaleChangedWithSize() _frontCrossRenderer->setScaleX(scaleX); _frontCrossRenderer->setScaleY(scaleY); } + _frontCrossRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2)); } void CheckBox::backGroundDisabledTextureScaleChangedWithSize() @@ -509,6 +531,7 @@ void CheckBox::backGroundDisabledTextureScaleChangedWithSize() _backGroundBoxDisabledRenderer->setScaleX(scaleX); _backGroundBoxDisabledRenderer->setScaleY(scaleY); } + _backGroundBoxDisabledRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2)); } void CheckBox::frontCrossDisabledTextureScaleChangedWithSize() @@ -530,6 +553,7 @@ void CheckBox::frontCrossDisabledTextureScaleChangedWithSize() _frontCrossDisabledRenderer->setScaleX(scaleX); _frontCrossDisabledRenderer->setScaleY(scaleY); } + _frontCrossDisabledRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2)); } std::string CheckBox::getDescription() const diff --git a/cocos/ui/UICheckBox.h b/cocos/ui/UICheckBox.h index ab704a547c..6b00c407c5 100644 --- a/cocos/ui/UICheckBox.h +++ b/cocos/ui/UICheckBox.h @@ -164,8 +164,6 @@ public: */ bool getSelectedState(); - //override "setAnchorPoint" method of widget. - virtual void setAnchorPoint(const Point &pt) override; //add a call back function would called when checkbox is selected or unselected. void addEventListenerCheckBox(Ref* target,SEL_SelectedStateEvent selector); @@ -173,8 +171,8 @@ public: //override "onTouchEnded" method of widget. virtual void onTouchEnded(Touch *touch, Event *unusedEvent); - //override "getContentSize" method of widget. - virtual const Size& getContentSize() const override; + //override "getVirtualRendererSize" method of widget. + virtual const Size& getVirtualRendererSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; @@ -213,6 +211,7 @@ protected: void frontCrossDisabledTextureScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; + virtual void adaptRenderers() override; protected: Sprite* _backGroundBoxRenderer; Sprite* _backGroundSelectedBoxRenderer; @@ -235,6 +234,12 @@ protected: std::string _frontCrossFileName; std::string _backGroundDisabledFileName; std::string _frontCrossDisabledFileName; + + bool _backGroundBoxRendererAdaptDirty; + bool _backGroundSelectedBoxRendererAdaptDirty; + bool _frontCrossRendererAdaptDirty; + bool _backGroundBoxDisabledRendererAdaptDirty; + bool _frontCrossDisabledRendererAdaptDirty; }; } diff --git a/cocos/ui/UIImageView.cpp b/cocos/ui/UIImageView.cpp index 691a33bd97..eb25b4b4fd 100644 --- a/cocos/ui/UIImageView.cpp +++ b/cocos/ui/UIImageView.cpp @@ -44,7 +44,8 @@ _capInsets(Rect::ZERO), _imageRenderer(nullptr), _textureFile(""), _imageTexType(UI_TEX_TYPE_LOCAL), -_imageTextureSize(_size) +_imageTextureSize(_size), +_imageRendererAdaptDirty(true) { } @@ -150,11 +151,11 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType) break; } _imageTextureSize = _imageRenderer->getContentSize(); - imageTextureScaleChangedWithSize(); - updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_imageRenderer); + updateContentSizeWithTextureSize(_imageTextureSize); + _imageRendererAdaptDirty = true; } void ImageView::setTextureRect(const Rect &rect) @@ -257,20 +258,23 @@ const Rect& ImageView::getCapInsets() { return _capInsets; } - -void ImageView::setAnchorPoint(const Point &pt) -{ - Widget::setAnchorPoint(pt); - _imageRenderer->setAnchorPoint(pt); -} void ImageView::onSizeChanged() { Widget::onSizeChanged(); - imageTextureScaleChangedWithSize(); + _imageRendererAdaptDirty = true; +} + +void ImageView::adaptRenderers() +{ + if (_imageRendererAdaptDirty) + { + imageTextureScaleChangedWithSize(); + _imageRendererAdaptDirty = false; + } } -const Size& ImageView::getContentSize() const +const Size& ImageView::getVirtualRendererSize() const { return _imageTextureSize; } @@ -287,7 +291,6 @@ void ImageView::imageTextureScaleChangedWithSize() if (!_scale9Enabled) { _imageRenderer->setScale(1.0f); - _size = _imageTextureSize; } } else @@ -310,6 +313,7 @@ void ImageView::imageTextureScaleChangedWithSize() _imageRenderer->setScaleY(scaleY); } } + _imageRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); } std::string ImageView::getDescription() const diff --git a/cocos/ui/UIImageView.h b/cocos/ui/UIImageView.h index 97e1051e6e..8b88b8e09b 100644 --- a/cocos/ui/UIImageView.h +++ b/cocos/ui/UIImageView.h @@ -99,9 +99,6 @@ public: const Rect& getCapInsets(); - //override "setAnchorPoint" method of widget. - virtual void setAnchorPoint(const Point &pt) override; - //override "ignoreContentAdaptWithSize" method of widget. virtual void ignoreContentAdaptWithSize(bool ignore) override; @@ -110,7 +107,7 @@ public: */ virtual std::string getDescription() const override; - virtual const Size& getContentSize() const override; + virtual const Size& getVirtualRendererSize() const override; virtual Node* getVirtualRenderer() override; CC_CONSTRUCTOR_ACCESS: @@ -129,6 +126,7 @@ protected: void imageTextureScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; + virtual void adaptRenderers() override; protected: bool _scale9Enabled; bool _prevIgnoreSize; @@ -137,6 +135,7 @@ protected: std::string _textureFile; TextureResType _imageTexType; Size _imageTextureSize; + bool _imageRendererAdaptDirty; }; } diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 9e4886e369..f57359a3b3 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -700,24 +700,14 @@ bool Layout::isClippingEnabled() { return _clippingEnabled; } - -bool Layout::hitTest(const Point &pt) -{ - Point nsp = convertToNodeSpace(pt); - Rect bb = Rect(0.0f, 0.0f, _size.width, _size.height); - if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height) - { - return true; - } - return false; -} - + void Layout::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) { if (!_enabled) { return; } + adaptRenderers(); if (_clippingEnabled) { switch (_clippingType) @@ -1075,7 +1065,6 @@ const Rect& Layout::getClippingRect() void Layout::onSizeChanged() { Widget::onSizeChanged(); - setContentSize(_size); setStencilClippingSize(_size); _doLayoutDirty = true; _clippingRectDirty = true; diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index 8d56d44610..ffec780a70 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -265,9 +265,7 @@ public: virtual void onEnter() override; virtual void onExit() override; - - virtual bool hitTest(const Point &pt); - + CC_CONSTRUCTOR_ACCESS: //override "init" method of widget. virtual bool init() override; diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index c6b5191bd0..dae641c1ac 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -43,7 +43,8 @@ _barRendererTextureSize(Size::ZERO), _scale9Enabled(false), _prevIgnoreSize(true), _capInsets(Rect::ZERO), -_textureFile("") +_textureFile(""), +_barRendererAdaptDirty(true) { } @@ -175,7 +176,9 @@ int LoadingBar::getDirection() } break; } - barRendererScaleChangedWithSize(); +// barRendererScaleChangedWithSize(); + updateContentSizeWithTextureSize(_barRendererTextureSize); + _barRendererAdaptDirty = true; } void LoadingBar::setScale9Enabled(bool enabled) @@ -265,7 +268,16 @@ int LoadingBar::getPercent() void LoadingBar::onSizeChanged() { Widget::onSizeChanged(); - barRendererScaleChangedWithSize(); + _barRendererAdaptDirty = true; +} + +void LoadingBar::adaptRenderers() +{ + if (_barRendererAdaptDirty) + { + barRendererScaleChangedWithSize(); + _barRendererAdaptDirty = false; + } } void LoadingBar::ignoreContentAdaptWithSize(bool ignore) @@ -277,7 +289,7 @@ void LoadingBar::ignoreContentAdaptWithSize(bool ignore) } } -const Size& LoadingBar::getContentSize() const +const Size& LoadingBar::getVirtualRendererSize() const { return _barRendererTextureSize; } @@ -295,7 +307,6 @@ void LoadingBar::barRendererScaleChangedWithSize() { _totalLength = _barRendererTextureSize.width; _barRenderer->setScale(1.0f); - _size = _barRendererTextureSize; } } else @@ -323,10 +334,10 @@ void LoadingBar::barRendererScaleChangedWithSize() switch (_barType) { case LoadingBarTypeLeft: - _barRenderer->setPosition(Point(-_totalLength * 0.5f, 0.0f)); + _barRenderer->setPosition(Point(0.0f, _contentSize.height / 2.0f)); break; case LoadingBarTypeRight: - _barRenderer->setPosition(Point(_totalLength * 0.5f, 0.0f)); + _barRenderer->setPosition(Point(_totalLength, _contentSize.height / 2.0f)); break; default: break; diff --git a/cocos/ui/UILoadingBar.h b/cocos/ui/UILoadingBar.h index 65e9a3e8de..f00de91acf 100644 --- a/cocos/ui/UILoadingBar.h +++ b/cocos/ui/UILoadingBar.h @@ -128,8 +128,8 @@ public: //override "ignoreContentAdaptWithSize" method of widget. virtual void ignoreContentAdaptWithSize(bool ignore) override; - //override "getContentSize" method of widget. - virtual const Size& getContentSize() const override; + //override "getVirtualRendererSize" method of widget. + virtual const Size& getVirtualRendererSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; @@ -148,6 +148,7 @@ protected: void barRendererScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; + virtual void adaptRenderers() override; protected: LoadingBarType _barType; int _percent; @@ -159,6 +160,7 @@ protected: bool _prevIgnoreSize; Rect _capInsets; std::string _textureFile; + bool _barRendererAdaptDirty; }; } diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index a3dc6a0245..33180f3b42 100644 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -211,12 +211,11 @@ void RichText::formatText() if (FileUtils::getInstance()->isFileExist(elmtText->_fontName)) { elementRenderer = Label::createWithTTF(elmtText->_text.c_str(), elmtText->_fontName, elmtText->_fontSize); - } + } else { elementRenderer = Label::createWithSystemFont(elmtText->_text.c_str(), elmtText->_fontName, elmtText->_fontSize); } - break; } case RICH_IMAGE: @@ -428,13 +427,15 @@ void RichText::formarRenderers() if (_ignoreSize) { - Size s = getContentSize(); + Size s = getVirtualRendererSize(); _size = s; } else { _size = _customSize; } + updateContentSizeWithTextureSize(_size); + _elementRenderersContainer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); } void RichText::pushToContainer(cocos2d::Node *renderer) @@ -466,7 +467,7 @@ void RichText::setAnchorPoint(const Point &pt) _elementRenderersContainer->setAnchorPoint(pt); } -const Size& RichText::getContentSize() const +const Size& RichText::getVirtualRendererSize() const { return _elementRenderersContainer->getContentSize(); } diff --git a/cocos/ui/UIRichText.h b/cocos/ui/UIRichText.h index d5e0f176b2..3334f5b8aa 100644 --- a/cocos/ui/UIRichText.h +++ b/cocos/ui/UIRichText.h @@ -105,7 +105,7 @@ public: virtual void visit(cocos2d::Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override; void setVerticalSpace(float space); virtual void setAnchorPoint(const Point &pt); - virtual const Size& getContentSize() const; + virtual const Size& getVirtualRendererSize() const override; void formatText(); virtual void ignoreContentAdaptWithSize(bool ignore); virtual std::string getDescription() const override; @@ -121,6 +121,7 @@ protected: void handleCustomRenderer(Node* renderer); void formarRenderers(); void addNewLine(); +// virtual void adaptRenderers() override; protected: bool _formatTextDirty; Vector _richElements; diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index a50279cba2..9b5828fed9 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -60,7 +60,9 @@ _barTexType(UI_TEX_TYPE_LOCAL), _progressBarTexType(UI_TEX_TYPE_LOCAL), _ballNTexType(UI_TEX_TYPE_LOCAL), _ballPTexType(UI_TEX_TYPE_LOCAL), -_ballDTexType(UI_TEX_TYPE_LOCAL) +_ballDTexType(UI_TEX_TYPE_LOCAL), +_barRendererAdaptDirty(true), +_progressBarRendererDirty(true) { } @@ -145,8 +147,9 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) break; } updateRGBAToRenderer(_barRenderer); - barRendererScaleChangedWithSize(); - progressBarRendererScaleChangedWithSize(); + _barRendererAdaptDirty = true; + _progressBarRendererDirty = true; + updateContentSizeWithTextureSize(_barRenderer->getContentSize()); } void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType texType) @@ -185,7 +188,7 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType updateRGBAToRenderer(_progressBarRenderer); _progressBarRenderer->setAnchorPoint(Point(0.0f, 0.5f)); _progressBarTextureSize = _progressBarRenderer->getContentSize(); - progressBarRendererScaleChangedWithSize(); + _progressBarRendererDirty = true; } void Slider::setScale9Enabled(bool able) @@ -364,7 +367,7 @@ void Slider::setPercent(int percent) _percent = percent; float res = percent / 100.0f; float dis = _barLength * res; - _slidBallRenderer->setPosition(Point(-_barLength/2.0f + dis, 0.0f)); + _slidBallRenderer->setPosition(Point(dis, _contentSize.height / 2.0f)); if (_scale9Enabled) { static_cast(_progressBarRenderer)->setPreferredSize(Size(dis,_progressBarTextureSize.height)); @@ -404,7 +407,6 @@ void Slider::onTouchMoved(Touch *touch, Event *unusedEvent) { _touchMovePos = touch->getLocation(); Point nsp = convertToNodeSpace(_touchMovePos); - _slidBallRenderer->setPosition(Point(nsp.x,0)); setPercent(getPercentWithBallPos(nsp.x)); percentChangedEvent(); } @@ -421,7 +423,7 @@ void Slider::onTouchCancelled(Touch *touch, Event *unusedEvent) float Slider::getPercentWithBallPos(float px) { - return (((px-(-_barLength/2.0f))/_barLength)*100.0f); + return ((px/_barLength)*100.0f); } void Slider::addEventListenerSlider(Ref *target, SEL_SlidPercentChangedEvent selector) @@ -446,11 +448,25 @@ int Slider::getPercent() void Slider::onSizeChanged() { Widget::onSizeChanged(); - barRendererScaleChangedWithSize(); - progressBarRendererScaleChangedWithSize(); + _barRendererAdaptDirty = true; + _progressBarRendererDirty = true; +} + +void Slider::adaptRenderers() +{ + if (_barRendererAdaptDirty) + { + barRendererScaleChangedWithSize(); + _barRendererAdaptDirty = false; + } + if (_progressBarRendererDirty) + { + progressBarRendererScaleChangedWithSize(); + _progressBarRendererDirty = false; + } } -const Size& Slider::getContentSize() const +const Size& Slider::getVirtualRendererSize() const { return _barRenderer->getContentSize(); } @@ -466,7 +482,6 @@ void Slider::barRendererScaleChangedWithSize() { _barRenderer->setScale(1.0f); - _size = _barRenderer->getContentSize(); _barLength = _size.width; } else @@ -490,6 +505,7 @@ void Slider::barRendererScaleChangedWithSize() _barRenderer->setScaleY(bscaleY); } } + _barRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); setPercent(_percent); } @@ -527,7 +543,7 @@ void Slider::progressBarRendererScaleChangedWithSize() _progressBarRenderer->setScaleY(pscaleY); } } - _progressBarRenderer->setPosition(Point(-_barLength * 0.5f, 0.0f)); + _progressBarRenderer->setPosition(0.0f, _contentSize.height / 2.0f); setPercent(_percent); } diff --git a/cocos/ui/UISlider.h b/cocos/ui/UISlider.h index 3a109b3ac4..aa21cccc4b 100644 --- a/cocos/ui/UISlider.h +++ b/cocos/ui/UISlider.h @@ -183,8 +183,8 @@ public: virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override; virtual void onTouchCancelled(Touch *touch, Event *unusedEvent) override; - //override "getContentSize" method of widget. - virtual const Size& getContentSize() const override; + //override "getVirtualRendererSize" method of widget. + virtual const Size& getVirtualRendererSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; @@ -217,6 +217,7 @@ protected: void progressBarRendererScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; + virtual void adaptRenderers() override; protected: Node* _barRenderer; Node* _progressBarRenderer; @@ -248,6 +249,8 @@ protected: TextureResType _ballNTexType; TextureResType _ballPTexType; TextureResType _ballDTexType; + bool _barRendererAdaptDirty; + bool _progressBarRendererDirty; }; } diff --git a/cocos/ui/UIText.cpp b/cocos/ui/UIText.cpp index d1e3d711b2..a0fc15131a 100644 --- a/cocos/ui/UIText.cpp +++ b/cocos/ui/UIText.cpp @@ -39,7 +39,8 @@ _normalScaleValueY(1.0f), _fontName("Thonburi"), _fontSize(10), _onSelectedScaleOffset(0.5), -_labelRenderer(nullptr) +_labelRenderer(nullptr), +_labelRendererAdaptDirty(true) { } @@ -104,7 +105,8 @@ void Text::initRenderer() void Text::setText(const std::string& text) { _labelRenderer->setString(text); - labelScaleChangedWithSize(); + updateContentSizeWithTextureSize(_labelRenderer->getContentSize()); + _labelRendererAdaptDirty = true; } const std::string& Text::getStringValue() @@ -121,7 +123,8 @@ void Text::setFontSize(int size) { _fontSize = size; _labelRenderer->setSystemFontSize(size); - labelScaleChangedWithSize(); + updateContentSizeWithTextureSize(_labelRenderer->getContentSize()); + _labelRendererAdaptDirty = true; } int Text::getFontSize() @@ -133,7 +136,8 @@ void Text::setFontName(const std::string& name) { _fontName = name; _labelRenderer->setSystemFontName(name); - labelScaleChangedWithSize(); + updateContentSizeWithTextureSize(_labelRenderer->getContentSize()); + _labelRendererAdaptDirty = true; } const std::string& Text::getFontName() @@ -144,7 +148,8 @@ const std::string& Text::getFontName() void Text::setTextAreaSize(const Size &size) { _labelRenderer->setDimensions(size.width,size.height); - labelScaleChangedWithSize(); + updateContentSizeWithTextureSize(_labelRenderer->getContentSize()); + _labelRendererAdaptDirty = true; } const Size& Text::getTextAreaSize() @@ -155,7 +160,8 @@ const Size& Text::getTextAreaSize() void Text::setTextHorizontalAlignment(TextHAlignment alignment) { _labelRenderer->setHorizontalAlignment(alignment); - labelScaleChangedWithSize(); + updateContentSizeWithTextureSize(_labelRenderer->getContentSize()); + _labelRendererAdaptDirty = true; } TextHAlignment Text::getTextHorizontalAlignment() @@ -166,7 +172,8 @@ TextHAlignment Text::getTextHorizontalAlignment() void Text::setTextVerticalAlignment(TextVAlignment alignment) { _labelRenderer->setVerticalAlignment(alignment); - labelScaleChangedWithSize(); + updateContentSizeWithTextureSize(_labelRenderer->getContentSize()); + _labelRendererAdaptDirty = true; } TextVAlignment Text::getTextVerticalAlignment() @@ -233,19 +240,22 @@ void Text::updateFlippedY() } } -void Text::setAnchorPoint(const Point &pt) -{ - Widget::setAnchorPoint(pt); - _labelRenderer->setAnchorPoint(pt); -} - void Text::onSizeChanged() { Widget::onSizeChanged(); - labelScaleChangedWithSize(); + _labelRendererAdaptDirty = true; +} + +void Text::adaptRenderers() +{ + if (_labelRendererAdaptDirty) + { + labelScaleChangedWithSize(); + _labelRendererAdaptDirty = false; + } } -const Size& Text::getContentSize() const +const Size& Text::getVirtualRendererSize() const { return _labelRenderer->getContentSize(); } @@ -261,7 +271,6 @@ void Text::labelScaleChangedWithSize() { _labelRenderer->setDimensions(0,0); _labelRenderer->setScale(1.0f); - _size = _labelRenderer->getContentSize(); _normalScaleValueX = _normalScaleValueY = 1.0f; } else @@ -280,7 +289,7 @@ void Text::labelScaleChangedWithSize() _normalScaleValueX = scaleX; _normalScaleValueY = scaleY; } - + _labelRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); } std::string Text::getDescription() const diff --git a/cocos/ui/UIText.h b/cocos/ui/UIText.h index 4113397787..65d1d04ed9 100644 --- a/cocos/ui/UIText.h +++ b/cocos/ui/UIText.h @@ -116,11 +116,8 @@ public: */ bool isTouchScaleChangeEnabled(); - //override "setAnchorPoint" method of widget. - virtual void setAnchorPoint(const Point &pt) override; - - //override "getContentSize" method of widget. - virtual const Size& getContentSize() const override; + //override "getVirtualRendererSize" method of widget. + virtual const Size& getVirtualRendererSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; @@ -162,6 +159,7 @@ protected: void labelScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; + virtual void adaptRenderers() override; protected: bool _touchScaleChangeEnabled; float _normalScaleValueX; @@ -170,6 +168,7 @@ protected: int _fontSize; float _onSelectedScaleOffset; Label* _labelRenderer; + bool _labelRendererAdaptDirty; }; } diff --git a/cocos/ui/UITextAtlas.cpp b/cocos/ui/UITextAtlas.cpp index f0cbc01421..0beb9c67b9 100644 --- a/cocos/ui/UITextAtlas.cpp +++ b/cocos/ui/UITextAtlas.cpp @@ -38,7 +38,8 @@ _stringValue(""), _charMapFileName(""), _itemWidth(0), _itemHeight(0), -_startCharMap("") +_startCharMap(""), +_labelAtlasRendererAdaptDirty(true) { } @@ -62,6 +63,7 @@ TextAtlas* TextAtlas::create() void TextAtlas::initRenderer() { _labelAtlasRenderer = LabelAtlas::create(); + _labelAtlasRenderer->setAnchorPoint(Point::ANCHOR_MIDDLE); addProtectedChild(_labelAtlasRenderer, LABELATLAS_RENDERER_Z, -1); } @@ -90,15 +92,18 @@ void TextAtlas::setProperty(const std::string& stringValue, const std::string& c _itemHeight = itemHeight; _startCharMap = startCharMap; _labelAtlasRenderer->initWithString(stringValue, charMapFile, itemWidth, itemHeight, (int)(startCharMap[0])); - updateAnchorPoint(); - labelAtlasScaleChangedWithSize(); + updateContentSizeWithTextureSize(_labelAtlasRenderer->getContentSize()); + _labelAtlasRendererAdaptDirty = true; + CCLOG("cs w %f, h %f", _contentSize.width, _contentSize.height); } void TextAtlas::setStringValue(const std::string& value) { _stringValue = value; _labelAtlasRenderer->setString(value); - labelAtlasScaleChangedWithSize(); + updateContentSizeWithTextureSize(_labelAtlasRenderer->getContentSize()); + _labelAtlasRendererAdaptDirty = true; + CCLOG("cssss w %f, h %f", _contentSize.width, _contentSize.height); } const std::string& TextAtlas::getStringValue() const @@ -106,19 +111,22 @@ const std::string& TextAtlas::getStringValue() const return _labelAtlasRenderer->getString(); } -void TextAtlas::setAnchorPoint(const Point &pt) -{ - Widget::setAnchorPoint(pt); - _labelAtlasRenderer->setAnchorPoint(Point(pt.x, pt.y)); -} - void TextAtlas::onSizeChanged() { Widget::onSizeChanged(); - labelAtlasScaleChangedWithSize(); + _labelAtlasRendererAdaptDirty = true; +} + +void TextAtlas::adaptRenderers() +{ + if (_labelAtlasRendererAdaptDirty) + { + labelAtlasScaleChangedWithSize(); + _labelAtlasRendererAdaptDirty = false; + } } -const Size& TextAtlas::getContentSize() const +const Size& TextAtlas::getVirtualRendererSize() const { return _labelAtlasRenderer->getContentSize(); } @@ -133,7 +141,6 @@ void TextAtlas::labelAtlasScaleChangedWithSize() if (_ignoreSize) { _labelAtlasRenderer->setScale(1.0f); - _size = _labelAtlasRenderer->getContentSize(); } else { @@ -148,6 +155,7 @@ void TextAtlas::labelAtlasScaleChangedWithSize() _labelAtlasRenderer->setScaleX(scaleX); _labelAtlasRenderer->setScaleY(scaleY); } + _labelAtlasRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); } std::string TextAtlas::getDescription() const diff --git a/cocos/ui/UITextAtlas.h b/cocos/ui/UITextAtlas.h index 501473f7cd..2a79e84803 100644 --- a/cocos/ui/UITextAtlas.h +++ b/cocos/ui/UITextAtlas.h @@ -78,11 +78,8 @@ public: //get string value for labelatlas. const std::string& getStringValue() const; - //override "setAnchorPoint" method of widget. - virtual void setAnchorPoint(const Point &pt) override; - - //override "getContentSize" method of widget. - virtual const Size& getContentSize() const override; + //override "getVirtualRendererSize" method of widget. + virtual const Size& getVirtualRendererSize() const override; //override "getVirtualRenderer" method of widget. virtual Node* getVirtualRenderer() override; @@ -92,6 +89,7 @@ public: */ virtual std::string getDescription() const override; + virtual void adaptRenderers() override; protected: virtual void initRenderer() override; virtual void onSizeChanged() override; @@ -108,6 +106,7 @@ protected: int _itemWidth; int _itemHeight; std::string _startCharMap; + bool _labelAtlasRendererAdaptDirty; }; } diff --git a/cocos/ui/UITextBMFont.cpp b/cocos/ui/UITextBMFont.cpp index 85b893fa9f..78648b464f 100644 --- a/cocos/ui/UITextBMFont.cpp +++ b/cocos/ui/UITextBMFont.cpp @@ -36,7 +36,8 @@ TextBMFont::TextBMFont(): _labelBMFontRenderer(nullptr), _fntFileHasInit(false), _fntFileName(""), -_stringValue("") +_stringValue(""), +_labelBMFontRendererAdaptDirty(true) { } @@ -85,8 +86,7 @@ void TextBMFont::setFntFile(const std::string& fileName) } _fntFileName = fileName; _labelBMFontRenderer->setBMFontFilePath(fileName); - updateAnchorPoint(); - labelBMFontScaleChangedWithSize(); + updateRGBAToRenderer(_labelBMFontRenderer); _fntFileHasInit = true; setText(_stringValue); } @@ -99,7 +99,8 @@ void TextBMFont::setText(const std::string& value) return; } _labelBMFontRenderer->setString(value); - labelBMFontScaleChangedWithSize(); + updateContentSizeWithTextureSize(_labelBMFontRenderer->getContentSize()); + _labelBMFontRendererAdaptDirty = true; } const std::string TextBMFont::getStringValue() @@ -107,19 +108,22 @@ const std::string TextBMFont::getStringValue() return _stringValue; } -void TextBMFont::setAnchorPoint(const Point &pt) -{ - Widget::setAnchorPoint(pt); - _labelBMFontRenderer->setAnchorPoint(pt); -} - void TextBMFont::onSizeChanged() { Widget::onSizeChanged(); - labelBMFontScaleChangedWithSize(); + _labelBMFontRendererAdaptDirty = true; +} + +void TextBMFont::adaptRenderers() +{ + if (_labelBMFontRendererAdaptDirty) + { + labelBMFontScaleChangedWithSize(); + _labelBMFontRendererAdaptDirty = false; + } } -const Size& TextBMFont::getContentSize() const +const Size& TextBMFont::getVirtualRendererSize() const { return _labelBMFontRenderer->getContentSize(); } @@ -134,7 +138,6 @@ void TextBMFont::labelBMFontScaleChangedWithSize() if (_ignoreSize) { _labelBMFontRenderer->setScale(1.0f); - _size = _labelBMFontRenderer->getContentSize(); } else { @@ -149,6 +152,7 @@ void TextBMFont::labelBMFontScaleChangedWithSize() _labelBMFontRenderer->setScaleX(scaleX); _labelBMFontRenderer->setScaleY(scaleY); } + _labelBMFontRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); } std::string TextBMFont::getDescription() const diff --git a/cocos/ui/UITextBMFont.h b/cocos/ui/UITextBMFont.h index e41cbea7fc..aa82126516 100644 --- a/cocos/ui/UITextBMFont.h +++ b/cocos/ui/UITextBMFont.h @@ -66,8 +66,7 @@ public: /** get string value for labelbmfont*/ const std::string getStringValue(); - virtual void setAnchorPoint(const Point &pt) override; - virtual const Size& getContentSize() const override; + virtual const Size& getVirtualRendererSize() const override; virtual Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. @@ -82,11 +81,13 @@ protected: void labelBMFontScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; + virtual void adaptRenderers() override; protected: cocos2d::Label* _labelBMFontRenderer; bool _fntFileHasInit; std::string _fntFileName; std::string _stringValue; + bool _labelBMFontRendererAdaptDirty; }; } diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index b96ef54dae..5a1914595e 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -364,7 +364,8 @@ _touchHeight(0.0f), _useTouchArea(false), _textFieldEventListener(nullptr), _textFieldEventSelector(nullptr), -_passwordStyleText("") +_passwordStyleText(""), +_textFieldRendererAdaptDirty(true) { } @@ -514,14 +515,15 @@ void TextField::setText(const std::string& text) { _textFieldRenderer->setString(content); } - - textfieldRendererScaleChangedWithSize(); + _textFieldRendererAdaptDirty = true; + updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } void TextField::setPlaceHolder(const std::string& value) { _textFieldRenderer->setPlaceHolder(value); - textfieldRendererScaleChangedWithSize(); + _textFieldRendererAdaptDirty = true; + updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } const std::string& TextField::getPlaceHolder() @@ -532,7 +534,8 @@ const std::string& TextField::getPlaceHolder() void TextField::setFontSize(int size) { _textFieldRenderer->setSystemFontSize(size); - textfieldRendererScaleChangedWithSize(); + _textFieldRendererAdaptDirty = true; + updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } int TextField::getFontSize() @@ -543,7 +546,8 @@ int TextField::getFontSize() void TextField::setFontName(const std::string& name) { _textFieldRenderer->setSystemFontName(name); - textfieldRendererScaleChangedWithSize(); + _textFieldRendererAdaptDirty = true; + updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } const std::string& TextField::getFontName() @@ -634,14 +638,16 @@ void TextField::update(float dt) insertTextEvent(); setInsertText(false); - textfieldRendererScaleChangedWithSize(); + _textFieldRendererAdaptDirty = true; + updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } if (getDeleteBackward()) { deleteBackwardEvent(); setDeleteBackward(false); - textfieldRendererScaleChangedWithSize(); + _textFieldRendererAdaptDirty = true; + updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize()); } } @@ -723,16 +729,19 @@ void TextField::addEventListenerTextField(Ref *target, SEL_TextFieldEvent seleco _textFieldEventSelector = selecor; } -void TextField::setAnchorPoint(const Point &pt) -{ - Widget::setAnchorPoint(pt); - _textFieldRenderer->setAnchorPoint(pt); -} - void TextField::onSizeChanged() { Widget::onSizeChanged(); - textfieldRendererScaleChangedWithSize(); + _textFieldRendererAdaptDirty = true; +} + +void TextField::adaptRenderers() +{ + if (_textFieldRendererAdaptDirty) + { + textfieldRendererScaleChangedWithSize(); + _textFieldRendererAdaptDirty = false; + } } void TextField::textfieldRendererScaleChangedWithSize() @@ -741,7 +750,6 @@ void TextField::textfieldRendererScaleChangedWithSize() { _textFieldRenderer->setDimensions(0,0); _textFieldRenderer->setScale(1.0f); - _size = getContentSize(); } else { @@ -757,9 +765,10 @@ void TextField::textfieldRendererScaleChangedWithSize() _textFieldRenderer->setScaleX(scaleX); _textFieldRenderer->setScaleY(scaleY); } + _textFieldRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); } -const Size& TextField::getContentSize() const +const Size& TextField::getVirtualRendererSize() const { return _textFieldRenderer->getContentSize(); } diff --git a/cocos/ui/UITextField.h b/cocos/ui/UITextField.h index 73e728cb8b..56733e06cd 100644 --- a/cocos/ui/UITextField.h +++ b/cocos/ui/UITextField.h @@ -145,15 +145,13 @@ public: bool getDeleteBackward(); void setDeleteBackward(bool deleteBackward); void addEventListenerTextField(Ref* target, SEL_TextFieldEvent selecor); - - virtual void setAnchorPoint(const Point &pt) override; /** * Returns the "class name" of widget. */ virtual std::string getDescription() const override; - virtual const Size& getContentSize() const override; + virtual const Size& getVirtualRendererSize() const override; virtual Node* getVirtualRenderer() override; void attachWithIME(); virtual void onEnter() override; @@ -178,6 +176,7 @@ protected: void textfieldRendererScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; + virtual void adaptRenderers() override; protected: UICCTextField* _textFieldRenderer; @@ -189,6 +188,7 @@ protected: SEL_TextFieldEvent _textFieldEventSelector; std::string _passwordStyleText; + bool _textFieldRendererAdaptDirty; }; } diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index d35c7b38a2..ff9e5edf6d 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -112,6 +112,7 @@ void Widget::visit(Renderer *renderer, const kmMat4 &parentTransform, bool paren { if (_enabled) { + adaptRenderers(); ProtectedNode::visit(renderer, parentTransform, parentTransformUpdated); } } @@ -177,7 +178,7 @@ void Widget::setSize(const Size &size) _customSize = size; if (_ignoreSize) { - _size = getContentSize(); + _size = getVirtualRendererSize(); } else { @@ -228,7 +229,7 @@ void Widget::setSizePercent(const Point &percent) } if (_ignoreSize) { - _size = getContentSize(); + _size = getVirtualRendererSize(); } else { @@ -261,7 +262,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize) { if (_ignoreSize) { - _size = getContentSize(); + _size = getVirtualRendererSize(); } else { @@ -285,7 +286,7 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize) Size cSize = Size(parentSize.width * _sizePercent.x , parentSize.height * _sizePercent.y); if (_ignoreSize) { - _size = getContentSize(); + _size = getVirtualRendererSize(); } else { @@ -343,7 +344,7 @@ void Widget::ignoreContentAdaptWithSize(bool ignore) _ignoreSize = ignore; if (_ignoreSize) { - Size s = getContentSize(); + Size s = getVirtualRendererSize(); _size = s; } else @@ -375,7 +376,7 @@ const Point& Widget::getSizePercent() const Point Widget::getWorldPosition() { - return convertToWorldSpace(Point::ZERO); + return convertToWorldSpace(Point(_anchorPoint.x * _contentSize.width, _anchorPoint.y * _contentSize.height)); } Node* Widget::getVirtualRenderer() @@ -385,6 +386,7 @@ Node* Widget::getVirtualRenderer() void Widget::onSizeChanged() { + setContentSize(_size); for (auto& child : getChildren()) { Widget* widgetChild = dynamic_cast(child); @@ -395,9 +397,22 @@ void Widget::onSizeChanged() } } -const Size& Widget::getContentSize() const +const Size& Widget::getVirtualRendererSize() const { - return _size; + return _contentSize; +} + +void Widget::updateContentSizeWithTextureSize(const cocos2d::Size &size) +{ + if (_ignoreSize) + { + _size = size; + } + else + { + _size = _customSize; + } + onSizeChanged(); } void Widget::setTouchEnabled(bool enable) @@ -617,8 +632,9 @@ void Widget::addTouchEventListener(Ref *target, SEL_TouchEvent selector) bool Widget::hitTest(const Point &pt) { Point nsp = convertToNodeSpace(pt); - Rect bb = Rect(-_size.width * _anchorPoint.x, -_size.height * _anchorPoint.y, _size.width, _size.height); - if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height) + Rect bb; + bb.size = _contentSize; + if (bb.containsPoint(nsp)) { return true; } @@ -712,11 +728,6 @@ void Widget::setPositionPercent(const Point &percent) } } -void Widget::updateAnchorPoint() -{ - setAnchorPoint(getAnchorPoint()); -} - const Point& Widget::getPositionPercent() { return _positionPercent; diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index 0f2aa4d40c..c26eb0020d 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -501,12 +501,15 @@ public: */ virtual Node* getVirtualRenderer(); - /** - * Gets the content size of widget. - * - * Content size is widget's texture size. - */ - virtual const Size& getContentSize() const; +// /** +// * Gets the content size of widget. +// * +// * Content size is widget's texture size. +// */ +// virtual const Size& getContentSize() const; + virtual const Size& getVirtualRendererSize() const; + + /** * Returns the "class name" of widget. @@ -549,7 +552,6 @@ protected: void moveEvent(); void releaseUpEvent(); void cancelUpEvent(); - void updateAnchorPoint(); virtual void updateTextureColor(){}; virtual void updateTextureOpacity(){}; virtual void updateTextureRGBA(){}; @@ -563,6 +565,8 @@ protected: virtual void copySpecialProperties(Widget* model); virtual void copyClonedWidgetChildren(Widget* model); Widget* getWidgetParent(); + void updateContentSizeWithTextureSize(const Size& size); + virtual void adaptRenderers(){}; protected: bool _enabled; ///< Highest control of widget bool _bright; ///< is this widget bright diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 725a96ce9f..0539c64528 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -40,7 +40,7 @@ bool UIButtonTest::init() "cocosui/animationbuttonpressed.png"); button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); button->addTouchEventListener(this, toucheventselector(UIButtonTest::touchEvent)); - _uiLayer->addChild(button); + _uiLayer->addChild(button); return true; } @@ -109,7 +109,7 @@ bool UIButtonTest_Scale9::init() // open scale9 render button->setScale9Enabled(true); button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - button->setSize(Size(150, button->getContentSize().height * 1.5f)); + button->setSize(Size(150, 70)); button->addTouchEventListener(this, toucheventselector(UIButtonTest_Scale9::touchEvent)); _uiLayer->addChild(button); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp index 9445db0c9a..885ef2bfff 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp @@ -21,7 +21,7 @@ bool UIImageViewTest::init() // Create the imageview ImageView* imageView = ImageView::create("cocosui/ccicon.png"); imageView->setPosition(Point(widgetSize.width / 2.0f, - widgetSize.height / 2.0f + imageView->getSize().height / 4.0f)); + widgetSize.height / 2.0f)); _uiLayer->addChild(imageView); @@ -53,7 +53,7 @@ bool UIImageViewTest_Scale9::init() imageView->setScale9Enabled(true); imageView->setSize(Size(300, 115)); imageView->setPosition(Point(widgetSize.width / 2.0f, - widgetSize.height / 2.0f + imageView->getSize().height / 4.0f)); + widgetSize.height / 2.0f)); _uiLayer->addChild(imageView); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp index 89d7347866..efab080cb6 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp @@ -53,7 +53,7 @@ bool UILayoutTest::init() Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); - button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height)); + button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f)); @@ -118,7 +118,7 @@ bool UILayoutTest_Color::init() Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); - button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height)); + button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f)); @@ -182,7 +182,7 @@ bool UILayoutTest_Gradient::init() Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); - button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height)); + button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f)); @@ -243,7 +243,7 @@ bool UILayoutTest_BackGroundImage::init() Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); - button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height)); + button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f)); @@ -305,7 +305,7 @@ bool UILayoutTest_BackGroundImage_Scale9::init() Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); - button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height)); + button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f)); layout->addChild(button_scale9); @@ -376,7 +376,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init() Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); - button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height)); + button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); layout->addChild(button_scale9); LinearLayoutParameter* lp3 = LinearLayoutParameter::create(); @@ -450,7 +450,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init() Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); - button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height)); + button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); layout->addChild(button_scale9); LinearLayoutParameter* lp3 = LinearLayoutParameter::create(); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index b728db0634..892b4a4b3c 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -193,7 +193,7 @@ bool UILoadingBarTest_Left_Scale9::init() loadingBar->setTag(0); loadingBar->setScale9Enabled(true); loadingBar->setCapInsets(Rect(0, 0, 0, 0)); - loadingBar->setSize(Size(300, loadingBar->getContentSize().height)); + loadingBar->setSize(Size(300, 13)); loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f)); @@ -275,7 +275,7 @@ bool UILoadingBarTest_Right_Scale9::init() loadingBar->setTag(0); loadingBar->setScale9Enabled(true); loadingBar->setCapInsets(Rect(0, 0, 0, 0)); - loadingBar->setSize(Size(300, loadingBar->getContentSize().height)); + loadingBar->setSize(Size(300, 13)); loadingBar->setDirection(LoadingBarTypeRight); loadingBar->setPosition(Point(widgetSize.width / 2.0f, diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp index 40fe24d6d3..3daf1fbc37 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp @@ -65,7 +65,7 @@ bool UIScrollViewTest_Vertical::init() Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); - button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height)); + button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); button_scale9->setPosition(Point(innerWidth / 2.0f, titleButton->getBottomInParent() - titleButton->getSize().height)); scrollView->addChild(button_scale9); @@ -143,7 +143,7 @@ bool UIScrollViewTest_Horizontal::init() Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png"); button_scale9->setScale9Enabled(true); - button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height)); + button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height)); button_scale9->setPosition(Point(titleButton->getRightInParent() + titleButton->getSize().width / 2.0f, titleButton->getBottomInParent() - titleButton->getSize().height / 2.0f)); scrollView->addChild(button_scale9); From a8bfa094c02de10d1f0bbebb705c4de81b1c09dd Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 17 Apr 2014 14:27:21 +0800 Subject: [PATCH 21/40] Remove useless codes --- cocos/ui/UIRichText.h | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/ui/UIRichText.h b/cocos/ui/UIRichText.h index 3334f5b8aa..6bf9fddf63 100644 --- a/cocos/ui/UIRichText.h +++ b/cocos/ui/UIRichText.h @@ -121,7 +121,6 @@ protected: void handleCustomRenderer(Node* renderer); void formarRenderers(); void addNewLine(); -// virtual void adaptRenderers() override; protected: bool _formatTextDirty; Vector _richElements; From a8a8ef85e62ae198831bfc40bf60a0f26a9bac3f Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 17 Apr 2014 14:46:52 +0800 Subject: [PATCH 22/40] add comment for EventListenerTouchOneByOne::checkAvailable() --- cocos/2d/CCEventListenerTouch.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/2d/CCEventListenerTouch.cpp b/cocos/2d/CCEventListenerTouch.cpp index 2dbbbe8d41..4730cc7f60 100644 --- a/cocos/2d/CCEventListenerTouch.cpp +++ b/cocos/2d/CCEventListenerTouch.cpp @@ -82,6 +82,8 @@ EventListenerTouchOneByOne* EventListenerTouchOneByOne::create() bool EventListenerTouchOneByOne::checkAvailable() { + // EventDispatcher will use the return value of 'onTouchBegan' to determine whether to pass following 'move', 'end' + // message to 'EventListenerTouchOneByOne' or not. So 'onTouchBegan' needs to be set. if (onTouchBegan == nullptr) { CCASSERT(false, "Invalid EventListenerTouchOneByOne!"); From 70c20ddfb201ecea624485a39fb49c1288bd8b37 Mon Sep 17 00:00:00 2001 From: heliclei Date: Thu, 17 Apr 2014 15:08:49 +0800 Subject: [PATCH 23/40] add execute permission --- tools/jenkins-scripts/upload_apk.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/jenkins-scripts/upload_apk.sh diff --git a/tools/jenkins-scripts/upload_apk.sh b/tools/jenkins-scripts/upload_apk.sh old mode 100644 new mode 100755 From 2914f60fcf5c8bb2d7be33658cf443d3ac6c0b9a Mon Sep 17 00:00:00 2001 From: cw Date: Thu, 17 Apr 2014 16:50:11 +0800 Subject: [PATCH 24/40] fixed xiaomi show ip error --- .../src/org/cocos2dx/lua/AppActivity.java | 58 ++++++++++++------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java index 0a013e908c..ac6dc0b14b 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java @@ -32,13 +32,20 @@ import java.net.SocketException; import java.util.Enumeration; import org.cocos2dx.lib.Cocos2dxActivity; + +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; +import android.content.pm.ApplicationInfo; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; import android.os.Bundle; import android.os.Environment; import android.provider.Settings; +import android.text.format.Formatter; import android.util.Log; import android.widget.Toast; @@ -47,20 +54,36 @@ import android.widget.Toast; public class AppActivity extends Cocos2dxActivity{ + static String hostIPAdress="0.0.0.0"; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); //2.Set the format of window - // getWindow().setFormat(PixelFormat.TRANSLUCENT); - if(!isWifiConnected()) + + // Check the wifi is open when the android:debuggable is "true". + if(0!=((this.getApplicationInfo().flags) & ApplicationInfo.FLAG_DEBUGGABLE)) { - Toast.makeText(this, "wifi is closed!", Toast.LENGTH_SHORT).show(); - startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); + if(!isWifiConnected()) + { + AlertDialog.Builder builder=new AlertDialog.Builder(this); + builder.setTitle("Warning"); + builder.setMessage("Open Wifi for debuging..."); + builder.setPositiveButton("OK",new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); + finish(); + } + }); + builder.setCancelable(false); + builder.show(); + } } + hostIPAdress = getHostIpAddress(); } - private boolean isWifiConnected() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { @@ -72,23 +95,15 @@ public class AppActivity extends Cocos2dxActivity{ return false; } + public String getHostIpAddress() { + WifiManager wifiMgr = (WifiManager) getSystemService(WIFI_SERVICE); + WifiInfo wifiInfo = wifiMgr.getConnectionInfo(); + int ip = wifiInfo.getIpAddress(); + return ((ip & 0xFF) + "." + ((ip >>>= 8) & 0xFF) + "." + ((ip >>>= 8) & 0xFF) + "." + ((ip >>>= 8) & 0xFF)); + } + public static String getLocalIpAddress() { - try { - for (Enumeration en = NetworkInterface - .getNetworkInterfaces(); en.hasMoreElements();) { - NetworkInterface intf = en.nextElement(); - for (Enumeration enumIpAddr = intf - .getInetAddresses(); enumIpAddr.hasMoreElements();) { - InetAddress inetAddress = enumIpAddr.nextElement(); - if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress()) { - return inetAddress.getHostAddress().toString(); - } - } - } - } catch (SocketException ex) { - Log.e("WifiPreference IpAddress", ex.toString()); - } - return null; + return hostIPAdress; } public static String getSDCardPath() { @@ -100,4 +115,3 @@ public class AppActivity extends Cocos2dxActivity{ } } - From c34b3d532497f5d23cfaa196a1b8637ec7d10a67 Mon Sep 17 00:00:00 2001 From: lm Date: Thu, 17 Apr 2014 17:04:28 +0800 Subject: [PATCH 25/40] [Jenkins][ci skip] Add android.permission.INTERNET to cpp-empty-test --- tools/jenkins-scripts/pull-request-builder.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/jenkins-scripts/pull-request-builder.py b/tools/jenkins-scripts/pull-request-builder.py index ea2e86c887..a77ac64c70 100755 --- a/tools/jenkins-scripts/pull-request-builder.py +++ b/tools/jenkins-scripts/pull-request-builder.py @@ -146,6 +146,11 @@ def main(): data = codecs.open(modify_file, encoding='UTF-8').read() data = re.sub("director->setDisplayStats\(true\);", "director->setDisplayStats(true); director->getConsole()->listenOnTCP(5678);", data) codecs.open(modify_file, 'wb', encoding='UTF-8').write(data) + #modify tests/cpp-empty-test/proj.android/AndroidManifest.xml to support Console + modify_file = 'tests/cpp-empty-test/proj.android/AndroidManifest.xml' + data = codecs.open(modify_file, encoding='UTF-8').read() + data = re.sub('', ' ', data) + codecs.open(modify_file, 'wb', encoding='UTF-8').write(data) print "Start build android..." ret = os.system("python build/android-build.py -n -j10 all") # create and save apk From 33472c7805235c3ae1e9d726ef764fc139b4928c Mon Sep 17 00:00:00 2001 From: zhangbin Date: Thu, 17 Apr 2014 17:18:39 +0800 Subject: [PATCH 26/40] closed #4863, Zipalign the apk generated with release mode. --- tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index f5768df8fd..70fa1ec93b 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit f5768df8fdd5a5a0069b9634aede93ce13e0c9d6 +Subproject commit 70fa1ec93b56f535b9714392ddee7ca53c220bb1 From dfeac8c7d2832888a80561708380014a0686a62f Mon Sep 17 00:00:00 2001 From: lm Date: Thu, 17 Apr 2014 18:08:15 +0800 Subject: [PATCH 27/40] [Jenkins][ci skip] Fix result comment body of Emptytest --- tools/jenkins-scripts/emptytest-post-build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/jenkins-scripts/emptytest-post-build.py b/tools/jenkins-scripts/emptytest-post-build.py index 3fdbff6178..afc92f390f 100644 --- a/tools/jenkins-scripts/emptytest-post-build.py +++ b/tools/jenkins-scripts/emptytest-post-build.py @@ -25,8 +25,8 @@ Headers = {"Authorization":"token " + access_token} result = J[os.environ['JOB_NAME']].get_build(build_number).get_status() if(result == STATUS_SUCCESS): - data['body'] = "Emptytest run Success: " + target_url + data['body'] = "Emptytest run successfully: " + target_url else: - data['body'] = "Emptytest run Failure: " + target_url + data['body'] = "Emptytest failed: " + target_url requests.post(comments_url, data=json.dumps(data), headers=Headers) From f5954139836c9159843810282c97db5c6969b25a Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 18 Apr 2014 09:36:34 +0800 Subject: [PATCH 28/40] closed #4903: Build libcurl.a with openssl --- external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id | 2 +- external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id b/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id index b832ed4fb2..dccfa8ac92 100644 --- a/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id +++ b/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id @@ -1 +1 @@ -dc1d98e73cda98024add3420a06fa29651c863d0 \ No newline at end of file +ee8d6b9b640f55a31fff715702df4fed30b34540 \ No newline at end of file diff --git a/external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id b/external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id index 709ec42a2a..f8ebb35264 100644 --- a/external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id +++ b/external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id @@ -1 +1 @@ -9b09288998b6198388456c41ccbdd5596622abe5 \ No newline at end of file +30f4d695532ecab63f94a54d52e0b4d61c910aa4 \ No newline at end of file From a78a1090c396d9e7bf846c621e9eea654eb5f839 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 18 Apr 2014 02:51:14 +0000 Subject: [PATCH 29/40] [AUTO]: updating luabinding automatically --- cocos/scripting/lua-bindings/auto/api/Button.lua | 7 +------ cocos/scripting/lua-bindings/auto/api/CheckBox.lua | 7 +------ .../scripting/lua-bindings/auto/api/ImageView.lua | 7 +------ cocos/scripting/lua-bindings/auto/api/Layout.lua | 6 ------ .../scripting/lua-bindings/auto/api/LoadingBar.lua | 2 +- cocos/scripting/lua-bindings/auto/api/RichText.lua | 12 ++++++------ cocos/scripting/lua-bindings/auto/api/Slider.lua | 2 +- cocos/scripting/lua-bindings/auto/api/Text.lua | 7 +------ .../scripting/lua-bindings/auto/api/TextAtlas.lua | 11 +++++------ .../scripting/lua-bindings/auto/api/TextBMFont.lua | 7 +------ .../scripting/lua-bindings/auto/api/TextField.lua | 7 +------ cocos/scripting/lua-bindings/auto/api/Widget.lua | 14 +++++++------- .../auto/lua_cocos2dx_ui_auto.cpp.REMOVED.git-id | 2 +- .../lua-bindings/auto/lua_cocos2dx_ui_auto.hpp | 1 - 14 files changed, 27 insertions(+), 65 deletions(-) diff --git a/cocos/scripting/lua-bindings/auto/api/Button.lua b/cocos/scripting/lua-bindings/auto/api/Button.lua index 203ab720b4..f4b9700b56 100644 --- a/cocos/scripting/lua-bindings/auto/api/Button.lua +++ b/cocos/scripting/lua-bindings/auto/api/Button.lua @@ -137,11 +137,6 @@ -- @param self -- @return Ref#Ref ret (return value: cc.Ref) --------------------------------- --- @function [parent=#Button] setAnchorPoint --- @param self --- @param #point_table point - -------------------------------- -- @function [parent=#Button] getVirtualRenderer -- @param self @@ -153,7 +148,7 @@ -- @return string#string ret (return value: string) -------------------------------- --- @function [parent=#Button] getContentSize +-- @function [parent=#Button] getVirtualRendererSize -- @param self -- @return size_table#size_table ret (return value: size_table) diff --git a/cocos/scripting/lua-bindings/auto/api/CheckBox.lua b/cocos/scripting/lua-bindings/auto/api/CheckBox.lua index c2a9ed2d91..4784f88235 100644 --- a/cocos/scripting/lua-bindings/auto/api/CheckBox.lua +++ b/cocos/scripting/lua-bindings/auto/api/CheckBox.lua @@ -73,11 +73,6 @@ -- @param self -- @return Ref#Ref ret (return value: cc.Ref) --------------------------------- --- @function [parent=#CheckBox] setAnchorPoint --- @param self --- @param #point_table point - -------------------------------- -- @function [parent=#CheckBox] getVirtualRenderer -- @param self @@ -89,7 +84,7 @@ -- @return string#string ret (return value: string) -------------------------------- --- @function [parent=#CheckBox] getContentSize +-- @function [parent=#CheckBox] getVirtualRendererSize -- @param self -- @return size_table#size_table ret (return value: size_table) diff --git a/cocos/scripting/lua-bindings/auto/api/ImageView.lua b/cocos/scripting/lua-bindings/auto/api/ImageView.lua index d841c5b850..43e733e104 100644 --- a/cocos/scripting/lua-bindings/auto/api/ImageView.lua +++ b/cocos/scripting/lua-bindings/auto/api/ImageView.lua @@ -50,11 +50,6 @@ -- @param self -- @return Ref#Ref ret (return value: cc.Ref) --------------------------------- --- @function [parent=#ImageView] setAnchorPoint --- @param self --- @param #point_table point - -------------------------------- -- @function [parent=#ImageView] getVirtualRenderer -- @param self @@ -66,7 +61,7 @@ -- @return string#string ret (return value: string) -------------------------------- --- @function [parent=#ImageView] getContentSize +-- @function [parent=#ImageView] getVirtualRendererSize -- @param self -- @return size_table#size_table ret (return value: size_table) diff --git a/cocos/scripting/lua-bindings/auto/api/Layout.lua b/cocos/scripting/lua-bindings/auto/api/Layout.lua index bcfe778653..8a5ef2c0e1 100644 --- a/cocos/scripting/lua-bindings/auto/api/Layout.lua +++ b/cocos/scripting/lua-bindings/auto/api/Layout.lua @@ -137,12 +137,6 @@ -- @param self -- @return color3B_table#color3B_table ret (return value: color3B_table) --------------------------------- --- @function [parent=#Layout] hitTest --- @param self --- @param #point_table point --- @return bool#bool ret (return value: bool) - -------------------------------- -- @function [parent=#Layout] setBackGroundImageScale9Enabled -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/LoadingBar.lua b/cocos/scripting/lua-bindings/auto/api/LoadingBar.lua index a4fc57235c..89637ee4f3 100644 --- a/cocos/scripting/lua-bindings/auto/api/LoadingBar.lua +++ b/cocos/scripting/lua-bindings/auto/api/LoadingBar.lua @@ -76,7 +76,7 @@ -- @return string#string ret (return value: string) -------------------------------- --- @function [parent=#LoadingBar] getContentSize +-- @function [parent=#LoadingBar] getVirtualRendererSize -- @param self -- @return size_table#size_table ret (return value: size_table) diff --git a/cocos/scripting/lua-bindings/auto/api/RichText.lua b/cocos/scripting/lua-bindings/auto/api/RichText.lua index b14dcddf9e..cd2dedd8c8 100644 --- a/cocos/scripting/lua-bindings/auto/api/RichText.lua +++ b/cocos/scripting/lua-bindings/auto/api/RichText.lua @@ -19,10 +19,6 @@ -- @param self -- @param #ccui.RichElement richelement --------------------------------- --- @function [parent=#RichText] formatText --- @param self - -------------------------------- -- @function [parent=#RichText] ignoreContentAdaptWithSize -- @param self @@ -34,9 +30,8 @@ -- @param #float float -------------------------------- --- @function [parent=#RichText] getContentSize +-- @function [parent=#RichText] formatText -- @param self --- @return size_table#size_table ret (return value: size_table) -------------------------------- -- overload function: removeElement(ccui.RichElement) @@ -57,6 +52,11 @@ -- @param self -- @return string#string ret (return value: string) +-------------------------------- +-- @function [parent=#RichText] getVirtualRendererSize +-- @param self +-- @return size_table#size_table ret (return value: size_table) + -------------------------------- -- @function [parent=#RichText] RichText -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/Slider.lua b/cocos/scripting/lua-bindings/auto/api/Slider.lua index e3a6e6b2ad..41b439b77e 100644 --- a/cocos/scripting/lua-bindings/auto/api/Slider.lua +++ b/cocos/scripting/lua-bindings/auto/api/Slider.lua @@ -118,7 +118,7 @@ -- @return bool#bool ret (return value: bool) -------------------------------- --- @function [parent=#Slider] getContentSize +-- @function [parent=#Slider] getVirtualRendererSize -- @param self -- @return size_table#size_table ret (return value: size_table) diff --git a/cocos/scripting/lua-bindings/auto/api/Text.lua b/cocos/scripting/lua-bindings/auto/api/Text.lua index ff84275e98..6e326cc7a7 100644 --- a/cocos/scripting/lua-bindings/auto/api/Text.lua +++ b/cocos/scripting/lua-bindings/auto/api/Text.lua @@ -95,11 +95,6 @@ -- @param self -- @return Ref#Ref ret (return value: cc.Ref) --------------------------------- --- @function [parent=#Text] setAnchorPoint --- @param self --- @param #point_table point - -------------------------------- -- @function [parent=#Text] getVirtualRenderer -- @param self @@ -111,7 +106,7 @@ -- @return string#string ret (return value: string) -------------------------------- --- @function [parent=#Text] getContentSize +-- @function [parent=#Text] getVirtualRendererSize -- @param self -- @return size_table#size_table ret (return value: size_table) diff --git a/cocos/scripting/lua-bindings/auto/api/TextAtlas.lua b/cocos/scripting/lua-bindings/auto/api/TextAtlas.lua index 1fe2b105f7..b1cba77fdf 100644 --- a/cocos/scripting/lua-bindings/auto/api/TextAtlas.lua +++ b/cocos/scripting/lua-bindings/auto/api/TextAtlas.lua @@ -17,6 +17,10 @@ -- @param self -- @return string#string ret (return value: string) +-------------------------------- +-- @function [parent=#TextAtlas] adaptRenderers +-- @param self + -------------------------------- -- @function [parent=#TextAtlas] setStringValue -- @param self @@ -41,11 +45,6 @@ -- @param self -- @return Ref#Ref ret (return value: cc.Ref) --------------------------------- --- @function [parent=#TextAtlas] setAnchorPoint --- @param self --- @param #point_table point - -------------------------------- -- @function [parent=#TextAtlas] getVirtualRenderer -- @param self @@ -57,7 +56,7 @@ -- @return string#string ret (return value: string) -------------------------------- --- @function [parent=#TextAtlas] getContentSize +-- @function [parent=#TextAtlas] getVirtualRendererSize -- @param self -- @return size_table#size_table ret (return value: size_table) diff --git a/cocos/scripting/lua-bindings/auto/api/TextBMFont.lua b/cocos/scripting/lua-bindings/auto/api/TextBMFont.lua index 961683e0ce..c0fe477b96 100644 --- a/cocos/scripting/lua-bindings/auto/api/TextBMFont.lua +++ b/cocos/scripting/lua-bindings/auto/api/TextBMFont.lua @@ -34,11 +34,6 @@ -- @param self -- @return Ref#Ref ret (return value: cc.Ref) --------------------------------- --- @function [parent=#TextBMFont] setAnchorPoint --- @param self --- @param #point_table point - -------------------------------- -- @function [parent=#TextBMFont] getVirtualRenderer -- @param self @@ -50,7 +45,7 @@ -- @return string#string ret (return value: string) -------------------------------- --- @function [parent=#TextBMFont] getContentSize +-- @function [parent=#TextBMFont] getVirtualRendererSize -- @param self -- @return size_table#size_table ret (return value: size_table) diff --git a/cocos/scripting/lua-bindings/auto/api/TextField.lua b/cocos/scripting/lua-bindings/auto/api/TextField.lua index 1e318ed19a..8b1c571dbf 100644 --- a/cocos/scripting/lua-bindings/auto/api/TextField.lua +++ b/cocos/scripting/lua-bindings/auto/api/TextField.lua @@ -184,11 +184,6 @@ -- @param self -- @return Ref#Ref ret (return value: cc.Ref) --------------------------------- --- @function [parent=#TextField] setAnchorPoint --- @param self --- @param #point_table point - -------------------------------- -- @function [parent=#TextField] getVirtualRenderer -- @param self @@ -205,7 +200,7 @@ -- @param #float float -------------------------------- --- @function [parent=#TextField] getContentSize +-- @function [parent=#TextField] getVirtualRendererSize -- @param self -- @return size_table#size_table ret (return value: size_table) diff --git a/cocos/scripting/lua-bindings/auto/api/Widget.lua b/cocos/scripting/lua-bindings/auto/api/Widget.lua index 1f97832c9f..3ec34ffdc8 100644 --- a/cocos/scripting/lua-bindings/auto/api/Widget.lua +++ b/cocos/scripting/lua-bindings/auto/api/Widget.lua @@ -63,11 +63,6 @@ -- @param self -- @return float#float ret (return value: float) --------------------------------- --- @function [parent=#Widget] getActionTag --- @param self --- @return int#int ret (return value: int) - -------------------------------- -- @function [parent=#Widget] getLayoutParameter -- @param self @@ -100,15 +95,20 @@ -- @param self -- @return bool#bool ret (return value: bool) +-------------------------------- +-- @function [parent=#Widget] getVirtualRendererSize +-- @param self +-- @return size_table#size_table ret (return value: size_table) + -------------------------------- -- @function [parent=#Widget] isTouchEnabled -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- --- @function [parent=#Widget] getContentSize +-- @function [parent=#Widget] getActionTag -- @param self --- @return size_table#size_table ret (return value: size_table) +-- @return int#int ret (return value: int) -------------------------------- -- @function [parent=#Widget] getWorldPosition diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp.REMOVED.git-id index db0a19197c..f10963bde4 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -a1f2ceee65fe7b4bdae2cd2c32ff84fa332a6b50 \ No newline at end of file +088e9951d4f001122370379060141d0e98b5a4d8 \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index 75d07761f8..fa8c906dcd 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -365,7 +365,6 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); - #endif // __cocos2dx_ui_h__ From a9e697523ea8cb17ca086b34af3825a4d8cd6b3b Mon Sep 17 00:00:00 2001 From: cw Date: Fri, 18 Apr 2014 11:40:51 +0800 Subject: [PATCH 30/40] amend comment --- .../proj.android/src/org/cocos2dx/lua/AppActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java index ac6dc0b14b..ceb209f981 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java @@ -62,7 +62,7 @@ public class AppActivity extends Cocos2dxActivity{ //2.Set the format of window - // Check the wifi is open when the android:debuggable is "true". + // Check the wifi is opened when the android:debuggable is "true". if(0!=((this.getApplicationInfo().flags) & ApplicationInfo.FLAG_DEBUGGABLE)) { if(!isWifiConnected()) From 914516a4e08789ad28b7c1dee22f152fd3c9d1e2 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Fri, 18 Apr 2014 11:54:57 +0800 Subject: [PATCH 31/40] fix the compile error about luabindings and add the `RichText` test cases. --- .../lua-bindings/manual/lua_cocos2dx_manual.cpp.REMOVED.git-id | 2 +- .../CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp.REMOVED.git-id index c6600f056d..4ee16ce11f 100644 --- a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp.REMOVED.git-id @@ -1 +1 @@ -468c9e8472db4be2923ca63484bc72ba2a30ae88 \ No newline at end of file +c6021dd4f0d5fbfab61453c2a5f045f4f789a18d \ No newline at end of file diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id index 52664ad56c..7300406178 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id @@ -1 +1 @@ -c43e2d2b4092953dba18fe8223330eb29809bb01 \ No newline at end of file +1f20f88e2a2985963fc6a2d89ea07be41e8e74d0 \ No newline at end of file From ef52c91849e385ef99589599286fbd911d118f3a Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 18 Apr 2014 13:56:49 +0800 Subject: [PATCH 32/40] [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index bf28ca4e25..29b3374386 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -5c54d396206175b71038b1b99d2db31443421952 \ No newline at end of file +ad6350e744a8efa02cb5dec0d7b3bb9367f7a26c \ No newline at end of file From 5fe9ab992ec75b8d660b79b0fe2592971e938319 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 18 Apr 2014 13:58:56 +0800 Subject: [PATCH 33/40] [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index 29b3374386..acda3cd7cc 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -ad6350e744a8efa02cb5dec0d7b3bb9367f7a26c \ No newline at end of file +d12b75e6d9ad47f2a2d44fdc17256174582042df \ No newline at end of file From 051d4cf62d7c36c36db65e945e0f25e33aef8afd Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 18 Apr 2014 14:02:26 +0800 Subject: [PATCH 34/40] [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index acda3cd7cc..5ada371008 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -d12b75e6d9ad47f2a2d44fdc17256174582042df \ No newline at end of file +95043bef1854b36f6cfb7f01b9d1ac570f9bca45 \ No newline at end of file From 5b4a65ea3ada90ccd3bc99817c442630763b3242 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 18 Apr 2014 14:21:06 +0800 Subject: [PATCH 35/40] [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 6abc36c6e3..b4ad7ae2b5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -818,6 +818,7 @@ Developers: Fixed a bug that the result of 'malloc' is incompatible with type 'unsigned char *' in Image::saveImageToPNG Fixed a potential memory leak in CCEditBoxImplIOS.mm Fixed incompatible pointer conversion in external/chipmunk/src/cpArray.c + Fix memory leak in CCImage ololomax Fixed a potential crash in SceneReader::createNodeWithSceneFile From 2aea2540b63f0351498cd90c285e0f469e910813 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 18 Apr 2014 14:22:21 +0800 Subject: [PATCH 36/40] [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index 5ada371008..71b4d4ca9e 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -95043bef1854b36f6cfb7f01b9d1ac570f9bca45 \ No newline at end of file +ae6f2a125c3cecc456cd93fa9c2918cd6977b323 \ No newline at end of file From 0a1c926d109ae084ad1b1f5bd2b244d8ddab159d Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 18 Apr 2014 16:52:41 +0800 Subject: [PATCH 37/40] Update CHANGELOG [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index 71b4d4ca9e..9c4fadda1c 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -ae6f2a125c3cecc456cd93fa9c2918cd6977b323 \ No newline at end of file +8b0ee4d2e4101318d32e8b612f1392953ae35733 \ No newline at end of file From 482fa3ece08813fdece472603427c1aa30f2cf1e Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 18 Apr 2014 16:53:18 +0800 Subject: [PATCH 38/40] Update CHANGELOG [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index 9c4fadda1c..2ec9d498f9 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -8b0ee4d2e4101318d32e8b612f1392953ae35733 \ No newline at end of file +0613c5d8504cc76995b53156f3f6e647e54269eb \ No newline at end of file From 9756709473e7c541f820f4e6b8f5816028fd7b82 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 18 Apr 2014 17:03:06 +0800 Subject: [PATCH 39/40] closed #4903: change HttpClientTest get test 3 to https protocol. --- .../Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp index 41f7cdcbb5..8b3cbf2ff3 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp @@ -102,7 +102,7 @@ void HttpClientTest::onMenuGetTestClicked(cocos2d::Ref *sender) // test 3 { HttpRequest* request = new HttpRequest(); - request->setUrl("http://httpbin.org/get"); + request->setUrl("https://httpbin.org/get"); request->setRequestType(HttpRequest::Type::GET); request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted)); request->setTag("GET test3"); From 618e49cf861b730e4b09ad48b590d6f5b67c16cc Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 18 Apr 2014 17:12:32 +0800 Subject: [PATCH 40/40] [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index 2ec9d498f9..ea85bf7037 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -0613c5d8504cc76995b53156f3f6e647e54269eb \ No newline at end of file +62ee83b9b745b3f49184d3f440092788aa97c795 \ No newline at end of file