Эх сурвалжийг харах

!71 增加draw_line_dsc_t接口获取line指针的接口,用于画布canvas_draw_arc画布上画圆弧
Merge pull request !71 from 豆豆/master

Wendal 4 жил өмнө
parent
commit
c7e65bcf33

+ 54 - 1
components/lvgl/binding/luat_lib_lvgl_struct.c

@@ -10,7 +10,7 @@
 #define META_LV_DRAW_LABEL_DSC_T "LV_DRAW_LABEL_DSC_T*"
 #define META_LV_DRAW_IMG_DSC_T "LV_DRAW_IMG_DSC_T*"
 #define META_LV_IMG_DSC_T "LV_IMG_DSC_T*"
-
+#define META_LV_LINE_DSC_T "LV_LINE_DSC_T*"
 //---------------------------------------------
 /*
 创建一个anim
@@ -279,6 +279,54 @@ int _lvgl_struct_draw_rect_dsc_t_newindex(lua_State *L) {
     return 0;
 }
 
+//---------------------------------------------
+/*
+创建一个lv_draw_line_dsc_t
+@api lvgl.draw_line_dsc_t()
+@return userdata lv_draw_line_dsc_t指针
+@usage
+local rect_dsc = lvgl.draw_line_dsc_t()
+*/
+int luat_lv_draw_line_dsc_t(lua_State *L){
+    lua_newuserdata(L, sizeof(lv_draw_line_dsc_t));
+    luaL_setmetatable(L, META_LV_LINE_DSC_T);
+    return 1;
+}
+
+int _lvgl_struct_draw_line_dsc_t_newindex(lua_State *L) {
+    lv_draw_line_dsc_t* line_dsc = (lv_draw_line_dsc_t*)lua_touserdata(L, 1);
+    const char* key = luaL_checkstring(L, 2);
+    if (!strcmp("color", key)) {
+        line_dsc->color.full = luaL_optinteger(L, 3, 0);
+    }
+    else if (!strcmp("width", key)) {
+        line_dsc->width = luaL_optinteger(L, 3, 0);
+    }
+    else if (!strcmp("dash_width", key)) {
+        line_dsc->dash_width = luaL_optinteger(L, 3, 0);
+    }
+    else if (!strcmp("dash_gap", key)) {
+        line_dsc->dash_gap = luaL_optinteger(L, 3, 0);
+    }
+    else if (!strcmp("opa", key)) {
+        line_dsc->opa = luaL_optinteger(L, 3, 0);
+    }
+    else if (!strcmp("blend_mode", key)) {
+        line_dsc->blend_mode = luaL_optinteger(L, 3, 0);
+    }
+    else if (!strcmp("round_start", key)) {
+        line_dsc->round_start = luaL_optinteger(L, 3, 0);
+    }
+    else if (!strcmp("round_end", key)) {
+        line_dsc->round_end = luaL_optinteger(L, 3, 0);
+    }
+    else if (!strcmp("raw_end", key)) {
+        line_dsc->raw_end = luaL_optinteger(L, 3, 0);
+    }
+    return 0;
+}
+
+
 //---------------------------------------------
 /*
 创建一个lv_draw_label_dsc_t
@@ -470,4 +518,9 @@ void luat_lvgl_struct_init(lua_State *L) {
     lua_pushcfunction(L, _lvgl_struct_img_dsc_t_newindex);
     lua_setfield( L, -2, "__newindex" );
     lua_pop(L, 1);
+
+    luaL_newmetatable(L, META_LV_LINE_DSC_T);
+    lua_pushcfunction(L, _lvgl_struct_draw_line_dsc_t_newindex);
+    lua_setfield( L, -2, "__newindex" );
+    lua_pop(L, 1);
 }

+ 2 - 1
components/lvgl/binding/luat_lvgl_struct.h

@@ -1,4 +1,3 @@
-
 #ifndef LUAT_LVGL_STRUCT
 #define LUAT_LVGL_STRUCT
 
@@ -14,6 +13,7 @@ int luat_lv_draw_rect_dsc_t(lua_State *L);
 int luat_lv_draw_label_dsc_t(lua_State *L);
 int luat_lv_draw_img_dsc_t(lua_State *L);
 int luat_lv_img_dsc_t(lua_State *L);
+int luat_lv_draw_line_dsc_t(lua_State *L);
 
 #define LUAT_LV_STRUCT_RLT {"anim_t", luat_lv_struct_anim_t, 0},\
 {"area_t", luat_lv_struct_area_t, 0},\
@@ -22,5 +22,6 @@ int luat_lv_img_dsc_t(lua_State *L);
 {"draw_label_dsc_t", luat_lv_draw_label_dsc_t, 0},\
 {"draw_img_dsc_t", luat_lv_draw_img_dsc_t, 0},\
 {"img_dsc_t", luat_lv_img_dsc_t, 0},\
+{"draw_line_dsc_t", luat_lv_draw_line_dsc_t, 0},\
 
 #endif