mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
table: apply bidi on cell values
This commit is contained in:
parent
6b5c89baf7
commit
bcdd680a2f
@ -145,13 +145,14 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const
|
||||
uint32_t cell = row * ext->col_cnt + col;
|
||||
lv_table_cell_format_t format;
|
||||
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(table);
|
||||
|
||||
/*Save the format byte*/
|
||||
if(ext->cell_data[cell]) {
|
||||
format.format_byte = ext->cell_data[cell][0];
|
||||
}
|
||||
/*Initialize the format byte*/
|
||||
else {
|
||||
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(table);
|
||||
if(base_dir == LV_BIDI_DIR_LTR) format.s.align = LV_LABEL_ALIGN_LEFT;
|
||||
else if(base_dir == LV_BIDI_DIR_RTL) format.s.align = LV_LABEL_ALIGN_RIGHT;
|
||||
else if(base_dir == LV_BIDI_DIR_AUTO) format.s.align = lv_bidi_detect_base_dir(txt);
|
||||
@ -162,7 +163,13 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const
|
||||
}
|
||||
|
||||
ext->cell_data[cell] = lv_mem_realloc(ext->cell_data[cell], strlen(txt) + 2); /*+1: trailing '\0; +1: format byte*/
|
||||
strcpy(ext->cell_data[cell] + 1, txt); /*Leave the format byte*/
|
||||
|
||||
#if LV_USE_BIDI == 0
|
||||
strcpy(ext->cell_data[cell] + 1, txt); /*+1 to skip the format byte*/
|
||||
#else
|
||||
lv_bidi_process(txt, ext->cell_data[cell] + 1, base_dir);
|
||||
#endif
|
||||
|
||||
ext->cell_data[cell][0] = format.format_byte;
|
||||
refr_size(table);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user