增加label控制
authorCaisking <3449750381@qq.com>
Tue, 8 Oct 2024 10:42:33 +0000 (18:42 +0800)
committerCaisking <3449750381@qq.com>
Tue, 8 Oct 2024 10:42:33 +0000 (18:42 +0800)
code/sdk/middleware/services/gui/uikit/ui/frameworks/components/ui_label.cpp

index 3cee7ed..06492f4 100755 (executable)
@@ -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<UILabel*>(view);
         if (label != nullptr) {