diff --git a/docs/changes.md b/docs/changes.md index e2977e317..ac0f7a8cf 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,7 +1,8 @@ # 最新动态 2021/04/06 - * add idle\_queue\_ex/timer\_queue\_ex for script binding. + * 增加 idle\_queue\_ex/timer\_queue\_ex 方便脚本绑定时使用。 + * 增加 hscroll\_label检测焦点状态下长度变化重新播放动画的机制(感谢智明提供补丁) 2021/04/04 * 增加 gui\_app\_start\_ex,方便嵌入式系统指定资源路径。 diff --git a/src/ext_widgets/scroll_label/hscroll_label.c b/src/ext_widgets/scroll_label/hscroll_label.c index af9818827..914752423 100644 --- a/src/ext_widgets/scroll_label/hscroll_label.c +++ b/src/ext_widgets/scroll_label/hscroll_label.c @@ -40,6 +40,12 @@ static ret_t hscroll_label_do_paint_self(widget_t* widget, canvas_t* c, uint32_t hscroll_label_t* hscroll_label = HSCROLL_LABEL(widget); hscroll_label->text_w = canvas_measure_text(c, text->str, text->size); + if (hscroll_label->text_w != hscroll_label->old_text_w) { + if (tk_str_eq(widget->state, WIDGET_STATE_FOCUSED)) { + hscroll_label_start(widget); + } + hscroll_label->old_text_w = hscroll_label->text_w; + } if (w < hscroll_label->text_w && hscroll_label->ellipses && !hscroll_label_is_running(widget)) { r = rect_init(left_margin, 0, w, widget->h); @@ -332,6 +338,10 @@ static ret_t hscroll_label_on_timer(const timer_info_t* info) { } } + if (ret != RET_REPEAT) { + hscroll_label->timer_id = TK_INVALID_ID; + } + return ret; } diff --git a/src/ext_widgets/scroll_label/hscroll_label.h b/src/ext_widgets/scroll_label/hscroll_label.h index 8e114c6c9..d55f62171 100644 --- a/src/ext_widgets/scroll_label/hscroll_label.h +++ b/src/ext_widgets/scroll_label/hscroll_label.h @@ -125,6 +125,7 @@ typedef struct _hscroll_label_t { int32_t text_w; /*private*/ + int32_t old_text_w; uint32_t timer_id; uint32_t elapsed; bool_t paused;