From 586b96250bdd770fe441dd9dac9d19cd03a71cd8 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Tue, 8 Oct 2024 18:42:33 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0label=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../ui/frameworks/components/ui_label.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp index 3cee7ede7..06492f4a4 100755 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp @@ -136,7 +136,7 @@ private: uint32_t time = HALTick::GetInstance().GetElapseTime(startTime_); float x0 = startPos_; float x1 = 1.0 * labelWidth_ - textWidth_; - +#if 0 float factor = 1000; // 1000: slow down the speed float v = speed_ / factor; v = x1 - x0 > 0 ? v : -v; @@ -150,7 +150,24 @@ private: } else { x = -v * (t - t1) + x1; } - +#else + float factor = 200000; // slow down the speed + float t = time * speed_ / factor; + float t1 = 1.0; + float period = 2.0; + while (t < 0) { + t += period; + } + while (t > period) { + t -= period; + } + float x = 0; + if (t >=0 && t < t1) { + x = (x1 - x0) * t / t1 + x0; + } else { + x = (x0 - x1) * (t - t1) / t1 + x1; + } +#endif UILabel *label = dynamic_cast(view); if (label != nullptr) { -- 2.17.1