static const int native_big_app_size = 90; //大图标
static const int native_small_app_size = 72; //小图标
static int native_app_position_update_startflag = 0; //native_app_position_update函数开始更新的标志位
-static constexpr int angleIncrement = 6;
+static int angleIncrement = 10;
// 圆形表的圆心坐标和半径
static const int CIRCLE_CENTER_X = 233;
prepoint = convertToRelativeCoordinates(event.GetStartPoint());
preX = event.GetStartPoint().x;
preY = event.GetStartPoint().y;
+ dragstartTimeStamp = event.GetTimeStamp();
return true;
}
isDirectRotateFlag = isDirectRotate(event);//获取是否是正向旋转的标志
}
#endif
- if(angle % 30 == 0) //不需要补偿角度
- {
- OnDragEndFlag = 0;
- }
- else
- {
- OnDragEndFlag = 1;
- }
+ 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
void Notify() override
{
#if 0
return;
#endif
}
+#endif
+
+ void ResetState()
+ {
+ OnDragEndFlag = 0;
+ isInitialized = false;
+ inertiaDragAngle = 0;
+ if (isEncoderEvent)
+ {
+ angleIncrement = 10;//还原为drag的角度
+ isEncoderEvent = false;
+ ui_api_vibrate_once_func();
+ }
+ }
+
+ void Notify() override
+ {
+ if (!OnDragEndFlag) {
+ return; // Early return if there's no drag end
+ }
+ static int targetAngle = 0;// 目标角度:就是等下惯性要滑多少角度
+ static int timeIndex = 0;
+
+ if(!isInitialized) {
+ isInitialized = true;
+
+ // Define target angles based on drag duration
+ std::vector<int> targetAngles = {0, 30, 60, 90, 150,180,210,240,270,300};
+ // 根据滑动时间确定对应的目标角度索引
+ uint32_t minDragDuration = 0; // 假设的最短滑动时间,单位:毫秒,可调整
+ uint32_t maxDragDuration = 1400; // 假设的最长滑动时间,单位:毫秒,可调整
+
+ if (dragDuration < minDragDuration) {
+ // dragDuration = minDragDuration; // 时间过短,按最短时间处理,避免索引越界等问题
+ } else if (dragDuration > maxDragDuration) {
+ dragDuration = maxDragDuration; // 时间过长,按最长时间处理
+ }
+ uint32_t durationRange = maxDragDuration - minDragDuration;
+
+
+ // Calculate the target angle index
+ timeIndex = (dragDuration) / (durationRange / targetAngles.size());
+ timeIndex = std::min(timeIndex, static_cast<int>(targetAngles.size() - 1)); // 防止越界
+ targetAngle = targetAngles[timeIndex];
+ }
+
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "拖动时间:%d 毫秒,当前角度:%d,目标角度:%d,时间索引:%d", dragDuration, angle, targetAngle, timeIndex);
+ // 根据旋转方向确定角度增量的正负以及计算角度增量大小
+ int angleIncrementSign = isDirectRotateFlag ? 1 : -1;
+
+ if(targetAngle != 0) {
+ if(inertiaDragAngle != targetAngle) {
+ angle += (angleIncrementSign * angleIncrement);
+ inertiaDragAngle += abs(angleIncrementSign * angleIncrement);
+ } else if(inertiaDragAngle == targetAngle && angle % 30 != 0) {
+ angle += (angleIncrementSign * angleIncrement); //还要再次补充角度
+ } else if(inertiaDragAngle == targetAngle && angle % 30 == 0) {
+ // Reset state when target angle is reached
+ ResetState();
+ return;
+ }
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "inertiaDragAngle:%d,angle:%d",inertiaDragAngle,angle);
+ // 调用视图更新函数,实时更新界面显示
+ native_app_position_update(CircleListAPP, CircleListAPPNum, CircleListSelectImage, angle, isDirectRotateFlag);
+ } else {
+ if(angle % 30 == 0) {
+ ResetState();
+ } else {
+ angle += (isDirectRotateFlag? angleIncrement : -angleIncrement);
+ native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag);
+ }
+ }
+ return;
+ }
bool OnRotateStart(UIView& view, const RotateEvent& event)
{
+ angleIncrement = 15;
+ preRotateAngle = angle;
return false;
}
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) //不需要补偿角度
- {
- OnDragEndFlag = 0;
- }
- else
- {
+ if(angle % 30 == 0) {
+ angleIncrement = 10; //还原为drag的角度
+ OnDragEndFlag = 0; //不需要补偿角度
+ if(preRotateAngle != angle) {
+ ui_api_vibrate_once_func();
+ }
+ } else {
OnDragEndFlag = 1;
}
RotateReportedCount = 0;
rotateangle = 0;
+ dragDuration = 0;
return false;
}
bool isEncoderEvent{false}; //是否为编码器事件
bool isDragEvent{false}; //是否为拖拽事件
int RotateReportedCount{0};
+
+ uint32_t dragstartTimeStamp{0}; //开始拖拽时的时间戳
+ uint32_t dragendTimeStamp{0}; //拖拽结束时的时间戳
+ uint32_t dragDuration{0}; //拖拽时间
+ int inertiaDragAngle{0}; //惯性拖拽角度
+ bool isInitialized {false};
+ int preRotateAngle{0};
};
void ApplistView::CircleListStyleOnStart(void)
CircleListScrollView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
CircleListScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
CircleListScrollView->SetStyle(STYLE_BORDER_RADIUS, 150);
- CircleListScrollView->SetRotateFactor(1.0);
+ CircleListScrollView->SetRotateFactor(30.0);
CircleListScrollView->RequestFocus();
CircleListGroup_->Add(CircleListScrollView);
}