#include "themestyle/include/ThemeStyleModel.h"
#include "ModelListenerSample.h"
#include "cmath"
+#include "../../../../../../drivers/peripheral/vibrator/service/vibrator_service.h"
namespace OHOS {
static constexpr int16 NUM_2 = 2;
delete CircleListPicker;
CircleListPicker = nullptr;
}
+ if(CircleListScrollView)
+ {
+ delete CircleListScrollView;
+ CircleListScrollView = nullptr;
+ }
for(int i = 0;i < CircleListAPPNum;i++)
{
if(nullptr != CircleListAPP[i])
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 constexpr int angleIncrement = 6;
// 圆形表的圆心坐标和半径
static const int CIRCLE_CENTER_X = 233;
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);
if(angle % 30 == 0) //不需要补偿角度
{
OnDragEndFlag = 0;
+ if(isEncoderEvent) {
+ isEncoderEvent = false;
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "震动一次");
+ ui_api_vibrate_once_func();
+ }
}
else
{
#endif
}
+ bool OnRotateStart(UIView& view, const RotateEvent& event)
+ {
+ return false;
+ }
+
bool OnRotate(UIView& view, const RotateEvent& event)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AppCircleListOnDragListener::OnRotate %d",event.GetRotate());
- if(event.GetRotate() > 0)
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnRotate回调次数%d",++RotateReportedCount);
+ isEncoderEvent = true;
+ isDragEvent = false;
+ if(RotateReportedCount > 4)
{
- 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);
+ 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();
+ }
}
-
return false;
}
bool OnRotateEnd(UIView& view, const RotateEvent& event)
{
OnDragEndFlag = 1;
}
+ RotateReportedCount = 0;
+ rotateangle = 0;
return false;
}
bool isDirectRotateFlag{false}; //是否是正向旋转的标志
int preX{0};
int preY{0};
+
+ bool isEncoderEvent{false}; //是否为编码器事件
+ bool isDragEvent{false}; //是否为拖拽事件
+ int RotateReportedCount{0};
};
void ApplistView::CircleListStyleOnStart(void)
int end = 3;
CircleListPicker->SetValues(start,end);
// printf("---%d\n",CircleListPicker->GetSelected());
- CircleListGroup_->Add(CircleListPicker);
+ // CircleListGroup_->Add(CircleListPicker);
+ }
+ /* -------------------------------------------------------------------------- */
+ if(CircleListScrollView == nullptr)
+ {
+ CircleListScrollView = new UIScrollView();
+ if(nullptr == CircleListScrollView)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListScrollView failed!! [%d]", __LINE__);
+ return;
+ }
+ CircleListScrollView->SetPosition(213, 213, 40, 40);
+ CircleListScrollView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ CircleListScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+ CircleListScrollView->SetStyle(STYLE_BORDER_RADIUS, 150);
+ CircleListScrollView->SetRotateFactor(1.0);
+ CircleListScrollView->RequestFocus();
+ CircleListGroup_->Add(CircleListScrollView);
}
/* -------------------------------------------------------------------------- */
// if(CircleListImage1 == nullptr)
}
}
CircleListGroup_->SetOnDragListener(static_cast<UIView::OnDragListener*>(AppCircleListOnDragListener_));
- CircleListPicker->SetOnRotateListener(static_cast<UIView::OnRotateListener *>(AppCircleListOnDragListener_));
+ CircleListScrollView->SetOnRotateListener(static_cast<UIView::OnRotateListener *>(AppCircleListOnDragListener_));
/* -------------------------------------------------------------------------- */
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistView::CircleListStyleOnStart success!! [%d]", __LINE__);
}