Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
b0f82a1a
G
Graphic Ui
项目概览
OpenHarmony
/
Graphic Ui
大约 1 年 前同步成功
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Graphic Ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b0f82a1a
编写于
9月 10, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 10, 2021
浏览文件
操作
浏览文件
下载
差异文件
!392 修复旋转表冠无惯性滑动问题
Merge pull request !392 from YueBiang/rotate_master
上级
efe76dca
466fe491
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
51 addition
and
40 deletion
+51
-40
frameworks/components/ui_abstract_scroll.cpp
frameworks/components/ui_abstract_scroll.cpp
+23
-11
frameworks/components/ui_list.cpp
frameworks/components/ui_list.cpp
+2
-7
frameworks/components/ui_swipe_view.cpp
frameworks/components/ui_swipe_view.cpp
+3
-9
frameworks/components/ui_time_picker.cpp
frameworks/components/ui_time_picker.cpp
+4
-8
interfaces/kits/components/ui_abstract_scroll.h
interfaces/kits/components/ui_abstract_scroll.h
+7
-3
interfaces/kits/components/ui_list.h
interfaces/kits/components/ui_list.h
+0
-1
interfaces/kits/components/ui_picker.h
interfaces/kits/components/ui_picker.h
+12
-0
interfaces/kits/components/ui_swipe_view.h
interfaces/kits/components/ui_swipe_view.h
+0
-1
未找到文件。
frameworks/components/ui_abstract_scroll.cpp
浏览文件 @
b0f82a1a
...
...
@@ -26,12 +26,6 @@
#include "graphic_timer.h"
#endif
namespace
{
#if ENABLE_ROTATE_INPUT
constexpr
uint8_t
DEFAULT_ROTATE_THRESHOLD
=
4
;
#endif
}
namespace
OHOS
{
#if DEFAULT_ANIMATION
class
BarEaseInOutAnimator
final
:
public
AnimatorCallback
{
...
...
@@ -142,8 +136,9 @@ UIAbstractScroll::UIAbstractScroll()
#endif
#if ENABLE_ROTATE_INPUT
rotateFactor_
=
DEFAULT_SCROLL_VIEW_ROTATE_FACTOR
;
threshold_
=
DEFAULT_ROTATE
_THRESHOLD
;
rotateThrowthreshold_
=
DEFAULT_ROTATE_THROW
_THRESHOLD
;
lastRotateLen_
=
0
;
isRotating_
=
false
;
#endif
isViewGroup_
=
true
;
touchable_
=
true
;
...
...
@@ -249,7 +244,12 @@ void UIAbstractScroll::CalculateDragDistance(Point currentPos,
int16_t
&
dragDistanceY
)
{
if
((
direction_
==
VERTICAL
)
||
(
direction_
==
HORIZONTAL_AND_VERTICAL
))
{
dragDistanceY
=
(
currentPos
.
y
-
lastPos
.
y
)
*
DRAG_DISTANCE_COEFFICIENT
;
dragDistanceY
=
currentPos
.
y
-
lastPos
.
y
;
if
(
isRotating_
)
{
dragDistanceY
*=
ROTATE_DISTANCE_COEFFICIENT
;
}
else
{
dragDistanceY
*=
DRAG_DISTANCE_COEFFICIENT
;
}
if
(
dragDistanceY
>
0
||
(
dragDistanceY
==
0
&&
dragDirection
==
DragEvent
::
DIRECTION_TOP_TO_BOTTOM
))
{
dragDistanceY
+=
GetMaxDelta
()
*
GetSwipeACCLevel
()
/
DRAG_ACC_FACTOR
;
}
else
if
(
dragDistanceY
<
0
||
(
dragDistanceY
==
0
&&
dragDirection
==
DragEvent
::
DIRECTION_BOTTOM_TO_TOP
))
{
...
...
@@ -258,7 +258,12 @@ void UIAbstractScroll::CalculateDragDistance(Point currentPos,
}
if
((
direction_
==
HORIZONTAL
)
||
(
direction_
==
HORIZONTAL_AND_VERTICAL
))
{
dragDistanceX
=
(
currentPos
.
x
-
lastPos
.
x
)
*
DRAG_DISTANCE_COEFFICIENT
;
dragDistanceX
=
currentPos
.
x
-
lastPos
.
x
;
if
(
isRotating_
)
{
dragDistanceX
*=
ROTATE_DISTANCE_COEFFICIENT
;
}
else
{
dragDistanceX
*=
DRAG_DISTANCE_COEFFICIENT
;
}
if
(
dragDistanceX
>
0
||
(
dragDistanceX
==
0
&&
dragDirection
==
DragEvent
::
DIRECTION_LEFT_TO_RIGHT
))
{
dragDistanceX
+=
GetMaxDelta
()
*
GetSwipeACCLevel
()
/
DRAG_ACC_FACTOR
;
}
else
if
(
dragDistanceX
<
0
||
(
dragDistanceX
==
0
&&
dragDirection
==
DragEvent
::
DIRECTION_RIGHT_TO_LEFT
))
{
...
...
@@ -317,6 +322,12 @@ void UIAbstractScroll::ListAnimatorCallback::Callback(UIView* view)
}
#if ENABLE_ROTATE_INPUT
bool
UIAbstractScroll
::
OnRotateStartEvent
(
const
RotateEvent
&
event
)
{
isRotating_
=
true
;
return
UIView
::
OnRotateStartEvent
(
event
);
}
bool
UIAbstractScroll
::
OnRotateEvent
(
const
RotateEvent
&
event
)
{
lastRotateLen_
=
static_cast
<
int16_t
>
(
event
.
GetRotate
()
*
rotateFactor_
);
...
...
@@ -330,6 +341,7 @@ bool UIAbstractScroll::OnRotateEvent(const RotateEvent& event)
bool
UIAbstractScroll
::
OnRotateEndEvent
(
const
RotateEvent
&
event
)
{
isRotating_
=
false
;
if
(
memset_s
(
lastDelta_
,
sizeof
(
lastDelta_
),
0
,
sizeof
(
lastDelta_
))
!=
EOK
)
{
return
UIView
::
OnRotateEndEvent
(
event
);
}
...
...
@@ -340,8 +352,8 @@ bool UIAbstractScroll::OnRotateEndEvent(const RotateEvent& event)
}
else
{
dir
=
(
lastRotateLen_
>=
0
)
?
DragEvent
::
DIRECTION_TOP_TO_BOTTOM
:
DragEvent
::
DIRECTION_BOTTOM_TO_TOP
;
}
bool
triggerAnimator
=
(
MATH_ABS
(
lastRotateLen_
)
>=
(
GetWidth
()
/
threshold_
))
||
(
MATH_ABS
(
lastRotateLen_
)
>=
(
GetHeight
()
/
threshold_
));
bool
triggerAnimator
=
(
MATH_ABS
(
lastRotateLen_
)
>=
(
GetWidth
()
/
rotateThrow
threshold_
))
||
(
MATH_ABS
(
lastRotateLen_
)
>=
(
GetHeight
()
/
rotateThrow
threshold_
));
if
(
throwDrag_
&&
triggerAnimator
)
{
Point
current
;
if
(
direction_
==
HORIZONTAL
)
{
...
...
frameworks/components/ui_list.cpp
浏览文件 @
b0f82a1a
...
...
@@ -169,7 +169,6 @@ UIList::UIList(uint8_t direction)
lastRotateLen_
=
0
;
#endif
#if ENABLE_VIBRATOR
needVibration_
=
false
;
vibratorType_
=
VibratorType
::
VIBRATOR_TYPE_ONE
;
#endif
#if ENABLE_FOCUS_MANAGER
...
...
@@ -240,16 +239,12 @@ bool UIList::OnRotateStartEvent(const RotateEvent& event)
if
(
scrollAnimator_
.
GetState
()
!=
Animator
::
STOP
)
{
UIAbstractScroll
::
StopAnimator
();
}
#if ENABLE_VIBRATOR
needVibration_
=
true
;
#endif
isReCalculateDragEnd_
=
true
;
return
UI
View
::
OnRotateStartEvent
(
event
);
return
UI
AbstractScroll
::
OnRotateStartEvent
(
event
);
}
bool
UIList
::
OnRotateEndEvent
(
const
RotateEvent
&
event
)
{
needVibration_
=
false
;
isReCalculateDragEnd_
=
false
;
return
UIAbstractScroll
::
OnRotateEndEvent
(
event
);
}
...
...
@@ -645,7 +640,7 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
}
#if ENABLE_VIBRATOR
VibratorFunc
vibratorFunc
=
VibratorManager
::
GetInstance
()
->
GetVibratorFunc
();
if
(
isSelectViewFind
&&
needVibration
_
&&
vibratorFunc
!=
nullptr
)
{
if
(
isSelectViewFind
&&
isRotating
_
&&
vibratorFunc
!=
nullptr
)
{
if
(
!
isLoopList_
&&
(
onSelectedIndex_
==
0
||
onSelectedIndex_
==
recycle_
.
adapter_
->
GetCount
()
-
1
))
{
vibratorFunc
(
VibratorType
::
VIBRATOR_TYPE_THREE
);
GRAPHIC_LOGI
(
"UIList::MoveChildByOffset calls TYPE_THREE vibrator"
);
...
...
frameworks/components/ui_swipe_view.cpp
浏览文件 @
b0f82a1a
...
...
@@ -28,7 +28,6 @@ UISwipeView::UISwipeView(uint8_t direction)
#endif
#if ENABLE_VIBRATOR
lastIndex_
=
0
;
needVibration_
=
false
;
#endif
direction_
=
direction
;
tickTime_
=
ANIMATOR_TIME
;
...
...
@@ -199,14 +198,12 @@ bool UISwipeView::OnRotateStartEvent(const RotateEvent& event)
if
(
scrollAnimator_
.
GetState
()
!=
Animator
::
STOP
)
{
UIAbstractScroll
::
StopAnimator
();
}
#if ENABLE_VIBRATOR
needVibration_
=
true
;
#endif
return
UIView
::
OnRotateStartEvent
(
event
);
return
UIAbstractScroll
::
OnRotateStartEvent
(
event
);
}
bool
UISwipeView
::
OnRotateEndEvent
(
const
RotateEvent
&
event
)
{
isRotating_
=
false
;
uint8_t
dir
;
if
(
direction_
==
HORIZONTAL
)
{
dir
=
(
lastRotateLen_
>=
0
)
?
DragEvent
::
DIRECTION_LEFT_TO_RIGHT
:
DragEvent
::
DIRECTION_RIGHT_TO_LEFT
;
...
...
@@ -219,9 +216,6 @@ bool UISwipeView::OnRotateEndEvent(const RotateEvent& event)
}
SwitchToPage
(
curIndex_
);
lastRotateLen_
=
0
;
#if ENABLE_VIBRATOR
needVibration_
=
false
;
#endif
return
UIView
::
OnRotateEndEvent
(
event
);
}
#endif
...
...
@@ -430,7 +424,7 @@ void UISwipeView::RefreshCurrentViewInner(int16_t distance,
}
#if ENABLE_VIBRATOR
VibratorFunc
vibratorFunc
=
VibratorManager
::
GetInstance
()
->
GetVibratorFunc
();
if
(
vibratorFunc
!=
nullptr
&&
needVibration
_
&&
curIndex_
!=
lastIndex_
)
{
if
(
vibratorFunc
!=
nullptr
&&
isRotating
_
&&
curIndex_
!=
lastIndex_
)
{
if
(
!
loop_
&&
(
curIndex_
==
0
||
curIndex_
==
childrenNum_
-
1
))
{
vibratorFunc
(
VibratorType
::
VIBRATOR_TYPE_THREE
);
GRAPHIC_LOGI
(
"UISwipeView::RefreshCurrentViewInner calls TYPE_THREE vibrator"
);
...
...
frameworks/components/ui_time_picker.cpp
浏览文件 @
b0f82a1a
...
...
@@ -143,15 +143,11 @@ void UITimePicker::InitPicker(UIPicker*& picker, int16_t start, int16_t end)
#if ENABLE_ROTATE_INPUT
if
(
end
==
HOUR_END
)
{
picker
->
GetChildrenHead
()
->
SetViewId
(
HOUR_LIST_NAME
);
return
;
}
else
if
(
end
==
MIN_END
)
{
if
(
minutePicker_
->
GetChildById
(
MIN_LIST_NAME
)
==
nullptr
)
{
picker
->
GetChildrenHead
()
->
SetViewId
(
MIN_LIST_NAME
);
return
;
}
}
else
if
(
end
==
MIN_END
&&
secondPicker_
==
nullptr
)
{
picker
->
GetChildrenHead
()
->
SetViewId
(
MIN_LIST_NAME
);
}
else
if
(
end
==
SEC_END
)
{
picker
->
GetChildrenHead
()
->
SetViewId
(
SEC_LIST_NAME
);
}
picker
->
GetChildrenHead
()
->
SetViewId
(
SEC_LIST_NAME
);
return
;
#endif
}
...
...
interfaces/kits/components/ui_abstract_scroll.h
浏览文件 @
b0f82a1a
...
...
@@ -255,16 +255,19 @@ public:
* @brief 设置触发惯性滑动的组件大小比例阈值.
*
* @param threshold 设置触发惯性滑动的比例阈值.
* 旋转表冠结束,如果最后一次旋转位移数值大于组件的宽或高除以threshold,则触发惯性滑动.
* @since 6
*/
void
SetRotateThreshold
(
uint8_t
threshold
)
void
SetRotateThr
owThr
eshold
(
uint8_t
threshold
)
{
if
(
threshold
==
0
)
{
return
;
}
threshold_
=
threshold
;
rotateThrow
threshold_
=
threshold
;
}
bool
OnRotateStartEvent
(
const
RotateEvent
&
event
)
override
;
bool
OnRotateEvent
(
const
RotateEvent
&
event
)
override
;
bool
OnRotateEndEvent
(
const
RotateEvent
&
event
)
override
;
...
...
@@ -435,8 +438,9 @@ protected:
Animator
scrollAnimator_
;
#if ENABLE_ROTATE_INPUT
float
rotateFactor_
;
int16_t
threshold_
;
int16_t
rotateThrow
threshold_
;
int16_t
lastRotateLen_
;
bool
isRotating_
;
#endif
bool
yScrollBarVisible_
=
false
;
UIAbstractScrollBar
*
yScrollBar_
=
nullptr
;
...
...
interfaces/kits/components/ui_list.h
浏览文件 @
b0f82a1a
...
...
@@ -467,7 +467,6 @@ private:
void
FixHorDistance
(
int16_t
&
distanceX
);
void
FixVerDistance
(
int16_t
&
distanceY
);
#if ENABLE_VIBRATOR
bool
needVibration_
;
void
SetMotorType
(
VibratorType
vibratorType
);
VibratorType
vibratorType_
;
#endif
...
...
interfaces/kits/components/ui_picker.h
浏览文件 @
b0f82a1a
...
...
@@ -455,6 +455,18 @@ public:
{
return
list_
.
GetRotateFactor
();
}
/**
* @brief 设置触发惯性滑动的组件大小比例阈值.
*
* @param threshold 设置触发惯性滑动的比例阈值.
* 旋转表冠结束,如果最后一次旋转位移数值大于组件的宽或高除以threshold,则触发惯性滑动.
* @since 6
*/
void
SetRotateThrowThreshold
(
uint8_t
threshold
)
{
list_
.
SetRotateThrowThreshold
(
threshold
);
}
#endif
protected:
...
...
interfaces/kits/components/ui_swipe_view.h
浏览文件 @
b0f82a1a
...
...
@@ -366,7 +366,6 @@ protected:
bool
loop_
;
#if ENABLE_VIBRATOR
uint16_t
lastIndex_
;
bool
needVibration_
;
#endif
private:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录