delete CircleListGroup_;
CircleListGroup_ = nullptr;
}
- if(CircleListImage1)
+ // if(CircleListImage1)
+ // {
+ // delete CircleListImage1;
+ // CircleListImage1 = nullptr;
+ // }
+ // if(CircleListImage2)
+ // {
+ // delete CircleListImage2;
+ // CircleListImage2 = nullptr;
+ // }
+ if(PointImage)
{
- delete CircleListImage1;
- CircleListImage1 = nullptr;
- }
- if(CircleListImage2)
- {
- delete CircleListImage2;
- CircleListImage2 = nullptr;
+ delete PointImage;
+ PointImage = nullptr;
}
if(CircleListSelectImage)
{
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 = 5;
+
+// 圆形表的圆心坐标和半径
+static const int CIRCLE_CENTER_X = 233;
+static const int CIRCLE_CENTER_Y = 233;
+static const int CIRCLE_RADIUS = 233;
+static OHOS::Point curpoint;
+static OHOS::Point prepoint;
+
+// 计算两点之间的距离
+static double calculateDistance(const OHOS::Point& p1, const OHOS::Point& p2)
+{
+ return std::sqrt(std::pow(p2.x - p1.x, 2) + std::pow(p2.y - p1.y, 2));
+}
+// 将触摸点坐标转换为相对于圆心的坐标
+static OHOS::Point convertToRelativeCoordinates(const OHOS::Point& point)
+{
+ OHOS::Point relativePoint;
+ relativePoint.x = point.x - CIRCLE_CENTER_X;
+ relativePoint.y = point.y - CIRCLE_CENTER_Y;
+ return relativePoint;
+}
+// 使用 atan2 函数计算点与水平正方向的夹角(弧度制)
+static double calculateAngle(const OHOS::Point& point)
+{
+ double angle = std::atan2(point.y, point.x);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "x:%d,y:%d",point.x,point.y);
+ return angle;
+}
//获取是否是正向旋转
-static bool isDirectRotate(const DragEvent& event)
+static void isDirectRotate(const DragEvent& event,bool &isDirectRotate)
{
- int startpointX = event.GetStartPoint().x;
- int startpointY = event.GetStartPoint().y;
- bool isDirectRotate = false;
- uint8_t dragDirection = event.GetDragDirection();
- if ((dragDirection == DragEvent::DIRECTION_TOP_TO_BOTTOM && startpointX >= 233) ||
- (dragDirection == DragEvent::DIRECTION_BOTTOM_TO_TOP && startpointX < 233) ||
- (dragDirection == DragEvent::DIRECTION_LEFT_TO_RIGHT && startpointY < 233) ||
- (dragDirection == DragEvent::DIRECTION_RIGHT_TO_LEFT && startpointY >= 233))
+ // 计算当前点与水平正方向的夹角(弧度制)
+ double angle_cur = calculateAngle(curpoint);
+ // 计算上一次点与水平正方向的夹角(弧度制)
+ double angle_pre = calculateAngle(prepoint);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "angle_cur:%lf,angle_pre:%lf",angle_cur,angle_pre);
+
+ // 判断滑动方向,通过比较角度差值
+ bool isDirectRotateTemp = isDirectRotate;
+ double angleDiff = angle_cur - angle_pre;
+ if (angleDiff >= 0)
{
isDirectRotate = true;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "顺时针滑动");
+ }
+ else
+ {
+ isDirectRotate = false;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "逆时针滑动");
+ }
+ if((angle_cur < 0 && angle_pre > 0) || (angle_cur > 0 && angle_pre < 0))
+ {
+ isDirectRotate = isDirectRotateTemp;
+ if(isDirectRotateTemp)
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "逆时针滑动->顺时针滑动");
+ else
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "顺时针滑动->逆时针滑动");
}
- return isDirectRotate;
}
+// 计算当前缩放比例
+// startangle: 起始角度
+// isClockwiseRotation: 是否顺时针旋转
+static int calculateCurscale(int startangle, bool isClockwiseRotation )
+{
+ int curscale = 0;
+ if (startangle!= 0 && startangle % 30 == 0) {
+ curscale = 30;
+ } else {
+ int baseMod = startangle % 30;
+ if (startangle > 0) {
+ curscale =!isClockwiseRotation ? 30 - baseMod : baseMod;
+ } else if (startangle < 0) {
+ curscale = isClockwiseRotation ? 30 + baseMod : baseMod;
+ } else {
+ curscale =!isClockwiseRotation ? 30 - baseMod : 30 + baseMod;
+ }
+ }
+
+ return curscale;
+}
static void native_app_position_init(UIImageView ** CircleListAPP,int CircleListAPPNum,int startangle,uint8_t array[])
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "startangle:%d",startangle);
-
+#if 0
double curangle = startangle;
double curscale = (int)curangle % NATIVE_APP_ANGEL_INTERVAL;
int x = 0;
curangle += NATIVE_APP_ANGEL_INTERVAL;
}
RootView::GetInstance()->Invalidate();
+#endif
+ double curangle = startangle;// 当前角度
+ int xPos = 0;
+ int yPos = 0;
+ int size = 81;
+ int margin = 100 - size;//边距
+ int R = CIRCLE_WATCH_R - size / 2 - margin;
+
+ if(startangle % 30 == 0)
+ {
+ int index = 0;
+ int appIndex = 0;
+ int circleIndex = 0;
+
+ int nativeAppNum = ApplistModel::GetInstance().GetAppListNum();
+ int native_app_image_start_index = 0;
+
+ if(startangle > 0 )
+ {
+ int numToChange = startangle / 30;
+ for (int i = 1; i <= numToChange; i++)
+ {
+ // 计算 index 和 appIndex
+ index = i % nativeAppNum + 11;
+ appIndex = index;
+ if (startangle >= 360) {
+ appIndex = index % nativeAppNum;
+ }
+
+ // 计算 circleIndex
+ circleIndex = (12 - i) % 12;
+ if (circleIndex < 0) {
+ circleIndex += 12;
+ }
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "circleIndex:%d,appIndex:%d name:%s", circleIndex, appIndex, ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetSrc(ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[appIndex].id);
+ }
+
+ }
+ else if(startangle < 0)
+ {
+ int numToChange = abs(startangle) / 30;
+ for (int i = 1; i <= numToChange; i++)
+ {
+ index = i % nativeAppNum + 11;
+ appIndex = index;
+ if (abs(startangle) >= 360)
+ {
+ appIndex = index % nativeAppNum;
+ }
+ circleIndex = ((abs(startangle) - 30) / 30 ) % 12;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "circleIndex:%d,appIndex:%d name:%s", circleIndex, appIndex, ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetSrc(ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[appIndex].id);
+ }
+ }
+ else
+ {
+ for(int i = 0;i < CircleListAPPNum;i++)
+ {
+ index = i % 2; // 使用取模操作实现循环列表
+ if(index == 0)
+ {
+ array[i] = 0;
+ }
+ else
+ {
+ array[i] = 1;
+ }
+ }
+ }
+ }
+
+ //更改图片位置和大小
+ for(int i = 0; i < CircleListAPPNum; i++)
+ {
+ xPos = ((CIRCLE_WATCH_R - cos(curangle*PI_OVER_180) * R) - size / 2);
+ yPos = ((CIRCLE_WATCH_R - sin(curangle*PI_OVER_180) * R) - size / 2);
+ CircleListAPP[i]->SetPosition(xPos, yPos, size,size);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "xPos:%d,yPos:%d",xPos,yPos);
+ curangle += NATIVE_APP_ANGEL_INTERVAL ; //每个NATIVE_APP位置变化NATIVE_APP_ANGEL_INTERVAL度
+ }
+ RootView::GetInstance()->Invalidate();
+}
+
+// 根据起始角度、旋转方向以及相关索引更新CircleListAPP和选中图片信息(顺时针且直接旋转情况)
+static void updateCircleListAndSelectImageForDirectClockwise(UIImageView** CircleListAPP,
+ UIImageView* CircleListSelectImage_,
+ int startangle,
+ int& curselectImageIndex,
+ int& preselectImageIndex,
+ int nativeAppNum)
+{
+ int nextstartangle = startangle + (30 - angleIncrement);
+ if (nextstartangle % 30 == 0) {
+ int tempIndex = (nextstartangle / 30);
+ // 计算 index 和 appIndex
+ int index = tempIndex % nativeAppNum + 11;
+ int appIndex = index;
+ if (nextstartangle >= 360) {
+ appIndex = index % nativeAppNum;
+ }
+
+ // 计算 circleIndex
+ int circleIndex = (12 - tempIndex) % 12;
+ if (circleIndex < 0) {
+ circleIndex += 12;
+ }
+
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "circleIndex:%d,appIndex:%d name:%s", circleIndex, appIndex, ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetSrc(ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[appIndex].id);
+
+ // 选中图片计算
+ if (nextstartangle <= 180) {
+ if (preselectImageIndex == 0 && curselectImageIndex == 12) {
+ preselectImageIndex = 1;
+ curselectImageIndex = 0;
+ } else {
+ preselectImageIndex = curselectImageIndex;
+ curselectImageIndex = (curselectImageIndex - 1) % nativeAppNum;
+ }
+ } else {
+ if (preselectImageIndex == 1 && curselectImageIndex == 0) {
+ preselectImageIndex = 0;
+ curselectImageIndex = 12;
+ } else {
+ preselectImageIndex = curselectImageIndex;
+ curselectImageIndex = (curselectImageIndex + 1) % nativeAppNum;
+ }
+ }
+
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[curselectImageIndex,preselectImageIndex]:[%d,%d]", curselectImageIndex, preselectImageIndex);
+ CircleListSelectImage_->SetSrc(ApplistModel::GetInstance().GetApplistItems()[curselectImageIndex].iconLarge);
+ CircleListSelectImage_->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[curselectImageIndex].id);
+ ApplistModel::GetInstance().SetCurselectImageIndex(curselectImageIndex);
+ ApplistModel::GetInstance().SetPreselectImageIndex(preselectImageIndex);
+ }
+}
+
+// 根据起始角度、旋转方向以及相关索引更新CircleListAPP(顺时针且非直接旋转情况)
+static void updateCircleListForClockwiseNotDirect(UIImageView** CircleListAPP,
+ UIImageView* CircleListSelectImage_,
+ int startangle,
+ int& curselectImageIndex,
+ int& preselectImageIndex,
+ int nativeAppNum)
+{
+ int prevStartAngle = startangle + angleIncrement;
+ if (prevStartAngle % 30 == 0)
+ {
+ int appIndex = (12 - (prevStartAngle) / 30) % nativeAppNum;
+ int circleIndex = appIndex % 12;
+ if (circleIndex < 0) {
+ circleIndex += 12;
+ }
+ if (appIndex < 0) {
+ appIndex = (- appIndex + 11) % nativeAppNum;
+ }
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "circleIndex:%d,appIndex:%d name:%s", circleIndex, appIndex, ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetSrc(ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[appIndex].id);
+ }
+
+ if(startangle % 30 == 0)
+ {
+ // 选中图片计算
+ if(startangle <= 180)
+ {
+ if(preselectImageIndex == 0 && curselectImageIndex == 12)
+ {
+ preselectImageIndex = 1;
+ curselectImageIndex = 0;
+ }
+ else
+ {
+ curselectImageIndex = preselectImageIndex;
+ preselectImageIndex = curselectImageIndex + 1 % nativeAppNum;
+ }
+ }
+ else
+ {
+ if(preselectImageIndex == 12 && curselectImageIndex == 13)
+ {
+ preselectImageIndex = 0;
+ curselectImageIndex = 12;
+ }
+ else
+ {
+ curselectImageIndex = (curselectImageIndex - 1 + nativeAppNum) % nativeAppNum;
+ preselectImageIndex = (preselectImageIndex - 1 + nativeAppNum) % nativeAppNum;
+ }
+ }
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[curselectImageIndex->preselectImageIndex]:[%d->%d]", curselectImageIndex,preselectImageIndex);
+ CircleListSelectImage_->SetSrc(ApplistModel::GetInstance().GetApplistItems()[curselectImageIndex].iconLarge);
+ CircleListSelectImage_->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[curselectImageIndex].id);
+ ApplistModel::GetInstance().SetCurselectImageIndex(curselectImageIndex);
+ ApplistModel::GetInstance().SetPreselectImageIndex(preselectImageIndex);
+ }
+}
+
+// 根据起始角度、旋转方向以及相关索引更新CircleListAPP和选中图片信息(逆时针且非直接旋转情况)
+static void updateCircleListAndSelectImageForCounterclockwiseNotDirect(UIImageView** CircleListAPP,
+ UIImageView* CircleListSelectImage_,
+ int startangle,
+ int& curselectImageIndex,
+ int& preselectImageIndex,
+ int nativeAppNum)
+{
+ int absStartAngle = abs(startangle - (30 - angleIncrement));
+ if (absStartAngle % 30 == 0) {
+ int index = (absStartAngle / 30) % nativeAppNum + 11;
+ int appIndex = index;
+ if (absStartAngle >= 360) {
+ appIndex = index % nativeAppNum;
+ }
+ int circleIndex = ((absStartAngle - 30) / 30 ) % 12;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "circleIndex:%d,appIndex:%d name:%s", circleIndex, appIndex, ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetSrc(ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[appIndex].id);
+
+ preselectImageIndex = curselectImageIndex;
+ curselectImageIndex = (curselectImageIndex + 1) % nativeAppNum;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[curselectImageIndex->preselectImageIndex]:[%d->%d]", curselectImageIndex, preselectImageIndex);
+ CircleListSelectImage_->SetSrc(ApplistModel::GetInstance().GetApplistItems()[curselectImageIndex].iconLarge);
+ CircleListSelectImage_->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[curselectImageIndex].id);
+ ApplistModel::GetInstance().SetCurselectImageIndex(curselectImageIndex);
+ ApplistModel::GetInstance().SetPreselectImageIndex(preselectImageIndex);
+ }
}
+
+// 根据起始角度、旋转方向以及相关索引更新CircleListAPP和选中图片信息(逆时针且直接旋转情况)
+static void updateCircleListAndSelectImageForCounterclockwiseDirect(UIImageView** CircleListAPP,
+ UIImageView* CircleListSelectImage_,
+ int startangle,
+ int& curselectImageIndex,
+ int& preselectImageIndex,
+ int nativeAppNum)
+{
+ int absStartAngle = abs(startangle);
+ if (absStartAngle % 30 == 0) {
+ int appIndex = (absStartAngle / 30) % nativeAppNum ;
+ int circleIndex = (absStartAngle / 30) % 12;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "circleIndex:%d,appIndex:%d name:%s", circleIndex, appIndex, ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetSrc(ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[appIndex].id);
+
+ curselectImageIndex = preselectImageIndex;
+ preselectImageIndex = (preselectImageIndex - 1 + nativeAppNum) % nativeAppNum;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[curselectImageIndex->preselectImageIndex]:[%d->%d]", curselectImageIndex, preselectImageIndex);
+ CircleListSelectImage_->SetSrc(ApplistModel::GetInstance().GetApplistItems()[curselectImageIndex].iconLarge);
+ CircleListSelectImage_->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[curselectImageIndex].id);
+ ApplistModel::GetInstance().SetCurselectImageIndex(curselectImageIndex);
+ ApplistModel::GetInstance().SetPreselectImageIndex(preselectImageIndex);
+ }
+}
+
+// 根据起始角度为0的情况更新CircleListAPP和选中图片信息
+static void updateCircleListAndSelectImageWhenStartangleZero(UIImageView** CircleListAPP,
+ UIImageView* CircleListSelectImage_,
+ int& curselectImageIndex,
+ int& preselectImageIndex,
+ bool isDirectRotate)
+{
+ int index = 0;
+ int appIndex = 0;
+ int circleIndex = 0;
+ if (!isDirectRotate) {
+ index = 0;
+ appIndex = 11;
+ circleIndex = 11;
+ } else {
+ index = 0;
+ appIndex = 0;
+ circleIndex = 0;
+ }
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "circleIndex:%d,appIndex:%d name:%s", circleIndex, appIndex, ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+ CircleListAPP[circleIndex]->SetSrc(ApplistModel::GetInstance().GetApplistItems()[appIndex].iconSmall);
+
+ curselectImageIndex = preselectImageIndex;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[curselectImageIndex->preselectImageIndex]:[%d->%d]", curselectImageIndex, preselectImageIndex);
+ CircleListSelectImage_->SetSrc(ApplistModel::GetInstance().GetApplistItems()[curselectImageIndex].iconLarge);
+ CircleListSelectImage_->SetViewIndex(ApplistModel::GetInstance().GetApplistItems()[curselectImageIndex].id);
+ ApplistModel::GetInstance().SetCurselectImageIndex(curselectImageIndex);
+ ApplistModel::GetInstance().SetPreselectImageIndex(preselectImageIndex);
+}
+
+static void fillArray(int CircleListAPPNum, int curscale) {
+ curscale = abs(curscale);
+ bool isEvenPattern = (curscale >= 0 && curscale % 60 == 0) || (curscale < 0 && curscale % 60 == -60);
+ bool isOddPattern = (curscale >= 0 && curscale % 60 == 30) || (curscale < 0 && curscale % 60 == -30);
+
+ for (int i = 0; i < CircleListAPPNum; ++i) {
+ if (isEvenPattern && i % 2 == 0) {
+ array[i] = 0;
+ } else if (isEvenPattern && i % 2!= 0) {
+ array[i] = 1;
+ } else if (isOddPattern && i % 2 == 0) {
+ array[i] = 1;
+ } else if (isOddPattern && i % 2!= 0) {
+ array[i] = 0;
+ }
+ }
+}
+
+//更改图片位置和大小的函数
+static void updateImagePositionAndSize(UIImageView** CircleListAPP, int CircleListAPPNum, int startangle, int curscale)
+{
+#if 0
+ double curangle = startangle;// 当前角度
+ int xPos = 0;
+ int yPos = 0;
+ int size = native_small_app_size + abs(curscale*0.6);
+ int size2 = native_big_app_size - abs(curscale*0.6);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "curscale:%d",curscale);
+ int margin1 = 100 - size;//边距
+ int margin2 = 100 - size2;//边距
+ int R = CIRCLE_WATCH_R - size / 2 - margin1;
+ int R2 = CIRCLE_WATCH_R - size2 / 2 - margin2;
+ //更改图片位置和大小
+ for(int i = 0; i < CircleListAPPNum; i++)
+ {
+ if(array[i] == 0)
+ {
+ xPos = ((CIRCLE_WATCH_R - cos(curangle*PI_OVER_180) * R) - size / 2);
+ yPos = ((CIRCLE_WATCH_R - sin(curangle*PI_OVER_180) * R) - size / 2);
+ CircleListAPP[i]->SetPosition(xPos, yPos, size,size);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "size:%d",size);
+ }
+ else
+ {
+ xPos = ((CIRCLE_WATCH_R - cos(curangle*PI_OVER_180) * R2) - size2 / 2);
+ yPos = ((CIRCLE_WATCH_R - sin(curangle*PI_OVER_180) * R2) - size2 / 2);
+ CircleListAPP[i]->SetPosition(xPos, yPos, size2,size2);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "size2:%d",size2);
+ }
+ curangle += NATIVE_APP_ANGEL_INTERVAL ; //每个NATIVE_APP位置变化NATIVE_APP_ANGEL_INTERVAL度
+ }
+ if(startangle % 30 == 0)
+ fillArray(CircleListAPPNum,startangle);
+#endif
+ /* -------------------------------------------------------------------------- */
+ double curangle = startangle;// 当前角度
+ int xPos = 0;
+ int yPos = 0;
+ int size = 81;
+ int margin = 100 - size;//边距
+ int R = CIRCLE_WATCH_R - size / 2 - margin;
+
+ //更改图片位置和大小
+ for(int i = 0; i < CircleListAPPNum; i++)
+ {
+ xPos = ((CIRCLE_WATCH_R - cos(curangle*PI_OVER_180) * R) - size / 2);
+ yPos = ((CIRCLE_WATCH_R - sin(curangle*PI_OVER_180) * R) - size / 2);
+ CircleListAPP[i]->SetPosition(xPos, yPos, size,size);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "xPos:%d,yPos:%d",xPos,yPos);
+ curangle += NATIVE_APP_ANGEL_INTERVAL ; //每个NATIVE_APP位置变化NATIVE_APP_ANGEL_INTERVAL度
+ }
+ /* -------------------------------------------------------------------------- */
+}
+
static void native_app_position_update(UIImageView ** CircleListAPP,int CircleListAPPNum,UIImageView *CircleListSelectImage_,int startangle,bool isDirectRotate)
{
// 打印起始角度
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "startangle:%d",startangle);
+ double curangle = startangle;// 当前角度
+ int curscale = 0;
+ // int curscale = calculateCurscale(startangle, isDirectRotate);// 缩放系数
+ int nativeAppNum = ApplistModel::GetInstance().GetAppListNum();
+ int curselectImageIndex = ApplistModel::GetInstance().GetCurselectImageIndex(); //当前选中图片索引
+ int preselectImageIndex = ApplistModel::GetInstance().GetPreselectImageIndex(); //上一次选中图片索引
- // 当前角度
- double curangle = startangle;
- // 缩放系数
- int curscale = 0;
+ if (startangle % 30 == 0) {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "startangle:%d,[curselectImageIndex,preselectImageIndex]:[%d,%d]", startangle, curselectImageIndex, preselectImageIndex);
+ native_app_position_update_startflag = 0; //表示可以下次更新了
+ ApplistModel::GetInstance().SetCircleListStartAngle(startangle);
+ }
- // 计算缩放系数
- if (startangle!= 0 && startangle % 30 == 0) {
- curscale = 30;
- } else {
- int baseMod = startangle % 30;
- if (startangle > 0) {
- curscale =!isDirectRotate? 30 - baseMod : baseMod;
- } else if (startangle < 0) {
- curscale = isDirectRotate? 30 + baseMod : baseMod;
- } else {
- curscale =!isDirectRotate? 30 - baseMod : 30 + baseMod;
+ if (startangle > 0)
+ {
+ //顺时针
+ if (isDirectRotate)
+ {
+ updateCircleListAndSelectImageForDirectClockwise(CircleListAPP,CircleListSelectImage_,startangle,curselectImageIndex,preselectImageIndex,nativeAppNum);
+ }
+ else//逆时针处理
+ {
+ updateCircleListForClockwiseNotDirect(CircleListAPP,CircleListSelectImage_,startangle,curselectImageIndex,preselectImageIndex,nativeAppNum);
}
}
+ else if(startangle < 0)
+ {
+ if (!isDirectRotate) //逆时针
+ {
+ updateCircleListAndSelectImageForCounterclockwiseNotDirect(CircleListAPP,CircleListSelectImage_,startangle,curselectImageIndex,preselectImageIndex,nativeAppNum);
+ }
+ else
+ {
+ updateCircleListAndSelectImageForCounterclockwiseDirect(CircleListAPP,CircleListSelectImage_,startangle,curselectImageIndex,preselectImageIndex,nativeAppNum);
+ }
+ }
+ else
+ {
+ updateCircleListAndSelectImageWhenStartangleZero(CircleListAPP,CircleListSelectImage_,curselectImageIndex,preselectImageIndex,isDirectRotate);
+ }
+
+ updateImagePositionAndSize(CircleListAPP, CircleListAPPNum, startangle, curscale);
+ RootView::GetInstance()->Invalidate();
+ return;
+
+ #if 0
+ // 打印起始角度
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startangle:%d",startangle);
+
+ // 当前角度
+ double curangle = startangle;
+ // 缩放系数
+ int curscale = calculateCurscale(startangle, isDirectRotate);
int nativeAppNum = ApplistModel::GetInstance().GetAppListNum();
}
else //逆时针处理
{
- int prevStartAngle = startangle + 3;
+ int prevStartAngle = startangle + angleIncrement;
if(prevStartAngle % 30 == 0)
{
appIndex = (12 - (prevStartAngle) / 30) % nativeAppNum;
else
{
curselectImageIndex = preselectImageIndex;
- preselectImageIndex = curselectImageIndex + 1;
+ preselectImageIndex = curselectImageIndex + 1 % nativeAppNum;
}
}
else
{
if(!isDirectRotate) //逆时针
{
- int absStartAngle = abs(startangle - (30 - 3));
+ int absStartAngle = abs(startangle - (30 - angleIncrement));
if(absStartAngle % 30 == 0)
{
index = (absStartAngle / 30) % nativeAppNum + 11;
// 刷新视图
RootView::GetInstance()->Invalidate();
+ #endif
/* -------------------------------------------------------------------------- */
}
class AppCircleListOnDragListener : public UIView::OnDragListener,
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;
return true;
}
bool OnDrag(UIView& view, const DragEvent& event) override
{
- int deltaX = abs(event.GetLastPoint().x - event.GetStartPoint().x);
- int deltaY = abs(event.GetLastPoint().y - event.GetStartPoint().y);
- if (deltaX < 50 && deltaY < 50)
+ 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;
+ /* -------------------------------------------------------------------------- */
return true;
}
bool OnDragEnd(UIView& view, const DragEvent& event) override
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppCircleListOnDragListener::OnDragEnd");
+#if 0
if(native_app_position_update_startflag == 0) {
native_app_position_update_startflag = 1;
OnDragEndFlag = 1;
isDirectRotateFlag = isDirectRotate(event);//获取是否是正向旋转的标志
}
+#endif
+ if(angle % 30 == 0) //不需要补偿角度
+ {
+ OnDragEndFlag = 0;
+ }
+ else
+ {
+ OnDragEndFlag = 1;
+ }
return true;
}
void Notify() override
{
+#if 0
if(OnDragEndFlag)
{
int angleIncrement = isDirectRotateFlag? 3 : -3;
if(native_app_position_update_startflag)
native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag);
}
+#else
+ if(OnDragEndFlag)
+ {
+ if(angle % 30 == 0) //不需要补偿角度
+ {
+ OnDragEndFlag = 0;
+ }
+ else
+ {
+ if(angle > 0)
+ {
+ if(isDirectRotateFlag)
+ {
+ angle += angleIncrement;
+ }
+ else
+ {
+ angle -= angleIncrement;
+ }
+ }
+ else
+ {
+ if(isDirectRotateFlag)
+ {
+ angle += angleIncrement;
+ }
+ else
+ {
+ angle -= angleIncrement;
+ }
+ }
+ native_app_position_update(CircleListAPP,CircleListAPPNum,CircleListSelectImage,angle,isDirectRotateFlag);
+ }
+ }
+ return;
+#endif
}
- void OnPickerStoped(UIPicker &picker) override
+
+ bool OnRotate(UIView& view, const RotateEvent& event)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "preOnSelectPickerIndex:%d,picker.GetSelected:%d",preOnSelectPickerIndex,picker.GetSelected());
- // 判断是否为逆时针方向
- if ((preOnSelectPickerIndex == 0 && picker.GetSelected() == 1) ||
- (preOnSelectPickerIndex == 1 && picker.GetSelected() == 2) ||
- (preOnSelectPickerIndex == 2 && picker.GetSelected() == 0)) {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppCircleListOnDragListener::OnRotate %d",event.GetRotate());
+ 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);
}
- // 判断是否为顺时针方向
- else if ((preOnSelectPickerIndex == 1 && picker.GetSelected() == 0) ||
- (preOnSelectPickerIndex == 0 && picker.GetSelected() == 2) ||
- (preOnSelectPickerIndex == 2 && picker.GetSelected() == 1)) {
- isDirectRotateFlag = true;
+
+ 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;
}
-
- if (preOnSelectPickerIndex!= picker.GetSelected())
+ else
{
- if (native_app_position_update_startflag == 0)
- {
- native_app_position_update_startflag = 1;
- OnDragEndFlag = 1;
- }
- // 更新之前选中的索引值为当前选中的值
- preOnSelectPickerIndex = picker.GetSelected();
+ OnDragEndFlag = 1;
}
- return;
+ return false;
}
+
private:
- UIImageView **CircleListAPP{nullptr};
- UIImageView *CircleListSelectImage{nullptr};
- int CircleListAPPNum{0};
- int angle = 0; //要旋转角度
- int rotateangle{0}; //旋转累计角度
- uint8_t OnDragEndFlag{0};//是否拖拽结束的标志
- bool isDirectRotateFlag{false};//是否是正向旋转的标志
- int preOnSelectPickerIndex{1};//当前picker选中索引
+ UIImageView **CircleListAPP{nullptr}; //图片组件数组
+ UIImageView *CircleListSelectImage{nullptr}; //中间选中图片的图片组件
+ int CircleListAPPNum{0}; //图片组件数量
+ int angle = 0; //要旋转角度
+ int rotateangle{0}; //旋转累计角度
+ uint8_t OnDragEndFlag{0}; //是否拖拽结束的标志
+ bool isDirectRotateFlag{false}; //是否是正向旋转的标志
+ int preX{0};
+ int preY{0};
};
void ApplistView::CircleListStyleOnStart(void)
CircleListPicker->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
CircleListPicker->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
CircleListPicker->SetStyle(STYLE_BORDER_RADIUS, 150);
- CircleListPicker->SetItemHeight(60);
+ CircleListPicker->SetItemHeight(30);
CircleListPicker->SetLoopState(true);
CircleListPicker->SetRotateFactor(1.0);
CircleListPicker->RequestFocus();
CircleListGroup_->Add(CircleListPicker);
}
/* -------------------------------------------------------------------------- */
- if(CircleListImage1 == nullptr)
- {
- CircleListImage1 = new UIImageView();
- if(nullptr == CircleListImage1)
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListImage1 failed!! [%d]", __LINE__);
- return;
- }
- CircleListImage1->SetPosition(114, 122, 220, 330);
- CircleListImage1->SetSrc("/user/res/themestyle/circlelist/circleListImage1.bin");
- CircleListGroup_->Add(CircleListImage1);
- }
+ // if(CircleListImage1 == nullptr)
+ // {
+ // CircleListImage1 = new UIImageView();
+ // if(nullptr == CircleListImage1)
+ // {
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListImage1 failed!! [%d]", __LINE__);
+ // return;
+ // }
+ // CircleListImage1->SetPosition(120, 122, 220, 330);
+ // CircleListImage1->SetSrc("/user/res/themestyle/circlelist/circleListImage1.bin");
+ // CircleListGroup_->Add(CircleListImage1);
+ // }
/* -------------------------------------------------------------------------- */
CircleListAPPNum = sizeof(CircleListAPP) / sizeof(CircleListAPP[0]);//图片显示数量
/* -------------------------------------------------------------------------- */
}
native_app_position_init(CircleListAPP,CircleListAPPNum,ApplistModel::GetInstance().GetCircleListStartAngle() ,array);
/* -------------------------------------------------------------------------- */
- if(CircleListImage2 == nullptr)
+ // if(CircleListImage2 == nullptr)
+ // {
+ // CircleListImage2 = new UIImageView();
+ // if(nullptr == CircleListImage2)
+ // {
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListImage2 failed!! [%d]", __LINE__);
+ // return;
+ // }
+ // int x = CircleListAPP[0]->GetX();
+ // int y = CircleListAPP[0]->GetY();
+ // int w = CircleListAPP[0]->GetWidth();
+ // int h = CircleListAPP[0]->GetHeight();
+ // CircleListImage2->SetAutoEnable(false);
+ // CircleListImage2->SetResizeMode(UIImageView::FILL);
+ // CircleListImage2->SetPosition(x, y, w, h);
+ // CircleListImage2->SetSrc("/user/res/themestyle/circlelist/circleListImage2.bin");
+ // CircleListImage2->SetTouchable(true);
+ // CircleListImage2->SetOnClickListener(presenter_);
+ // CircleListImage2->SetViewIndex(VIEW_INVALID);
+ // CircleListGroup_->Add(CircleListImage2);
+ // }
+ /* -------------------------------------------------------------------------- */
+ if(nullptr == PointImage)
{
- CircleListImage2 = new UIImageView();
- if(nullptr == CircleListImage2)
+ PointImage = new UIImageView();
+ if(nullptr == PointImage)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListImage2 failed!! [%d]", __LINE__);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::PointImage failed!! [%d]", __LINE__);
return;
}
- CircleListImage2->SetPosition(28, 197, 72, 72);
- CircleListImage2->SetSrc("/user/res/themestyle/circlelist/circleListImage2.bin");
- CircleListImage2->SetTouchable(true);
- CircleListImage2->SetOnClickListener(presenter_);
- CircleListImage2->SetViewIndex(VIEW_INVALID);
- CircleListGroup_->Add(CircleListImage2);
+ PointImage->SetPosition(330, 233, 10, 10);
+ PointImage->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ PointImage->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ PointImage->SetStyle(STYLE_BORDER_RADIUS, 200);
+ CircleListGroup_->Add(PointImage);
}
+ /* -------------------------------------------------------------------------- */
if(CircleListSelectImage == nullptr)
{
CircleListSelectImage = new UIImageView();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListSelectImage failed!! [%d]", __LINE__);
return;
}
- CircleListSelectImage->SetPosition(CircleListImage1->GetX() + 30, CircleListImage1->GetY() + 30,160,160);
+ CircleListSelectImage->SetPosition(153, 153,160,160);
CircleListSelectImage->SetAutoEnable(false);
CircleListSelectImage->SetResizeMode(UIImageView::SCALE_DOWN);
CircleListSelectImage->SetSrc(ApplistModel::GetInstance().GetApplistItems()[ApplistModel::GetInstance().GetCurselectImageIndex()].iconLarge);
}
}
CircleListGroup_->SetOnDragListener(static_cast<UIView::OnDragListener*>(AppCircleListOnDragListener_));
- CircleListPicker->RegisterSelectedListener(static_cast<UIPicker::SelectedListener *>(AppCircleListOnDragListener_));
+ CircleListPicker->SetOnRotateListener(static_cast<UIView::OnRotateListener *>(AppCircleListOnDragListener_));
/* -------------------------------------------------------------------------- */
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListStyleOnStart success!! [%d]", __LINE__);
}