diff --git a/lv_draw/lv_draw.c b/lv_draw/lv_draw.c index 38058ce3c..acbc35091 100644 --- a/lv_draw/lv_draw.c +++ b/lv_draw/lv_draw.c @@ -96,22 +96,22 @@ void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_style_ { if(area_get_height(cords_p) < 1 || area_get_width(cords_p) < 1) return; - if(style_p->swidth != 0) { + if(style_p->shadow.width != 0) { lv_draw_rect_shadow(cords_p, mask_p, style_p); } - if(style_p->empty == 0){ + if(style_p->body.empty == 0){ lv_draw_rect_main_mid(cords_p, mask_p, style_p); - if(style_p->radius != 0) { + if(style_p->body.radius != 0) { lv_draw_rect_main_corner(cords_p, mask_p, style_p); } } - if(style_p->bwidth != 0) { + if(style_p->border.width != 0) { lv_draw_rect_border_straight(cords_p, mask_p, style_p); - if(style_p->radius != 0) { + if(style_p->body.radius != 0) { lv_draw_rect_border_corner(cords_p, mask_p, style_p); } } @@ -238,29 +238,29 @@ void lv_draw_triangle(const point_t * points, const area_t * mask_p, color_t col void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_t * style, const char * txt, txt_flag_t flag, point_t * offset) { - const font_t * font = style->font; + const font_t * font = style->txt.font; cord_t w; if((flag & TXT_FLAG_EXPAND) == 0) { w = area_get_width(cords_p); } else { point_t p; - txt_get_size(&p, txt, style->font, style->letter_space, style->line_space, CORD_MAX, flag); + txt_get_size(&p, txt, style->txt.font, style->txt.space_letter, style->txt.space_line, CORD_MAX, flag); w = p.x; } /*Init variables for the first line*/ cord_t line_length = 0; uint32_t line_start = 0; - uint32_t line_end = txt_get_next_line(txt, font, style->letter_space, w, flag); + uint32_t line_end = txt_get_next_line(txt, font, style->txt.space_letter, w, flag); point_t pos; pos.x = cords_p->x1; pos.y = cords_p->y1; /*Align the line to middle if enabled*/ - if(style->txt_align == LV_TXT_ALIGN_MID) { + if(style->txt.align == LV_TXT_ALIGN_MID) { line_length = txt_get_width(&txt[line_start], line_end - line_start, - font, style->letter_space, flag); + font, style->txt.space_letter, flag); pos.x += (w - line_length) / 2; } @@ -311,7 +311,7 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_ sscanf(buf, "%02x%02x%02x", &r, &g, &b); recolor = COLOR_MAKE(r, g, b); } else { - recolor.full = style->ccolor.full; + recolor.full = style->txt.color.full; } cmd_state = CMD_STATE_IN; /*After the parameter the text is in the command*/ } @@ -319,28 +319,28 @@ void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_ } } - color_t color = style->ccolor; + color_t color = style->txt.color; if(cmd_state == CMD_STATE_IN) color = recolor; - letter_fp(&pos, mask_p, font, letter, color, style->opa); + letter_fp(&pos, mask_p, font, letter, color, style->body.opa); - pos.x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->letter_space; + pos.x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->txt.space_letter; } /*Go to next line*/ line_start = line_end; - line_end += txt_get_next_line(&txt[line_start], font, style->letter_space, w, flag); + line_end += txt_get_next_line(&txt[line_start], font, style->txt.space_letter, w, flag); pos.x = cords_p->x1; /*Align to middle*/ - if(style->txt_align == LV_TXT_ALIGN_MID) { + if(style->txt.align == LV_TXT_ALIGN_MID) { line_length = txt_get_width(&txt[line_start], line_end - line_start, - font, style->letter_space, flag); + font, style->txt.space_letter, flag); pos.x += (w - line_length) / 2; } /*Go the next line position*/ pos.y += font_get_height(font) >> FONT_ANTIALIAS; - pos.y += style->line_space; + pos.y += style->txt.space_line; } } @@ -395,7 +395,7 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p, const_data = true; uint8_t * f_data = ((ufs_file_t*)file.file_d)->ent->data_d; f_data += sizeof(lv_img_raw_header_t); - map_fp(cords_p, &mask_com, (void*)f_data , style->opa, header.transp, upscale, style->ccolor, style->img_recolor); + map_fp(cords_p, &mask_com, (void*)f_data , style->body.opa, header.transp, upscale, style->img.color, style->img.intense); } #endif @@ -429,8 +429,8 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p, for(row = mask_com.y1; row <= mask_com.y2; row += us_val) { res = fs_read(&file, buf, useful_data, &br); - map_fp(&line, &mask_com, buf, style->opa, header.transp, upscale, - style->ccolor, style->img_recolor); + map_fp(&line, &mask_com, buf, style->body.opa, header.transp, upscale, + style->img.color, style->img.intense); fs_tell(&file, &act_pos); fs_seek(&file, act_pos + next_row); @@ -460,7 +460,7 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p, void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p, const lv_style_t * style) { - if(style->line_width == 0) return; + if(style->line.width == 0) return; if(p1->x == p2->x && p1->y == p2->y) return; @@ -496,7 +496,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p, } /*Make the correction on lie width*/ - width = ((style->line_width - 1) * width_corr_array[wcor]) >> LINE_WIDTH_CORR_SHIFT; + width = ((style->line.width - 1) * width_corr_array[wcor]) >> LINE_WIDTH_CORR_SHIFT; width_half = width >> 1; width_1 = width & 0x1 ? 1 : 0; @@ -515,7 +515,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p, draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2); draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2); draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2); - fill_fp(&draw_area, mask_p, style->ccolor, style->opa); + fill_fp(&draw_area, mask_p, style->line.color, style->body.opa); } if (hor == false && last_x != act_point.x) { area_t act_area; @@ -531,7 +531,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p, draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2); draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2); draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2); - fill_fp(&draw_area, mask_p, style->ccolor, style->opa); + fill_fp(&draw_area, mask_p, style->line.color, style->body.opa); } /*Calc. the next point of the line*/ @@ -559,7 +559,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p, draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2); draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2); draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2); - fill_fp(&draw_area, mask_p, style->ccolor, style->opa); + fill_fp(&draw_area, mask_p, style->line.color, style->body.opa); } if (hor == false) { area_t act_area; @@ -573,7 +573,7 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p, draw_area.x2 = MATH_MAX(act_area.x1, act_area.x2); draw_area.y1 = MATH_MIN(act_area.y1, act_area.y2); draw_area.y2 = MATH_MAX(act_area.y1, act_area.y2); - fill_fp(&draw_area, mask_p, style->ccolor, style->opa); + fill_fp(&draw_area, mask_p, style->line.color, style->body.opa); } } @@ -590,12 +590,12 @@ void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p, */ static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style) { - uint16_t radius = style->radius; + uint16_t radius = style->body.radius; - color_t mcolor = style->mcolor; - color_t gcolor = style->gcolor; + color_t mcolor = style->body.color_main; + color_t gcolor = style->body.color_grad; uint8_t mix; - opa_t opa = style->opa; + opa_t opa = style->body.opa; cord_t height = area_get_height(cords_p); cord_t width = area_get_width(cords_p); @@ -640,12 +640,12 @@ static void lv_draw_rect_main_mid(const area_t * cords_p, const area_t * mask_p, */ static void lv_draw_rect_main_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p) { - uint16_t radius = style_p->radius; + uint16_t radius = style_p->body.radius; - color_t mcolor = style_p->mcolor; - color_t gcolor = style_p->gcolor; + color_t mcolor = style_p->body.color_main; + color_t gcolor = style_p->body.color_grad; color_t act_color; - opa_t opa = style_p->opa; + opa_t opa = style_p->body.opa; uint8_t mix; cord_t height = area_get_height(cords_p); cord_t width = area_get_width(cords_p); @@ -811,12 +811,12 @@ if(edge_top_area.y1 != mid_top_area.y1) { */ static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p) { - uint16_t radius = style_p->radius; + uint16_t radius = style_p->body.radius; cord_t width = area_get_width(cords_p); cord_t height = area_get_height(cords_p); - uint16_t bwidth = style_p->bwidth; - opa_t bopa = (uint16_t)((uint16_t) style_p->opa * style_p->bopa) >> 8; + uint16_t bwidth = style_p->border.width; + opa_t bopa = (uint16_t)((uint16_t) style_p->body.opa * style_p->border.opa) >> 8; area_t work_area; cord_t length_corr = 0; cord_t corner_size = 0; @@ -836,7 +836,7 @@ static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t * /* Modify the corner_size if corner is drawn */ corner_size ++; - color_t b_color = style_p->bcolor; + color_t b_color = style_p->border.color; /*Left border*/ work_area.x1 = cords_p->x1; @@ -927,10 +927,10 @@ static void lv_draw_rect_border_straight(const area_t * cords_p, const area_t * */ static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style) { - uint16_t radius = style->radius; - uint16_t bwidth = style->bwidth; - color_t bcolor = style->bcolor; - opa_t bopa = (uint16_t)((uint16_t) style->opa * style->bopa ) >> 8; + uint16_t radius = style->body.radius; + uint16_t bwidth = style->border.width; + color_t bcolor = style->border.color; + opa_t bopa = (uint16_t)((uint16_t) style->body.opa * style->border.opa ) >> 8; /*0 px border width drawn as 1 px, so decrement the bwidth*/ bwidth--; @@ -1062,7 +1062,7 @@ static void lv_draw_rect_border_corner(const area_t * cords_p, const area_t * ma static void lv_draw_rect_shadow(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style) { /* If mask is in the middle of cords do not draw shadow*/ - cord_t radius = style->radius; + cord_t radius = style->body.radius; cord_t width = area_get_width(cords_p); cord_t height = area_get_height(cords_p); radius = lv_draw_cont_radius_corr(radius, width, height); @@ -1080,16 +1080,16 @@ static void lv_draw_rect_shadow(const area_t * cords_p, const area_t * mask_p, c area_tmp.y2 -= radius; if(area_is_in(mask_p, &area_tmp) != false) return; - if(style->stype == LV_STYPE_FULL) { + if(style->shadow.type == LV_STYPE_FULL) { lv_draw_cont_shadow_full(cords_p, mask_p, style); - } else if(style->stype == LV_STYPE_BOTTOM) { + } else if(style->shadow.type == LV_STYPE_BOTTOM) { lv_draw_cont_shadow_bottom(cords_p, mask_p, style); } } static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style) { - cord_t radius = style->radius; + cord_t radius = style->body.radius; cord_t width = area_get_width(cords_p); cord_t height = area_get_height(cords_p); @@ -1109,10 +1109,10 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask int16_t row; uint16_t opa_h_result[LV_HOR_RES]; - int16_t filter_size = 2 * style->swidth + 1; + int16_t filter_size = 2 * style->shadow.width + 1; for(row = 0; row < filter_size; row++) { - opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->opa * 2) / (filter_size); + opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->body.opa * 2) / (filter_size); } uint16_t p; @@ -1139,13 +1139,13 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask ofs_lt.y = cords_p->y1 + radius; - for(row = 0; row < radius + style->swidth; row++) { - for(p = 0; p < radius + style->swidth; p++) { + for(row = 0; row < radius + style->shadow.width; row++) { + for(p = 0; p < radius + style->shadow.width; p++) { int16_t v; uint32_t opa_tmp = 0; int16_t row_v; bool swidth_out = false; - for(v = -style->swidth; v < style->swidth; v++) { + for(v = -style->shadow.width; v < style->shadow.width; v++) { row_v = row + v; if(row_v < 0) row_v = 0; /*Rows above the corner*/ @@ -1156,19 +1156,19 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask else { int16_t p_tmp = p - (cruve_x[row_v] - cruve_x[row]); - if(p_tmp < -style->swidth) { /*Cols before the filtered shadow (still not blurred)*/ - opa_tmp += style->opa * 2; + if(p_tmp < -style->shadow.width) { /*Cols before the filtered shadow (still not blurred)*/ + opa_tmp += style->body.opa * 2; } /*Cols after the filtered shadow (already no effect) */ - else if (p_tmp > style->swidth) { + else if (p_tmp > style->shadow.width) { /* If on the current point the filter top point is already out of swidth then * the remaining part will not do not anything on this point*/ - if(v == -style->swidth) { /*Is the first point?*/ + if(v == -style->shadow.width) { /*Is the first point?*/ swidth_out = true; } break; } else { - opa_tmp += opa_h_result[p_tmp + style->swidth]; + opa_tmp += opa_h_result[p_tmp + style->shadow.width]; } } } @@ -1197,19 +1197,19 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask for(d = 0; d < p; d++) { if(point_rt.x != point_lt.x) { - px_fp(point_lt.x,point_lt.y , mask_p, style->scolor, opa_v_result[d]); + px_fp(point_lt.x,point_lt.y , mask_p, style->shadow.color, opa_v_result[d]); } if(point_rb.x != point_lb.x && point_lt.y != point_lb.y) { - px_fp(point_lb.x,point_lb.y , mask_p, style->scolor, opa_v_result[d]); + px_fp(point_lb.x,point_lb.y , mask_p, style->shadow.color, opa_v_result[d]); } if(point_lt.y != point_lb.y) { - px_fp(point_rb.x,point_rb.y , mask_p, style->scolor, opa_v_result[d]); + px_fp(point_rb.x,point_rb.y , mask_p, style->shadow.color, opa_v_result[d]); } - px_fp(point_rt.x,point_rt.y , mask_p, style->scolor, opa_v_result[d]); + px_fp(point_rt.x,point_rt.y , mask_p, style->shadow.color, opa_v_result[d]); point_rb.x++; @@ -1229,7 +1229,7 @@ static void lv_draw_cont_shadow_full(const area_t * cords_p, const area_t * mask static void lv_draw_cont_shadow_bottom(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style) { - cord_t radius = style->radius; + cord_t radius = style->body.radius; cord_t width = area_get_width(cords_p); cord_t height = area_get_height(cords_p); @@ -1249,10 +1249,10 @@ static void lv_draw_cont_shadow_bottom(const area_t * cords_p, const area_t * ma int16_t row; opa_t opa_h_result[LV_HOR_RES]; - int16_t filter_size = 2 * style->swidth + 1; + int16_t filter_size = 2 * style->shadow.width + 1; for(row = 0; row < filter_size; row++) { - opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->opa) / (filter_size); + opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->body.opa) / (filter_size); } point_t point_l; @@ -1275,11 +1275,11 @@ static void lv_draw_cont_shadow_bottom(const area_t * cords_p, const area_t * ma point_r.y = ofs2.y + cruve_x[row]; uint16_t d; - for(d= style->swidth; d < filter_size; d++) { - px_fp(point_l.x, point_l.y, mask_p, style->scolor, opa_h_result[d]); + for(d= style->shadow.width; d < filter_size; d++) { + px_fp(point_l.x, point_l.y, mask_p, style->shadow.color, opa_h_result[d]); point_l.y ++; - px_fp(point_r.x, point_r.y, mask_p, style->scolor, opa_h_result[d]); + px_fp(point_r.x, point_r.y, mask_p, style->shadow.color, opa_h_result[d]); point_r.y ++; } @@ -1291,8 +1291,8 @@ static void lv_draw_cont_shadow_bottom(const area_t * cords_p, const area_t * ma area_mid.y2 = area_mid.y1; uint16_t d; - for(d= style->swidth; d < filter_size; d++) { - fill_fp(&area_mid, mask_p, style->scolor, opa_h_result[d]); + for(d= style->shadow.width; d < filter_size; d++) { + fill_fp(&area_mid, mask_p, style->shadow.color, opa_h_result[d]); area_mid.y1 ++; area_mid.y2 ++; } @@ -1301,7 +1301,7 @@ static void lv_draw_cont_shadow_bottom(const area_t * cords_p, const area_t * ma static void lv_draw_cont_shadow_full_straight(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style, const opa_t * map) { - cord_t radius = style->radius; + cord_t radius = style->body.radius; cord_t width = area_get_width(cords_p); cord_t height = area_get_height(cords_p); @@ -1333,20 +1333,20 @@ static void lv_draw_cont_shadow_full_straight(const area_t * cords_p, const area sideb_area.y2 = sideb_area.y1; int16_t d; - for(d = 0; d < style->swidth; d++) { - fill_fp(&sider_area, mask_p, style->scolor, map[d]); + for(d = 0; d < style->shadow.width; d++) { + fill_fp(&sider_area, mask_p, style->shadow.color, map[d]); sider_area.x1++; sider_area.x2++; - fill_fp(&sidel_area, mask_p, style->scolor, map[d]); + fill_fp(&sidel_area, mask_p, style->shadow.color, map[d]); sidel_area.x1--; sidel_area.x2--; - fill_fp(&sidet_area, mask_p, style->scolor, map[d]); + fill_fp(&sidet_area, mask_p, style->shadow.color, map[d]); sidet_area.y1--; sidet_area.y2--; - fill_fp(&sideb_area, mask_p, style->scolor, map[d]); + fill_fp(&sideb_area, mask_p, style->shadow.color, map[d]); sideb_area.y1++; sideb_area.y2++; } diff --git a/lv_obj/lv_group.c b/lv_obj/lv_group.c index f5186085f..55b6680ad 100644 --- a/lv_obj/lv_group.c +++ b/lv_obj/lv_group.c @@ -253,12 +253,12 @@ lv_obj_t * lv_group_get_focused(lv_group_t * group) static void style_mod_def(lv_style_t * style) { /*Make the style a little bit orange*/ - style->bcolor = COLOR_ORANGE; - style->bopa = OPA_COVER; - if(style->bwidth == 0 && style->empty == 0) style->bwidth = 2 * LV_DOWNSCALE; /*Add border to not transparent styles*/ - else style->bwidth = style->bwidth * 2; /*Make the border thicker*/ - style->mcolor = color_mix(style->mcolor, COLOR_ORANGE, OPA_80); - style->gcolor = color_mix(style->gcolor, COLOR_ORANGE, OPA_80); + style->border.color = COLOR_ORANGE; + style->border.opa = OPA_COVER; + if(style->border.width == 0 && style->body.empty == 0) style->border.width = 2 * LV_DOWNSCALE; /*Add border to not transparent styles*/ + else style->border.width = style->border.width * 2; /*Make the border thicker*/ + style->body.color_main = color_mix(style->body.color_main, COLOR_ORANGE, OPA_80); + style->body.color_grad = color_mix(style->body.color_grad, COLOR_ORANGE, OPA_80); } #endif /*LV_OBJ_GROUP != 0*/ diff --git a/lv_obj/lv_obj.c b/lv_obj/lv_obj.c index c9c846eed..5e55dcba8 100644 --- a/lv_obj/lv_obj.c +++ b/lv_obj/lv_obj.c @@ -343,7 +343,7 @@ bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) if(lv_obj_is_protected(obj, LV_PROTECT_CHILD_CHG) != false) valid = false; break; case LV_SIGNAL_REFR_EXT_SIZE: - if(style->swidth > obj->ext_size) obj->ext_size = style->swidth; + if(style->shadow.width > obj->ext_size) obj->ext_size = style->shadow.width; break; case LV_SIGNAL_STYLE_CHG: lv_obj_refr_ext_size(obj); @@ -1287,7 +1287,7 @@ lv_style_t * lv_obj_get_style(lv_obj_t * obj) while(par != NULL) { if(par->style_p != NULL) { - if(par->style_p->glass == 0) { + if(par->style_p->body.glass == 0) { style_act = par->style_p; break; } @@ -1485,9 +1485,9 @@ static bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode /* Because of the radius it is not sure the area is covered * Check the areas where there is no radius*/ lv_style_t * style = lv_obj_get_style(obj); - if(style->empty != 0) return false; + if(style->body.empty != 0) return false; - uint16_t r = style->radius; + uint16_t r = style->body.radius; if(r == LV_RADIUS_CIRCLE) return false; @@ -1561,7 +1561,7 @@ static void lv_child_refr_style(lv_obj_t * obj) if(child->style_p == NULL) { lv_child_refr_style(child); /*Check children too*/ lv_obj_refr_style(child); /*Notify the child about the style change*/ - } else if(child->style_p->glass) { + } else if(child->style_p->body.glass) { /*Children with 'glass' parent might be effected if their style == NULL*/ lv_child_refr_style(child); } diff --git a/lv_obj/lv_refr.c b/lv_obj/lv_refr.c index 9d4fd986a..8f56af87d 100644 --- a/lv_obj/lv_refr.c +++ b/lv_obj/lv_refr.c @@ -352,7 +352,7 @@ static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj) /*If no better children check this object*/ if(found_p == NULL) { lv_style_t * style = lv_obj_get_style(obj); - if(style->opa == OPA_COVER && + if(style->body.opa == OPA_COVER && obj->design_f(obj, area_p, LV_DESIGN_COVER_CHK) != false) { found_p = obj; } @@ -439,7 +439,7 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p) /* Redraw the object */ lv_style_t * style = lv_obj_get_style(obj); - if(style->opa != OPA_TRANSP) { + if(style->body.opa != OPA_TRANSP) { obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN); //tick_wait_ms(100); /*DEBUG: Wait after every object draw to see the order of drawing*/ } @@ -472,7 +472,7 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p) } /* If all the children are redrawn make 'post draw' design */ - if(style->opa != OPA_TRANSP) { + if(style->body.opa != OPA_TRANSP) { obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST); } } diff --git a/lv_obj/lv_style.c b/lv_obj/lv_style.c index 9ed7b470a..9178d2e40 100644 --- a/lv_obj/lv_style.c +++ b/lv_obj/lv_style.c @@ -68,112 +68,128 @@ void lv_style_init (void) * HUE = 210*/ /*Screen style*/ - lv_style_scr.ccolor = COLOR_MAKE(0x20, 0x20, 0x20); - lv_style_scr.opa = OPA_COVER; + lv_style_scr.body.opa = OPA_COVER; + lv_style_scr.body.color_main = COLOR_WHITE; + lv_style_scr.body.color_grad = COLOR_WHITE; + lv_style_scr.body.radius = 0; + lv_style_scr.body.pad_ver = LV_DPI / 12; + lv_style_scr.body.pad_hor = LV_DPI / 12; + lv_style_scr.body.pad_obj = LV_DPI / 12; + lv_style_scr.body.empty = 0; + lv_style_scr.body.glass = 0; - lv_style_scr.mcolor = COLOR_WHITE; - lv_style_scr.gcolor = COLOR_WHITE; - lv_style_scr.bcolor = COLOR_BLACK; - lv_style_scr.scolor = COLOR_GRAY; - lv_style_scr.radius = 0; - lv_style_scr.bwidth = 0; - lv_style_scr.swidth = 0; - lv_style_scr.stype = LV_STYPE_FULL; - lv_style_scr.vpad = LV_DPI / 12; - lv_style_scr.hpad = LV_DPI / 12; - lv_style_scr.opad = LV_DPI / 12; - lv_style_scr.bopa = OPA_COVER; - lv_style_scr.empty = 0; - lv_style_scr.glass = 0; + lv_style_scr.border.color = COLOR_BLACK; + lv_style_scr.border.opa = OPA_COVER; + lv_style_scr.border.width = 0; - lv_style_scr.font = font_get(FONT_DEFAULT); - lv_style_scr.letter_space = 1 * LV_DOWNSCALE; - lv_style_scr.line_space = 2 * LV_DOWNSCALE; - lv_style_scr.txt_align = LV_TXT_ALIGN_LEFT; - lv_style_scr.img_recolor = OPA_TRANSP; - lv_style_scr.line_width = 1 * LV_DOWNSCALE; + lv_style_scr.shadow.color = COLOR_GRAY; + lv_style_scr.shadow.type = LV_STYPE_FULL; + lv_style_scr.shadow.width = 0; + + lv_style_scr.txt.color = COLOR_MAKE(0x20, 0x20, 0x20); + lv_style_scr.txt.font = font_get(FONT_DEFAULT); + lv_style_scr.txt.space_letter = 1 * LV_DOWNSCALE; + lv_style_scr.txt.space_line = 2 * LV_DOWNSCALE; + lv_style_scr.txt.align = LV_TXT_ALIGN_LEFT; + + lv_style_scr.img.color = COLOR_MAKE(0x20, 0x20, 0x20); + lv_style_scr.img.intense = OPA_TRANSP; + + lv_style_scr.line.color = COLOR_MAKE(0x20, 0x20, 0x20); + lv_style_scr.line.width = 1 * LV_DOWNSCALE; /*Plain style (by default near the same as the screen style)*/ memcpy(&lv_style_plain, &lv_style_scr, sizeof(lv_style_t)); - lv_style_plain.mcolor = COLOR_WHITE; - lv_style_plain.gcolor = COLOR_WHITE; - lv_style_plain.bcolor = COLOR_WHITE; /*Plain color style*/ memcpy(&lv_style_plain_color, &lv_style_plain, sizeof(lv_style_t)); - lv_style_plain_color.ccolor = COLOR_MAKE(0xf0, 0xf0, 0xf0); - lv_style_plain_color.mcolor = COLOR_MAKE(0x55, 0x96, 0xd8); - lv_style_plain_color.gcolor = lv_style_plain_color.mcolor; + lv_style_plain_color.txt.color = COLOR_MAKE(0xf0, 0xf0, 0xf0); + lv_style_plain_color.img.color = COLOR_MAKE(0xf0, 0xf0, 0xf0); + lv_style_plain_color.line.color = COLOR_MAKE(0xf0, 0xf0, 0xf0); + lv_style_plain_color.body.color_main = COLOR_MAKE(0x55, 0x96, 0xd8); + lv_style_plain_color.body.color_grad = lv_style_plain_color.body.color_main; /*Pretty style */ memcpy(&lv_style_pretty, &lv_style_plain, sizeof(lv_style_t)); - lv_style_pretty.ccolor = COLOR_MAKE(0x20, 0x20, 0x20); - lv_style_pretty.mcolor = COLOR_WHITE; - lv_style_pretty.gcolor = COLOR_SILVER; - lv_style_pretty.bcolor = COLOR_MAKE(0x40, 0x40, 0x40); - lv_style_pretty.radius = LV_DPI / 15; - lv_style_pretty.bwidth = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1; - lv_style_pretty.bopa = OPA_50; + lv_style_pretty.txt.color = COLOR_MAKE(0x20, 0x20, 0x20); + lv_style_pretty.img.color = COLOR_MAKE(0x20, 0x20, 0x20); + lv_style_pretty.line.color = COLOR_MAKE(0x20, 0x20, 0x20); + lv_style_pretty.body.color_main = COLOR_WHITE; + lv_style_pretty.body.color_grad = COLOR_SILVER; + lv_style_pretty.body.radius = LV_DPI / 15; + lv_style_pretty.border.color = COLOR_MAKE(0x40, 0x40, 0x40); + lv_style_pretty.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1; + lv_style_pretty.border.opa = OPA_50; /*Pretty color style*/ memcpy(&lv_style_pretty_color, &lv_style_pretty, sizeof(lv_style_t)); - lv_style_pretty_color.ccolor = COLOR_MAKE(0xe0, 0xe0, 0xe0); - lv_style_pretty_color.mcolor = COLOR_MAKE(0x6b, 0x9a, 0xc7); - lv_style_pretty_color.gcolor = COLOR_MAKE(0x2b, 0x59, 0x8b); - lv_style_pretty_color.bcolor = COLOR_MAKE(0x15, 0x2c, 0x42); + lv_style_pretty_color.txt.color = COLOR_MAKE(0xe0, 0xe0, 0xe0); + lv_style_pretty_color.img.color = COLOR_MAKE(0xe0, 0xe0, 0xe0); + lv_style_pretty_color.line.color = COLOR_MAKE(0xe0, 0xe0, 0xe0); + lv_style_pretty_color.body.color_main = COLOR_MAKE(0x6b, 0x9a, 0xc7); + lv_style_pretty_color.body.color_grad = COLOR_MAKE(0x2b, 0x59, 0x8b); + lv_style_pretty_color.border.color = COLOR_MAKE(0x15, 0x2c, 0x42); /*Transparent style*/ memcpy(&lv_style_transp, &lv_style_plain, sizeof(lv_style_t)); - lv_style_transp.empty = 1; - lv_style_transp.bwidth = 0; - lv_style_transp.glass = 1; + lv_style_transp.body.empty = 1; + lv_style_transp.body.glass = 1; + lv_style_transp.border.width = 0; /*Transparent tight style*/ memcpy(&lv_style_transp_tight, &lv_style_transp, sizeof(lv_style_t)); - lv_style_transp_tight.hpad = 0; - lv_style_transp_tight.vpad = 0; + lv_style_transp_tight.body.pad_hor = 0; + lv_style_transp_tight.body.pad_ver = 0; /*Button released style*/ memcpy(&lv_style_btn_rel, &lv_style_plain, sizeof(lv_style_t)); - lv_style_btn_rel.mcolor = COLOR_MAKE(0x76, 0xa2, 0xd0); - lv_style_btn_rel.gcolor = COLOR_MAKE(0x19, 0x3a, 0x5d); - lv_style_btn_rel.bcolor = COLOR_MAKE(0x0b, 0x19, 0x28); - lv_style_btn_rel.ccolor = COLOR_MAKE(0xff, 0xff, 0xff); - lv_style_btn_rel.bwidth = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1; - lv_style_btn_rel.radius = LV_DPI / 15; - lv_style_btn_rel.bopa = OPA_70; - lv_style_btn_rel.scolor = COLOR_GRAY; - lv_style_btn_rel.swidth = 0; - lv_style_btn_rel.hpad = LV_DPI / 4; - lv_style_btn_rel.vpad = LV_DPI / 6; - lv_style_btn_rel.opad = LV_DPI / 10; - lv_style_btn_rel.txt_align = LV_TXT_ALIGN_MID; + lv_style_btn_rel.body.color_main = COLOR_MAKE(0x76, 0xa2, 0xd0); + lv_style_btn_rel.body.color_grad = COLOR_MAKE(0x19, 0x3a, 0x5d); + lv_style_btn_rel.body.radius = LV_DPI / 15; + lv_style_btn_rel.body.pad_hor = LV_DPI / 4; + lv_style_btn_rel.body.pad_ver = LV_DPI / 6; + lv_style_btn_rel.body.pad_obj = LV_DPI / 10; + lv_style_btn_rel.border.color = COLOR_MAKE(0x0b, 0x19, 0x28); + lv_style_btn_rel.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1; + lv_style_btn_rel.border.opa = OPA_70; + lv_style_btn_rel.txt.color = COLOR_MAKE(0xff, 0xff, 0xff); + lv_style_btn_rel.txt.align = LV_TXT_ALIGN_MID; + lv_style_btn_rel.shadow.color = COLOR_GRAY; + lv_style_btn_rel.shadow.width = 0; /*Button pressed style*/ memcpy(&lv_style_btn_pr, &lv_style_btn_rel, sizeof(lv_style_t)); - lv_style_btn_pr.mcolor = COLOR_MAKE(0x33, 0x62, 0x94); - lv_style_btn_pr.gcolor = COLOR_MAKE(0x10, 0x26, 0x3c); - lv_style_btn_pr.ccolor = COLOR_MAKE(0xa4, 0xb5, 0xc6); + lv_style_btn_pr.body.color_main = COLOR_MAKE(0x33, 0x62, 0x94); + lv_style_btn_pr.body.color_grad = COLOR_MAKE(0x10, 0x26, 0x3c); + lv_style_btn_pr.txt.color = COLOR_MAKE(0xa4, 0xb5, 0xc6); + lv_style_btn_pr.img.color = COLOR_MAKE(0xa4, 0xb5, 0xc6); + lv_style_btn_pr.line.color = COLOR_MAKE(0xa4, 0xb5, 0xc6); /*Button toggle released style*/ memcpy(&lv_style_btn_trel, &lv_style_btn_rel, sizeof(lv_style_t)); - lv_style_btn_trel.mcolor = COLOR_MAKE(0x0a, 0x11, 0x22); - lv_style_btn_trel.gcolor = COLOR_MAKE(0x37, 0x62, 0x90); - lv_style_btn_trel.bcolor = COLOR_MAKE(0x01, 0x07, 0x0d); - lv_style_btn_trel.ccolor = COLOR_MAKE(0xc8, 0xdd, 0xf4); + lv_style_btn_trel.body.color_main = COLOR_MAKE(0x0a, 0x11, 0x22); + lv_style_btn_trel.body.color_grad = COLOR_MAKE(0x37, 0x62, 0x90); + lv_style_btn_trel.border.color = COLOR_MAKE(0x01, 0x07, 0x0d); + lv_style_btn_trel.txt.color = COLOR_MAKE(0xc8, 0xdd, 0xf4); + lv_style_btn_trel.img.color = COLOR_MAKE(0xc8, 0xdd, 0xf4); + lv_style_btn_trel.line.color = COLOR_MAKE(0xc8, 0xdd, 0xf4); /*Button toggle pressed style*/ memcpy(&lv_style_btn_tpr, &lv_style_btn_rel, sizeof(lv_style_t)); - lv_style_btn_tpr.mcolor = COLOR_MAKE(0x02, 0x14, 0x27); - lv_style_btn_tpr.gcolor = COLOR_MAKE(0x2b, 0x4c, 0x70); - lv_style_btn_tpr.ccolor = COLOR_MAKE(0xa4, 0xb5, 0xc6); + lv_style_btn_tpr.body.color_main = COLOR_MAKE(0x02, 0x14, 0x27); + lv_style_btn_tpr.body.color_grad = COLOR_MAKE(0x2b, 0x4c, 0x70); + lv_style_btn_tpr.txt.color = COLOR_MAKE(0xa4, 0xb5, 0xc6); + lv_style_btn_tpr.img.color = COLOR_MAKE(0xa4, 0xb5, 0xc6); + lv_style_btn_tpr.line.color = COLOR_MAKE(0xa4, 0xb5, 0xc6); /*Button inactive style*/ memcpy(&lv_style_btn_ina, &lv_style_btn_rel, sizeof(lv_style_t)); - lv_style_btn_ina.mcolor = COLOR_MAKE(0xd8, 0xd8, 0xd8); - lv_style_btn_ina.gcolor = COLOR_MAKE(0xd8, 0xd8, 0xd8); - lv_style_btn_ina.bcolor = COLOR_MAKE(0x90, 0x90, 0x90); - lv_style_btn_ina.ccolor = COLOR_MAKE(0x70, 0x70, 0x70); + lv_style_btn_ina.body.color_main = COLOR_MAKE(0xd8, 0xd8, 0xd8); + lv_style_btn_ina.body.color_grad = COLOR_MAKE(0xd8, 0xd8, 0xd8); + lv_style_btn_ina.border.color = COLOR_MAKE(0x90, 0x90, 0x90); + lv_style_btn_ina.txt.color = COLOR_MAKE(0x70, 0x70, 0x70); + lv_style_btn_ina.img.color = COLOR_MAKE(0x70, 0x70, 0x70); + lv_style_btn_ina.line.color = COLOR_MAKE(0x70, 0x70, 0x70); } @@ -286,39 +302,41 @@ static void lv_style_aimator(lv_style_anim_dsc_t * dsc, int32_t val) const lv_style_t * end = dsc->style_end; lv_style_t * act = dsc->style_anim; - STYLE_ATTR_ANIM(opa, val); - STYLE_ATTR_ANIM(radius, val); - STYLE_ATTR_ANIM(bwidth, val); - STYLE_ATTR_ANIM(swidth, val); - STYLE_ATTR_ANIM(hpad, val); - STYLE_ATTR_ANIM(vpad, val); - STYLE_ATTR_ANIM(opad, val); - STYLE_ATTR_ANIM(line_space, val); - STYLE_ATTR_ANIM(letter_space, val); - STYLE_ATTR_ANIM(line_width, val); - STYLE_ATTR_ANIM(img_recolor, val); + STYLE_ATTR_ANIM(body.opa, val); + STYLE_ATTR_ANIM(body.radius, val); + STYLE_ATTR_ANIM(border.width, val); + STYLE_ATTR_ANIM(shadow.width, val); + STYLE_ATTR_ANIM(body.pad_hor, val); + STYLE_ATTR_ANIM(body.pad_ver, val); + STYLE_ATTR_ANIM(body.pad_obj, val); + STYLE_ATTR_ANIM(txt.space_line, val); + STYLE_ATTR_ANIM(txt.space_letter, val); + STYLE_ATTR_ANIM(line.width, val); + STYLE_ATTR_ANIM(img.intense, val); - act->mcolor = color_mix(end->mcolor, start->mcolor, val); - act->gcolor = color_mix(end->gcolor, start->gcolor, val); - act->bcolor = color_mix(end->bcolor, start->bcolor, val); - act->scolor = color_mix(end->scolor, start->scolor, val); - act->ccolor = color_mix(end->ccolor, start->ccolor, val); + act->body.color_main = color_mix(end->body.color_main, start->body.color_main, val); + act->body.color_grad = color_mix(end->body.color_grad, start->body.color_grad, val); + act->border.color = color_mix(end->border.color, start->border.color, val); + act->shadow.color = color_mix(end->shadow.color, start->shadow.color, val); + act->txt.color = color_mix(end->txt.color, start->txt.color, val); + act->img.color = color_mix(end->img.color, start->img.color, val); + act->line.color = color_mix(end->line.color, start->line.color, val); if(val == 0) { - act->empty = start->empty; - act->glass = start->glass; - act->font = start->font; - act->stype = start->stype; - act->txt_align = start->txt_align; + act->body.empty = start->body.empty; + act->body.glass = start->body.glass; + act->txt.font = start->txt.font; + act->shadow.type = start->shadow.type; + act->txt.align = start->txt.align; } if(val == LV_STYLE_ANIM_RES) { - act->empty = end->empty; - act->glass = end->glass; - act->font = end->font; - act->stype = end->stype; - act->txt_align = end->txt_align; + act->body.empty = end->body.empty; + act->body.glass = end->body.glass; + act->txt.font = end->txt.font; + act->shadow.type = end->shadow.type; + act->txt.align = end->txt.align; } lv_style_refr_objs(dsc->style_anim); diff --git a/lv_obj/lv_style.h b/lv_obj/lv_style.h index a57c192af..a9848878e 100644 --- a/lv_obj/lv_style.h +++ b/lv_obj/lv_style.h @@ -43,29 +43,49 @@ typedef enum typedef struct { - /*Object level styles*/ - color_t ccolor; /*Content color (e.g. text or image re-color )*/ - opa_t opa; /*Opacity of the object*/ - uint8_t glass :1; /*1: Do not inherit this style*/ - uint8_t empty :1; /*Transparent background (border drawn)*/ - uint8_t stype :2; /*Shadow type from 'lv_shadow_type_t'*/ - uint8_t txt_align:2; - color_t mcolor; /*Main color of background*/ - color_t gcolor; /*Gradient color of background*/ - color_t bcolor; /*Border color of background*/ - color_t scolor; /*Shadow color of background*/ - cord_t radius; /*Corner radius of background*/ - cord_t bwidth; /*Width of the background border*/ - cord_t swidth; /*Width of the background shadow effect*/ - cord_t vpad; /*Vertical padding*/ - cord_t hpad; /*Horizontal padding*/ - cord_t opad; /*Object padding on the background*/ - opa_t bopa; /*Opacity of background border*/ - const font_t * font; - cord_t letter_space; - cord_t line_space; - opa_t img_recolor; - cord_t line_width; + struct { + color_t color_main; + color_t color_grad; + opa_t opa; + cord_t pad_ver; /*Vertical padding*/ + cord_t pad_hor; /*Horizontal padding*/ + cord_t pad_obj; /*Object padding on the background*/ + cord_t radius; /*Corner radius of background*/ + uint8_t glass :1; /*1: Do not inherit this style*/ + uint8_t empty :1; /*Transparent background (border still drawn)*/ + }body; + + struct { + color_t color; + cord_t width; + opa_t opa; /*Opacity of background border*/ + }border; + + struct { + color_t color; + cord_t width; + uint8_t type; + }shadow; + + + struct { + color_t color; + const font_t * font; + cord_t space_letter; + cord_t space_line; + uint8_t align:2; + }txt; + + struct { + color_t color; + opa_t intense; + }img; + + struct { + color_t color; + cord_t width; + }line; + }lv_style_t; typedef enum { diff --git a/lv_objx/lv_bar.c b/lv_objx/lv_bar.c index 0253b62d4..d57af5398 100644 --- a/lv_objx/lv_bar.c +++ b/lv_objx/lv_bar.c @@ -111,7 +111,7 @@ bool lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param) if(valid != false) { if(sign == LV_SIGNAL_REFR_EXT_SIZE) { lv_style_t * style_indic = lv_bar_get_style_indic(bar); - if(style_indic->swidth > bar->ext_size) bar->ext_size = style_indic->swidth; + if(style_indic->shadow.width > bar->ext_size) bar->ext_size = style_indic->shadow.width; } } @@ -285,10 +285,10 @@ static bool lv_bar_design(lv_obj_t * bar, const area_t * mask, lv_design_mode_t lv_style_t * style_indic = lv_bar_get_style_indic(bar); area_t indic_area; area_cpy(&indic_area, &bar->cords); - indic_area.x1 += style_indic->hpad; - indic_area.x2 -= style_indic->hpad; - indic_area.y1 += style_indic->vpad; - indic_area.y2 -= style_indic->vpad; + indic_area.x1 += style_indic->body.pad_hor; + indic_area.x2 -= style_indic->body.pad_hor; + indic_area.y1 += style_indic->body.pad_ver; + indic_area.y2 -= style_indic->body.pad_ver; cord_t w = area_get_width(&indic_area); cord_t h = area_get_height(&indic_area); diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 30699d3f5..b5f1ba143 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -264,9 +264,9 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) /*Set size and positions of the buttons*/ lv_style_t * btnms = lv_obj_get_style(btnm); - cord_t max_w = lv_obj_get_width(btnm) - 2 * btnms->hpad; - cord_t max_h = lv_obj_get_height(btnm) - 2 * btnms->vpad; - cord_t act_y = btnms->vpad; + cord_t max_w = lv_obj_get_width(btnm) - 2 * btnms->body.pad_hor; + cord_t max_h = lv_obj_get_height(btnm) - 2 * btnms->body.pad_ver; + cord_t act_y = btnms->body.pad_ver; /*Count the lines to calculate button height*/ uint8_t line_cnt = 1; @@ -275,7 +275,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) if(strcmp(map[li], "\n") == 0) line_cnt ++; } - cord_t btn_h = max_h - ((line_cnt - 1) * btnms->opad); + cord_t btn_h = max_h - ((line_cnt - 1) * btnms->body.pad_obj); btn_h = btn_h / line_cnt; /* Count the units and the buttons in a line @@ -301,11 +301,11 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) /*Only deal with the non empty lines*/ if(btn_cnt != 0) { /*Calculate the width of all units*/ - cord_t all_unit_w = max_w - ((btn_cnt-1) * btnms->opad); + cord_t all_unit_w = max_w - ((btn_cnt-1) * btnms->body.pad_obj); /*Set the button size and positions and set the texts*/ uint16_t i; - cord_t act_x = btnms->hpad; + cord_t act_x = btnms->body.pad_hor; cord_t act_unit_w; unit_act_cnt = 0; for(i = 0; i < btn_cnt; i++) { @@ -315,7 +315,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) act_unit_w = (all_unit_w * lv_btnm_get_width_unit(map_p_tmp[i])) / unit_cnt; /*Always recalculate act_x because of rounding errors */ - act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * btnms->opad + btnms->hpad; + act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * btnms->body.pad_obj + btnms->body.pad_hor; area_set(&ext->btn_areas[btn_i], act_x, act_y, @@ -328,7 +328,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) btn_i ++; } } - act_y += btn_h + btnms->opad; + act_y += btn_h + btnms->body.pad_obj; if(strlen(map_p_tmp[btn_cnt]) == 0) break; /*Break on end of map*/ map_p_tmp = &map_p_tmp[btn_cnt + 1]; /*Set the map to the next line*/ i_tot ++; /*Skip the '\n'*/ @@ -515,10 +515,10 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_ lv_draw_rect(&area_tmp, mask, btn_style); /*Calculate the size of the text*/ - const font_t * font = btn_style->font; + const font_t * font = btn_style->txt.font; point_t txt_size; txt_get_size(&txt_size, ext->map_p[txt_i], font, - btn_style->letter_space, btn_style->line_space, + btn_style->txt.space_letter, btn_style->txt.space_line, area_get_width(&area_btnm), TXT_FLAG_NONE); area_tmp.x1 += (btn_w - txt_size.x) / 2; diff --git a/lv_objx/lv_cb.c b/lv_objx/lv_cb.c index 52bae6188..11590a549 100644 --- a/lv_objx/lv_cb.c +++ b/lv_objx/lv_cb.c @@ -120,7 +120,7 @@ bool lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param) * make the object specific signal handling */ if(valid != false) { if(sign == LV_SIGNAL_STYLE_CHG) { - lv_obj_set_size(ext->bullet, font_get_height(style->font), font_get_height(style->font)); + lv_obj_set_size(ext->bullet, font_get_height(style->txt.font), font_get_height(style->txt.font)); } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { @@ -239,7 +239,7 @@ static bool lv_bullet_design(lv_obj_t * bullet, const area_t * mask, lv_design_m lv_obj_t * bg = lv_obj_get_parent(bullet); lv_style_t * style_page = lv_obj_get_style(bg); lv_group_t * g = lv_obj_get_group(bg); - if(style_page->empty != 0 || style_page->opa == OPA_TRANSP) { /*Background is visible?*/ + if(style_page->body.empty != 0 || style_page->body.opa == OPA_TRANSP) { /*Background is visible?*/ if(lv_group_get_focused(g) == bg) { lv_style_t * style_mod; style_mod = lv_group_mod_style(g, style_ori); diff --git a/lv_objx/lv_chart.c b/lv_objx/lv_chart.c index e3d18f2df..bdde865c3 100644 --- a/lv_objx/lv_chart.c +++ b/lv_objx/lv_chart.c @@ -413,7 +413,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask) if(ext->hdiv_num != 0) { /*Draw slide lines if no border*/ - if(style->bwidth != 0) { + if(style->border.width != 0) { div_i_start = 1; div_i_end = ext->hdiv_num; } else { @@ -426,8 +426,8 @@ static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask) for(div_i = div_i_start; div_i <= div_i_end; div_i++) { p1.y = (int32_t)((int32_t)h * div_i) / (ext->hdiv_num + 1); p1.y += y_ofs; - if(div_i == div_i_start) p1.y += (style->line_width >> 1) + 1; /*The first line might not be visible*/ - if(div_i == div_i_end) p1.y -= (style->line_width >> 1) + 1; /*The last line might not be visible*/ + if(div_i == div_i_start) p1.y += (style->line.width >> 1) + 1; /*The first line might not be visible*/ + if(div_i == div_i_end) p1.y -= (style->line.width >> 1) + 1; /*The last line might not be visible*/ p2.y = p1.y; lv_draw_line(&p1, &p2, mask, style); @@ -436,7 +436,7 @@ static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask) if(ext->vdiv_num != 0) { /*Draw slide lines if no border*/ - if(style->bwidth != 0) { + if(style->border.width != 0) { div_i_start = 1; div_i_end = ext->vdiv_num; } else { @@ -449,8 +449,8 @@ static void lv_chart_draw_div(lv_obj_t * chart, const area_t * mask) for(div_i = div_i_start; div_i <= div_i_end; div_i ++) { p1.x = (int32_t)((int32_t)w * div_i) / (ext->vdiv_num + 1); p1.x += x_ofs; - if(div_i == div_i_start) p1.x += (style->line_width >> 1) + 1; /*The first line might not be visible*/ - if(div_i == div_i_end) p1.x -= (style->line_width >> 1) + 1; /*The last line might not be visible*/ + if(div_i == div_i_start) p1.x += (style->line.width >> 1) + 1; /*The first line might not be visible*/ + if(div_i == div_i_end) p1.x -= (style->line.width >> 1) + 1; /*The last line might not be visible*/ p2.x = p1.x; lv_draw_line(&p1, &p2, mask, style); } @@ -477,12 +477,12 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const area_t * mask) lv_chart_dl_t * dl; lv_style_t lines; lv_style_get(LV_STYLE_PLAIN, &lines); - lines.opa = (uint16_t)((uint16_t)style->opa * ext->dl_opa) >> 8; - lines.line_width = ext->dl_width; + lines.body.opa = (uint16_t)((uint16_t)style->body.opa * ext->dl_opa) >> 8; + lines.line.width = ext->dl_width; /*Go through all data lines*/ LL_READ_BACK(ext->dl_ll, dl) { - lines.ccolor = dl->color; + lines.line.color = dl->color; p1.x = 0 + x_ofs; p2.x = 0 + x_ofs; @@ -527,27 +527,27 @@ static void lv_chart_draw_points(lv_obj_t * chart, const area_t * mask) lv_style_t style_point; lv_style_get(LV_STYLE_PLAIN, &style_point); - style_point.bwidth = 0; - style_point.empty = 0; - style_point.radius = LV_RADIUS_CIRCLE; - style_point.opa = (uint16_t)((uint16_t)style->opa * ext->dl_opa) >> 8; - style_point.radius = ext->dl_width; + style_point.border.width = 0; + style_point.body.empty = 0; + style_point.body.radius = LV_RADIUS_CIRCLE; + style_point.body.opa = (uint16_t)((uint16_t)style->body.opa * ext->dl_opa) >> 8; + style_point.body.radius = ext->dl_width; /*Go through all data lines*/ LL_READ_BACK(ext->dl_ll, dl) { - style_point.mcolor = dl->color; - style_point.gcolor = color_mix(COLOR_BLACK, dl->color, ext->dl_dark); + style_point.body.color_main = dl->color; + style_point.body.color_grad = color_mix(COLOR_BLACK, dl->color, ext->dl_dark); for(i = 0; i < ext->pnum; i ++) { cir_a.x1 = ((w * i) / (ext->pnum - 1)) + x_ofs; - cir_a.x2 = cir_a.x1 + style_point.radius; - cir_a.x1 -= style_point.radius; + cir_a.x2 = cir_a.x1 + style_point.body.radius; + cir_a.x1 -= style_point.body.radius; y_tmp = (int32_t)((int32_t) dl->points[i] - ext->ymin) * h; y_tmp = y_tmp / (ext->ymax - ext->ymin); cir_a.y1 = h - y_tmp + y_ofs; - cir_a.y2 = cir_a.y1 + style_point.radius; - cir_a.y1 -= style_point.radius; + cir_a.y2 = cir_a.y1 + style_point.body.radius; + cir_a.y1 -= style_point.body.radius; lv_draw_rect(&cir_a, mask, &style_point); } @@ -578,10 +578,10 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask) cord_t x_ofs = col_w / 2; /*Shift with a half col.*/ lv_style_get(LV_STYLE_PLAIN, &rects); - rects.bwidth = 0; - rects.empty = 0; - rects.radius = 0; - rects.opa = (uint16_t)((uint16_t)style->opa * ext->dl_opa) >> 8; + rects.border.width = 0; + rects.body.empty = 0; + rects.body.radius = 0; + rects.body.opa = (uint16_t)((uint16_t)style->body.opa * ext->dl_opa) >> 8; col_a.y2 = chart->cords.y2; @@ -594,8 +594,8 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask) /*Draw the current point of all data line*/ LL_READ_BACK(ext->dl_ll, dl) { - rects.mcolor = dl->color; - rects.gcolor = color_mix(COLOR_BLACK, dl->color, ext->dl_dark); + rects.body.color_main = dl->color; + rects.body.color_grad = color_mix(COLOR_BLACK, dl->color, ext->dl_dark); col_a.x1 = x_act; col_a.x2 = col_a.x1 + col_w; x_act += col_w; diff --git a/lv_objx/lv_cont.c b/lv_objx/lv_cont.c index f754ba847..4afd7c56d 100644 --- a/lv_objx/lv_cont.c +++ b/lv_objx/lv_cont.c @@ -277,23 +277,23 @@ static void lv_cont_layout_col(lv_obj_t * cont) /*Adjust margin and get the alignment type*/ lv_align_t align; lv_style_t * style = lv_obj_get_style(cont); - cord_t hpad_corr; + cord_t pad_hor_corr; switch(type) { case LV_CONT_LAYOUT_COL_L: - hpad_corr = style->hpad; + pad_hor_corr = style->body.pad_hor; align = LV_ALIGN_IN_TOP_LEFT; break; case LV_CONT_LAYOUT_COL_M: - hpad_corr = 0; + pad_hor_corr = 0; align = LV_ALIGN_IN_TOP_MID; break; case LV_CONT_LAYOUT_COL_R: - hpad_corr = -style->hpad; + pad_hor_corr = -style->body.pad_hor; align = LV_ALIGN_IN_TOP_RIGHT; break; default: - hpad_corr = 0; + pad_hor_corr = 0; align = LV_ALIGN_IN_TOP_LEFT; break; } @@ -302,13 +302,13 @@ static void lv_cont_layout_col(lv_obj_t * cont) * an unnecessary child change signals could be sent*/ lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG); /* Align the children */ - cord_t last_cord = style->vpad; + cord_t last_cord = style->body.pad_ver; LL_READ_BACK(cont->child_ll, child) { if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; - lv_obj_align(child, cont, align, hpad_corr , last_cord); - last_cord += lv_obj_get_height(child) + style->opad; + lv_obj_align(child, cont, align, pad_hor_corr , last_cord); + last_cord += lv_obj_get_height(child) + style->body.pad_obj; } lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG); @@ -326,23 +326,23 @@ static void lv_cont_layout_row(lv_obj_t * cont) /*Adjust margin and get the alignment type*/ lv_align_t align; lv_style_t * style = lv_obj_get_style(cont); - cord_t vpad_corr = style->vpad; + cord_t pad_ver_corr = style->body.pad_ver; switch(type) { case LV_CONT_LAYOUT_ROW_T: - vpad_corr = style->vpad; + pad_ver_corr = style->body.pad_ver; align = LV_ALIGN_IN_TOP_LEFT; break; case LV_CONT_LAYOUT_ROW_M: - vpad_corr = 0; + pad_ver_corr = 0; align = LV_ALIGN_IN_LEFT_MID; break; case LV_CONT_LAYOUT_ROW_B: - vpad_corr = -style->vpad; + pad_ver_corr = -style->body.pad_ver; align = LV_ALIGN_IN_BOTTOM_LEFT; break; default: - vpad_corr = 0; + pad_ver_corr = 0; align = LV_ALIGN_IN_TOP_LEFT; break; } @@ -352,13 +352,13 @@ static void lv_cont_layout_row(lv_obj_t * cont) lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG); /* Align the children */ - cord_t last_cord = style->hpad; + cord_t last_cord = style->body.pad_hor; LL_READ_BACK(cont->child_ll, child) { if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; - lv_obj_align(child, cont, align, last_cord, vpad_corr); - last_cord += lv_obj_get_width(child) + style->opad; + lv_obj_align(child, cont, align, last_cord, pad_ver_corr); + last_cord += lv_obj_get_width(child) + style->body.pad_obj; } lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG); @@ -378,13 +378,13 @@ static void lv_cont_layout_center(lv_obj_t * cont) LL_READ(cont->child_ll, child) { if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; - h_tot += lv_obj_get_height(child) + style->opad; + h_tot += lv_obj_get_height(child) + style->body.pad_obj; obj_num ++; } if(obj_num == 0) return; - h_tot -= style->opad; + h_tot -= style->body.pad_obj; /* Disable child change action because the children will be moved a lot * an unnecessary child change signals could be sent*/ @@ -397,7 +397,7 @@ static void lv_cont_layout_center(lv_obj_t * cont) lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; lv_obj_align(child, cont, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2); - last_cord += lv_obj_get_height(child) + style->opad; + last_cord += lv_obj_get_height(child) + style->body.pad_obj; } lv_obj_clr_protect(cont, LV_PROTECT_CHILD_CHG); @@ -415,7 +415,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont) lv_obj_t * child_tmp; /* Temporary child */ lv_style_t * style = lv_obj_get_style(cont); cord_t w_obj = lv_obj_get_width(cont); - cord_t act_y = style->vpad; + cord_t act_y = style->body.pad_ver; /* Disable child change action because the children will be moved a lot * an unnecessary child change signals could be sent*/ @@ -427,7 +427,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont) child_rc = child_rs; /*Initially the the row starter and closer is the same*/ while(child_rs != NULL) { cord_t h_row = 0; - cord_t w_row = style->hpad * 2; /*The width is at least the left+right hpad*/ + cord_t w_row = style->body.pad_hor * 2; /*The width is at least the left+right hpad*/ uint32_t obj_num = 0; /*Find the row closer object and collect some data*/ @@ -442,7 +442,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont) } break; } - w_row += lv_obj_get_width(child_rc) + style->opad; /*Add the object width + opad*/ + w_row += lv_obj_get_width(child_rc) + style->body.pad_obj; /*Add the object width + opad*/ h_row = MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/ obj_num ++; if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW)) break; /*If can not be followed by an other object then break here*/ @@ -474,9 +474,9 @@ static void lv_cont_layout_pretty(lv_obj_t * cont) } /* Align the children (from child_rs to child_rc)*/ else { - w_row -= style->opad * obj_num; + w_row -= style->body.pad_obj * obj_num; cord_t new_opad = (w_obj - w_row) / (obj_num - 1); - cord_t act_x = style->hpad; /*x init*/ + cord_t act_x = style->body.pad_hor; /*x init*/ child_tmp = child_rs; while(child_tmp != NULL) { if(lv_obj_get_hidden(child_tmp) == false && @@ -491,7 +491,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont) } if(child_rc == NULL) break; - act_y += style->opad + h_row; /*y increment*/ + act_y += style->body.pad_obj + h_row; /*y increment*/ child_rs = ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/ child_rc = child_rs; } @@ -509,22 +509,22 @@ static void lv_cont_layout_grid(lv_obj_t * cont) cord_t w_tot = lv_obj_get_width(cont); cord_t w_obj = lv_obj_get_width(lv_obj_get_child(cont, NULL)); cord_t h_obj = lv_obj_get_height(lv_obj_get_child(cont, NULL)); - uint16_t obj_row = (w_tot - (2 * style->hpad)) / (w_obj + style->opad); /*Obj. num. in a row*/ + uint16_t obj_row = (w_tot - (2 * style->body.pad_hor)) / (w_obj + style->body.pad_obj); /*Obj. num. in a row*/ cord_t x_ofs; if(obj_row > 1) { - x_ofs = w_obj + (w_tot - (2 * style->hpad) - (obj_row * w_obj)) / (obj_row - 1); + x_ofs = w_obj + (w_tot - (2 * style->body.pad_hor) - (obj_row * w_obj)) / (obj_row - 1); } else { x_ofs = w_tot / 2 - w_obj / 2; } - cord_t y_ofs = h_obj + style->opad; + cord_t y_ofs = h_obj + style->body.pad_obj; /* Disable child change action because the children will be moved a lot * an unnecessary child change signals could be sent*/ lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG); /* Align the children */ - cord_t act_x = style->hpad; - cord_t act_y = style->vpad; + cord_t act_x = style->body.pad_hor; + cord_t act_y = style->body.pad_ver; uint16_t obj_cnt = 0; LL_READ_BACK(cont->child_ll, child) { if(lv_obj_get_hidden(child) != false || @@ -540,7 +540,7 @@ static void lv_cont_layout_grid(lv_obj_t * cont) if(obj_cnt >= obj_row) { obj_cnt = 0; - act_x = style->hpad; + act_x = style->body.pad_hor; act_y += y_ofs; } } @@ -565,8 +565,8 @@ static void lv_cont_refr_autofit(lv_obj_t * cont) area_t ori; lv_style_t * style = lv_obj_get_style(cont); lv_obj_t * i; - cord_t hpad = style->hpad; - cord_t vpad = style->vpad; + cord_t hpad = style->body.pad_hor; + cord_t vpad = style->body.pad_ver; /*Search the side coordinates of the children*/ lv_obj_get_cords(cont, &ori); diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index 5845427f3..e8f47c371 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -417,15 +417,15 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_m lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist); if(ext->opened != 0) { lv_style_t * style = lv_obj_get_style(ddlist); - const font_t * font = style->font; + const font_t * font = style->txt.font; cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS; area_t rect_area; rect_area.y1 = ext->opt_label->cords.y1; - rect_area.y1 += ext->sel_opt * (font_h + style->line_space); - rect_area.y1 -= style->line_space / 2; + rect_area.y1 += ext->sel_opt * (font_h + style->txt.space_line); + rect_area.y1 -= style->txt.space_line / 2; - rect_area.y2 = rect_area.y1 + font_h + style->line_space; - rect_area.x1 = ext->opt_label->cords.x1 - style->hpad; + rect_area.y2 = rect_area.y1 + font_h + style->txt.space_line; + rect_area.x1 = ext->opt_label->cords.x1 - style->body.pad_hor; rect_area.x2 = rect_area.x1 + lv_obj_get_width(lv_page_get_scrl(ddlist)); lv_draw_rect(&rect_area, mask, ext->style_sel); @@ -494,13 +494,13 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time) lv_style_t * style = lv_obj_get_style(ddlist); cord_t new_height; if(ext->opened) { /*Open the list*/ - if(ext->fix_height == 0) new_height = lv_obj_get_height(lv_page_get_scrl(ddlist)) + 2 * style->vpad; + if(ext->fix_height == 0) new_height = lv_obj_get_height(lv_page_get_scrl(ddlist)) + 2 * style->body.pad_ver; else new_height = ext->fix_height; } else { /*Close the list*/ - const font_t * font = style->font; + const font_t * font = style->txt.font; lv_style_t * label_style = lv_obj_get_style(ext->opt_label); cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS; - new_height = font_h + 2 * label_style->line_space; + new_height = font_h + 2 * label_style->txt.space_line; } if(anim_time == 0) { lv_obj_set_height(ddlist, new_height); @@ -532,13 +532,13 @@ static void lv_ddlist_pos_act_option(lv_obj_t * ddlist) { lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist); lv_style_t * style = lv_obj_get_style(ddlist); - const font_t * font = style->font; + const font_t * font = style->txt.font; cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS; lv_style_t * label_style = lv_obj_get_style(ext->opt_label); lv_obj_t * scrl = lv_page_get_scrl(ddlist); cord_t h = lv_obj_get_height(ddlist); - cord_t line_y1 = ext->sel_opt * (font_h + label_style->line_space) + ext->opt_label->cords.y1 - scrl->cords.y1; + cord_t line_y1 = ext->sel_opt * (font_h + label_style->txt.space_line) + ext->opt_label->cords.y1 - scrl->cords.y1; lv_obj_set_y(scrl, - line_y1 + (h - font_h) / 2); diff --git a/lv_objx/lv_gauge.c b/lv_objx/lv_gauge.c index 4252beb98..7f473112e 100644 --- a/lv_objx/lv_gauge.c +++ b/lv_objx/lv_gauge.c @@ -134,7 +134,7 @@ bool lv_gauge_signal(lv_obj_t * gauge, lv_signal_t sign, void * param) } else if(sign == LV_SIGNAL_REFR_EXT_SIZE) { lv_style_t * style_crit = lv_gauge_get_style_critical(gauge); - if(style_crit->swidth > gauge->ext_size) gauge->ext_size = style_crit->swidth; + if(style_crit->shadow.width > gauge->ext_size) gauge->ext_size = style_crit->shadow.width; } } @@ -334,13 +334,13 @@ static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mod /*Mix the normal and the critical style*/ memcpy(&style_bg, style_base, sizeof(lv_style_t)); - style_bg.ccolor = color_mix(style_critical->ccolor, style_base->ccolor, ratio); - style_bg.mcolor= color_mix(style_critical->mcolor, style_base->mcolor, ratio); - style_bg.gcolor = color_mix(style_critical->gcolor, style_base->gcolor, ratio); - style_bg.bcolor = color_mix(style_critical->bcolor, style_base->bcolor, ratio); - style_bg.scolor = color_mix(style_critical->scolor, style_base->scolor, ratio); - style_bg.swidth = (cord_t)(((cord_t)style_critical->swidth * ratio) + ((cord_t)style_base->swidth * (OPA_COVER - ratio))) >> 8; - style_bg.opa = (cord_t)(((uint16_t)style_critical->opa * ratio) + ((uint16_t)style_base->opa * (OPA_COVER - ratio))) >> 8; + style_bg.txt.color = color_mix(style_critical->txt.color, style_base->txt.color, ratio); + style_bg.body.color_main= color_mix(style_critical->body.color_main, style_base->body.color_main, ratio); + style_bg.body.color_grad = color_mix(style_critical->body.color_grad, style_base->body.color_grad, ratio); + style_bg.border.color = color_mix(style_critical->border.color, style_base->border.color, ratio); + style_bg.shadow.color = color_mix(style_critical->shadow.color, style_base->shadow.color, ratio); + style_bg.shadow.width = (cord_t)(((cord_t)style_critical->shadow.width * ratio) + ((cord_t)style_base->shadow.width * (OPA_COVER - ratio))) >> 8; + style_bg.body.opa = (cord_t)(((uint16_t)style_critical->body.opa * ratio) + ((uint16_t)style_base->body.opa * (OPA_COVER - ratio))) >> 8; lv_draw_rect(&gauge->cords, mask, &style_bg); @@ -365,7 +365,7 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask, lv_style_ { char scale_txt[16]; - cord_t r = lv_obj_get_width(gauge) / 2 - style->hpad; + cord_t r = lv_obj_get_width(gauge) / 2 - style->body.pad_hor; cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1; cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1; int16_t scale_angle = lv_lmeter_get_scale_angle(gauge); @@ -391,8 +391,8 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask, lv_style_ area_t label_cord; point_t label_size; - txt_get_size(&label_size, scale_txt, style->font, - style->letter_space, style->line_space, + txt_get_size(&label_size, scale_txt, style->txt.font, + style->txt.space_letter, style->txt.space_line, CORD_MAX, TXT_FLAG_NONE); /*Draw the label*/ @@ -414,7 +414,7 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style lv_style_t style_needle; lv_gauge_ext_t * ext = lv_obj_get_ext(gauge); - cord_t r = lv_obj_get_width(gauge) / 2 - style->opad; + cord_t r = lv_obj_get_width(gauge) / 2 - style->body.pad_obj; cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1; cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1; uint16_t angle = lv_lmeter_get_scale_angle(gauge); @@ -436,8 +436,8 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style p_end.x = (trigo_sin(needle_angle + 90) * r) / TRIGO_SIN_MAX + x_ofs; /*Draw the needle with the corresponding color*/ - if(ext->needle_colors == NULL) style_needle.ccolor = LV_GAUGE_DEF_NEEDLE_COLOR; - else style_needle.ccolor = ext->needle_colors[i]; + if(ext->needle_colors == NULL) style_needle.line.color = LV_GAUGE_DEF_NEEDLE_COLOR; + else style_needle.line.color = ext->needle_colors[i]; lv_draw_line(&p_mid, &p_end, mask, &style_needle); } @@ -445,15 +445,15 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask, lv_style /*Draw the needle middle area*/ lv_style_t style_neddle_mid; lv_style_get(LV_STYLE_PLAIN, &style_neddle_mid); - style_neddle_mid.mcolor = style->bcolor; - style_neddle_mid.gcolor = style->bcolor; - style_neddle_mid.radius = LV_RADIUS_CIRCLE; + style_neddle_mid.body.color_main = style->border.color; + style_neddle_mid.body.color_grad = style->border.color; + style_neddle_mid.body.radius = LV_RADIUS_CIRCLE; area_t nm_cord; - nm_cord.x1 = x_ofs - style->opad; - nm_cord.y1 = y_ofs - style->opad; - nm_cord.x2 = x_ofs + style->opad; - nm_cord.y2 = y_ofs + style->opad; + nm_cord.x1 = x_ofs - style->body.pad_obj; + nm_cord.y1 = y_ofs - style->body.pad_obj; + nm_cord.x2 = x_ofs + style->body.pad_obj; + nm_cord.y2 = y_ofs + style->body.pad_obj; lv_draw_rect(&nm_cord, mask, &style_neddle_mid); } diff --git a/lv_objx/lv_img.c b/lv_objx/lv_img.c index 62de520ff..f9d000b7f 100644 --- a/lv_objx/lv_img.c +++ b/lv_objx/lv_img.c @@ -195,7 +195,7 @@ void lv_img_set_file(lv_obj_t * img, const char * fn) #if LV_IMG_ENABLE_SYMBOLS lv_style_t * style = lv_obj_get_style(img); point_t size; - txt_get_size(&size, fn, style->font, style->letter_space, style->line_space, CORD_MAX, TXT_FLAG_NONE); + txt_get_size(&size, fn, style->txt.font, style->txt.space_letter, style->txt.space_line, CORD_MAX, TXT_FLAG_NONE); ext->w = size.x; ext->h = size.y; ext->transp = 1; /*Symbols always have transparent parts*/ diff --git a/lv_objx/lv_label.c b/lv_objx/lv_label.c index f17209db8..6afeda5d0 100644 --- a/lv_objx/lv_label.c +++ b/lv_objx/lv_label.c @@ -386,7 +386,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos) uint32_t new_line_start = 0; cord_t max_w = lv_obj_get_width(label); lv_style_t * style = lv_obj_get_style(label); - const font_t * font = style->font; + const font_t * font = style->txt.font; uint8_t letter_height = font_get_height(font) >> FONT_ANTIALIAS; cord_t y = 0; txt_flag_t flag = TXT_FLAG_NONE; @@ -404,16 +404,16 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos) /*Search the line of the index letter */; while (txt[new_line_start] != '\0') { - new_line_start += txt_get_next_line(&txt[line_start], font, style->letter_space, max_w, flag); + new_line_start += txt_get_next_line(&txt[line_start], font, style->txt.space_letter, max_w, flag); if(index < new_line_start || txt[new_line_start] == '\0') break; /*The line of 'index' letter begins at 'line_start'*/ - y += letter_height + style->line_space; + y += letter_height + style->txt.space_line; line_start = new_line_start; } /*If the last character is line break then go to the next line*/ if((txt[index - 1] == '\n' || txt[index - 1] == '\r') && txt[index] == '\0') { - y += letter_height + style->line_space; + y += letter_height + style->txt.space_line; line_start = index; } @@ -432,13 +432,13 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos) continue; /*Skip the letter is it is part of a command*/ } } - x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->letter_space; + x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->txt.space_letter; } - if(style->txt_align == LV_TXT_ALIGN_MID) { + if(style->txt.align == LV_TXT_ALIGN_MID) { cord_t line_w; line_w = txt_get_width(&txt[line_start], new_line_start - line_start, - font, style->letter_space, flag); + font, style->txt.space_letter, flag); x += lv_obj_get_width(label) / 2 - line_w / 2; } @@ -461,7 +461,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos) uint32_t new_line_start = 0; cord_t max_w = lv_obj_get_width(label); lv_style_t * style = lv_obj_get_style(label); - const font_t * font = style->font; + const font_t * font = style->txt.font; uint8_t letter_height = font_get_height(font) >> FONT_ANTIALIAS; cord_t y = 0; txt_flag_t flag = TXT_FLAG_NONE; @@ -477,18 +477,18 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos) /*Search the line of the index letter */; while (txt[line_start] != '\0') { - new_line_start += txt_get_next_line(&txt[line_start], font, style->letter_space, max_w, flag); - if(pos->y <= y + letter_height + style->line_space) break; /*The line is found ('line_start')*/ - y += letter_height + style->line_space; + new_line_start += txt_get_next_line(&txt[line_start], font, style->txt.space_letter, max_w, flag); + if(pos->y <= y + letter_height + style->txt.space_line) break; /*The line is found ('line_start')*/ + y += letter_height + style->txt.space_line; line_start = new_line_start; } /*Calculate the x coordinate*/ cord_t x = 0; - if(style->txt_align == LV_TXT_ALIGN_MID) { + if(style->txt.align == LV_TXT_ALIGN_MID) { cord_t line_w; line_w = txt_get_width(&txt[line_start], new_line_start - line_start, - font, style->letter_space, flag); + font, style->txt.space_letter, flag); x += lv_obj_get_width(label) / 2 - line_w / 2; } @@ -504,7 +504,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos) } } - x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->letter_space; + x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->txt.space_letter; if(pos->x < x) break; /*Get the position*/ } @@ -573,7 +573,7 @@ static void lv_label_refr_text(lv_obj_t * label) cord_t max_w = lv_obj_get_width(label); lv_style_t * style = lv_obj_get_style(label); - const font_t * font = style->font; + const font_t * font = style->txt.font; ext->dot_end = LV_LABEL_DOT_END_INV; /*Initialize the dot end index*/ @@ -589,7 +589,7 @@ static void lv_label_refr_text(lv_obj_t * label) if(ext->recolor != 0) flag |= TXT_FLAG_RECOLOR; if(ext->expand != 0) flag |= TXT_FLAG_EXPAND; if(ext->no_break != 0) flag |= TXT_FLAG_NO_BREAK; - txt_get_size(&size, ext->txt, font, style->letter_space, style->line_space, max_w, flag); + txt_get_size(&size, ext->txt, font, style->txt.space_letter, style->txt.space_line, max_w, flag); /*Refresh the full size in expand mode*/ if(ext->long_mode == LV_LABEL_LONG_EXPAND || ext->long_mode == LV_LABEL_LONG_SCROLL) { diff --git a/lv_objx/lv_led.c b/lv_objx/lv_led.c index 245bb4183..39bfb8cce 100644 --- a/lv_objx/lv_led.c +++ b/lv_objx/lv_led.c @@ -201,13 +201,13 @@ static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t memcpy(&leds_tmp, style, sizeof(leds_tmp)); /*Mix. the color with black proportionally with brightness*/ - leds_tmp.mcolor = color_mix(leds_tmp.mcolor, COLOR_BLACK, ext->bright); - leds_tmp.gcolor = color_mix(leds_tmp.gcolor, COLOR_BLACK, ext->bright); - leds_tmp.bcolor = color_mix(leds_tmp.bcolor, COLOR_BLACK, ext->bright); + leds_tmp.body.color_main = color_mix(leds_tmp.body.color_main, COLOR_BLACK, ext->bright); + leds_tmp.body.color_grad = color_mix(leds_tmp.body.color_grad, COLOR_BLACK, ext->bright); + leds_tmp.border.color = color_mix(leds_tmp.border.color, COLOR_BLACK, ext->bright); /*Set the current swidth according to brightness proportionally between LV_LED_BRIGHT_OFF and LV_LED_BRIGHT_ON*/ uint16_t bright_tmp = ext->bright; - leds_tmp.swidth = ((bright_tmp - LV_LED_BRIGHT_OFF) * style->swidth) / (LV_LED_BRIGHT_ON - LV_LED_BRIGHT_OFF); + leds_tmp.shadow.width = ((bright_tmp - LV_LED_BRIGHT_OFF) * style->shadow.width) / (LV_LED_BRIGHT_ON - LV_LED_BRIGHT_OFF); led->style_p = &leds_tmp; ancestor_design_f(led, mask, mode); diff --git a/lv_objx/lv_line.c b/lv_objx/lv_line.c index 556416ace..d90aa7da0 100644 --- a/lv_objx/lv_line.c +++ b/lv_objx/lv_line.c @@ -141,7 +141,7 @@ void lv_line_set_points(lv_obj_t * line, const point_t * point_a, uint16_t point } lv_style_t * lines = lv_obj_get_style(line); - lv_obj_set_size(line, xmax + lines->line_width, ymax + lines->line_width); + lv_obj_set_size(line, xmax + lines->line.width, ymax + lines->line.width); } } diff --git a/lv_objx/lv_list.c b/lv_objx/lv_list.c index 04c4d6df9..6517d1dcf 100644 --- a/lv_objx/lv_list.c +++ b/lv_objx/lv_list.c @@ -225,12 +225,12 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, l /*Make the size adjustment*/ cord_t w = lv_obj_get_width(list); lv_style_t * style_scrl = lv_obj_get_style(lv_page_get_scrl(list)); - cord_t hpad_tot = style->hpad + style_scrl->hpad; - w -= hpad_tot * 2; + cord_t pad_hor_tot = style->body.pad_hor + style_scrl->body.pad_hor; + w -= pad_hor_tot * 2; - /*Make place for the scrollbar if hpad_tot is too small*/ + /*Make place for the scrollbar if pad_hor_tot is too small*/ if(ext->sb_out != 0) { - if(hpad_tot < ext->page.sb_width) w -= ext->page.sb_width - hpad_tot; + if(pad_hor_tot < ext->page.sb_width) w -= ext->page.sb_width - pad_hor_tot; } lv_obj_set_width(liste, w); #if USE_LV_IMG != 0 && USE_FSINT != 0 diff --git a/lv_objx/lv_lmeter.c b/lv_objx/lv_lmeter.c index ca5feb3f0..a37474c3f 100644 --- a/lv_objx/lv_lmeter.c +++ b/lv_objx/lv_lmeter.c @@ -186,7 +186,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_m memcpy(&style_tmp, style, sizeof(lv_style_t)); cord_t r_out = lv_obj_get_width(lmeter) / 2; - cord_t r_in =r_out - style->hpad; + cord_t r_in =r_out - style->body.pad_hor; cord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->cords.x1; cord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->cords.y1; int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2; @@ -195,7 +195,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_m int16_t level = (int32_t)((int32_t)(lv_bar_get_value(lmeter) - min) * ext->scale_num) / (max - min); uint8_t i; - style_tmp.ccolor = style->mcolor; + style_tmp.line.color = style->body.color_main; for(i = 0; i < ext->scale_num; i++) { /*Calculate the position a scale label*/ @@ -215,9 +215,9 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_m p1.x = x_out+ x_ofs; p1.y = y_out + y_ofs; - if(i > level) style_tmp.ccolor = style->ccolor; + if(i > level) style_tmp.line.color = style->line.color; else { - style_tmp.ccolor=color_mix(style->gcolor, style->mcolor, (255 * i) / ext->scale_num); + style_tmp.line.color = color_mix(style->body.color_grad, style->body.color_main, (255 * i) / ext->scale_num); } lv_draw_line(&p1, &p2, mask, &style_tmp); diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index c036d3d78..59c2e4af8 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -89,7 +89,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy) lv_obj_set_style(ext->scrl, lv_style_get(LV_STYLE_PRETTY, NULL)); lv_obj_set_design_f(ext->scrl, lv_scrl_design); - lv_page_set_sb_width(new_page, style->hpad); + lv_page_set_sb_width(new_page, style->body.pad_hor); lv_page_set_sb_mode(new_page, ext->sb_mode); lv_page_set_style_sb(new_page, ext->style_sb); @@ -156,7 +156,7 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) } else if(sign == LV_SIGNAL_STYLE_CHG) { lv_style_t * style = lv_obj_get_style(page); if(lv_cont_get_hfit(ext->scrl) == false) { - lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->hpad); + lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.pad_hor); } else { ext->scrl->signal_f(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->cords); } @@ -178,7 +178,7 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) lv_obj_get_height(page) != area_get_height(param))) { if(lv_cont_get_hfit(ext->scrl) == false) { - lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->hpad); + lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.pad_hor); } ext->scrl->signal_f(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->cords); @@ -229,7 +229,7 @@ bool lv_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param) /*Be sure the width of the scrollable is correct*/ if(lv_cont_get_hfit(scrl) == false) { - lv_obj_set_width(scrl, lv_obj_get_width(page) - 2 * page_style->hpad); + lv_obj_set_width(scrl, lv_obj_get_width(page) - 2 * page_style->body.pad_hor); } cord_t new_x; @@ -238,8 +238,8 @@ bool lv_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param) bool refr_y = false; area_t page_cords; area_t scrl_cords; - cord_t hpad = page_style->hpad; - cord_t vpad = page_style->vpad; + cord_t hpad = page_style->body.pad_hor; + cord_t vpad = page_style->body.pad_ver; new_x = lv_obj_get_x(scrl); new_y = lv_obj_get_y(scrl); @@ -288,8 +288,8 @@ bool lv_page_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param) lv_page_sb_refresh(page); } else if(sign == LV_SIGNAL_DRAG_BEGIN) { if(page_ext->sb_mode == LV_PAGE_SB_MODE_DRAG ) { - cord_t sbh_pad = MATH_MAX(page_ext->sb_width, page_style->hpad); - cord_t sbv_pad = MATH_MAX(page_ext->sb_width, page_style->vpad); + cord_t sbh_pad = MATH_MAX(page_ext->sb_width, page_style->body.pad_hor); + cord_t sbv_pad = MATH_MAX(page_ext->sb_width, page_style->body.pad_ver); if(area_get_height(&page_ext->sbv) < lv_obj_get_height(scrl) - 2 * sbv_pad) { page_ext->sbv_draw = 1; } @@ -438,8 +438,8 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time) if((obj_h <= page_h && top_err > 0) || (obj_h > page_h && top_err < bot_err)) { /*Calculate a new position and to let scrable_rects.vpad space above*/ - scrlable_y = -(obj_y - style_scrl->vpad - style->vpad); - scrlable_y += style_scrl->vpad; + scrlable_y = -(obj_y - style_scrl->body.pad_ver - style->body.pad_ver); + scrlable_y += style_scrl->body.pad_ver; } /*Out of the page on the bottom*/ else if((obj_h <= page_h && bot_err > 0) || @@ -447,7 +447,7 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time) /*Calculate a new position and to let scrable_rects.vpad space below*/ scrlable_y = -obj_y; scrlable_y += page_h - obj_h; - scrlable_y -= style_scrl->vpad; + scrlable_y -= style_scrl->body.pad_ver; } else { /*Alraedy in focus*/ return; @@ -594,7 +594,7 @@ static bool lv_scrl_design(lv_obj_t * scrl, const area_t * mask, lv_design_mode_ lv_obj_t * page = lv_obj_get_parent(scrl); lv_style_t * style_page = lv_obj_get_style(page); lv_group_t * g = lv_obj_get_group(page); - if(style_page->empty != 0 || style_page->opa == OPA_TRANSP) { /*Background is visible?*/ + if(style_page->body.empty != 0 || style_page->body.opa == OPA_TRANSP) { /*Background is visible?*/ if(lv_group_get_focused(g) == page) { lv_style_t * style_mod; style_mod = lv_group_mod_style(g, style_ori); @@ -633,12 +633,12 @@ static void lv_page_sb_refresh(lv_obj_t * page) cord_t size_tmp; cord_t scrl_w = lv_obj_get_width(scrl); cord_t scrl_h = lv_obj_get_height(scrl); - cord_t hpad = style->hpad; - cord_t vpad = style->vpad; + cord_t hpad = style->body.pad_hor; + cord_t vpad = style->body.pad_ver; cord_t obj_w = lv_obj_get_width(page); cord_t obj_h = lv_obj_get_height(page); - cord_t sbh_pad = MATH_MAX(ext->sb_width, style->hpad); - cord_t sbv_pad = MATH_MAX(ext->sb_width, style->vpad); + cord_t sbh_pad = MATH_MAX(ext->sb_width, style->body.pad_hor); + cord_t sbv_pad = MATH_MAX(ext->sb_width, style->body.pad_ver); if(ext->sb_mode == LV_PAGE_SB_MODE_OFF) return; diff --git a/lv_objx/lv_roller.c b/lv_objx/lv_roller.c index d7a6a4d5c..fa70fa063 100644 --- a/lv_objx/lv_roller.c +++ b/lv_objx/lv_roller.c @@ -77,8 +77,8 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy) lv_ddlist_open(new_roller, true, 0); lv_style_t * style_label = lv_obj_get_style(ext->ddlist.opt_label); - lv_ddlist_set_fix_height(new_roller, (font_get_height(style_label->font) >> FONT_ANTIALIAS) * 3 - + style_label->line_space * 4); + lv_ddlist_set_fix_height(new_roller, (font_get_height(style_label->txt.font) >> FONT_ANTIALIAS) * 3 + + style_label->txt.space_line * 4); lv_obj_refr_style(new_roller); /*To set scrollable size automatically*/ } /*Copy an existing roller*/ @@ -187,13 +187,13 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m lv_style_t * style = lv_obj_get_style(roller); lv_draw_rect(&roller->cords, mask, style); - const font_t * font = style->font; + const font_t * font = style->txt.font; lv_roller_ext_t * ext = lv_obj_get_ext(roller); cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS; area_t rect_area; - rect_area.y1 = roller->cords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->line_space - 2; - rect_area.y2 = rect_area.y1 + font_h + style->line_space; - rect_area.x1 = ext->ddlist.opt_label->cords.x1 - style->hpad; + rect_area.y1 = roller->cords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->txt.space_line - 2; + rect_area.y2 = rect_area.y1 + font_h + style->txt.space_line; + rect_area.x1 = ext->ddlist.opt_label->cords.x1 - style->body.pad_hor; rect_area.x2 = rect_area.x1 + lv_obj_get_width(lv_page_get_scrl(roller)); lv_draw_rect(&rect_area, mask, ext->ddlist.style_sel); @@ -228,12 +228,12 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * lv_obj_t * roller = lv_obj_get_parent(roller_scrl); lv_roller_ext_t * ext = lv_obj_get_ext(roller); lv_style_t * style_label = lv_obj_get_style(ext->ddlist.opt_label); - const font_t * font = style_label->font; + const font_t * font = style_label->txt.font; cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS; if(sign == LV_SIGNAL_DRAG_END) { /*If dragged then align the list to there be an element in the middle*/ cord_t label_y1 = ext->ddlist.opt_label->cords.y1 - roller->cords.y1; - cord_t label_unit = (font_get_height(style_label->font) >> FONT_ANTIALIAS) + style_label->line_space / 2; + cord_t label_unit = (font_get_height(style_label->txt.font) >> FONT_ANTIALIAS) + style_label->txt.space_line / 2; cord_t mid = (roller->cords.y2 - roller->cords.y1) / 2; id = (mid - label_y1) / label_unit; if(id < 0) id = 0; @@ -246,7 +246,7 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * point_t p; lv_indev_get_point(indev, &p); p.y = p.y - ext->ddlist.opt_label->cords.y1; - id = p.y / (font_h + style_label->line_space); + id = p.y / (font_h + style_label->txt.space_line); if(id < 0) id = 0; if(id >= ext->ddlist.num_opt) id = ext->ddlist.num_opt - 1; ext->ddlist.sel_opt = id; @@ -256,7 +256,7 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * /*Position the scrollable according to the new selected option*/ if(id != -1) { cord_t h = lv_obj_get_height(roller); - cord_t line_y1 = id * (font_h + style_label->line_space) + ext->ddlist.opt_label->cords.y1 - roller_scrl->cords.y1; + cord_t line_y1 = id * (font_h + style_label->txt.space_line) + ext->ddlist.opt_label->cords.y1 - roller_scrl->cords.y1; cord_t new_y = - line_y1 + (h - font_h) / 2; if(ext->ddlist.anim_time == 0) { diff --git a/lv_objx/lv_slider.c b/lv_objx/lv_slider.c index a425d2963..d4e6a4615 100644 --- a/lv_objx/lv_slider.c +++ b/lv_objx/lv_slider.c @@ -155,7 +155,7 @@ bool lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param) if(slider->ext_size < x) slider->ext_size = x; } else { lv_style_t * style = lv_obj_get_style(slider); - cord_t pad = MATH_MIN(style->hpad, style->vpad); + cord_t pad = MATH_MIN(style->body.pad_hor, style->body.pad_ver); if(pad < 0) { pad = -pad; if(slider->ext_size < pad) slider->ext_size = pad; @@ -290,19 +290,19 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m area_t area_bar; area_cpy(&area_bar, &slider->cords); /*Be sure at least vpad/hpad width bar will remain*/ - cord_t vpad_bar = style_slider->vpad; - cord_t hpad_bar = style_slider->hpad; - if(vpad_bar * 2 + LV_SLIDER_SIZE_MIN > area_get_height(&area_bar)) { - vpad_bar = (area_get_height(&area_bar) - LV_SLIDER_SIZE_MIN) >> 1; + cord_t pad_ver_bar = style_slider->body.pad_ver; + cord_t pad_hor_bar = style_slider->body.pad_hor; + if(pad_ver_bar * 2 + LV_SLIDER_SIZE_MIN > area_get_height(&area_bar)) { + pad_ver_bar = (area_get_height(&area_bar) - LV_SLIDER_SIZE_MIN) >> 1; } - if(hpad_bar * 2 + LV_SLIDER_SIZE_MIN > area_get_width(&area_bar)) { - hpad_bar = (area_get_width(&area_bar) - LV_SLIDER_SIZE_MIN) >> 1; + if(pad_hor_bar * 2 + LV_SLIDER_SIZE_MIN > area_get_width(&area_bar)) { + pad_hor_bar = (area_get_width(&area_bar) - LV_SLIDER_SIZE_MIN) >> 1; } - area_bar.x1 += hpad_bar; - area_bar.x2 -= hpad_bar; - area_bar.y1 += vpad_bar; - area_bar.y2 -= vpad_bar; + area_bar.x1 += pad_hor_bar; + area_bar.x2 -= pad_hor_bar; + area_bar.y1 += pad_ver_bar; + area_bar.y2 -= pad_ver_bar; lv_draw_rect(&area_bar, mask, style_slider); /*Draw the indicator*/ @@ -310,19 +310,19 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m area_cpy(&area_indic, &area_bar); /*Be sure at least vpad/hpad width indicator will remain*/ - cord_t vpad_indic = style_indic->vpad; - cord_t hpad_indic = style_indic->hpad; - if(vpad_indic * 2 + LV_SLIDER_SIZE_MIN > area_get_height(&area_bar)) { - vpad_indic = (area_get_height(&area_bar) - LV_SLIDER_SIZE_MIN) >> 1; + cord_t pad_ver_indic = style_indic->body.pad_ver; + cord_t pad_hor_indic = style_indic->body.pad_hor; + if(pad_ver_indic * 2 + LV_SLIDER_SIZE_MIN > area_get_height(&area_bar)) { + pad_ver_indic = (area_get_height(&area_bar) - LV_SLIDER_SIZE_MIN) >> 1; } - if(hpad_indic * 2 + LV_SLIDER_SIZE_MIN > area_get_width(&area_bar)) { - hpad_indic = (area_get_width(&area_bar) - LV_SLIDER_SIZE_MIN) >> 1; + if(pad_hor_indic * 2 + LV_SLIDER_SIZE_MIN > area_get_width(&area_bar)) { + pad_hor_indic = (area_get_width(&area_bar) - LV_SLIDER_SIZE_MIN) >> 1; } - area_indic.x1 += hpad_indic; - area_indic.x2 -= hpad_indic; - area_indic.y1 += vpad_indic; - area_indic.y2 -= vpad_indic; + area_indic.x1 += pad_hor_indic; + area_indic.x2 -= pad_hor_indic; + area_indic.y1 += pad_ver_indic; + area_indic.y2 -= pad_ver_indic; cord_t slider_w = area_get_width(&slider->cords); cord_t slider_h = area_get_height(&slider->cords); diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 60ee1f601..e66df4e9f 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -176,11 +176,11 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) lv_style_t * style_scrl = lv_obj_get_style(scrl); if(ext->one_line) { /*In one line mode refresh the Text Area height because 'vpad' can modify it*/ lv_style_t * style_label = lv_obj_get_style(ext->label); - cord_t font_h = font_get_height(style_label->font) >> FONT_ANTIALIAS; - lv_obj_set_height(ta, font_h + (style_ta->vpad + style_scrl->vpad) * 2); + cord_t font_h = font_get_height(style_label->txt.font) >> FONT_ANTIALIAS; + lv_obj_set_height(ta, font_h + (style_ta->body.pad_ver + style_scrl->body.pad_ver) * 2); } else { /*In not one line mode refresh the Label width because 'hpad' can modify it*/ - lv_obj_set_width(ext->label, lv_obj_get_width(scrl) - 2 * style_scrl->hpad); - lv_obj_set_pos(ext->label, style_scrl->hpad, style_scrl->vpad); /*Be sure the Label is in the correct position*/ + lv_obj_set_width(ext->label, lv_obj_get_width(scrl) - 2 * style_scrl->body.pad_hor); + lv_obj_set_pos(ext->label, style_scrl->body.pad_hor, style_scrl->body.pad_ver); /*Be sure the Label is in the correct position*/ } lv_label_set_text(ext->label, NULL); @@ -193,8 +193,8 @@ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) lv_obj_get_height(ta) != area_get_height(param)) { lv_obj_t * scrl = lv_page_get_scrl(ta); lv_style_t * style_scrl = lv_obj_get_style(scrl); - lv_obj_set_width(ext->label, lv_obj_get_width(scrl) - 2 * style_scrl->hpad); - lv_obj_set_pos(ext->label, style_scrl->hpad, style_scrl->vpad); + lv_obj_set_width(ext->label, lv_obj_get_width(scrl) - 2 * style_scrl->body.pad_hor); + lv_obj_set_pos(ext->label, style_scrl->body.pad_hor, style_scrl->body.pad_ver); lv_label_set_text(ext->label, NULL); /*Refresh the label*/ } } @@ -238,7 +238,7 @@ bool lv_ta_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * param) lv_ta_ext_t * ext = lv_obj_get_ext(ta); lv_style_t * style_label = lv_obj_get_style(ext->label); - scrl->ext_size = MATH_MAX(scrl->ext_size, style_label->line_space + font_get_height(style_label->font)); + scrl->ext_size = MATH_MAX(scrl->ext_size, style_label->txt.space_line + font_get_height(style_label->txt.font)); } } return valid; @@ -367,7 +367,7 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt) /*Don't let 'width == 0' because cursor will not be visible*/ if(lv_obj_get_width(ext->label) == 0) { lv_style_t * style = lv_obj_get_style(ext->label); - lv_obj_set_width(ext->label, font_get_width(style->font, ' ')); + lv_obj_set_width(ext->label, font_get_width(style->txt.font, ' ')); } /*It is a valid x step so save it*/ @@ -419,7 +419,7 @@ void lv_ta_del(lv_obj_t * ta) /*Don't let 'width == 0' because cursor will not be visible*/ if(lv_obj_get_width(ext->label) == 0) { lv_style_t * style = lv_obj_get_style(ext->label); - lv_obj_set_width(ext->label, style->line_width); + lv_obj_set_width(ext->label, style->line.width); } if(ext->pwd_mode != 0) { @@ -465,7 +465,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos) lv_obj_t * label_par = lv_obj_get_parent(ext->label); point_t cur_pos; lv_style_t * style = lv_obj_get_style(ta); - const font_t * font_p = style->font; + const font_t * font_p = style->txt.font; area_t label_cords; area_t ta_cords; lv_label_get_letter_pos(ext->label, pos, &cur_pos); @@ -479,9 +479,9 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos) /*Check the bottom*/ cord_t font_h = font_get_height(font_p) >> FONT_ANTIALIAS; - if(label_cords.y1 + cur_pos.y + font_h + style_scrl->vpad > ta_cords.y2) { + if(label_cords.y1 + cur_pos.y + font_h + style_scrl->body.pad_ver > ta_cords.y2) { lv_obj_set_y(label_par, -(cur_pos.y - lv_obj_get_height(ta) + - font_h + 2 * style_scrl->vpad)); + font_h + 2 * style_scrl->body.pad_ver)); } /*Check the left (use the font_h as general unit)*/ if(lv_obj_get_x(label_par) + cur_pos.x < font_h) { @@ -489,9 +489,9 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos) } /*Check the right (use the font_h as general unit)*/ - if(label_cords.x1 + cur_pos.x + font_h + style_scrl->hpad > ta_cords.x2) { + if(label_cords.x1 + cur_pos.x + font_h + style_scrl->body.pad_hor > ta_cords.x2) { lv_obj_set_x(label_par, -(cur_pos.x - lv_obj_get_width(ta) + - font_h + 2 * style_scrl->hpad)); + font_h + 2 * style_scrl->body.pad_hor)); } /*Reset cursor blink animation*/ @@ -558,9 +558,9 @@ void lv_ta_cursor_down(lv_obj_t * ta) /*Increment the y with one line and keep the valid x*/ lv_style_t * label_style = lv_obj_get_style(ext->label); - const font_t * font_p = label_style->font; + const font_t * font_p = label_style->txt.font; cord_t font_h = font_get_height(font_p) >> FONT_ANTIALIAS; - pos.y += font_h + label_style->line_space + 1; + pos.y += font_h + label_style->txt.space_line + 1; pos.x = ext->cursor_valid_x; /*Do not go below he last line*/ @@ -585,9 +585,9 @@ void lv_ta_cursor_up(lv_obj_t * ta) /*Decrement the y with one line and keep the valid x*/ lv_style_t * label_style = lv_obj_get_style(ext->label); - const font_t * font = label_style->font; + const font_t * font = label_style->txt.font; cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS; - pos.y -= font_h + label_style->line_space - 1; + pos.y -= font_h + label_style->txt.space_line - 1; pos.x = ext->cursor_valid_x; /*Get the letter index on the new cursor position and set it*/ @@ -679,14 +679,14 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en) lv_style_t * style_ta = lv_obj_get_style(ta); lv_style_t * style_scrl = lv_obj_get_style(lv_page_get_scrl(ta)); lv_style_t * style_label = lv_obj_get_style(ext->label); - cord_t font_h = font_get_height(style_label->font) >> FONT_ANTIALIAS; + cord_t font_h = font_get_height(style_label->txt.font) >> FONT_ANTIALIAS; ext->one_line = 1; lv_cont_set_fit(lv_page_get_scrl(ta), true, true); - lv_obj_set_height(ta, font_h + (style_ta->vpad + style_scrl->vpad) * 2); + lv_obj_set_height(ta, font_h + (style_ta->body.pad_ver + style_scrl->body.pad_ver) * 2); lv_label_set_long_mode(ext->label, LV_LABEL_LONG_EXPAND); lv_label_set_no_break(ext->label, true); - lv_obj_set_pos(lv_page_get_scrl(ta), style_ta->hpad, style_ta->vpad); + lv_obj_set_pos(lv_page_get_scrl(ta), style_ta->body.pad_hor, style_ta->body.pad_ver); } else { lv_ta_ext_t * ext = lv_obj_get_ext(ta); lv_style_t * style_ta = lv_obj_get_style(ta); @@ -696,7 +696,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en) lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK); lv_label_set_no_break(ext->label, false); lv_obj_set_height(ta, LV_TA_DEF_HEIGHT); - lv_obj_set_pos(lv_page_get_scrl(ta), style_ta->hpad, style_ta->vpad); + lv_obj_set_pos(lv_page_get_scrl(ta), style_ta->body.pad_hor, style_ta->body.pad_ver); } } @@ -859,20 +859,20 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design else { /*If cursor style is not specified then use the modified label style */ lv_style_cpy(&cur_style, label_style); - color_t ccolor_tmp = cur_style.ccolor; /*Make letter color to cursor color*/ - cur_style.ccolor = cur_style.mcolor; /*In block mode the letter color will be current background color*/ - cur_style.mcolor = ccolor_tmp; - cur_style.gcolor = ccolor_tmp; - cur_style.bcolor = ccolor_tmp; - cur_style.bopa = OPA_COVER; - cur_style.bwidth = 1 * LV_DOWNSCALE; - cur_style.line_width = 1 * LV_DOWNSCALE; - cur_style.swidth = 0; - cur_style.radius = 0; - cur_style.empty = 0; - cur_style.opa = OPA_COVER; - cur_style.hpad = 0; - cur_style.vpad = 0; + color_t ccolor_tmp = cur_style.txt.color; /*Make letter color to cursor color*/ + cur_style.txt.color = cur_style.body.color_main; /*In block mode the letter color will be current background color*/ + cur_style.body.color_main = ccolor_tmp; + cur_style.body.color_grad = ccolor_tmp; + cur_style.border.color = ccolor_tmp; + cur_style.border.opa = OPA_COVER; + cur_style.border.width = 1 * LV_DOWNSCALE; + cur_style.line.width = 1 * LV_DOWNSCALE; + cur_style.shadow.width = 0; + cur_style.body.radius = 0; + cur_style.body.empty = 0; + cur_style.body.opa = OPA_COVER; + cur_style.body.pad_hor = 0; + cur_style.body.pad_ver = 0; } uint16_t cur_pos = lv_ta_get_cursor_pos(ta); @@ -885,13 +885,13 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design #endif uint32_t letter = txt_utf8_next(&txt[byte_pos], NULL); - cord_t letter_h = font_get_height(label_style->font) >> FONT_ANTIALIAS; + cord_t letter_h = font_get_height(label_style->txt.font) >> FONT_ANTIALIAS; /*Set letter_w (set not 0 on non printable but valid chars)*/ cord_t letter_w; if(letter == '\0' || letter == '\n' || letter == '\r') { - letter_w = font_get_width(label_style->font, ' '); + letter_w = font_get_width(label_style->txt.font, ' '); } else { - letter_w = font_get_width(label_style->font, letter); + letter_w = font_get_width(label_style->txt.font, letter); } point_t letter_pos; @@ -900,7 +900,7 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design /*If the cursor is out of the text (most right) draw it to the next line*/ if(letter_pos.x + ta_ext->label->cords.x1 + letter_w > ta_ext->label->cords.x2 && ta_ext->one_line == 0) { letter_pos.x = 0; - letter_pos.y += letter_h + label_style->line_space; + letter_pos.y += letter_h + label_style->txt.space_line; if(letter != '\0'){ byte_pos += txt_utf8_size(txt[byte_pos]); @@ -908,25 +908,25 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design } if(letter == '\0' || letter == '\n' || letter == '\r') { - letter_w = font_get_width(label_style->font, ' '); + letter_w = font_get_width(label_style->txt.font, ' '); } else { - letter_w = font_get_width(label_style->font, letter); + letter_w = font_get_width(label_style->txt.font, letter); } } /*Draw he cursor according to the type*/ area_t cur_area; if(ta_ext->cursor_type == LV_TA_CURSOR_LINE) { - cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.hpad - (cur_style.line_width >> 1) - (cur_style.line_width & 0x1); - cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.vpad; - cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.hpad + (cur_style.line_width >> 1); - cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.vpad + letter_h; + cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.pad_hor - (cur_style.line.width >> 1) - (cur_style.line.width & 0x1); + cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.body.pad_ver; + cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.pad_hor + (cur_style.line.width >> 1); + cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.body.pad_ver + letter_h; lv_draw_rect(&cur_area, mask, &cur_style); } else if(ta_ext->cursor_type == LV_TA_CURSOR_BLOCK) { - cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 - cur_style.hpad; - cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 - cur_style.vpad; - cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.hpad + letter_w; - cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.vpad + letter_h; + cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 - cur_style.body.pad_hor; + cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 - cur_style.body.pad_ver; + cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.pad_hor + letter_w; + cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.body.pad_ver + letter_h; lv_draw_rect(&cur_area, mask, &cur_style); @@ -939,24 +939,24 @@ static bool lv_ta_scrling_design(lv_obj_t * scrl, const area_t * mask, lv_design char letter_buf[8] = {0}; memcpy(letter_buf, &txt[byte_pos], txt_utf8_size(txt[byte_pos])); #endif - cur_area.x1 += cur_style.hpad; - cur_area.y1 += cur_style.vpad; + cur_area.x1 += cur_style.body.pad_hor; + cur_area.y1 += cur_style.body.pad_ver; lv_draw_label(&cur_area, mask, &cur_style, letter_buf, TXT_FLAG_NONE, 0); } else if(ta_ext->cursor_type == LV_TA_CURSOR_OUTLINE) { - cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 - cur_style.hpad; - cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 - cur_style.vpad; - cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.hpad + letter_w; - cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 - cur_style.vpad+ letter_h; + cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 - cur_style.body.pad_hor; + cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 - cur_style.body.pad_ver; + cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.pad_hor + letter_w; + cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 - cur_style.body.pad_ver+ letter_h; - cur_style.empty = 1; - if(cur_style.bwidth == 0) cur_style.bwidth = 1 * LV_DOWNSCALE; /*Be sure the border will be drawn*/ + cur_style.body.empty = 1; + if(cur_style.border.width == 0) cur_style.border.width = 1 * LV_DOWNSCALE; /*Be sure the border will be drawn*/ lv_draw_rect(&cur_area, mask, &cur_style); } else if(ta_ext->cursor_type == LV_TA_CURSOR_UNDERLINE) { - cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.hpad; - cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.vpad + letter_h - (cur_style.line_width >> 1); - cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.hpad + letter_w; - cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.vpad + letter_h + (cur_style.line_width >> 1) + (cur_style.line_width & 0x1); + cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.pad_hor; + cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.body.pad_ver + letter_h - (cur_style.line.width >> 1); + cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + cur_style.body.pad_hor + letter_w; + cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + cur_style.body.pad_ver + letter_h + (cur_style.line.width >> 1) + (cur_style.line.width & 0x1); lv_draw_rect(&cur_area, mask, &cur_style); } diff --git a/lv_objx/lv_tabview.c b/lv_objx/lv_tabview.c index 543c331ca..1d002ed10 100644 --- a/lv_objx/lv_tabview.c +++ b/lv_objx/lv_tabview.c @@ -97,7 +97,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy) ext->indic = lv_obj_create(ext->tabs, NULL); lv_style_t * style_indic = lv_obj_get_style(ext->indic); - lv_obj_set_size(ext->indic, LV_DPI, style_indic->line_width); + lv_obj_set_size(ext->indic, LV_DPI, style_indic->line.width); lv_obj_align(ext->indic, ext->tabs, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); lv_obj_set_click(ext->indic, false); @@ -201,9 +201,9 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name) /*Modify the indicator size*/ lv_style_t * style_tabs = lv_obj_get_style(ext->tabs); - cord_t indic_width = (lv_obj_get_width(tabview) - style_tabs->opad * (ext->tab_cnt - 1) - 2 * style_tabs->hpad) / ext->tab_cnt; + cord_t indic_width = (lv_obj_get_width(tabview) - style_tabs->body.pad_obj * (ext->tab_cnt - 1) - 2 * style_tabs->body.pad_hor) / ext->tab_cnt; lv_obj_set_width(ext->indic, indic_width); - lv_obj_set_x(ext->indic, indic_width * ext->tab_act + style_tabs->opad * ext->tab_act + style_tabs->hpad); + lv_obj_set_x(ext->indic, indic_width * ext->tab_act + style_tabs->body.pad_obj * ext->tab_act + style_tabs->body.pad_hor); /*Set the first tab as active*/ if(ext->tab_cnt == 1) { @@ -235,7 +235,7 @@ void lv_tabview_set_act(lv_obj_t * tabview, uint16_t id, bool anim_en) anim_en = false; #endif - cord_t cont_x = -(lv_obj_get_width(tabview) * id + style->opad * id + style->hpad); + cord_t cont_x = -(lv_obj_get_width(tabview) * id + style->body.pad_obj * id + style->body.pad_hor); if(anim_en == false) { lv_obj_set_x(ext->content, cont_x); } else { @@ -258,7 +258,7 @@ void lv_tabview_set_act(lv_obj_t * tabview, uint16_t id, bool anim_en) /*Move the indicator*/ cord_t indic_width = lv_obj_get_width(ext->indic); lv_style_t * tabs_style = lv_obj_get_style(ext->tabs); - cord_t indic_x = indic_width * id + tabs_style->opad * id + tabs_style->hpad; + cord_t indic_x = indic_width * id + tabs_style->body.pad_obj * id + tabs_style->body.pad_hor; if(anim_en == false) { lv_obj_set_x(ext->indic, indic_x); @@ -375,8 +375,8 @@ void lv_tabview_realign(lv_obj_t * tabview) if(ext->tab_cnt != 0) { lv_style_t * style_tabs = lv_obj_get_style(ext->tabs); - cord_t indic_width = (lv_obj_get_width(tabview) - style_tabs->opad * (ext->tab_cnt - 1) - - 2 * style_tabs->hpad) / ext->tab_cnt; + cord_t indic_width = (lv_obj_get_width(tabview) - style_tabs->body.pad_obj * (ext->tab_cnt - 1) - + 2 * style_tabs->body.pad_hor) / ext->tab_cnt; lv_obj_set_width(ext->indic, indic_width); } @@ -532,9 +532,9 @@ static void tabpage_pressing_hadler(lv_obj_t * tabview, lv_obj_t * tabpage) cord_t indic_width = lv_obj_get_width(ext->indic); lv_style_t * tabs_style = lv_obj_get_style(ext->tabs); lv_style_t * indic_style = lv_obj_get_style(ext->indic); - cord_t p = ((tabpage->cords.x1 - tabview->cords.x1) * (indic_width + tabs_style->opad)) / lv_obj_get_width(tabview); + cord_t p = ((tabpage->cords.x1 - tabview->cords.x1) * (indic_width + tabs_style->body.pad_obj)) / lv_obj_get_width(tabview); - lv_obj_set_x(ext->indic, indic_width * ext->tab_act + tabs_style->opad * ext->tab_act + indic_style->hpad - p); + lv_obj_set_x(ext->indic, indic_width * ext->tab_act + tabs_style->body.pad_obj * ext->tab_act + indic_style->body.pad_hor - p); } } diff --git a/lv_objx/lv_win.c b/lv_objx/lv_win.c index 8ce1a697a..6a742f707 100644 --- a/lv_objx/lv_win.c +++ b/lv_objx/lv_win.c @@ -341,7 +341,7 @@ cord_t lv_win_get_width(lv_obj_t * win) lv_obj_t * scrl = lv_page_get_scrl(ext->page); lv_style_t * style_scrl = lv_obj_get_style(scrl); - return lv_obj_get_width(scrl) - 2 * style_scrl->hpad; + return lv_obj_get_width(scrl) - 2 * style_scrl->body.pad_hor; } /** @@ -412,16 +412,16 @@ static void lv_win_realign(lv_obj_t * win) } lv_style_t * btnh_style = lv_obj_get_style(ext->btnh); - lv_obj_set_height(ext->btnh, ext->cbtn_size + 2 * btnh_style->vpad * 2); + lv_obj_set_height(ext->btnh, ext->cbtn_size + 2 * btnh_style->body.pad_ver * 2); lv_obj_set_width(ext->header, lv_obj_get_width(win)); /*Align the higher object first to make the correct header size first*/ if(lv_obj_get_height(ext->title) > lv_obj_get_height(ext->btnh)) { - lv_obj_align(ext->title, NULL, LV_ALIGN_IN_LEFT_MID, ext->style_header->hpad, 0); - lv_obj_align(ext->btnh, NULL, LV_ALIGN_IN_RIGHT_MID, - ext->style_header->hpad, 0); + lv_obj_align(ext->title, NULL, LV_ALIGN_IN_LEFT_MID, ext->style_header->body.pad_hor, 0); + lv_obj_align(ext->btnh, NULL, LV_ALIGN_IN_RIGHT_MID, - ext->style_header->body.pad_hor, 0); } else { - lv_obj_align(ext->btnh, NULL, LV_ALIGN_IN_RIGHT_MID, - ext->style_header->hpad, 0); - lv_obj_align(ext->title, NULL, LV_ALIGN_IN_LEFT_MID, ext->style_header->hpad, 0); + lv_obj_align(ext->btnh, NULL, LV_ALIGN_IN_RIGHT_MID, - ext->style_header->body.pad_hor, 0); + lv_obj_align(ext->title, NULL, LV_ALIGN_IN_LEFT_MID, ext->style_header->body.pad_hor, 0); } lv_obj_set_pos_us(ext->header, 0, 0); @@ -433,7 +433,7 @@ static void lv_win_realign(lv_obj_t * win) lv_style_t * style_page = lv_obj_get_style(page); lv_obj_t * scrl = lv_page_get_scrl(page); - lv_obj_set_width(scrl, lv_obj_get_width(page) - 2 * style_page->hpad); + lv_obj_set_width(scrl, lv_obj_get_width(page) - 2 * style_page->body.pad_hor); } #endif