Port and fix our luavgl additions
This commit is contained in:
@@ -7,19 +7,20 @@
|
||||
#include "font.c"
|
||||
#include "fs.c"
|
||||
#include "group.c"
|
||||
#include "imgdata.c"
|
||||
#include "indev.c"
|
||||
#include "obj.c"
|
||||
#include "timer.c"
|
||||
#include "util.c"
|
||||
|
||||
static const struct luaL_Reg luavgl_methods[] = {
|
||||
{"Timer", luavgl_timer_create}, /* timer.c */
|
||||
{"Font", luavgl_font_create }, /* font.c */
|
||||
{"Style", luavgl_style_create}, /* style.c */
|
||||
{"Anim", luavgl_anim_create }, /* anim.c */
|
||||
{"ImgData", luavgl_imgdata_create}, /* imgdata.c */
|
||||
{"Timer", luavgl_timer_create }, /* timer.c */
|
||||
{"Font", luavgl_font_create }, /* font.c */
|
||||
{"Style", luavgl_style_create }, /* style.c */
|
||||
{"Anim", luavgl_anim_create }, /* anim.c */
|
||||
{"ImgData", luavgl_imgdata_create}, /* imgdata.c */
|
||||
|
||||
{NULL, NULL },
|
||||
{NULL, NULL },
|
||||
};
|
||||
|
||||
LUALIB_API luavgl_ctx_t *luavgl_context(lua_State *L)
|
||||
|
||||
@@ -685,6 +685,29 @@ static int luavgl_obj_get_pos(lua_State *L)
|
||||
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
|
||||
*/
|
||||
@@ -763,6 +786,8 @@ static const luaL_Reg luavgl_obj_methods[] = {
|
||||
{"indev_search", luavgl_obj_indev_search },
|
||||
{"get_coords", luavgl_obj_get_coords },
|
||||
{"get_pos", luavgl_obj_get_pos },
|
||||
{"focus", luavgl_obj_focus },
|
||||
{"move_to_index", luavgl_obj_move_to_index },
|
||||
|
||||
{"onevent", luavgl_obj_on_event },
|
||||
{"onPressed", luavgl_obj_on_pressed },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "luavgl.h"
|
||||
#include "private.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)
|
||||
{
|
||||
@@ -46,7 +46,7 @@ LUALIB_API int luavgl_bar_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 bar.\n");
|
||||
LV_LOG_ERROR("unkown property for bar.\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -12,7 +12,7 @@ LUALIB_API int luavgl_btn_set_property_kv(lua_State *L, void *data)
|
||||
/* a base obj property? */
|
||||
int ret = luavgl_obj_set_property_kv(L, obj);
|
||||
if (ret != 0) {
|
||||
debug("unkown property for btn.\n");
|
||||
LV_LOG_ERROR("unkown property for btn.\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -46,7 +46,7 @@ static const luaL_Reg luavgl_btn_methods[] = {
|
||||
|
||||
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_setfield(L, -2, "__tostring");
|
||||
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[] = {
|
||||
{"text", SETTER_TYPE_STACK, {.setter_stack = _lv_label_set_txt} },
|
||||
{"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
|
||||
{"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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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},
|
||||
{"get_text", luavgl_label_get_text },
|
||||
{"get_long_mode", luavgl_label_get_long_mode },
|
||||
{"get_recolor", luavgl_label_get_recolor },
|
||||
{"ins_text", luavgl_label_ins_text },
|
||||
{"cut_text", luavgl_label_cut_text },
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "lua.h"
|
||||
#include "luavgl.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) {
|
||||
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? */
|
||||
ret = luavgl_obj_set_property_kv(L, obj);
|
||||
if (ret != 0) {
|
||||
debug("unkown property for slider.\n");
|
||||
LV_LOG_ERROR("unkown property for slider.\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "luavgl.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) {
|
||||
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 */
|
||||
int ret = luavgl_obj_set_property_kv(L, obj);
|
||||
if (ret != 0) {
|
||||
debug("unkown property for switch.\n");
|
||||
LV_LOG_ERROR("unkown property for switch.\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "bar.c"
|
||||
#endif
|
||||
|
||||
#if LV_USE_BTN
|
||||
#if LV_USE_BUTTON
|
||||
#include "btn.c"
|
||||
#endif
|
||||
|
||||
@@ -66,7 +66,7 @@ static const luaL_Reg widget_create_methods[] = {
|
||||
{"Bar", luavgl_bar_create},
|
||||
#endif
|
||||
|
||||
#if LV_USE_BTN
|
||||
#if LV_USE_BUTTON
|
||||
{"Button", luavgl_btn_create},
|
||||
#endif
|
||||
|
||||
@@ -162,7 +162,7 @@ static void luavgl_widgets_init(lua_State *L)
|
||||
luavgl_dropdown_init(L);
|
||||
#endif
|
||||
|
||||
#if LV_USE_BTN
|
||||
#if LV_USE_BUTTON
|
||||
luavgl_btn_init(L);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user