Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
9ed1ebb0
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,发现更多精彩内容 >>
提交
9ed1ebb0
编写于
9月 18, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 18, 2021
浏览文件
操作
浏览文件
下载
差异文件
!423 增加旋转表冠惯性滑动控制因子接口
Merge pull request !423 from JayLeeHW/master-rotate-inertial
上级
ee10a2ed
57d9f1d9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
15 deletion
+48
-15
frameworks/components/ui_abstract_scroll.cpp
frameworks/components/ui_abstract_scroll.cpp
+20
-12
interfaces/kits/components/ui_abstract_scroll.h
interfaces/kits/components/ui_abstract_scroll.h
+28
-3
未找到文件。
frameworks/components/ui_abstract_scroll.cpp
浏览文件 @
9ed1ebb0
...
...
@@ -246,28 +246,36 @@ void UIAbstractScroll::CalculateDragDistance(Point currentPos,
if
((
direction_
==
VERTICAL
)
||
(
direction_
==
HORIZONTAL_AND_VERTICAL
))
{
dragDistanceY
=
currentPos
.
y
-
lastPos
.
y
;
if
(
isRotating_
)
{
dragDistanceY
*=
ROTATE_DISTANCE_COEFFICIENT
;
// 255 : uint8 max value
uint8_t
coeff
=
(
rotateAccCoefficient_
>=
255
-
ROTATE_DISTANCE_COEFFICIENT
)
?
255
:
(
ROTATE_DISTANCE_COEFFICIENT
+
rotateAccCoefficient_
);
// 255 : uint8 max value
dragDistanceY
*=
coeff
;
}
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
))
{
dragDistanceY
-=
GetMaxDelta
()
*
GetSwipeACCLevel
()
/
DRAG_ACC_FACTOR
;
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
))
{
dragDistanceY
-=
GetMaxDelta
()
*
GetSwipeACCLevel
()
/
DRAG_ACC_FACTOR
;
}
}
}
if
((
direction_
==
HORIZONTAL
)
||
(
direction_
==
HORIZONTAL_AND_VERTICAL
))
{
dragDistanceX
=
currentPos
.
x
-
lastPos
.
x
;
if
(
isRotating_
)
{
dragDistanceX
*=
ROTATE_DISTANCE_COEFFICIENT
;
// 255 : uint8 max value
uint8_t
coeff
=
(
rotateAccCoefficient_
>=
255
-
ROTATE_DISTANCE_COEFFICIENT
)
?
255
:
(
ROTATE_DISTANCE_COEFFICIENT
+
rotateAccCoefficient_
);
// 255 : uint8 max value
dragDistanceX
*=
coeff
;
}
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
))
{
dragDistanceX
-=
GetMaxDelta
()
*
GetSwipeACCLevel
()
/
DRAG_ACC_FACTOR
;
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
))
{
dragDistanceX
-=
GetMaxDelta
()
*
GetSwipeACCLevel
()
/
DRAG_ACC_FACTOR
;
}
}
}
...
...
interfaces/kits/components/ui_abstract_scroll.h
浏览文件 @
9ed1ebb0
...
...
@@ -223,6 +223,30 @@ public:
}
#if ENABLE_ROTATE_INPUT
/**
* @brief Sets coefficient for rotation dragthrow animation. The view will roll farther with larger coeffcient.
*
* @param value Indicates the coefficient to set. The default value is <b>0</b>.
* @since 1.0
* @version 1.0
*/
void
SetRotateACCLevel
(
uint16_t
value
)
{
rotateAccCoefficient_
=
value
;
}
/**
* @brief Obtains the coefficient for rotation drag throw animation.
*
* @return Returns the coefficient for rotation drag throw animation.
* @since 1.0
* @version 1.0
*/
uint8_t
GetRotateACCLevel
()
const
{
return
rotateAccCoefficient_
;
}
/**
* @brief Obtains the rotation factor.
*
...
...
@@ -252,10 +276,10 @@ public:
}
/**
* @brief 设置触发惯性滑动的组件大小比例阈值.
* @brief Sets threshold for rotation drag throw animation. The view will roll easier with larger threshold.
*
* @param threshold Indicates the rotation factor to set.
*
* @param threshold 设置触发惯性滑动的比例阈值.
* 旋转表冠结束,如果最后一次旋转位移数值大于组件的宽或高除以threshold,则触发惯性滑动.
* @since 6
*/
void
SetRotateThrowThreshold
(
uint8_t
threshold
)
...
...
@@ -434,6 +458,7 @@ protected:
ListAnimatorCallback
animatorCallback_
;
Animator
scrollAnimator_
;
#if ENABLE_ROTATE_INPUT
uint8_t
rotateAccCoefficient_
=
0
;
float
rotateFactor_
;
int16_t
rotateThrowthreshold_
;
int16_t
lastRotateLen_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录