diff --git a/src/lvgl.lua b/src/lvgl.lua index 3f9762b..b86944b 100644 --- a/src/lvgl.lua +++ b/src/lvgl.lua @@ -303,23 +303,23 @@ lvgl.LAYOUT_GRID = 0 --- return a opacity value in lvgl unit(0..255) ---@param p integer opacity value in range of 0..100 ----@return integer +--- @return integer function lvgl.OPA(p) end --- return a layout in percent ---@param p integer ----@return integer +--- @return integer function lvgl.PCT(p) end --- return lvgl horizontal resolution ----@return integer +--- @return integer function lvgl.HOR_RES() end --- return lvgl vertical resolution ----@return integer +--- @return integer function lvgl.VER_RES() end @@ -538,6 +538,7 @@ end --- --- Set object property --- @param p StyleProp +--- @return Object --- function obj:set(p) end @@ -553,6 +554,7 @@ end --- --- Set object property --- @param p AlignToPara +--- @return Object --- function obj:align_to(p) end @@ -565,7 +567,7 @@ end --- --- Delete all children of this object ---- @return nil +--- @return Object function obj:clean() end @@ -622,7 +624,7 @@ end --- @field anim boolean --- --- @param p ScrollToPara ---- @return ObjState +--- @return Object function obj:scroll_to(p) end @@ -641,28 +643,28 @@ end --- --- add flag to object --- @param p ObjFlag ---- @return nil +--- @return Object function obj:add_flag(p) end --- --- clear object flag --- @param p ObjFlag ---- @return nil +--- @return Object function obj:clear_flag(p) end --- --- add state to object --- @param p ObjState ---- @return nil +--- @return Object function obj:add_state(p) end --- --- clear object state --- @param p ObjState ---- @return nil +--- @return Object function obj:clear_state(p) end @@ -670,7 +672,7 @@ end --- add style to object --- @param s Style --- @param selector? integer ---- @return nil +--- @return Object function obj:add_style(s, selector) end @@ -692,6 +694,7 @@ end ---@param x integer ---@param y integer ---@param anim_en? boolean +--- @return Object function obj:scroll_by(x, y, anim_en) end @@ -699,11 +702,13 @@ end ---@param x integer ---@param y integer ---@param anim_en boolean +--- @return Object function obj:scroll_by_bounded(x, y, anim_en) end --- Scroll to an object until it becomes visible on its parent ---@param anim_en? boolean +--- @return Object function obj:scroll_to_view(anim_en) end @@ -711,6 +716,7 @@ end --- Do the same on the parent's parent, and so on. --- Therefore the object will be scrolled into view even it has nested scrollable parents ---@param anim_en? boolean +--- @return Object function obj:scroll_to_view_recursive(anim_en) end @@ -718,45 +724,48 @@ end ---@param x integer ---@param y integer ---@param anim_en boolean +--- @return Object function obj:scroll_by_raw(x, y, anim_en) end ---Invalidate the area of the scrollbars +--- @return Object function obj:scrollbar_invalidate() end ---Checked if the content is scrolled "in" and adjusts it to a normal position. ---@param anim_en boolean +--- @return Object function obj:readjust_scroll(anim_en) end ---If object is editable ----@return boolean +--- @return boolean function obj:is_editable() end --- class group def ----@return boolean +--- @return boolean function obj:is_group_def() end --- Test whether the and object is positioned by a layout or not ----@return boolean +--- @return boolean function obj:is_layout_positioned() end --- Mark the object for layout update. ----@return nil +--- @return Object function obj:mark_layout_as_dirty() end --- Align an object to the center on its parent. same as obj:set{align={type = lvgl.ALIGN.CENTER}} ----@return nil +--- @return Object function obj:center() end --- Align an object to the center on its parent. same as obj:set{align={type = lvgl.ALIGN.CENTER}} ----@return nil +--- @return nil function obj:invalidate() end diff --git a/src/obj.c b/src/obj.c index 15dddb8..b9e9772 100644 --- a/src/obj.c +++ b/src/obj.c @@ -194,8 +194,8 @@ static int luavgl_obj_clean(lua_State *L) luavgl_obj_delete(L); } - lua_pop(L, 1); /* remove the userdata para */ - return 0; + lua_settop(L, 1); + return 1; } static int luavgl_obj_set(lua_State *L) @@ -204,11 +204,14 @@ static int luavgl_obj_set(lua_State *L) if (!lua_istable(L, -1)) { luaL_error(L, "expect a table on 2nd para"); - return 0; + lua_settop(L, 1); + return 1; } luavgl_setup_obj(L, obj); - return 0; + + lua_settop(L, 1); + return 1; } /** @@ -244,7 +247,9 @@ static int luavgl_obj_align_to(lua_State *L) lua_pop(L, 1); lv_obj_align_to(obj, base, align, x_ofs, y_ofs); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_set_parent(lua_State *L) @@ -252,7 +257,8 @@ static int luavgl_obj_set_parent(lua_State *L) lv_obj_t *obj = luavgl_to_obj(L, 1); lv_obj_t *parent = luavgl_to_obj(L, 2); lv_obj_set_parent(obj, parent); - return 0; + lua_pop(L, 1); + return 1; } static int luavgl_obj_get_screen(lua_State *L) @@ -372,7 +378,8 @@ static int luavgl_obj_scroll_to(lua_State *L) } lua_pop(L, 1); - return 0; + lua_settop(L, 1); + return 1; } static int luavgl_obj_is_visible(lua_State *L) @@ -389,7 +396,8 @@ static int luavgl_obj_add_flag(lua_State *L) lv_obj_flag_t flag = lua_tointeger(L, 2); lv_obj_add_flag(obj, flag); - return 0; + lua_settop(L, 1); + return 1; } static int luavgl_obj_clear_flag(lua_State *L) @@ -398,7 +406,8 @@ static int luavgl_obj_clear_flag(lua_State *L) lv_obj_flag_t flag = lua_tointeger(L, 2); lv_obj_clear_flag(obj, flag); - return 0; + lua_settop(L, 1); + return 1; } static int luavgl_obj_add_state(lua_State *L) @@ -406,7 +415,9 @@ static int luavgl_obj_add_state(lua_State *L) lv_obj_t *obj = luavgl_to_obj(L, 1); lv_state_t state = lua_tointeger(L, 2); lv_obj_add_state(obj, state); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_clear_state(lua_State *L) @@ -414,7 +425,9 @@ static int luavgl_obj_clear_state(lua_State *L) lv_obj_t *obj = luavgl_to_obj(L, 1); lv_state_t state = lua_tointeger(L, 2); lv_obj_clear_state(obj, state); - return 0; + + lua_settop(L, 1); + return 1; } /** @@ -428,7 +441,9 @@ static int luavgl_obj_scroll_by(lua_State *L) int anim_en = luavgl_tointeger(L, 4); lv_obj_scroll_by(obj, x, y, anim_en); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_scroll_by_bounded(lua_State *L) @@ -439,7 +454,8 @@ static int luavgl_obj_scroll_by_bounded(lua_State *L) int anim_en = luavgl_tointeger(L, 4); lv_obj_scroll_by_bounded(obj, dx, dy, anim_en); - return 0; + lua_settop(L, 1); + return 1; } static int luavgl_obj_scroll_to_view(lua_State *L) @@ -448,7 +464,8 @@ static int luavgl_obj_scroll_to_view(lua_State *L) int anim_en = luavgl_tointeger(L, 2); lv_obj_scroll_to_view(obj, anim_en); - return 0; + lua_settop(L, 1); + return 1; } static int luavgl_obj_scroll_to_view_recursive(lua_State *L) @@ -457,7 +474,9 @@ static int luavgl_obj_scroll_to_view_recursive(lua_State *L) int anim_en = luavgl_tointeger(L, 2); lv_obj_scroll_to_view_recursive(obj, anim_en); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_scroll_by_raw(lua_State *L) @@ -469,7 +488,9 @@ static int luavgl_obj_scroll_by_raw(lua_State *L) _lv_obj_scroll_by_raw(obj, x, y); #endif - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_is_scrolling(lua_State *L) @@ -483,7 +504,9 @@ static int luavgl_obj_scrollbar_invalidate(lua_State *L) { lv_obj_t *obj = luavgl_to_obj(L, 1); lv_obj_scrollbar_invalidate(obj); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_readjust_scroll(lua_State *L) @@ -491,7 +514,9 @@ static int luavgl_obj_readjust_scroll(lua_State *L) lv_obj_t *obj = luavgl_to_obj(L, 1); int anim_en = luavgl_tointeger(L, 2); lv_obj_readjust_scroll(obj, anim_en); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_is_editable(lua_State *L) @@ -519,21 +544,26 @@ static int luavgl_obj_mark_layout_as_dirty(lua_State *L) { lv_obj_t *obj = luavgl_to_obj(L, 1); lv_obj_mark_layout_as_dirty(obj); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_center(lua_State *L) { lv_obj_t *obj = luavgl_to_obj(L, 1); lv_obj_center(obj); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_invalidate(lua_State *L) { lv_obj_t *obj = luavgl_to_obj(L, 1); lv_obj_invalidate(obj); - return 0; + + return 1; } static int luavgl_obj_set_flex_flow(lua_State *L) @@ -542,7 +572,9 @@ static int luavgl_obj_set_flex_flow(lua_State *L) lv_flex_flow_t flow = luavgl_tointeger(L, 2); lv_obj_set_flex_flow(obj, flow); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_set_flex_align(lua_State *L) @@ -553,7 +585,9 @@ static int luavgl_obj_set_flex_align(lua_State *L) lv_flex_align_t t = luavgl_tointeger(L, 4); lv_obj_set_flex_align(obj, m, c, t); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_set_flex_grow(lua_State *L) @@ -562,7 +596,9 @@ static int luavgl_obj_set_flex_grow(lua_State *L) uint8_t grow = luavgl_tointeger(L, 2); lv_obj_set_flex_grow(obj, grow); - return 0; + + lua_settop(L, 1); + return 1; } static int luavgl_obj_indev_search(lua_State *L)