mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7203 from samuele3hu/v3_ui_focus
Add coco studio ui focus test cases for Lua and add deprecated support for some functions
This commit is contained in:
commit
f1943ca350
|
@ -161,6 +161,8 @@ public:
|
|||
EVENT_PHYSICS_CONTACT_POSTSOLVE,
|
||||
EVENT_PHYSICS_CONTACT_SEPERATE,
|
||||
|
||||
EVENT_FOCUS,
|
||||
|
||||
EVENT_CUSTOM_BEGAN = 10000,
|
||||
EVENT_CUSTOM_ENDED = 11000,
|
||||
};
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#else
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#include "ui/UIWidget.h"
|
||||
|
||||
static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S)
|
||||
{
|
||||
|
@ -6134,6 +6135,182 @@ static void extendTMXLayer(lua_State* tolua_S)
|
|||
lua_pop(tolua_S, 1);
|
||||
}
|
||||
|
||||
static int tolua_cocos2dx_EventListenerFocus_create(lua_State* tolua_S)
|
||||
{
|
||||
if (nullptr == tolua_S)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertable(tolua_S, 1, "cc.EventListenerFocus", 0, &tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
cocos2d::EventListenerFocus* tolua_ret = cocos2d::EventListenerFocus::create();
|
||||
if(nullptr == tolua_ret)
|
||||
return 0;
|
||||
|
||||
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerFocus");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
CCLOG("'create' has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'create'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cloneFocusHandler(const EventListenerFocus* src,EventListenerFocus* dst )
|
||||
{
|
||||
if (nullptr == src || nullptr == dst)
|
||||
return;
|
||||
|
||||
LUA_FUNCTION handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)src, ScriptHandlerMgr::HandlerType::EVENT_FOCUS);
|
||||
if (0 != handler)
|
||||
{
|
||||
int newscriptHandler = cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->reallocateScriptHandler(handler);
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)dst, newscriptHandler, ScriptHandlerMgr::HandlerType::EVENT_FOCUS);
|
||||
dst->onFocusChanged = [=](ui::Widget* widgetLostFocus, ui::Widget* widgetGetFocus){
|
||||
lua_State* tolua_S = LuaEngine::getInstance()->getLuaStack()->getLuaState();
|
||||
int id = (widgetLostFocus) ? (int)widgetLostFocus->_ID : -1;
|
||||
int* luaID = (widgetLostFocus) ? &widgetLostFocus->_luaID : nullptr;
|
||||
toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)widgetLostFocus,"ccui.Widget");
|
||||
id = (widgetGetFocus) ? (int)widgetGetFocus->_ID : -1;
|
||||
luaID = (widgetGetFocus) ? &widgetGetFocus->_luaID : nullptr;
|
||||
toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)widgetGetFocus,"ccui.Widget");
|
||||
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static int tolua_cocos2dx_EventListenerFocus_clone(lua_State* tolua_S)
|
||||
{
|
||||
if (nullptr == tolua_S)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
EventListenerFocus* self = nullptr;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerFocus", 0, &tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<EventListenerFocus*>(tolua_tousertype(tolua_S,1,0));
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerFocus_clone'\n", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
cocos2d::EventListenerFocus* tolua_ret = cocos2d::EventListenerFocus::create();
|
||||
if(nullptr == tolua_ret)
|
||||
return 0;
|
||||
|
||||
cloneFocusHandler(self, tolua_ret);
|
||||
|
||||
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerFocus");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
CCLOG("'clone' has wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'clone'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static int tolua_cocos2dx_EventListenerFocus_registerScriptHandler(lua_State* tolua_S)
|
||||
{
|
||||
if (nullptr == tolua_S)
|
||||
return 0;
|
||||
|
||||
int argc = 0;
|
||||
EventListenerFocus* self = nullptr;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerFocus", 0, &tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
self = static_cast<EventListenerFocus*>(tolua_tousertype(tolua_S,1,0));
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (nullptr == self) {
|
||||
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerFocus_registerScriptHandler'\n", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(tolua_S) - 1;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err))
|
||||
{
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0);
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::EVENT_FOCUS);
|
||||
|
||||
self->onFocusChanged = [=](ui::Widget* widgetLostFocus, ui::Widget* widgetGetFocus){
|
||||
int id = (widgetLostFocus) ? (int)widgetLostFocus->_ID : -1;
|
||||
int* luaID = (widgetLostFocus) ? &widgetLostFocus->_luaID : nullptr;
|
||||
toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)widgetLostFocus,"ccui.Widget");
|
||||
id = (widgetGetFocus) ? (int)widgetGetFocus->_ID : -1;
|
||||
luaID = (widgetGetFocus) ? &widgetGetFocus->_luaID : nullptr;
|
||||
toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)widgetGetFocus,"ccui.Widget");
|
||||
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCLOG("'registerScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void extendEventListenerFocus(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "cc.EventListenerFocus");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
tolua_function(tolua_S, "create", tolua_cocos2dx_EventListenerFocus_create);
|
||||
tolua_function(tolua_S, "registerScriptHandler", tolua_cocos2dx_EventListenerFocus_registerScriptHandler);
|
||||
tolua_function(tolua_S, "clone", tolua_cocos2dx_EventListenerFocus_clone);
|
||||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
}
|
||||
|
||||
|
||||
int register_all_cocos2dx_manual(lua_State* tolua_S)
|
||||
{
|
||||
|
@ -6186,6 +6363,7 @@ int register_all_cocos2dx_manual(lua_State* tolua_S)
|
|||
extendGLProgramState(tolua_S);
|
||||
extendOrbitCamera(tolua_S);
|
||||
extendTMXLayer(tolua_S);
|
||||
extendEventListenerFocus(tolua_S);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1230,6 +1230,18 @@ function UIWidgetDeprecated.getTopInParent(self)
|
|||
end
|
||||
rawset(ccui.Widget,"getTopInParent", UIWidgetDeprecated.getTopInParent)
|
||||
|
||||
function UIWidgetDeprecated.getSize(self)
|
||||
deprecatedTip("ccui.Widget:getSize","ccui.Widget:getContentSize")
|
||||
return self:getContentSize()
|
||||
end
|
||||
rawset(ccui.Widget,"getSize", UIWidgetDeprecated.getSize)
|
||||
|
||||
function UIWidgetDeprecated.setSize(self, ...)
|
||||
deprecatedTip("ccui.Widget:setSize","ccui.Widget:setContentSize")
|
||||
return self:setContentSize(...)
|
||||
end
|
||||
rawset(ccui.Widget,"setSize", UIWidgetDeprecated.setSize)
|
||||
|
||||
--functions of ccui.Widget will be deprecated end
|
||||
|
||||
--functions of ccui.CheckBox will be deprecated begin
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -44,7 +44,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
|
|||
LayerColor::[getBlendFunc setBlendFunc],
|
||||
ParticleSystem::[(g|s)etBlendFunc updateQuadWithParticle initParticle],
|
||||
DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground],
|
||||
Director::[getAccelerometer (g|s)et.*Dispatcher getProjection getFrustum getRenderer],
|
||||
Director::[getAccelerometer getProjection getFrustum getRenderer],
|
||||
Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased],
|
||||
Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns],
|
||||
MenuItem.*::[create setCallback initWithCallback],
|
||||
|
|
|
@ -30,7 +30,7 @@ headers = %(cocosdir)s/cocos/ui/CocosGUI.h
|
|||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = Helper Widget Layer Layout RootWidget Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider Switch TextField ScrollView ListView PageView LayoutParameter LinearLayoutParameter RelativeLayoutParameter Rich.*
|
||||
classes = Helper Widget Layer Layout RootWidget Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider Switch TextField ScrollView ListView PageView LayoutParameter LinearLayoutParameter RelativeLayoutParameter Rich.* HBox VBox RelativeBox
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
|
|
Loading…
Reference in New Issue