|
|
@@ -104,33 +104,49 @@ int luat_lv_obj_set_signal_cb(lua_State *L) {
|
|
|
|
|
|
static int l_obj_anim_cb(lua_State *L, void*ptr) {
|
|
|
rtos_msg_t* msg = (rtos_msg_t*)lua_topointer(L, -1);
|
|
|
- struct _lv_anim_t * anim = (struct _lv_anim_t *)ptr;
|
|
|
lua_geti(L, LUA_REGISTRYINDEX, msg->arg1);
|
|
|
if (lua_isfunction(L, -1)) {
|
|
|
- lua_pushlightuserdata(L, anim->user_data.obj);
|
|
|
+ lua_pushlightuserdata(L, ptr);
|
|
|
lua_pushinteger(L, msg->arg2);
|
|
|
lua_call(L, 2, 0);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static void luat_lv_anim_exec_cb(struct _lv_anim_t * anim, lv_coord_t value) {
|
|
|
+// static void luat_lv_anim_exec_cb(struct _lv_anim_t * anim, lv_coord_t value) {
|
|
|
+// if (anim->user_data.exec_cb_ref == 0)
|
|
|
+// return;
|
|
|
+// rtos_msg_t msg = {0};
|
|
|
+// msg.handler = l_obj_anim_cb;
|
|
|
+// msg.ptr = anim;
|
|
|
+// msg.arg1 = anim->user_data.exec_cb_ref;
|
|
|
+// msg.arg2 = value;
|
|
|
+// luat_msgbus_put(&msg, 0);
|
|
|
+// }
|
|
|
+
|
|
|
+static void luat_lv_anim_exec_cb(void* var, lv_coord_t value) {
|
|
|
+ lv_anim_t* anim = lv_anim_get(var, luat_lv_anim_exec_cb);
|
|
|
+ if (anim == NULL) {
|
|
|
+ LLOGW("lv_anim_get return NULL!!!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (anim->user_data.exec_cb_ref == 0)
|
|
|
return;
|
|
|
rtos_msg_t msg = {0};
|
|
|
msg.handler = l_obj_anim_cb;
|
|
|
- msg.ptr = anim;
|
|
|
+ msg.ptr = var;
|
|
|
msg.arg1 = anim->user_data.exec_cb_ref;
|
|
|
msg.arg2 = value;
|
|
|
luat_msgbus_put(&msg, 0);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/*
|
|
|
设置动画回调
|
|
|
-@api lvgl.anim_set_exec_cb(anim, obj, func)
|
|
|
+@api lvgl.anim_set_exec_cb(anim, func)
|
|
|
@userdata 动画指针
|
|
|
@userdata lvgl组件指针
|
|
|
-@func lua函数, 参数有2个 (anim, value), 其中obj是当前对象, signal是信号类型, 为整型
|
|
|
+@func lua函数, 参数有2个 (obj, value), 其中obj是当前对象, signal是信号类型, 为整型
|
|
|
@return nil 无返回值
|
|
|
*/
|
|
|
int luat_lv_anim_set_exec_cb(lua_State *L) {
|
|
|
@@ -139,14 +155,14 @@ int luat_lv_anim_set_exec_cb(lua_State *L) {
|
|
|
LLOGW("obj is NULL when set event cb");
|
|
|
return 0;
|
|
|
}
|
|
|
- lv_obj_t* obj = lua_touserdata(L, 2);
|
|
|
- anim->user_data.obj = obj;
|
|
|
+ // lv_obj_t* obj = lua_touserdata(L, 2);
|
|
|
+ // anim->user_data.obj = obj;
|
|
|
|
|
|
if (anim->user_data.exec_cb_ref != 0) {
|
|
|
luaL_unref(L, LUA_REGISTRYINDEX, anim->user_data.exec_cb_ref);
|
|
|
}
|
|
|
- if (lua_isfunction(L, 3)) {
|
|
|
- lua_settop(L, 3);
|
|
|
+ if (lua_isfunction(L, 2)) {
|
|
|
+ lua_settop(L, 2);
|
|
|
anim->user_data.exec_cb_ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
|
|
lv_anim_set_custom_exec_cb(anim, luat_lv_anim_exec_cb);
|
|
|
}
|