table: optimize style queries

This commit is contained in:
Gabor Kiss-Vamosi
2020-03-01 02:00:03 +01:00
parent ac75bfaa54
commit e51962e361
3 changed files with 7 additions and 1 deletions

View File

@@ -367,7 +367,7 @@ static void linemeter_init(void)
lv_style_init(&lmeter); lv_style_init(&lmeter);
lv_style_copy(&lmeter, &panel); lv_style_copy(&lmeter, &panel);
lv_style_set_radius(&lmeter, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); 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_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_left(&lmeter, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_right(&lmeter, LV_STATE_DEFAULT, LV_DPI / 10); lv_style_set_pad_right(&lmeter, LV_STATE_DEFAULT, LV_DPI / 10);

View File

@@ -79,6 +79,7 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
ext->cell_data = NULL; ext->cell_data = NULL;
ext->col_cnt = 0; ext->col_cnt = 0;
ext->row_cnt = 0; ext->row_cnt = 0;
ext->cell_types = 1;
uint16_t i; uint16_t i;
for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; 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.format_byte = ext->cell_data[cell][0];
format.s.type = type; format.s.type = type;
ext->cell_data[cell][0] = format.format_byte; 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; uint16_t i;
for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; 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_draw_rect_dsc_init(&rect_dsc[i]);
lv_obj_init_draw_rect_dsc(table, LV_TABLE_PART_CELL1 + i, &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]; const lv_font_t * font[LV_TABLE_CELL_STYLE_CNT];
for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; i++) { 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_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_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); cell_top[i] = lv_obj_get_style_pad_top(table, LV_TABLE_PART_CELL1 + i);

View File

@@ -60,6 +60,7 @@ typedef struct {
char ** cell_data; char ** cell_data;
lv_style_list_t cell_style[LV_TABLE_CELL_STYLE_CNT]; lv_style_list_t cell_style[LV_TABLE_CELL_STYLE_CNT];
lv_coord_t col_w[LV_TABLE_COL_MAX]; 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; } lv_table_ext_t;
/*Parts of the table*/ /*Parts of the table*/