You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
53 lines
1.1 KiB
#include "luavgl.h"
|
|
#include "private.h"
|
|
|
|
static int luavgl_btn_create(lua_State *L)
|
|
{
|
|
return luavgl_obj_create_helper(L, lv_btn_create);
|
|
}
|
|
|
|
LUALIB_API int luavgl_btn_set_property_kv(lua_State *L, void *data)
|
|
{
|
|
lv_obj_t *obj = data;
|
|
/* a base obj property? */
|
|
int ret = luavgl_obj_set_property_kv(L, obj);
|
|
if (ret != 0) {
|
|
debug("unkown property for btn.\n");
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int luavgl_btn_set(lua_State *L)
|
|
{
|
|
lv_obj_t *obj = luavgl_to_obj(L, 1);
|
|
|
|
if (!lua_istable(L, -1)) {
|
|
luaL_error(L, "expect a table on 2nd para.");
|
|
return 0;
|
|
}
|
|
|
|
luavgl_iterate(L, -1, luavgl_btn_set_property_kv, obj);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int luavgl_btn_tostring(lua_State *L)
|
|
{
|
|
lv_obj_t *obj = luavgl_to_obj(L, 1);
|
|
lua_pushfstring(L, "lv_btn:%p", obj);
|
|
return 1;
|
|
}
|
|
|
|
static const luaL_Reg luavgl_btn_methods[] = {
|
|
{"set", luavgl_btn_set },
|
|
{NULL, NULL },
|
|
};
|
|
|
|
static void luavgl_btn_init(lua_State *L)
|
|
{
|
|
luavgl_obj_newmetatable(L, &lv_btn_class, "lv_btn", luavgl_btn_methods);
|
|
lua_pushcfunction(L, luavgl_btn_tostring);
|
|
lua_setfield(L, -2, "__tostring");
|
|
lua_pop(L, 1);
|
|
}
|
|
|