diff --git a/lv_draw/lv_draw.c b/lv_draw/lv_draw.c index 318ddda4a..237145ea2 100644 --- a/lv_draw/lv_draw.c +++ b/lv_draw/lv_draw.c @@ -47,14 +47,14 @@ static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color #else static void (*fill_fp)(const area_t * cords_p, const area_t * mask_p, color_t color, opa_t opa) = lv_rfill; static void (*letter_fp)(const point_t * pos_p, const area_t * mask_p, const font_t * font_p, uint8_t letter, color_t color, opa_t opa) = lv_rletter; -static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp) = lv_rmap; +static void (*map_fp)(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, color_t recolor, opa_t recolor_opa) = lv_rmap; #endif static lv_rects_t lv_img_no_pic_rects = { .objs.color = COLOR_BLACK, .gcolor = COLOR_BLACK, .bcolor = COLOR_RED, .bwidth = 2 * LV_STYLE_MULT, .bopa = 100, - .round = 0, .objs.empty = 0 + .round = 0, .empty = 0 }; static lv_labels_t lv_img_no_pic_labels = { @@ -80,7 +80,7 @@ static lv_labels_t lv_img_no_pic_labels = { void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_rects_t * rects_p, opa_t opa) { - if(rects_p->objs.empty == 0){ + if(rects_p->empty == 0){ lv_draw_rect_main_mid(cords_p, mask_p, rects_p, opa); if(rects_p->round != 0) { diff --git a/lv_draw/lv_draw_rbasic.c b/lv_draw/lv_draw_rbasic.c index 7cbc4c0b7..74508df99 100644 --- a/lv_draw/lv_draw_rbasic.c +++ b/lv_draw/lv_draw_rbasic.c @@ -111,7 +111,7 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p, */ void lv_rmap(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, - color_t recolor, color_t recolor_opa) + color_t recolor, opa_t recolor_opa) { area_t masked_a; bool union_ok; diff --git a/lv_draw/lv_draw_rbasic.h b/lv_draw/lv_draw_rbasic.h index 455b73105..222ad0c07 100644 --- a/lv_draw/lv_draw_rbasic.h +++ b/lv_draw/lv_draw_rbasic.h @@ -31,7 +31,7 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p, color_t color, opa_t opa); void lv_rmap(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, - color_t recolor, color_t recolor_opa); + color_t recolor, opa_t recolor_opa); /********************** * MACROS **********************/ diff --git a/lv_draw/lv_draw_vbasic.h b/lv_draw/lv_draw_vbasic.h index a7d6b80a5..a9a8b0e8a 100644 --- a/lv_draw/lv_draw_vbasic.h +++ b/lv_draw/lv_draw_vbasic.h @@ -37,7 +37,7 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p, void lv_vmap(const area_t * cords_p, const area_t * mask_p, const color_t * map_p, opa_t opa, bool transp, - color_t recolor, color_t recolor_opa); + color_t recolor, opa_t recolor_opa); /********************** diff --git a/lv_obj/lv_obj.c b/lv_obj/lv_obj.c index def01b80e..2017005f8 100644 --- a/lv_obj/lv_obj.c +++ b/lv_obj/lv_obj.c @@ -34,10 +34,8 @@ lv_obj_t* def_scr_dp = NULL; lv_obj_t* act_scr_dp = NULL; ll_dsc_t scr_ll; -lv_objs_t lv_objs_def = {.color = COLOR_GRAY, .empty = 0}; -lv_objs_t lv_objs_scr = {.color = LV_OBJ_DEF_SCR_COLOR, .empty = 0}; -lv_objs_t lv_objs_color = {.color = COLOR_RED, .empty = 0}; -lv_objs_t lv_objs_empty = {.color = COLOR_GRAY, .empty = 1}; +lv_objs_t lv_objs_def = {.color = COLOR_RED}; +lv_objs_t lv_objs_scr = {.color = LV_OBJ_DEF_SCR_COLOR}; /********************** * MACROS @@ -326,14 +324,9 @@ lv_objs_t * lv_objs_get(lv_objs_builtin_t style, lv_objs_t * copy_p) case LV_OBJS_DEF: style_p = &lv_objs_def; break; - case LV_OBJS_COLOR: - style_p = &lv_objs_color; - break; case LV_OBJS_SCR: style_p = &lv_objs_scr; break; - case LV_OBJS_EMPTY: - style_p = &lv_objs_empty; break; default: style_p = NULL; @@ -1232,9 +1225,6 @@ static bool lv_obj_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo } lv_objs_t * objs_p = lv_obj_get_style(obj_dp); - - /*Do not draw the empty objects*/ - if(objs_p->empty != 0) return true; opa_t opa = lv_obj_get_opa(obj_dp); color_t color = objs_p->color; diff --git a/lv_obj/lv_obj.h b/lv_obj/lv_obj.h index ec26e7fb2..ff286c4bd 100644 --- a/lv_obj/lv_obj.h +++ b/lv_obj/lv_obj.h @@ -133,15 +133,12 @@ typedef enum typedef struct { color_t color; - uint8_t empty :1; }lv_objs_t; typedef enum { LV_OBJS_DEF, - LV_OBJS_COLOR, LV_OBJS_SCR, - LV_OBJS_EMPTY, }lv_objs_builtin_t; /********************** diff --git a/lv_objx/lv_btn.c b/lv_objx/lv_btn.c index ef35e684b..4dfeff058 100644 --- a/lv_objx/lv_btn.c +++ b/lv_objx/lv_btn.c @@ -58,7 +58,7 @@ static lv_btns_t lv_btns_def = .rects.bwidth = 2 * LV_STYLE_MULT, .rects.bopa = 50, - .rects.objs.empty = 0, + .rects.empty = 0, .rects.round = 4 * LV_STYLE_MULT, .rects.hpad = 10 * LV_STYLE_MULT, .rects.vpad = 15 * LV_STYLE_MULT, @@ -66,7 +66,7 @@ static lv_btns_t lv_btns_def = static lv_btns_t lv_btns_transp = { .rects.bwidth = 0, - .rects.objs.empty = 1, + .rects.empty = 1, .rects.hpad = 10 * LV_STYLE_MULT, .rects.vpad = 15 * LV_STYLE_MULT, }; @@ -79,7 +79,7 @@ static lv_btns_t lv_btns_border = .bcolor[LV_BTN_STATE_TGL_PR] = COLOR_BLACK, .bcolor[LV_BTN_STATE_INA] = COLOR_GRAY, .rects.bwidth = 2 * LV_STYLE_MULT, - .rects.objs.empty = 1, + .rects.empty = 1, .rects.bopa = 50, .rects.round = 4 * LV_STYLE_MULT, .rects.hpad = 10 * LV_STYLE_MULT, diff --git a/lv_objx/lv_img.c b/lv_objx/lv_img.c index 854e03854..0bb3f0fdb 100644 --- a/lv_objx/lv_img.c +++ b/lv_objx/lv_img.c @@ -71,7 +71,9 @@ lv_obj_t* lv_img_create(lv_obj_t* par_dp, lv_obj_t * copy_dp) img_ext_dp->fn_dp = NULL; img_ext_dp->w = lv_obj_get_width(new_obj_dp); img_ext_dp->h = lv_obj_get_height(new_obj_dp); + img_ext_dp->transp = 0; + /*Enable auto size for non screens*/ if(par_dp != NULL) { img_ext_dp->auto_size = 1; } else { @@ -190,12 +192,14 @@ void lv_img_set_file(lv_obj_t* obj_dp, const char * fn) /*Create a dummy header*/ header.w = lv_obj_get_width(obj_dp); header.h = lv_obj_get_height(obj_dp); + header.transp = 0; } fs_close(&file); img_ext_p->w = header.w; img_ext_p->h = header.h; + img_ext_p->transp = header.transp; #if LV_UPSCALE_MAP != 0 img_ext_p->w *= LV_DOWNSCALE; img_ext_p->h *= LV_DOWNSCALE; @@ -257,9 +261,10 @@ bool lv_img_get_auto_size(lv_obj_t* obj_dp) static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode) { lv_imgs_t * imgs_p = lv_obj_get_style(obj_dp); + lv_img_ext_t * ext_p = lv_obj_get_ext(obj_dp); if(mode == LV_DESIGN_COVER_CHK) { - if(imgs_p->objs.empty == 0) { + if(ext_p->transp == 0) { bool cover; cover = area_is_in(mask_p, &obj_dp->cords); return cover; @@ -267,7 +272,6 @@ static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod else return false; } - lv_img_ext_t * img_ext_p = lv_obj_get_ext(obj_dp); area_t cords; lv_obj_get_cords(obj_dp, &cords); @@ -275,13 +279,13 @@ static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod area_t cords_tmp; cords_tmp.y1 = cords.y1; - cords_tmp.y2 = cords.y1 + img_ext_p->h - 1; + cords_tmp.y2 = cords.y1 + ext_p->h - 1; - for(; cords_tmp.y1 < cords.y2; cords_tmp.y1 += img_ext_p->h, cords_tmp.y2 += img_ext_p->h) { + for(; cords_tmp.y1 < cords.y2; cords_tmp.y1 += ext_p->h, cords_tmp.y2 += ext_p->h) { cords_tmp.x1 = cords.x1; - cords_tmp.x2 = cords.x1 + img_ext_p->w - 1; - for(; cords_tmp.x1 < cords.x2; cords_tmp.x1 += img_ext_p->w, cords_tmp.x2 += img_ext_p->w) { - lv_draw_img(&cords_tmp, mask_p, lv_obj_get_style(obj_dp),opa, img_ext_p->fn_dp); + cords_tmp.x2 = cords.x1 + ext_p->w - 1; + for(; cords_tmp.x1 < cords.x2; cords_tmp.x1 += ext_p->w, cords_tmp.x2 += ext_p->w) { + lv_draw_img(&cords_tmp, mask_p, imgs_p, opa, ext_p->fn_dp); } } return true; diff --git a/lv_objx/lv_img.h b/lv_objx/lv_img.h index fad994acb..a5f70ca40 100644 --- a/lv_objx/lv_img.h +++ b/lv_objx/lv_img.h @@ -35,6 +35,7 @@ typedef struct cord_t w; cord_t h; uint8_t auto_size :1; + uint8_t transp :1; /*Transp. bit in the images header (library handles this)*/ }lv_img_ext_t; typedef enum diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index c1ee75f55..a1bcb1066 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -38,7 +38,7 @@ static lv_pages_t lv_pages_def = .bg_rects.bopa = 50, .bg_rects.bwidth = 0 * LV_STYLE_MULT, .bg_rects.round = 2 * LV_STYLE_MULT, - .bg_rects.objs.empty = 0, + .bg_rects.empty = 0, .bg_rects.hpad = 10, .bg_rects.vpad = 10, @@ -48,7 +48,7 @@ static lv_pages_t lv_pages_def = .sb_rects.bopa = 50, .sb_rects.bwidth = 1 * LV_STYLE_MULT, .sb_rects.round = 5 * LV_STYLE_MULT, - .sb_rects.objs.empty = 0, + .sb_rects.empty = 0, .sb_width= 8 * LV_STYLE_MULT, .sb_opa=50, @@ -69,7 +69,7 @@ static lv_pages_t lv_pages_paper = .bg_rects.bopa = 100, .bg_rects.bwidth = 2 * LV_STYLE_MULT, .bg_rects.round = 0 * LV_STYLE_MULT, - .bg_rects.objs.empty = 0, + .bg_rects.empty = 0, .bg_rects.hpad = 20 * LV_STYLE_MULT, .bg_rects.vpad = 20 * LV_STYLE_MULT, @@ -79,7 +79,7 @@ static lv_pages_t lv_pages_paper = .sb_rects.bopa = 100, .sb_rects.bwidth = 1 * LV_STYLE_MULT, .sb_rects.round = 5 * LV_STYLE_MULT, - .sb_rects.objs.empty = 0, + .sb_rects.empty = 0, .sb_width = 10 * LV_STYLE_MULT, .sb_opa=50, @@ -93,7 +93,7 @@ static lv_pages_t lv_pages_paper = static lv_pages_t lv_pages_transp = { - .bg_rects.objs.empty = 1, + .bg_rects.empty = 1, .bg_rects.hpad = 1, .bg_rects.vpad = 1, @@ -103,7 +103,7 @@ static lv_pages_t lv_pages_transp = .sb_rects.bopa = 0, .sb_rects.bwidth = 1 * LV_STYLE_MULT, .sb_rects.round = 5 * LV_STYLE_MULT, - .sb_rects.objs.empty = 0, + .sb_rects.empty = 0, .sb_width = 8 * LV_STYLE_MULT, .sb_opa = 50, diff --git a/lv_objx/lv_page.h b/lv_objx/lv_page.h index fd4211cd5..4ebd2b956 100644 --- a/lv_objx/lv_page.h +++ b/lv_objx/lv_page.h @@ -57,7 +57,6 @@ typedef enum LV_PAGES_TRANSP, }lv_pages_builtin_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_rect.c b/lv_objx/lv_rect.c index de6da8828..0e5799768 100644 --- a/lv_objx/lv_rect.c +++ b/lv_objx/lv_rect.c @@ -33,16 +33,16 @@ static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo static lv_rects_t lv_rects_def = { .objs.color = COLOR_MAKE(0x50, 0x70, 0x90), .gcolor = COLOR_MAKE(0x20, 0x40, 0x60), .bcolor = COLOR_WHITE, .bwidth = 2 * LV_STYLE_MULT, .bopa = 50, - .round = 4 * LV_STYLE_MULT, .objs.empty = 0, + .round = 4 * LV_STYLE_MULT, .empty = 0, .hpad = 0, .vpad = 0 }; static lv_rects_t lv_rects_transp = -{ .bwidth = 0, .objs.empty = 0, +{ .bwidth = 0, .empty = 1, .hpad = 0, .vpad = 0 }; static lv_rects_t lv_rects_border = { .bcolor = COLOR_BLACK, .bwidth = 2 * LV_STYLE_MULT, .bopa = 100, - .round = 4 * LV_STYLE_MULT, .objs.empty = 1, + .round = 4 * LV_STYLE_MULT, .empty = 1, .hpad = 0, .vpad = 0}; /********************** @@ -265,7 +265,7 @@ static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo { /* Because of the radius it is not sure the area is covered*/ if(mode == LV_DESIGN_COVER_CHK) { - if(LV_SA(obj_dp, lv_rects_t)->objs.empty != 0) return false; + if(LV_SA(obj_dp, lv_rects_t)->empty != 0) return false; uint16_t r = LV_SA(obj_dp, lv_rects_t)->round; area_t area_tmp; diff --git a/lv_objx/lv_rect.h b/lv_objx/lv_rect.h index 181a20c68..cb5f15781 100644 --- a/lv_objx/lv_rect.h +++ b/lv_objx/lv_rect.h @@ -31,8 +31,9 @@ typedef struct uint16_t bwidth; cord_t hpad; cord_t vpad; - uint8_t bopa; uint16_t round; + uint8_t bopa; + uint8_t empty :1; }lv_rects_t;