From e51962e36118420f7849d2b901f3c388eeead4fb Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 1 Mar 2020 02:00:03 +0100 Subject: [PATCH] table: optimize style queries --- src/lv_themes/lv_theme_material.c | 2 +- src/lv_widgets/lv_table.c | 5 +++++ src/lv_widgets/lv_table.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 086093a67..a20b95f40 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -367,7 +367,7 @@ static void linemeter_init(void) lv_style_init(&lmeter); lv_style_copy(&lmeter, &panel); lv_style_set_radius(&lmeter, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_border_side(&lmeter, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL); + lv_style_set_border_side(&lmeter, LV_STATE_DEFAULT, LV_BORDER_SIDE_LEFT | LV_BORDER_SIDE_TOP); lv_style_set_bg_opa(&lmeter, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_pad_left(&lmeter, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_right(&lmeter, LV_STATE_DEFAULT, LV_DPI / 10); diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index 133595b6b..ca45402a2 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -79,6 +79,7 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy) ext->cell_data = NULL; ext->col_cnt = 0; ext->row_cnt = 0; + ext->cell_types = 1; uint16_t i; for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; i++) { @@ -314,6 +315,8 @@ void lv_table_set_cell_type(lv_obj_t * table, uint16_t row, uint16_t col, uint8_ format.format_byte = ext->cell_data[cell][0]; format.s.type = type; ext->cell_data[cell][0] = format.format_byte; + + ext->cell_types |= 1 << type; } /** @@ -608,6 +611,7 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_ uint16_t i; for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; i++) { + if((ext->cell_types & (1 << i)) == 0) continue; /*Skip unused cell types*/ lv_draw_rect_dsc_init(&rect_dsc[i]); lv_obj_init_draw_rect_dsc(table, LV_TABLE_PART_CELL1 + i, &rect_dsc[i]); @@ -872,6 +876,7 @@ static void refr_size(lv_obj_t * table) const lv_font_t * font[LV_TABLE_CELL_STYLE_CNT]; for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; i++) { + if((ext->cell_types & (1 << i)) == 0) continue; /*Skip unused cell types*/ cell_left[i] = lv_obj_get_style_pad_left(table, LV_TABLE_PART_CELL1 + i); cell_right[i] = lv_obj_get_style_pad_right(table, LV_TABLE_PART_CELL1 + i); cell_top[i] = lv_obj_get_style_pad_top(table, LV_TABLE_PART_CELL1 + i); diff --git a/src/lv_widgets/lv_table.h b/src/lv_widgets/lv_table.h index 08071531f..b91ef2599 100644 --- a/src/lv_widgets/lv_table.h +++ b/src/lv_widgets/lv_table.h @@ -60,6 +60,7 @@ typedef struct { char ** cell_data; lv_style_list_t cell_style[LV_TABLE_CELL_STYLE_CNT]; lv_coord_t col_w[LV_TABLE_COL_MAX]; + uint8_t cell_types :4; /*Keep track which cell types exists to avoid dealing with unused ones*/ } lv_table_ext_t; /*Parts of the table*/