Port and fix our luavgl additions

custom
jacqueline 10 months ago
parent bd01bf3845
commit 611176ed66
  1. 1
      lib/luavgl/src/luavgl.c
  2. 25
      lib/luavgl/src/obj.c
  3. 4
      lib/luavgl/src/widgets/bar.c
  4. 4
      lib/luavgl/src/widgets/btn.c
  5. 9
      lib/luavgl/src/widgets/label.c
  6. 4
      lib/luavgl/src/widgets/slider.c
  7. 4
      lib/luavgl/src/widgets/switch.c
  8. 6
      lib/luavgl/src/widgets/widgets.c

@ -7,6 +7,7 @@
#include "font.c" #include "font.c"
#include "fs.c" #include "fs.c"
#include "group.c" #include "group.c"
#include "imgdata.c"
#include "indev.c" #include "indev.c"
#include "obj.c" #include "obj.c"
#include "timer.c" #include "timer.c"

@ -685,6 +685,29 @@ static int luavgl_obj_get_pos(lua_State *L)
return 1; return 1;
} }
/**
* set this object as the current selection
*/
static int luavgl_obj_focus(lua_State *L) {
lv_obj_t *obj = luavgl_to_obj(L, 1);
lv_group_t *group = lv_obj_get_group(obj);
if (group == NULL) {
return 0;
}
lv_group_focus_obj(obj);
return 0;
}
static int luavgl_obj_move_to_index(lua_State *L) {
lv_obj_t *obj = luavgl_to_obj(L, 1);
int idx = luavgl_tointeger(L, 2);
lv_obj_move_to_index(obj, idx);
return 0;
}
/** /**
* Remove all animations associates to this object * Remove all animations associates to this object
*/ */
@ -763,6 +786,8 @@ static const luaL_Reg luavgl_obj_methods[] = {
{"indev_search", luavgl_obj_indev_search }, {"indev_search", luavgl_obj_indev_search },
{"get_coords", luavgl_obj_get_coords }, {"get_coords", luavgl_obj_get_coords },
{"get_pos", luavgl_obj_get_pos }, {"get_pos", luavgl_obj_get_pos },
{"focus", luavgl_obj_focus },
{"move_to_index", luavgl_obj_move_to_index },
{"onevent", luavgl_obj_on_event }, {"onevent", luavgl_obj_on_event },
{"onPressed", luavgl_obj_on_pressed }, {"onPressed", luavgl_obj_on_pressed },

@ -1,7 +1,7 @@
#include "luavgl.h" #include "luavgl.h"
#include "private.h" #include "private.h"
#include <src/misc/lv_anim.h> #include <src/misc/lv_anim.h>
#include <src/widgets/lv_bar.h> #include <src/widgets/bar/lv_bar.h>
static int luavgl_bar_create(lua_State *L) static int luavgl_bar_create(lua_State *L)
{ {
@ -46,7 +46,7 @@ LUALIB_API int luavgl_bar_set_property_kv(lua_State *L, void *data)
/* a base obj property? */ /* a base obj property? */
ret = luavgl_obj_set_property_kv(L, obj); ret = luavgl_obj_set_property_kv(L, obj);
if (ret != 0) { if (ret != 0) {
debug("unkown property for bar.\n"); LV_LOG_ERROR("unkown property for bar.\n");
} }
return ret; return ret;

@ -12,7 +12,7 @@ LUALIB_API int luavgl_btn_set_property_kv(lua_State *L, void *data)
/* a base obj property? */ /* a base obj property? */
int ret = luavgl_obj_set_property_kv(L, obj); int ret = luavgl_obj_set_property_kv(L, obj);
if (ret != 0) { if (ret != 0) {
debug("unkown property for btn.\n"); LV_LOG_ERROR("unkown property for btn.\n");
} }
return ret; return ret;
@ -46,7 +46,7 @@ static const luaL_Reg luavgl_btn_methods[] = {
static void luavgl_btn_init(lua_State *L) static void luavgl_btn_init(lua_State *L)
{ {
luavgl_obj_newmetatable(L, &lv_btn_class, "lv_btn", luavgl_btn_methods); luavgl_obj_newmetatable(L, &lv_button_class, "lv_btn", luavgl_btn_methods);
lua_pushcfunction(L, luavgl_btn_tostring); lua_pushcfunction(L, luavgl_btn_tostring);
lua_setfield(L, -2, "__tostring"); lua_setfield(L, -2, "__tostring");
lua_pop(L, 1); lua_pop(L, 1);

@ -19,7 +19,6 @@ static void _lv_label_set_txt(void *obj, lua_State *L)
static const luavgl_value_setter_t label_property_table[] = { static const luavgl_value_setter_t label_property_table[] = {
{"text", SETTER_TYPE_STACK, {.setter_stack = _lv_label_set_txt} }, {"text", SETTER_TYPE_STACK, {.setter_stack = _lv_label_set_txt} },
{"long_mode", 0, {.setter = (setter_int_t)lv_label_set_long_mode} }, {"long_mode", 0, {.setter = (setter_int_t)lv_label_set_long_mode} },
{"recolor", 0, {.setter = (setter_int_t)lv_label_set_recolor} },
#if LVGL_VERSION_MAJOR == 9 #if LVGL_VERSION_MAJOR == 9
{"text_selection_start", {"text_selection_start",
0, {.setter = (setter_int_t)lv_label_set_text_selection_start}}, 0, {.setter = (setter_int_t)lv_label_set_text_selection_start}},
@ -81,13 +80,6 @@ static int luavgl_label_get_long_mode(lua_State *L)
return 1; return 1;
} }
static int luavgl_label_get_recolor(lua_State *L)
{
lv_obj_t *obj = luavgl_to_obj(L, 1);
lua_pushinteger(L, lv_label_get_recolor(obj));
return 1;
}
static int luavgl_label_ins_text(lua_State *L) static int luavgl_label_ins_text(lua_State *L)
{ {
lv_obj_t *obj = luavgl_to_obj(L, 1); lv_obj_t *obj = luavgl_to_obj(L, 1);
@ -139,7 +131,6 @@ static const luaL_Reg luavgl_label_methods[] = {
{"set_text_static", luavgl_label_set_text_static}, {"set_text_static", luavgl_label_set_text_static},
{"get_text", luavgl_label_get_text }, {"get_text", luavgl_label_get_text },
{"get_long_mode", luavgl_label_get_long_mode }, {"get_long_mode", luavgl_label_get_long_mode },
{"get_recolor", luavgl_label_get_recolor },
{"ins_text", luavgl_label_ins_text }, {"ins_text", luavgl_label_ins_text },
{"cut_text", luavgl_label_cut_text }, {"cut_text", luavgl_label_cut_text },

@ -1,7 +1,7 @@
#include "lua.h" #include "lua.h"
#include "luavgl.h" #include "luavgl.h"
#include "private.h" #include "private.h"
#include <src/widgets/lv_slider.h> #include <src/widgets/slider/lv_slider.h>
static int luavgl_slider_create(lua_State *L) { static int luavgl_slider_create(lua_State *L) {
return luavgl_obj_create_helper(L, lv_slider_create); return luavgl_obj_create_helper(L, lv_slider_create);
@ -42,7 +42,7 @@ LUALIB_API int luavgl_slider_set_property_kv(lua_State *L, void *data) {
/* a base obj property? */ /* a base obj property? */
ret = luavgl_obj_set_property_kv(L, obj); ret = luavgl_obj_set_property_kv(L, obj);
if (ret != 0) { if (ret != 0) {
debug("unkown property for slider.\n"); LV_LOG_ERROR("unkown property for slider.\n");
} }
return ret; return ret;

@ -1,6 +1,6 @@
#include "luavgl.h" #include "luavgl.h"
#include "private.h" #include "private.h"
#include <src/widgets/lv_switch.h> #include <src/widgets/switch/lv_switch.h>
static int luavgl_switch_create(lua_State *L) { static int luavgl_switch_create(lua_State *L) {
return luavgl_obj_create_helper(L, lv_switch_create); return luavgl_obj_create_helper(L, lv_switch_create);
@ -11,7 +11,7 @@ LUALIB_API int luavgl_switch_set_property_kv(lua_State *L, void *data) {
/* switches only use base properties */ /* switches only use base properties */
int ret = luavgl_obj_set_property_kv(L, obj); int ret = luavgl_obj_set_property_kv(L, obj);
if (ret != 0) { if (ret != 0) {
debug("unkown property for switch.\n"); LV_LOG_ERROR("unkown property for switch.\n");
} }
return ret; return ret;

@ -5,7 +5,7 @@
#include "bar.c" #include "bar.c"
#endif #endif
#if LV_USE_BTN #if LV_USE_BUTTON
#include "btn.c" #include "btn.c"
#endif #endif
@ -66,7 +66,7 @@ static const luaL_Reg widget_create_methods[] = {
{"Bar", luavgl_bar_create}, {"Bar", luavgl_bar_create},
#endif #endif
#if LV_USE_BTN #if LV_USE_BUTTON
{"Button", luavgl_btn_create}, {"Button", luavgl_btn_create},
#endif #endif
@ -162,7 +162,7 @@ static void luavgl_widgets_init(lua_State *L)
luavgl_dropdown_init(L); luavgl_dropdown_init(L);
#endif #endif
#if LV_USE_BTN #if LV_USE_BUTTON
luavgl_btn_init(L); luavgl_btn_init(L);
#endif #endif

Loading…
Cancel
Save