From bd01bf3845fd67dc4e03f56d044b3bc53245eeed Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 12 Jun 2024 16:29:31 +1000 Subject: WIP bump luavgl to latest --- lib/luavgl/src/widgets/calendar.c | 2 +- lib/luavgl/src/widgets/checkbox.c | 2 +- lib/luavgl/src/widgets/dropdown.c | 22 +++++++++++---------- lib/luavgl/src/widgets/img.c | 40 +++++++++++++++++++-------------------- lib/luavgl/src/widgets/keyboard.c | 4 ++-- lib/luavgl/src/widgets/label.c | 2 +- lib/luavgl/src/widgets/led.c | 2 +- lib/luavgl/src/widgets/list.c | 2 +- lib/luavgl/src/widgets/roller.c | 2 +- lib/luavgl/src/widgets/textarea.c | 4 +++- lib/luavgl/src/widgets/widgets.c | 6 +++--- 11 files changed, 46 insertions(+), 42 deletions(-) (limited to 'lib/luavgl/src/widgets') diff --git a/lib/luavgl/src/widgets/calendar.c b/lib/luavgl/src/widgets/calendar.c index 2fb8fd9b..20e5175b 100644 --- a/lib/luavgl/src/widgets/calendar.c +++ b/lib/luavgl/src/widgets/calendar.c @@ -65,7 +65,7 @@ LUALIB_API int luavgl_calendar_set_property_kv(lua_State *L, void *data) /* a base obj property? */ ret = luavgl_obj_set_property_kv(L, obj); if (ret != 0) { - debug("unkown property for calendar.\n"); + LV_LOG_ERROR("unkown property for calendar."); } return ret; diff --git a/lib/luavgl/src/widgets/checkbox.c b/lib/luavgl/src/widgets/checkbox.c index e7885c8e..a74238cd 100644 --- a/lib/luavgl/src/widgets/checkbox.c +++ b/lib/luavgl/src/widgets/checkbox.c @@ -32,7 +32,7 @@ LUALIB_API int luavgl_checkbox_set_property_kv(lua_State *L, void *data) /* a base obj property? */ ret = luavgl_obj_set_property_kv(L, obj); if (ret != 0) { - debug("unkown property for checkbox.\n"); + LV_LOG_ERROR("unkown property for checkbox"); } return ret; diff --git a/lib/luavgl/src/widgets/dropdown.c b/lib/luavgl/src/widgets/dropdown.c index a211c10b..d2bcfc0b 100644 --- a/lib/luavgl/src/widgets/dropdown.c +++ b/lib/luavgl/src/widgets/dropdown.c @@ -36,7 +36,7 @@ LUALIB_API int luavgl_dropdown_set_property_kv(lua_State *L, void *data) /* a base obj property? */ ret = luavgl_obj_set_property_kv(L, obj); if (ret != 0) { - debug("unkown property for dropdown.\n"); + LV_LOG_ERROR("unkown property for dropdown"); } return ret; @@ -72,7 +72,7 @@ static int luavgl_dropdown_get(lua_State *L) } const char *key = lua_tostring(L, 2); - if (strcmp(key, "list") == 0) { + if (lv_strcmp(key, "list") == 0) { lv_obj_t *list = lv_dropdown_get_list(obj); lua_pushlightuserdata(L, list); lua_rawget(L, LUA_REGISTRYINDEX); @@ -83,45 +83,47 @@ static int luavgl_dropdown_get(lua_State *L) return 1; } - if (strcmp(key, "text") == 0) { + if (lv_strcmp(key, "text") == 0) { lua_pushstring(L, lv_dropdown_get_text(obj)); return 1; } - if (strcmp(key, "options") == 0) { + if (lv_strcmp(key, "options") == 0) { lua_pushstring(L, lv_dropdown_get_options(obj)); return 1; } - if (strcmp(key, "selected") == 0) { + if (lv_strcmp(key, "selected") == 0) { lua_pushinteger(L, lv_dropdown_get_selected(obj)); return 1; } - if (strcmp(key, "option_cnt") == 0) { + if (lv_strcmp(key, "option_cnt") == 0) { lua_pushinteger(L, lv_dropdown_get_option_cnt(obj)); return 1; } - if (strcmp(key, "selected_str") == 0) { + if (lv_strcmp(key, "selected_str") == 0) { char buf[64]; lv_dropdown_get_selected_str(obj, buf, sizeof(buf)); lua_pushstring(L, buf); return 1; } - if (strcmp(key, "option_index") == 0) { +#if LV_VERSION_CHECK(8, 3, 0) + if (lv_strcmp(key, "option_index") == 0) { const char *option = lua_tostring(L, 3); lua_pushinteger(L, lv_dropdown_get_option_index(obj, option)); return 1; } +#endif - if (strcmp(key, "symbol") == 0) { + if (lv_strcmp(key, "symbol") == 0) { lua_pushlightuserdata(L, (void *)lv_dropdown_get_symbol(obj)); return 1; } - if (strcmp(key, "dir") == 0) { + if (lv_strcmp(key, "dir") == 0) { lua_pushinteger(L, lv_dropdown_get_dir(obj)); return 1; } diff --git a/lib/luavgl/src/widgets/img.c b/lib/luavgl/src/widgets/img.c index 9332cd99..7f92ef65 100644 --- a/lib/luavgl/src/widgets/img.c +++ b/lib/luavgl/src/widgets/img.c @@ -3,14 +3,14 @@ static int luavgl_img_create(lua_State *L) { - return luavgl_obj_create_helper(L, lv_img_create); + return luavgl_obj_create_helper(L, lv_image_create); } -static void _lv_img_set_pivot(void *obj, lua_State *L) +static void lv_image_set_pivot_(void *obj, lua_State *L) { if (!lua_istable(L, -1)) { luaL_argerror(L, -1, "should be table."); - debug("para should be table."); + LV_LOG_ERROR("para should be table."); return; } @@ -22,18 +22,18 @@ static void _lv_img_set_pivot(void *obj, lua_State *L) lv_coord_t y = lua_tointeger(L, -1); lua_pop(L, 1); - lv_img_set_pivot(obj, x, y); + lv_image_set_pivot(obj, x, y); } static const luavgl_value_setter_t img_property_table[] = { {"src", - SETTER_TYPE_IMGSRC, {.setter_pointer = (setter_pointer_t)lv_img_set_src}}, - {"offset_x", 0, {.setter = (setter_int_t)lv_img_set_offset_x} }, - {"offset_y", 0, {.setter = (setter_int_t)lv_img_set_offset_y} }, + SETTER_TYPE_IMGSRC, {.setter_pointer = (setter_pointer_t)lv_image_set_src}}, + {"offset_x", 0, {.setter = (setter_int_t)lv_image_set_offset_x} }, + {"offset_y", 0, {.setter = (setter_int_t)lv_image_set_offset_y} }, {"angle", 0, {.setter = (setter_int_t)lv_img_set_angle} }, {"zoom", 0, {.setter = (setter_int_t)lv_img_set_zoom} }, - {"antialias", 0, {.setter = (setter_int_t)lv_img_set_antialias} }, - {"pivot", SETTER_TYPE_STACK, {.setter_stack = _lv_img_set_pivot} }, + {"antialias", 0, {.setter = (setter_int_t)lv_image_set_antialias} }, + {"pivot", SETTER_TYPE_STACK, {.setter_stack = lv_image_set_pivot_} }, }; LUALIB_API int luavgl_img_set_property_kv(lua_State *L, void *data) @@ -48,7 +48,7 @@ LUALIB_API int luavgl_img_set_property_kv(lua_State *L, void *data) /* a base obj property? */ ret = luavgl_obj_set_property_kv(L, obj); if (ret != 0) { - debug("unkown property for image.\n"); + LV_LOG_ERROR("unkown property for image"); } return ret; @@ -69,11 +69,11 @@ static int luavgl_img_set(lua_State *L) const char *src = NULL; if (lua_isuserdata(L, -1)) { src = lua_touserdata(L, -1); - debug("set img src to user data: %p\n", src); + LV_LOG_INFO("set img src to user data: %p", src); } else { src = lua_tostring(L, -1); } - lv_img_set_src(obj, src); + lv_image_set_src(obj, src); } lua_pop(L, 1); @@ -90,7 +90,7 @@ static int luavgl_img_set_src(lua_State *L) lv_obj_t *obj = luavgl_to_obj(L, 1); const char *src = luavgl_toimgsrc(L, 2); if (src != NULL) { - lv_img_set_src(obj, src); + lv_image_set_src(obj, src); } return 0; @@ -114,14 +114,14 @@ static int luavgl_img_set_offset(lua_State *L) if (!lua_isnil(L, -1)) { v = lua_tointeger(L, -1); lua_pop(L, 1); - lv_img_set_offset_x(obj, v); + lv_image_set_offset_x(obj, v); } lua_getfield(L, -1, "y"); if (!lua_isnil(L, -1)) { v = lua_tointeger(L, -1); lua_pop(L, 1); - lv_img_set_offset_y(obj, v); + lv_image_set_offset_y(obj, v); } return 0; @@ -145,7 +145,7 @@ static int luavgl_img_set_pivot(lua_State *L) lua_getfield(L, -1, "y"); y = lua_tointeger(L, -1); - lv_img_set_pivot(obj, x, y); + lv_image_set_pivot(obj, x, y); return 0; } @@ -161,13 +161,13 @@ static int luavgl_get_img_size(lua_State *L) const void *src = NULL; if (lua_isnoneornil(L, 2)) { - src = lv_img_get_src(obj); + src = lv_image_get_src(obj); } else { src = luavgl_toimgsrc(L, 2); } - lv_img_header_t header; - if (src == NULL || lv_img_decoder_get_info(src, &header) != LV_RES_OK) { + lv_image_header_t header; + if (src == NULL || lv_image_decoder_get_info(src, &header) != LV_RES_OK) { lua_pushnil(L); lua_pushnil(L); } else { @@ -191,6 +191,6 @@ static const luaL_Reg luavgl_img_methods[] = { static void luavgl_img_init(lua_State *L) { - luavgl_obj_newmetatable(L, &lv_img_class, "lv_img", luavgl_img_methods); + luavgl_obj_newmetatable(L, &lv_image_class, "lv_img", luavgl_img_methods); lua_pop(L, 1); } diff --git a/lib/luavgl/src/widgets/keyboard.c b/lib/luavgl/src/widgets/keyboard.c index e7121de0..366f4693 100644 --- a/lib/luavgl/src/widgets/keyboard.c +++ b/lib/luavgl/src/widgets/keyboard.c @@ -36,7 +36,7 @@ LUALIB_API int luavgl_keyboard_set_property_kv(lua_State *L, void *data) /* a base obj property? */ ret = luavgl_obj_set_property_kv(L, obj); if (ret != 0) { - debug("unkown property for keyboard.\n"); + LV_LOG_ERROR("unkown property for keyboard"); } return ret; @@ -67,7 +67,7 @@ static void luavgl_keyboard_init(lua_State *L) static const luaL_Reg btm_methods[] = { {NULL, NULL}, }; - luavgl_obj_newmetatable(L, &lv_btnmatrix_class, "lv_btnm", btm_methods); + luavgl_obj_newmetatable(L, &lv_buttonmatrix_class, "lv_btnm", btm_methods); lua_pop(L, 1); luavgl_obj_newmetatable(L, &lv_keyboard_class, "lv_keyboard", diff --git a/lib/luavgl/src/widgets/label.c b/lib/luavgl/src/widgets/label.c index 701c56f3..9b477d07 100644 --- a/lib/luavgl/src/widgets/label.c +++ b/lib/luavgl/src/widgets/label.c @@ -47,7 +47,7 @@ LUALIB_API int luavgl_label_set_property_kv(lua_State *L, void *data) /* a base obj property? */ ret = luavgl_obj_set_property_kv(L, obj); if (ret != 0) { - debug("unkown property for label.\n"); + LV_LOG_ERROR("unkown property for label"); } return ret; diff --git a/lib/luavgl/src/widgets/led.c b/lib/luavgl/src/widgets/led.c index 38f22a05..3e9d19b8 100644 --- a/lib/luavgl/src/widgets/led.c +++ b/lib/luavgl/src/widgets/led.c @@ -25,7 +25,7 @@ LUALIB_API int luavgl_led_set_property_kv(lua_State *L, void *data) /* a base obj property? */ ret = luavgl_obj_set_property_kv(L, obj); if (ret != 0) { - debug("unkown property for led.\n"); + LV_LOG_ERROR("unkown property for led"); } return ret; diff --git a/lib/luavgl/src/widgets/list.c b/lib/luavgl/src/widgets/list.c index 825a7bff..dc41b3dc 100644 --- a/lib/luavgl/src/widgets/list.c +++ b/lib/luavgl/src/widgets/list.c @@ -24,7 +24,7 @@ LUALIB_API int luavgl_list_set_property_kv(lua_State *L, void *data) /* a base obj property? */ ret = luavgl_obj_set_property_kv(L, obj); if (ret != 0) { - debug("unkown property for list.\n"); + LV_LOG_ERROR("unkown property for list"); } return ret; diff --git a/lib/luavgl/src/widgets/roller.c b/lib/luavgl/src/widgets/roller.c index 574fc066..4d3ea548 100644 --- a/lib/luavgl/src/widgets/roller.c +++ b/lib/luavgl/src/widgets/roller.c @@ -69,7 +69,7 @@ LUALIB_API int luavgl_roller_set_property_kv(lua_State *L, void *data) /* a base obj property? */ ret = luavgl_obj_set_property_kv(L, obj); if (ret != 0) { - debug("unkown property for roller.\n"); + LV_LOG_ERROR("unkown property for roller"); } return ret; diff --git a/lib/luavgl/src/widgets/textarea.c b/lib/luavgl/src/widgets/textarea.c index 7c6170c1..e197c413 100644 --- a/lib/luavgl/src/widgets/textarea.c +++ b/lib/luavgl/src/widgets/textarea.c @@ -28,12 +28,14 @@ static void _lv_textarea_set_placeholder_txt(void *obj, lua_State *L) static void _lv_textarea_set_password_bullet(void *obj, lua_State *L) { +#if LV_VERSION_CHECK(8, 3, 0) if (!lua_isstring(L, -1)) { luaL_argerror(L, -1, "expect string"); return; } lv_textarea_set_password_bullet(obj, lua_tostring(L, -1)); +#endif } static void _lv_textarea_set_accepted_chars(void *obj, lua_State *L) @@ -72,7 +74,7 @@ LUALIB_API int luavgl_textarea_set_property_kv(lua_State *L, void *data) /* a base obj property? */ ret = luavgl_obj_set_property_kv(L, obj); if (ret != 0) { - debug("unkown property for textarea: %s\n", lua_tostring(L, -2)); + LV_LOG_ERROR("unkown property for textarea: %s", lua_tostring(L, -2)); } return -1; diff --git a/lib/luavgl/src/widgets/widgets.c b/lib/luavgl/src/widgets/widgets.c index 4a7a126e..6d140217 100644 --- a/lib/luavgl/src/widgets/widgets.c +++ b/lib/luavgl/src/widgets/widgets.c @@ -21,7 +21,7 @@ #include "dropdown.c" #endif -#if LV_USE_IMG +#if LV_USE_IMAGE #include "img.c" #endif @@ -82,7 +82,7 @@ static const luaL_Reg widget_create_methods[] = { {"Dropdown", luavgl_dropdown_create}, #endif -#if LV_USE_IMG +#if LV_USE_IMAGE {"Image", luavgl_img_create }, #endif @@ -122,7 +122,7 @@ static const luaL_Reg widget_create_methods[] = { static void luavgl_widgets_init(lua_State *L) { -#if LV_USE_IMG +#if LV_USE_IMAGE luavgl_img_init(L); #endif -- cgit v1.2.3