From 736e91e0cf64f837194915f72d3864116679717a Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 28 Feb 2025 16:11:02 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3=E6=8B=A8=E5=8F=B7=E7=9B=98?= =?utf8?q?=E9=A3=8E=E6=A0=BC=E8=BD=AC=E5=8A=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/applist/src/ApplistView.cpp | 156 ++++++++++-------- 1 file changed, 88 insertions(+), 68 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp index 968e85fec..b228896d2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp @@ -1269,37 +1269,40 @@ public: bool OnDragStart(UIView& view, const DragEvent& event) override { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppCircleListOnDragListener::OnDragStart"); - prepoint = convertToRelativeCoordinates(event.GetStartPoint()); - preX = event.GetStartPoint().x; - preY = event.GetStartPoint().y; - dragstartTimeStamp = event.GetTimeStamp(); + if(!isEncoderEvent) //如果此时编码器未旋转 + { + isDragEvent = true; + prepoint = convertToRelativeCoordinates(event.GetStartPoint()); + preX = event.GetStartPoint().x; + preY = event.GetStartPoint().y; + dragstartTimeStamp = event.GetTimeStamp(); + } return true; } bool OnDrag(UIView& view, const DragEvent& event) override { - isEncoderEvent = false; - isDragEvent = true; - - int curX = event.GetCurrentPos().x; - int curY = event.GetCurrentPos().y; - int deltaX = abs(curX - preX); - int deltaY = abs(curY - preY); - if (deltaX < 8 && deltaY < 8) + if(isDragEvent) { - return false; + int curX = event.GetCurrentPos().x; + int curY = event.GetCurrentPos().y; + int deltaX = abs(curX - preX); + int deltaY = abs(curY - preY); + if (deltaX < 8 && deltaY < 8) + { + return false; + } + curpoint = convertToRelativeCoordinates(event.GetCurrentPos()); + /* -------------------------------------------------------------------------- */ + isDirectRotate(event,isDirectRotateFlag); + angle += (isDirectRotateFlag ? angleIncrement : - angleIncrement); + native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag); + /* -------------------------------------------------------------------------- */ + prepoint = curpoint; + preX = curX; + preY = curY; + /* -------------------------------------------------------------------------- */ } - curpoint = convertToRelativeCoordinates(event.GetCurrentPos()); - /* -------------------------------------------------------------------------- */ - isDirectRotate(event,isDirectRotateFlag); - angle += (isDirectRotateFlag ? angleIncrement : - angleIncrement); - native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag); - /* -------------------------------------------------------------------------- */ - prepoint = curpoint; - preX = curX; - preY = curY; - /* -------------------------------------------------------------------------- */ - return true; } @@ -1313,14 +1316,17 @@ public: isDirectRotateFlag = isDirectRotate(event);//获取是否是正向旋转的标志 } #endif - dragendTimeStamp = event.GetTimeStamp(); - dragDuration = dragendTimeStamp - dragstartTimeStamp; - // OnDragEndFlag = (dragDuration >= 25 ? 1 : 0);//点击应用的时候容易产生滑动,小于25ms的屏蔽 - OnDragEndFlag = 1; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "dragDuration:%d,dragstartTimeStamp:%d,dragendTimeStamp:%d",dragDuration,dragstartTimeStamp,dragendTimeStamp); - int deltaX = abs(event.GetLastPoint().x - event.GetStartPoint().x); - int deltaY = abs(event.GetLastPoint().y - event.GetStartPoint().y); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "拖动时间:%d 毫秒,deltaX:%d,deltaY:%d",dragDuration,deltaX,deltaY); + if(isDragEvent) + { + dragendTimeStamp = event.GetTimeStamp(); + dragDuration = dragendTimeStamp - dragstartTimeStamp; + // OnDragEndFlag = (dragDuration >= 25 ? 1 : 0);//点击应用的时候容易产生滑动,小于25ms的屏蔽 + OnDragEndFlag = 1; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "dragDuration:%d,dragstartTimeStamp:%d,dragendTimeStamp:%d",dragDuration,dragstartTimeStamp,dragendTimeStamp); + int deltaX = abs(event.GetLastPoint().x - event.GetStartPoint().x); + int deltaY = abs(event.GetLastPoint().y - event.GetStartPoint().y); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "拖动时间:%d 毫秒,deltaX:%d,deltaY:%d",dragDuration,deltaX,deltaY); + } return true; } #if 0 @@ -1389,7 +1395,8 @@ public: { OnDragEndFlag = 0; isInitialized = false; - inertiaDragAngle = 0; + inertiaDragAngle = 0; + isDragEvent = false; if (isEncoderEvent) { angleIncrement = 10;//还原为drag的角度 @@ -1460,8 +1467,12 @@ public: bool OnRotateStart(UIView& view, const RotateEvent& event) { - angleIncrement = 15; - preRotateAngle = angle; + if(!isDragEvent) //如果此时未拖拽 + { + isEncoderEvent = true; + angleIncrement = 15; + preRotateAngle = angle; + } return false; } @@ -1469,50 +1480,59 @@ public: { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppCircleListOnDragListener::OnRotate %d",event.GetRotate()); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRotate回调次数%d",++RotateReportedCount); - ++RotateReportedCount; - isEncoderEvent = true; - isDragEvent = false; - if(RotateReportedCount > 4) + if(isEncoderEvent) { - if(event.GetRotate() > 0) - { - isDirectRotateFlag = true; - angle += angleIncrement; - native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag); - } - else + ++RotateReportedCount; + if(RotateReportedCount > 4) { - isDirectRotateFlag = false; - angle -= angleIncrement; - native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag); - } + if(event.GetRotate() > 0) + { + isDirectRotateFlag = true; + angle += angleIncrement; + native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag); + } + else + { + isDirectRotateFlag = false; + angle -= angleIncrement; + native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag); + } - // rotateangle += angleIncrement; - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rotateangle:%d",rotateangle); - // if(rotateangle >= 30 || rotateangle <= -30) - // { - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "震动一次"); - // rotateangle = 0; - // ui_api_vibrate_once_func(); - // } + // rotateangle += angleIncrement; + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rotateangle:%d",rotateangle); + // if(rotateangle >= 30 || rotateangle <= -30) + // { + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "震动一次"); + // rotateangle = 0; + // ui_api_vibrate_once_func(); + // } + } } return false; } bool OnRotateEnd(UIView& view, const RotateEvent& event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppCircleListOnDragListener::OnRotateEnd %d",event.GetRotate()); - if(angle % 30 == 0) { - angleIncrement = 10; //还原为drag的角度 - OnDragEndFlag = 0; //不需要补偿角度 - if(preRotateAngle != angle) { - ui_api_vibrate_once_func(); + if(isEncoderEvent) + { + if(angle % 30 == 0) + { + angleIncrement = 10; //还原为drag的角度 + OnDragEndFlag = 0; //不需要补偿角度 + isEncoderEvent = false; + if(preRotateAngle != angle) + { + ui_api_vibrate_once_func(); + } + } + else + { + OnDragEndFlag = 1; } - } else { - OnDragEndFlag = 1; + RotateReportedCount = 0; + rotateangle = 0; + dragDuration = 0; } - RotateReportedCount = 0; - rotateangle = 0; - dragDuration = 0; return false; } -- 2.17.1