From fb8faed09704f1e4975fa4dae22fd2d131b4ea79 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 11 Mar 2021 12:20:09 +0100 Subject: [PATCH] fix(grid): support fr on LV_SIZE_CONTENT parents too --- src/extra/layouts/grid/lv_grid.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/extra/layouts/grid/lv_grid.c b/src/extra/layouts/grid/lv_grid.c index 731cf721f..e6dd3057a 100644 --- a/src/extra/layouts/grid/lv_grid.c +++ b/src/extra/layouts/grid/lv_grid.c @@ -248,14 +248,16 @@ static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c) uint32_t col_fr_cnt = 0; lv_coord_t grid_w = 0; - bool auto_w = cont->w_set == LV_SIZE_CONTENT ? true : false; for(i = 0; i < c->col_num; i++) { lv_coord_t x = grid->col_dsc[i]; - if(IS_FR(x)) col_fr_cnt += GET_FR(x); + if(IS_FR(x)) { + col_fr_cnt += GET_FR(x); + } else if (IS_CONTENT(x)) { grid_w += c->w[i]; - } else { + } + else { c->w[i] = x; grid_w += x; } @@ -268,11 +270,8 @@ static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c) for(i = 0; i < c->col_num; i++) { lv_coord_t x = grid->col_dsc[i]; if(IS_FR(x)) { - if(auto_w) c->w[i] = 0; /*Fr is considered zero if the cont has auto width*/ - else { - lv_coord_t f = GET_FR(x); - c->w[i] = (free_w * f) / col_fr_cnt; - } + lv_coord_t f = GET_FR(x); + c->w[i] = (free_w * f) / col_fr_cnt; } } } @@ -310,12 +309,11 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c) uint32_t row_fr_cnt = 0; lv_coord_t grid_h = 0; - bool auto_h = cont->h_set == LV_SIZE_CONTENT ? true : false; - for(i = 0; i < c->row_num; i++) { lv_coord_t x = grid->row_dsc[i]; - if(IS_FR(x)) row_fr_cnt += GET_FR(x); - else if (IS_CONTENT(x)) { + if(IS_FR(x)) { + row_fr_cnt += GET_FR(x); + } else if (IS_CONTENT(x)) { grid_h += c->h[i]; } else { c->h[i] = x; @@ -330,11 +328,8 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c) for(i = 0; i < grid->row_dsc_len; i++) { lv_coord_t x = grid->row_dsc[i]; if(IS_FR(x)) { - if(auto_h) c->h[i] = 0; /*Fr is considered zero if the obj has auto height*/ - else { - lv_coord_t f = GET_FR(x); - c->h[i] = (free_h * f) / row_fr_cnt; - } + lv_coord_t f = GET_FR(x); + c->h[i] = (free_h * f) / row_fr_cnt; } } }