Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc update of simulator, obj and doc #74

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions simulator/lua_in_C.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include "lua.h"
#include <luavgl.h>
#include <lvgl.h>
#include <src/core/lv_obj.h>
#include <src/core/lv_obj_event.h>
#include <src/lv_api_map_v8.h>
#include <src/misc/lv_event.h>

#define _STRINGIZE(...) #__VA_ARGS__
#define STRINGIZE(...) _STRINGIZE(__VA_ARGS__)
Expand Down
13 changes: 11 additions & 2 deletions src/luavgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,17 @@ static int root_clean(lua_State *L)
{
LV_LOG_INFO("enter");
luavgl_ctx_t *ctx = luavgl_context(L);
lv_obj_clean(ctx->root);
if (ctx->root)
lv_obj_clean(ctx->root);
return 0;
}

static void root_delete_cb(lv_event_t *e)
{
luavgl_ctx_t *ctx = e->user_data;
ctx->root = NULL;
}

LUALIB_API int luaopen_lvgl(lua_State *L)
{
luavgl_ctx_t *ctx = luavgl_context(L);
Expand Down Expand Up @@ -148,7 +155,7 @@ LUALIB_API int luaopen_lvgl(lua_State *L)

#ifdef LUAVGL_EXPOSE_WIDGET_API
const luaL_Reg *reg;
for (int i = 0; ;i++) {
for (int i = 0;; i++) {
reg = &widget_create_methods[i];
if (reg->name == NULL)
break;
Expand All @@ -158,6 +165,8 @@ LUALIB_API int luaopen_lvgl(lua_State *L)
}
#endif

lv_obj_add_event_cb(root, root_delete_cb, LV_EVENT_DELETE, ctx);

(void)dumpstack;
(void)dumptable;
(void)dumpvalue;
Expand Down
12 changes: 9 additions & 3 deletions src/lvgl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,11 @@ end
--- @param parent? Object | nil
--- @param property? StyleProp
--- @return Object
function lvgl.Object(parent, property)
function Object(parent, property)
end

lvgl.Object = Object

--- Create Calendar widget on parent
--- @param parent? Object | nil
--- @param property? StyleProp
Expand Down Expand Up @@ -364,17 +366,21 @@ end
--- @param parent? Object | nil
--- @param property? ImageStyle
--- @return Image
function lvgl.Image(parent, property)
function Image(parent, property)
end

lvgl.Image = Image

---
--- Create Label on parent
--- @param parent? Object | nil
--- @param property? LabelStyle
--- @return Label
function lvgl.Label(parent, property)
function Label(parent, property)
end

lvgl.Label = Label

---
--- Create Textarea Widget on parent
--- @param parent? Object | nil
Expand Down
13 changes: 9 additions & 4 deletions src/style.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ static int luavgl_obj_set_style(lua_State *L)
lua_pop(L, 1); /* remove value, keep the key to continue. */
}

return 0;
lua_settop(L, 1);
return 1;
}

/**
Expand All @@ -697,7 +698,8 @@ static int luavgl_obj_add_style(lua_State *L)

lv_obj_add_style(obj, &s->style, selector);

return 0;
lua_settop(L, 1);
return 1;
}

/**
Expand All @@ -714,7 +716,9 @@ static int luavgl_obj_remove_style(lua_State *L)
}

lv_obj_remove_style(obj, &s->style, selector);
return 0;

lua_settop(L, 1);
return 1;
}

/**
Expand All @@ -725,7 +729,8 @@ static int luavgl_obj_remove_style_all(lua_State *L)
lv_obj_t *obj = luavgl_to_obj(L, 1);

lv_obj_remove_style_all(obj);
return 0;
lua_settop(L, 1);
return 1;
}

static const rotable_Reg luavgl_style_methods[] = {
Expand Down