mirror of
https://github.com/lvgl/lvgl.git
synced 2025-02-04 07:13:00 +08:00
fix(span): fix align text to center and right layout issues. (#7615)
Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
This commit is contained in:
parent
2cdcf8d729
commit
7ab421ed30
@ -1041,6 +1041,12 @@ static void lv_draw_span(lv_obj_t * obj, lv_layer_t * layer)
|
|||||||
uint32_t i;
|
uint32_t i;
|
||||||
for(i = 0; i < item_cnt; i++) {
|
for(i = 0; i < item_cnt; i++) {
|
||||||
lv_snippet_t * pinfo = lv_get_snippet(i);
|
lv_snippet_t * pinfo = lv_get_snippet(i);
|
||||||
|
if(ellipsis_valid && i == item_cnt - 1) {
|
||||||
|
uint32_t n_ofs = 0;
|
||||||
|
lv_text_get_snippet(pinfo->txt, pinfo->font, pinfo->letter_space, max_width - txts_w,
|
||||||
|
LV_TEXT_FLAG_BREAK_ALL, &pinfo->txt_w, &n_ofs);
|
||||||
|
pinfo->bytes = n_ofs;
|
||||||
|
}
|
||||||
txts_w = txts_w + pinfo->txt_w;
|
txts_w = txts_w + pinfo->txt_w;
|
||||||
}
|
}
|
||||||
txts_w -= lv_get_snippet(item_cnt - 1)->letter_space;
|
txts_w -= lv_get_snippet(item_cnt - 1)->letter_space;
|
||||||
|
BIN
tests/ref_imgs/widgets/span_10.png
Normal file
BIN
tests/ref_imgs/widgets/span_10.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
tests/ref_imgs_vg_lite/widgets/span_10.png
Normal file
BIN
tests/ref_imgs_vg_lite/widgets/span_10.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
@ -479,4 +479,23 @@ void test_spangroup_get_span_coords(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void test_spangroup_set_right_align_on_overflow(void)
|
||||||
|
{
|
||||||
|
active_screen = lv_screen_active();
|
||||||
|
spangroup = lv_spangroup_create(active_screen);
|
||||||
|
|
||||||
|
lv_obj_set_style_outline_width(spangroup, 1, 0);
|
||||||
|
|
||||||
|
lv_obj_set_width(spangroup, 180);
|
||||||
|
lv_obj_set_height(spangroup, 20);
|
||||||
|
|
||||||
|
lv_spangroup_set_align(spangroup, LV_TEXT_ALIGN_RIGHT);
|
||||||
|
|
||||||
|
lv_span_t * span = lv_spangroup_new_span(spangroup);
|
||||||
|
lv_span_set_text_static(span, "China is a beautiful country.");
|
||||||
|
lv_spangroup_set_overflow(spangroup, LV_SPAN_OVERFLOW_ELLIPSIS);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/span_10.png");
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user