From a0cb2dddc5e2eac2c631a295bb6ca3eadfe7271c Mon Sep 17 00:00:00 2001 From: lixianjing Date: Thu, 15 Aug 2019 03:04:14 -0700 Subject: [PATCH] improve progressbar --- src/widgets/progress_bar.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/widgets/progress_bar.c b/src/widgets/progress_bar.c index 96f93d6d1..64defb4a8 100644 --- a/src/widgets/progress_bar.c +++ b/src/widgets/progress_bar.c @@ -65,11 +65,6 @@ static ret_t progress_bar_on_paint_self(widget_t* widget, canvas_t* c) { widget_fill_fg_rect(widget, c, &r, draw_type); if (progress_bar->show_text) { - char str[TK_NUM_MAX_LEN + 1]; - - tk_snprintf(str, TK_NUM_MAX_LEN, "%d%%", progress_bar->value); - widget_set_text_utf8(widget, str); - return widget_paint_helper(widget, c, NULL, NULL); } @@ -90,6 +85,13 @@ ret_t progress_bar_set_value(widget_t* widget, uint8_t value) { e = event_init(EVT_VALUE_CHANGED, widget); widget_dispatch(widget, &e); widget_invalidate(widget, NULL); + + if (progress_bar->show_text) { + char str[TK_NUM_MAX_LEN + 1]; + + tk_snprintf(str, TK_NUM_MAX_LEN, "%d%%", progress_bar->value); + widget_set_text_utf8(widget, str); + } } return RET_OK;