优化亮屏跑马灯效果
authorxue <2144439972@qq.com>
Sat, 13 Dec 2025 02:31:58 +0000 (10:31 +0800)
committerxue <2144439972@qq.com>
Sat, 13 Dec 2025 02:31:58 +0000 (10:31 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdDialogueView.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdGuideView.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp

index 097112c..a9ce8e1 100644 (file)
@@ -4,6 +4,7 @@
 #include "wearable_log.h"
 #include <custom_utils.h>
 #include "ln_api.h"
+#include "ai_media.h"
 
 namespace OHOS
 {
@@ -241,6 +242,10 @@ namespace OHOS
             {
                 TextLabel->SetPosition(37, 66, 325, 42);       
                 TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+                // 先清空文本,重置跑马灯偏移,避免从右侧滚动出来
+                TextLabel->SetVisible(false);
+                TextLabel->SetText("");
+                // 再设置真实文本,确保从左侧开始显示
                 TextLabel->SetText(currentStatusText.c_str());
                 TextLabel->SetVisible(true);
             }
@@ -254,8 +259,12 @@ namespace OHOS
     void ThunderBirdDialogueView::UpdateDialogueText(const char *text)
     {
         if(!TextLabel) return;    
-        // 设置文本
-        TextLabel->SetText(text); 
+        // 先清空文本,重置跑马灯偏移,避免从右侧滚动出来
+        TextLabel->SetVisible(false);
+        TextLabel->SetText("");
+        // 再设置真实文本,确保从左侧开始显示
+        TextLabel->SetText(text);
+        TextLabel->SetVisible(true);
     }
 
     void ThunderBirdDialogueView::AudioPlaybackEnd()
index e72de5f..1000a96 100644 (file)
@@ -27,18 +27,21 @@ namespace OHOS
     void ThunderBirdGuideView::OnWsConnected()
     {
         // Called when WS becomes connected: stop band animation and show QR code
-        if (bandAnimator) {
-            bandAnimator->Stop();
-            bandAnimator->SetVisible(false);
-        }
-        if (qrcode_) {
-            qrcode_->SetQrcodeInfo(ThunderBirdModel::GetInstance()->GetQrcodeContent().c_str());
-            qrcode_->SetPosition(119, 157, 111, 111);
-            qrcode_->SetVisible(true);
-        }
-        if (TextLabel) {
-            TextLabel->SetText("换角色,挑声音,哄睡...\nAmby小程序扫码尽享");
-        }
+        if(ThunderBirdMainView::GetInstance()->GetCurrentSubView() == THUNDERBIRD_GUIDEVIEW_5)
+        {        
+            if (bandAnimator) {
+                bandAnimator->Stop();
+                bandAnimator->SetVisible(false);
+            }
+            if (qrcode_) {
+                qrcode_->SetQrcodeInfo(ThunderBirdModel::GetInstance()->GetQrcodeContent().c_str());
+                qrcode_->SetPosition(119, 157, 111, 111);
+                qrcode_->SetVisible(true);
+            }
+            if (TextLabel) {
+                TextLabel->SetText("换角色,挑声音,哄睡...\nAmby小程序扫码尽享");
+            }
+       }
         FirstShow = false;
     }
 
index aa975e0..d9e6cc8 100644 (file)
@@ -110,6 +110,24 @@ namespace OHOS
             {
                 g_videoPlay->ResumeVideoPlay();
             }
+            // 亮屏时,如果当前在状态展示界面,刷新字幕显示(重置跑马灯偏移)
+                int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
+                int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView();
+                if (currentView == THUNDERBIRD_DIALOGUEVIEW && 
+                    currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW) {
+                    // 刷新字幕显示,重置跑马灯偏移
+                    ThunderBirdDialogueView *dialogueView = ThunderBirdDialogueView::GetInstance();
+                    if (dialogueView != nullptr) {
+                        ThunderBirdModel *model = ThunderBirdModel::GetInstance();
+                        if (model != nullptr) {
+                            std::string currentStatusText = model->GetCurrentStatusText();
+                            if (currentStatusText.empty()) {
+                                currentStatusText = "发呆中...     ";
+                            }
+                            dialogueView->UpdateDialogueText(currentStatusText.c_str());
+                        }
+                    }
+                }
             // ln_ws_exit_sleep();
         }
         g_lastPlayed = temp;