音乐播放器的声音视图优化修改
authorluozheng <1732036298@qq.com>
Wed, 7 Aug 2024 08:14:01 +0000 (16:14 +0800)
committerluozheng <1732036298@qq.com>
Wed, 7 Aug 2024 08:14:01 +0000 (16:14 +0800)
code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingView.h
code/sdk/application/wearable/fd230app/nativeui/main/src/VolumeSettingView.cpp

index 1076ee7..bccd376 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-05 15:20:02
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-06 16:26:51
+ * @LastEditTime: 2024-08-07 15:25:29
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/VolumeSettingView.h
  */
 
@@ -38,6 +38,7 @@ private:
     UISlider *progress{nullptr};
     UIButton *increaseButton{nullptr};
     UIButton *decreaseButton{nullptr};
+    UIImageView *VolumeVetor{nullptr};
     int ShowVolume();
 };
 } // namespace OHOS
index 89e2da8..44dd657 100644 (file)
@@ -15,10 +15,10 @@ static constexpr uint16_t BUTTON_Y = 0;
 static constexpr uint16_t BUTTON_Y2 = 363;
 static constexpr uint16_t BUTTON_WIDTH = 90;
 static constexpr uint16_t BUTTON_HEIGHT = 90;
-static constexpr uint16_t SLIDER_X = 207;
-static constexpr uint16_t SLIDER_Y = 90;
-static constexpr uint16_t SLIDER_WIDTH = 40;
-static constexpr uint16_t SLIDER_HEIGHT = 274;
+static constexpr uint16_t SLIDER_X = 167;
+static constexpr uint16_t SLIDER_Y = 77;
+static constexpr uint16_t SLIDER_WIDTH = 130;
+static constexpr uint16_t SLIDER_HEIGHT = 310;
 
 constexpr uint16_t VOLUME_OK = 0;
 constexpr int16_t VOLUME_ERROR = (-1);
@@ -36,14 +36,23 @@ VolumeSettingView::~VolumeSettingView()
         delete listener;
         listener = nullptr;
     }
-    delete increaseButton;
-    increaseButton = nullptr;
-
-    delete decreaseButton;
-    decreaseButton = nullptr;
-
-    delete progress;
-    progress = nullptr;
+    if(increaseButton) {
+        delete increaseButton;
+        increaseButton = nullptr;
+    }
+    if(decreaseButton) {
+        delete decreaseButton;
+        decreaseButton = nullptr;
+    }
+    if(VolumeVetor!=nullptr)
+    {
+        delete VolumeVetor;
+        VolumeVetor = nullptr;
+    }
+    if(progress!=nullptr){
+        delete progress;
+        progress = nullptr;
+    }
 }
 
 bool VolumeSettingView::SetUpVolume(void)
@@ -65,6 +74,23 @@ bool VolumeSettingView::SetUpVolume(void)
     progress->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP);
     progress->SetViewId(VOLUME_PROGRESS);
     progress->SetRange(VOLUME_MAX, VOLUME_MIN);
+    progress->SetStyle(STYLE_BORDER_RADIUS, 100);
+    progress->SetBackgroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
+    progress->SetForegroundStyle(STYLE_LINE_CAP, CapType::CAP_ROUND);
+    progress->SetSliderColor(Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+    progress->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff);
+    progress->RequestFocus();
+    progress->SetRotateFactor(1.0);
+
+    VolumeVetor = new UIImageView();
+    if (VolumeVetor == nullptr)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VolumeVetor new fail");
+        return false;
+    }
+    VolumeVetor->SetPosition(213, 213, 40, 40);
+    VolumeVetor->SetSrc("/user/res/VolumeControlVector.bin");
+
 
     if (listener == nullptr) {
         listener = new VolumeSliderEventListener(this);
@@ -82,6 +108,7 @@ bool VolumeSettingView::SetUpVolume(void)
     SetDraggable(true);
     SetTouchable(true);
     Add(progress);
+    Add(VolumeVetor);
     ShowVolume();
 
     return true;
@@ -118,6 +145,7 @@ int VolumeSettingView::ShowVolume(void)
     increaseButton->SetImageSrc(image, image);
     increaseButton->SetOnClickListener(listener);
     Add(increaseButton);
+    increaseButton->SetVisible(false);
 
     if (decreaseButton == nullptr) {
         decreaseButton = new UIButton();
@@ -131,6 +159,7 @@ int VolumeSettingView::ShowVolume(void)
     image = ImageCacheManager::GetInstance().LoadOneInMultiRes(PLAYER_DECREASE_BUTTON, PLAYER_IAMGES);
     decreaseButton->SetImageSrc(image, image);
     decreaseButton->SetOnClickListener(listener);
+    decreaseButton->SetVisible(false);
     Add(decreaseButton);
 
     return VOLUME_OK;