fix(label): fix long mode clip #7922 (#7957)

Thank you! The faling CI is unrelated.
This commit is contained in:
Paul Vogel
2025-03-28 12:55:05 -05:00
committed by GitHub
parent f55c8d4dbe
commit 76d42e3f57
2 changed files with 31 additions and 1 deletions
+3 -1
View File
@@ -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);
+28
View File
@@ -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