diff --git a/src/widgets/label/lv_label.c b/src/widgets/label/lv_label.c index 1747cd2ab0..28164a2992 100644 --- a/src/widgets/label/lv_label.c +++ b/src/widgets/label/lv_label.c @@ -876,7 +876,9 @@ static void draw_main(lv_event_t * e) lv_area_move(&txt_coords, 0, -s); txt_coords.y2 = obj->coords.y2; } - if(label->long_mode == LV_LABEL_LONG_MODE_SCROLL || label->long_mode == LV_LABEL_LONG_MODE_SCROLL_CIRCULAR) { + if(label->long_mode == LV_LABEL_LONG_MODE_SCROLL || + label->long_mode == LV_LABEL_LONG_MODE_SCROLL_CIRCULAR || + label->long_mode == LV_LABEL_LONG_MODE_CLIP) { const lv_area_t clip_area_ori = layer->_clip_area; layer->_clip_area = txt_clip; lv_draw_label(layer, &label_draw_dsc, &txt_coords); diff --git a/tests/src/test_cases/widgets/test_label.c b/tests/src/test_cases/widgets/test_label.c index cfd663f4d1..6241c7e2c3 100644 --- a/tests/src/test_cases/widgets/test_label.c +++ b/tests/src/test_cases/widgets/test_label.c @@ -663,4 +663,32 @@ void test_label_scroll_mid_update(void) } } +/* + * For the LONG_MODE_CLIP mode, just re-use the screenshot from the initial + * screen of the long mode scroll + */ + +void test_label_long_mode_clip(void) +{ + lv_obj_clean(lv_screen_active()); + + const char * text1 = "This is a long text that we will update while scrolling"; + + lv_obj_t * label1 = lv_label_create(lv_screen_active()); + lv_label_set_long_mode(label1, LV_LABEL_LONG_MODE_CLIP); + lv_label_set_text(label1, text1); + lv_obj_set_width(label1, 150); + lv_obj_set_pos(label1, 10, 10); + + lv_obj_t * label2 = lv_label_create(lv_screen_active()); + lv_label_set_long_mode(label2, LV_LABEL_LONG_MODE_CLIP); + lv_label_set_text(label2, text1); + lv_obj_set_width(label2, 150); + lv_obj_set_pos(label2, 10, 80); + + char buf[128]; + lv_snprintf(buf, sizeof(buf), "widgets/label_scroll_0.png"); + TEST_ASSERT_EQUAL_SCREENSHOT(buf); +} + #endif