diff --git a/CHANGELOG.md b/CHANGELOG.md index cfc5c48a1..58dee444e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Bugfixes - Theme update to support text selection background - Fix imgbtn state change +- Support RTL in table (draw columns right to left) ## v7.6.1 (06.10.2020) diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 372f8a0e8..1e96d3a8e 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -823,7 +823,7 @@ static void table_init(void) style_init_reset(&styles->table_cell); lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER); lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1); - lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM); +// lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM); lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF); diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index f2f4adeb3..ee23f7d52 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -848,6 +848,8 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_ uint16_t row; uint16_t cell = 0; + bool rtl = lv_obj_get_base_dir(table) == LV_BIDI_DIR_RTL ? true : false; + cell_area.y2 = table->coords.y1 + bg_top - 1; for(row = 0; row < ext->row_cnt; row++) { lv_coord_t h_row = ext->row_h[row]; @@ -857,7 +859,8 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_ if(cell_area.y1 > clip_area->y2) return LV_DESIGN_RES_OK; - cell_area.x2 = table->coords.x1 + bg_left - 1; + if(rtl) cell_area.x1 = table->coords.x2 - bg_right - 1; + else cell_area.x2 = table->coords.x1 + bg_left - 1; for(col = 0; col < ext->col_cnt; col++) { @@ -872,15 +875,21 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_ format.s.crop = 1; } - cell_area.x1 = cell_area.x2 + 1; - cell_area.x2 = cell_area.x1 + ext->col_w[col] - 1; + if(rtl) { + cell_area.x2 = cell_area.x1 - 1; + cell_area.x1 = cell_area.x2 - ext->col_w[col] + 1; + } else { + cell_area.x1 = cell_area.x2 + 1; + cell_area.x2 = cell_area.x1 + ext->col_w[col] - 1; + } uint16_t col_merge = 0; for(col_merge = 0; col_merge + col < ext->col_cnt - 1; col_merge++) { if(ext->cell_data[cell + col_merge] != NULL) { format.format_byte = ext->cell_data[cell + col_merge][0]; if(format.s.right_merge) - cell_area.x2 += ext->col_w[col + col_merge + 1]; + if(rtl) cell_area.x1 -= ext->col_w[col + col_merge + 1]; + else cell_area.x2 += ext->col_w[col + col_merge + 1]; else break; }