Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
da44ea90
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,发现更多精彩内容 >>
提交
da44ea90
编写于
9月 28, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 28, 2021
浏览文件
操作
浏览文件
下载
差异文件
!445 修复 rotate 惯性滑动
Merge pull request !445 from guyuanzhang/rotate
上级
7913c878
3dd4074c
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
112 addition
and
91 deletion
+112
-91
frameworks/components/ui_abstract_scroll.cpp
frameworks/components/ui_abstract_scroll.cpp
+54
-27
frameworks/components/ui_list.cpp
frameworks/components/ui_list.cpp
+0
-4
frameworks/components/ui_scroll_view.cpp
frameworks/components/ui_scroll_view.cpp
+10
-20
frameworks/components/ui_slider.cpp
frameworks/components/ui_slider.cpp
+10
-10
frameworks/components/ui_swipe_view.cpp
frameworks/components/ui_swipe_view.cpp
+9
-16
interfaces/kits/components/ui_abstract_scroll.h
interfaces/kits/components/ui_abstract_scroll.h
+15
-2
interfaces/kits/components/ui_scroll_view.h
interfaces/kits/components/ui_scroll_view.h
+0
-2
interfaces/kits/components/ui_swipe_view.h
interfaces/kits/components/ui_swipe_view.h
+0
-2
test/uitest/test_rotate_input/ui_test_rotate_input.cpp
test/uitest/test_rotate_input/ui_test_rotate_input.cpp
+14
-8
未找到文件。
frameworks/components/ui_abstract_scroll.cpp
浏览文件 @
da44ea90
...
...
@@ -39,7 +39,9 @@ public:
BarEaseInOutAnimator
(
UIAbstractScroll
&
scrollView
)
:
scrollView_
(
scrollView
),
timer_
(
APPEAR_PERIOD
,
TimerCb
,
this
),
animator_
(
this
,
nullptr
,
ANIMATOR_DURATION
,
false
)
{}
animator_
(
this
,
nullptr
,
ANIMATOR_DURATION
,
false
)
{
}
~
BarEaseInOutAnimator
()
{
...
...
@@ -88,8 +90,7 @@ private:
if
(
scrollView_
.
yScrollBarVisible_
)
{
scrollView_
.
yScrollBar_
->
SetOpacity
(
OPA_OPAQUE
);
}
if
(
Screen
::
GetInstance
().
GetScreenShape
()
==
ScreenShape
::
RECTANGLE
&&
scrollView_
.
xScrollBarVisible_
)
{
if
(
Screen
::
GetInstance
().
GetScreenShape
()
==
ScreenShape
::
RECTANGLE
&&
scrollView_
.
xScrollBarVisible_
)
{
scrollView_
.
xScrollBar_
->
SetOpacity
(
OPA_OPAQUE
);
}
timer_
.
Start
();
// The timer is triggered when animation stops.
...
...
@@ -124,6 +125,7 @@ private:
UIAbstractScroll
::
UIAbstractScroll
()
:
direction_
(
VERTICAL
),
deltaIndex_
(
0
),
rotateIndex_
(
0
),
reserve_
(
0
),
easingFunc_
(
EasingEquation
::
CubicEaseOut
),
scrollAnimator_
(
&
animatorCallback_
,
this
,
0
,
true
),
...
...
@@ -137,7 +139,6 @@ UIAbstractScroll::UIAbstractScroll()
#if ENABLE_ROTATE_INPUT
rotateFactor_
=
DEFAULT_SCROLL_VIEW_ROTATE_FACTOR
;
rotateThrowthreshold_
=
DEFAULT_ROTATE_THROW_THRESHOLD
;
lastRotateLen_
=
0
;
isRotating_
=
false
;
#endif
isViewGroup_
=
true
;
...
...
@@ -192,6 +193,31 @@ int16_t UIAbstractScroll::GetMaxDelta() const
return
result
;
}
int16_t
UIAbstractScroll
::
GetMaxRotate
()
const
{
int16_t
result
=
0
;
for
(
int16_t
i
=
0
;
i
<
MAX_DELTA_SIZE
;
i
++
)
{
if
(
MATH_ABS
(
result
)
<
MATH_ABS
(
lastRotate_
[
i
]))
{
result
=
lastRotate_
[
i
];
}
}
return
result
;
}
void
UIAbstractScroll
::
InitDelta
()
{
if
(
memset_s
(
lastDelta_
,
sizeof
(
lastDelta_
),
0
,
sizeof
(
lastDelta_
))
!=
EOK
)
{
GRAPHIC_LOGE
(
"memset_s error"
);
}
}
void
UIAbstractScroll
::
InitRotate
()
{
if
(
memset_s
(
lastRotate_
,
sizeof
(
lastRotate_
),
0
,
sizeof
(
lastRotate_
))
!=
EOK
)
{
GRAPHIC_LOGE
(
"memset_s error"
);
}
}
void
UIAbstractScroll
::
StopAnimator
()
{
scrollAnimator_
.
Stop
();
...
...
@@ -199,10 +225,7 @@ void UIAbstractScroll::StopAnimator()
isDragging_
=
false
;
}
bool
UIAbstractScroll
::
DragThrowAnimator
(
Point
currentPos
,
Point
lastPos
,
uint8_t
dragDirection
,
bool
dragBack
)
bool
UIAbstractScroll
::
DragThrowAnimator
(
Point
currentPos
,
Point
lastPos
,
uint8_t
dragDirection
,
bool
dragBack
)
{
if
(
!
throwDrag_
&&
(
reboundSize_
==
0
))
{
return
false
;
...
...
@@ -248,7 +271,8 @@ void UIAbstractScroll::CalculateDragDistance(Point currentPos,
if
(
isRotating_
)
{
// 255 : uint8 max value
uint8_t
coeff
=
(
rotateAccCoefficient_
>=
255
-
ROTATE_DISTANCE_COEFFICIENT
)
?
255
:
(
ROTATE_DISTANCE_COEFFICIENT
+
rotateAccCoefficient_
);
// 255 : uint8 max value
255
:
// 255 : uint8 max value
(
ROTATE_DISTANCE_COEFFICIENT
+
rotateAccCoefficient_
);
dragDistanceY
*=
coeff
;
}
else
{
dragDistanceY
*=
DRAG_DISTANCE_COEFFICIENT
;
...
...
@@ -266,7 +290,8 @@ void UIAbstractScroll::CalculateDragDistance(Point currentPos,
if
(
isRotating_
)
{
// 255 : uint8 max value
uint8_t
coeff
=
(
rotateAccCoefficient_
>=
255
-
ROTATE_DISTANCE_COEFFICIENT
)
?
255
:
(
ROTATE_DISTANCE_COEFFICIENT
+
rotateAccCoefficient_
);
// 255 : uint8 max value
255
:
// 255 : uint8 max value
(
ROTATE_DISTANCE_COEFFICIENT
+
rotateAccCoefficient_
);
dragDistanceX
*=
coeff
;
}
else
{
dragDistanceX
*=
DRAG_DISTANCE_COEFFICIENT
;
...
...
@@ -333,47 +358,49 @@ void UIAbstractScroll::ListAnimatorCallback::Callback(UIView* view)
bool
UIAbstractScroll
::
OnRotateStartEvent
(
const
RotateEvent
&
event
)
{
isRotating_
=
true
;
if
(
scrollAnimator_
.
GetState
()
!=
Animator
::
STOP
)
{
UIAbstractScroll
::
StopAnimator
();
}
return
UIView
::
OnRotateStartEvent
(
event
);
}
bool
UIAbstractScroll
::
OnRotateEvent
(
const
RotateEvent
&
event
)
{
lastRotateLen_
=
static_cast
<
int16_t
>
(
event
.
GetRotate
()
*
rotateFactor_
);
int16_t
rotateLen
=
static_cast
<
int16_t
>
(
event
.
GetRotate
()
*
rotateFactor_
);
RefreshRotate
(
rotateLen
);
if
(
direction_
==
HORIZONTAL
)
{
DragXInner
(
lastRotateLen_
);
DragXInner
(
rotateLen
);
}
else
{
DragYInner
(
lastRotateLen_
);
DragYInner
(
rotateLen
);
}
return
UIView
::
OnRotateEvent
(
event
);
}
bool
UIAbstractScroll
::
OnRotateEndEvent
(
const
RotateEvent
&
event
)
{
isRotating_
=
false
;
if
(
memset_s
(
lastDelta_
,
sizeof
(
lastDelta_
),
0
,
sizeof
(
lastDelta_
))
!=
EOK
)
{
return
UIView
::
OnRotateEndEvent
(
event
);
}
InitDelta
();
uint8_t
dir
;
int16_t
lastRotateLen
=
GetMaxRotate
();
if
(
direction_
==
HORIZONTAL
)
{
dir
=
(
lastRotateLen
_
>=
0
)
?
DragEvent
::
DIRECTION_LEFT_TO_RIGHT
:
DragEvent
::
DIRECTION_RIGHT_TO_LEFT
;
dir
=
(
lastRotateLen
>=
0
)
?
DragEvent
::
DIRECTION_LEFT_TO_RIGHT
:
DragEvent
::
DIRECTION_RIGHT_TO_LEFT
;
}
else
{
dir
=
(
lastRotateLen
_
>=
0
)
?
DragEvent
::
DIRECTION_TOP_TO_BOTTOM
:
DragEvent
::
DIRECTION_BOTTOM_TO_TOP
;
dir
=
(
lastRotateLen
>=
0
)
?
DragEvent
::
DIRECTION_TOP_TO_BOTTOM
:
DragEvent
::
DIRECTION_BOTTOM_TO_TOP
;
}
bool
triggerAnimator
=
(
MATH_ABS
(
lastRotateLen_
)
>=
(
GetWidth
()
/
rotateThrowthreshold_
))
||
(
MATH_ABS
(
lastRotateLen_
)
>=
(
GetHeight
()
/
rotateThrowthreshold_
));
bool
triggerAnimator
=
(
MATH_ABS
(
lastRotateLen
)
>=
rotateThrowthreshold_
);
if
(
throwDrag_
&&
triggerAnimator
)
{
Point
current
;
if
(
direction_
==
HORIZONTAL
)
{
current
=
{
lastRotateLen
_
,
0
};
current
=
{
lastRotateLen
,
0
};
}
else
{
current
=
{
0
,
lastRotateLen
_
};
current
=
{
0
,
lastRotateLen
};
}
DragThrowAnimator
(
current
,
{
0
,
0
},
dir
,
dragBack_
);
}
else
{
DragThrowAnimator
({
0
,
0
},
{
0
,
0
},
dir
,
dragBack_
);
}
lastRotateLen_
=
0
;
isRotating_
=
false
;
InitRotate
();
return
UIView
::
OnRotateEndEvent
(
event
);
}
#endif
...
...
@@ -420,8 +447,8 @@ void UIAbstractScroll::OnPostDraw(BufferInfo& gfxDstBuffer, const Rect& invalida
yScrollBar_
->
SetPosition
(
scrollRect
.
GetRight
()
-
SCROLL_BAR_WIDTH
+
1
,
scrollRect
.
GetTop
(),
SCROLL_BAR_WIDTH
,
scrollRect
.
GetHeight
());
}
else
{
yScrollBar_
->
SetPosition
(
scrollRect
.
GetLeft
(),
scrollRect
.
GetTop
(),
SCROLL_BAR_WIDTH
,
scrollRect
.
GetHeight
());
yScrollBar_
->
SetPosition
(
scrollRect
.
GetLeft
(),
scrollRect
.
GetTop
(),
SCROLL_BAR_WIDTH
,
scrollRect
.
GetHeight
());
}
yScrollBar_
->
OnDraw
(
gfxDstBuffer
,
invalidatedArea
,
opa
);
}
...
...
@@ -445,7 +472,7 @@ void UIAbstractScroll::OnPostDraw(BufferInfo& gfxDstBuffer, const Rect& invalida
x
=
scrollRect
.
GetX
()
+
scrollBarCenter_
.
x
;
y
=
scrollRect
.
GetY
()
+
scrollBarCenter_
.
y
;
}
else
{
x
=
scrollRect
.
GetX
()
+
(
GetWidth
()
/
2
);
// 2: half
x
=
scrollRect
.
GetX
()
+
(
GetWidth
()
/
2
);
// 2: half
y
=
scrollRect
.
GetY
()
+
(
GetHeight
()
/
2
);
// 2: half
}
yScrollBar_
->
SetPosition
(
x
,
y
,
SCROLL_BAR_WIDTH
,
GetWidth
()
/
2
);
// 2: half
...
...
frameworks/components/ui_list.cpp
浏览文件 @
da44ea90
...
...
@@ -166,7 +166,6 @@ UIList::UIList(uint8_t direction)
{
#if ENABLE_ROTATE_INPUT
rotateFactor_
=
DEFAULT_LIST_ROTATE_FACTOR
;
lastRotateLen_
=
0
;
#endif
#if ENABLE_FOCUS_MANAGER
focusable_
=
true
;
...
...
@@ -233,9 +232,6 @@ bool UIList::OnPressEvent(const PressEvent& event)
#if ENABLE_ROTATE_INPUT
bool
UIList
::
OnRotateStartEvent
(
const
RotateEvent
&
event
)
{
if
(
scrollAnimator_
.
GetState
()
!=
Animator
::
STOP
)
{
UIAbstractScroll
::
StopAnimator
();
}
isReCalculateDragEnd_
=
true
;
return
UIAbstractScroll
::
OnRotateStartEvent
(
event
);
}
...
...
frameworks/components/ui_scroll_view.cpp
浏览文件 @
da44ea90
...
...
@@ -22,12 +22,10 @@
#include "gfx_utils/graphic_log.h"
namespace
OHOS
{
UIScrollView
::
UIScrollView
()
:
scrollListener_
(
nullptr
)
UIScrollView
::
UIScrollView
()
:
scrollListener_
(
nullptr
)
{
#if ENABLE_ROTATE_INPUT
rotateFactor_
=
DEFAULT_SCROLL_VIEW_ROTATE_FACTOR
;
lastRotateLen_
=
0
;
#endif
#if ENABLE_VIBRATOR
totalRotateLen_
=
0
;
...
...
@@ -87,20 +85,12 @@ bool UIScrollView::OnPressEvent(const PressEvent& event)
}
#if ENABLE_ROTATE_INPUT
bool
UIScrollView
::
OnRotateStartEvent
(
const
RotateEvent
&
event
)
{
if
(
scrollAnimator_
.
GetState
()
!=
Animator
::
STOP
)
{
UIAbstractScroll
::
StopAnimator
();
}
return
UIView
::
OnRotateStartEvent
(
event
);
}
bool
UIScrollView
::
OnRotateEvent
(
const
RotateEvent
&
event
)
{
if
(
direction_
==
HORIZONTAL_NOR_VERTICAL
)
{
return
UIView
::
OnRotateEvent
(
event
);
}
lastRotateLen_
=
static_cast
<
int16_t
>
(
event
.
GetRotate
()
*
rotateFactor_
);
int16_t
rotateLen
=
static_cast
<
int16_t
>
(
event
.
GetRotate
()
*
rotateFactor_
);
#if ENABLE_VIBRATOR
bool
lastIsEdge
=
false
;
Rect
childRect
=
GetAllChildRelativeRect
();
...
...
@@ -114,13 +104,14 @@ bool UIScrollView::OnRotateEvent(const RotateEvent& event)
}
}
#endif
RefreshRotate
(
rotateLen
);
if
(
direction_
==
HORIZONTAL
)
{
DragXInner
(
lastRotateLen_
);
DragXInner
(
rotateLen
);
}
else
{
DragYInner
(
lastRotateLen_
);
DragYInner
(
rotateLen
);
}
#if ENABLE_VIBRATOR
totalRotateLen_
+=
lastRotateLen_
;
totalRotateLen_
+=
rotateLen
;
childRect
=
GetAllChildRelativeRect
();
bool
isEdge
=
false
;
if
(
direction_
==
HORIZONTAL
)
{
...
...
@@ -230,9 +221,9 @@ bool UIScrollView::DragYInner(int16_t distance)
int16_t
childBottom
=
childRect
.
GetBottom
();
int16_t
scrollHeight
=
GetHeight
();
if
(
childBottom
<
scrollHeight
-
(
scrollBlankSize_
+
reboundSize
))
{
distance
=
0
;
distance
=
0
;
}
else
if
(
childBottom
+
distance
<
scrollHeight
-
(
scrollBlankSize_
+
reboundSize
))
{
distance
=
scrollHeight
-
(
scrollBlankSize_
+
reboundSize
)
-
childBottom
-
1
;
distance
=
scrollHeight
-
(
scrollBlankSize_
+
reboundSize
)
-
childBottom
-
1
;
}
}
...
...
@@ -266,8 +257,7 @@ void UIScrollView::RefreshScrollBar()
if
(
yScrollBarVisible_
)
{
yScrollBar_
->
SetForegroundProportion
(
static_cast
<
float
>
(
len
)
/
totalLen
);
/* calculate scrolling progress */
yScrollBar_
->
SetScrollProgress
(
static_cast
<
float
>
(
scrollBlankSize_
-
childrenRect
.
GetTop
())
/
(
totalLen
-
len
));
yScrollBar_
->
SetScrollProgress
(
static_cast
<
float
>
(
scrollBlankSize_
-
childrenRect
.
GetTop
())
/
(
totalLen
-
len
));
}
if
(
xScrollBarVisible_
)
{
/* so do x-bar */
...
...
@@ -275,7 +265,7 @@ void UIScrollView::RefreshScrollBar()
len
=
GetWidth
();
xScrollBar_
->
SetForegroundProportion
(
static_cast
<
float
>
(
len
)
/
totalLen
);
xScrollBar_
->
SetScrollProgress
(
static_cast
<
float
>
(
scrollBlankSize_
-
childrenRect
.
GetLeft
())
/
(
totalLen
-
len
));
(
totalLen
-
len
));
}
RefreshAnimator
();
}
...
...
frameworks/components/ui_slider.cpp
浏览文件 @
da44ea90
...
...
@@ -14,6 +14,7 @@
*/
#include "components/ui_slider.h"
#include "common/image.h"
#include "dock/focus_manager.h"
#include "dock/vibrator_manager.h"
...
...
@@ -24,8 +25,7 @@
#include "themes/theme_manager.h"
namespace
OHOS
{
UISlider
::
UISlider
()
:
knobWidth_
(
0
),
knobStyleAllocFlag_
(
false
),
knobImage_
(
nullptr
),
listener_
(
nullptr
)
UISlider
::
UISlider
()
:
knobWidth_
(
0
),
knobStyleAllocFlag_
(
false
),
knobImage_
(
nullptr
),
listener_
(
nullptr
)
{
touchable_
=
true
;
draggable_
=
true
;
...
...
@@ -121,25 +121,25 @@ void UISlider::DrawKnob(BufferInfo& gfxDstBuffer, const Rect& invalidatedArea, c
case
Direction
::
DIR_LEFT_TO_RIGHT
:
{
offset
=
(
knobWidth_
-
progressHeight_
)
/
2
;
// 2: half
knobBar
.
SetRect
(
foregroundRect
.
GetRight
()
-
halfKnobWidth
,
foregroundRect
.
GetTop
()
-
offset
,
foregroundRect
.
GetRight
()
+
halfKnobWidth
,
foregroundRect
.
GetBottom
()
+
offset
);
foregroundRect
.
GetRight
()
+
halfKnobWidth
,
foregroundRect
.
GetBottom
()
+
offset
);
break
;
}
case
Direction
::
DIR_RIGHT_TO_LEFT
:
{
offset
=
(
knobWidth_
-
progressHeight_
)
/
2
;
// 2: half
knobBar
.
SetRect
(
foregroundRect
.
GetLeft
()
-
halfKnobWidth
,
foregroundRect
.
GetTop
()
-
offset
,
foregroundRect
.
GetLeft
()
+
halfKnobWidth
,
foregroundRect
.
GetBottom
()
+
offset
);
foregroundRect
.
GetLeft
()
+
halfKnobWidth
,
foregroundRect
.
GetBottom
()
+
offset
);
break
;
}
case
Direction
::
DIR_BOTTOM_TO_TOP
:
{
offset
=
(
knobWidth_
-
progressWidth_
)
/
2
;
// 2: half
knobBar
.
SetRect
(
foregroundRect
.
GetLeft
()
-
offset
,
foregroundRect
.
GetTop
()
-
halfKnobWidth
,
foregroundRect
.
GetRight
()
+
offset
,
foregroundRect
.
GetTop
()
+
halfKnobWidth
);
foregroundRect
.
GetRight
()
+
offset
,
foregroundRect
.
GetTop
()
+
halfKnobWidth
);
break
;
}
case
Direction
::
DIR_TOP_TO_BOTTOM
:
{
offset
=
(
knobWidth_
-
progressWidth_
)
/
2
;
// 2: half
knobBar
.
SetRect
(
foregroundRect
.
GetLeft
()
-
offset
,
foregroundRect
.
GetBottom
()
-
halfKnobWidth
,
foregroundRect
.
GetRight
()
+
offset
,
foregroundRect
.
GetBottom
()
+
halfKnobWidth
);
foregroundRect
.
GetRight
()
+
offset
,
foregroundRect
.
GetBottom
()
+
halfKnobWidth
);
break
;
}
default:
{
...
...
@@ -201,7 +201,7 @@ void UISlider::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invalidatedA
case
Direction
::
DIR_LEFT_TO_RIGHT
:
{
length
=
GetCurrentPos
(
progressWidth_
+
1
);
foregroundRect
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth
-
1
,
startPoint
.
y
+
progressHeight_
-
1
);
startPoint
.
y
+
progressHeight_
-
1
);
left
=
startPoint
.
x
-
radius
-
1
;
right
=
left
+
length
;
...
...
@@ -211,7 +211,7 @@ void UISlider::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invalidatedA
case
Direction
::
DIR_RIGHT_TO_LEFT
:
{
length
=
GetCurrentPos
(
progressWidth_
+
1
);
foregroundRect
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth
-
1
,
startPoint
.
y
+
progressHeight_
-
1
);
startPoint
.
y
+
progressHeight_
-
1
);
right
=
startPoint
.
x
+
progressWidth
+
radius
+
1
;
left
=
right
-
length
;
...
...
@@ -221,7 +221,7 @@ void UISlider::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invalidatedA
case
Direction
::
DIR_TOP_TO_BOTTOM
:
{
length
=
GetCurrentPos
(
progressHeight_
+
1
);
foregroundRect
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth_
-
1
,
startPoint
.
y
+
progressHeight
-
1
);
startPoint
.
y
+
progressHeight
-
1
);
top
=
startPoint
.
y
-
radius
-
1
;
bottom
=
top
+
length
;
...
...
@@ -231,7 +231,7 @@ void UISlider::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invalidatedA
case
Direction
::
DIR_BOTTOM_TO_TOP
:
{
length
=
GetCurrentPos
(
progressHeight_
+
1
);
foregroundRect
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth_
-
1
,
startPoint
.
y
+
progressHeight
-
1
);
startPoint
.
y
+
progressHeight
-
1
);
bottom
=
startPoint
.
y
+
progressHeight
+
radius
+
1
;
top
=
bottom
-
length
;
...
...
frameworks/components/ui_swipe_view.cpp
浏览文件 @
da44ea90
...
...
@@ -24,7 +24,6 @@ UISwipeView::UISwipeView(uint8_t direction)
{
#if ENABLE_ROTATE_INPUT
rotateFactor_
=
DEFAULT_SWIPE_VIEW_ROTATE_FACTOR
;
lastRotateLen_
=
0
;
#endif
direction_
=
direction
;
tickTime_
=
ANIMATOR_TIME
;
...
...
@@ -193,22 +192,16 @@ bool UISwipeView::OnDragEndEvent(const DragEvent& event)
}
#if ENABLE_ROTATE_INPUT
bool
UISwipeView
::
OnRotateStartEvent
(
const
RotateEvent
&
event
)
{
if
(
scrollAnimator_
.
GetState
()
!=
Animator
::
STOP
)
{
UIAbstractScroll
::
StopAnimator
();
}
return
UIAbstractScroll
::
OnRotateStartEvent
(
event
);
}
bool
UISwipeView
::
OnRotateEvent
(
const
RotateEvent
&
event
)
{
lastRotateLen_
=
static_cast
<
int16_t
>
(
event
.
GetRotate
()
*
rotateFactor_
);
int16_t
rotateLen
=
static_cast
<
int16_t
>
(
event
.
GetRotate
()
*
rotateFactor_
);
RefreshRotate
(
rotateLen
);
if
(
direction_
==
HORIZONTAL
)
{
DragXInner
(
lastRotateLen_
);
DragXInner
(
rotateLen
);
RefreshCurrentViewByPosition
(
&
UIView
::
GetX
,
&
UIView
::
GetWidthWithMargin
);
}
else
{
DragYInner
(
lastRotateLen_
);
DragYInner
(
rotateLen
);
RefreshCurrentViewByPosition
(
&
UIView
::
GetY
,
&
UIView
::
GetHeightWithMargin
);
}
...
...
@@ -218,21 +211,21 @@ bool UISwipeView::OnRotateEvent(const RotateEvent& event)
bool
UISwipeView
::
OnRotateEndEvent
(
const
RotateEvent
&
event
)
{
uint8_t
dir
;
int16_t
lastRotateLen
=
GetMaxRotate
();
if
(
direction_
==
HORIZONTAL
)
{
dir
=
(
lastRotateLen
_
>=
0
)
?
DragEvent
::
DIRECTION_LEFT_TO_RIGHT
:
DragEvent
::
DIRECTION_RIGHT_TO_LEFT
;
dir
=
(
lastRotateLen
>=
0
)
?
DragEvent
::
DIRECTION_LEFT_TO_RIGHT
:
DragEvent
::
DIRECTION_RIGHT_TO_LEFT
;
}
else
{
dir
=
(
lastRotateLen
_
>=
0
)
?
DragEvent
::
DIRECTION_TOP_TO_BOTTOM
:
DragEvent
::
DIRECTION_BOTTOM_TO_TOP
;
dir
=
(
lastRotateLen
>=
0
)
?
DragEvent
::
DIRECTION_TOP_TO_BOTTOM
:
DragEvent
::
DIRECTION_BOTTOM_TO_TOP
;
}
if
(
direction_
==
HORIZONTAL
)
{
RefreshCurrentViewByThrow
(
lastRotateLen
_
,
dir
,
&
UIView
::
GetX
,
&
UIView
::
GetWidthWithMargin
);
RefreshCurrentViewByThrow
(
lastRotateLen
,
dir
,
&
UIView
::
GetX
,
&
UIView
::
GetWidthWithMargin
);
}
else
{
RefreshCurrentViewByThrow
(
lastRotateLen
_
,
dir
,
&
UIView
::
GetY
,
&
UIView
::
GetHeightWithMargin
);
RefreshCurrentViewByThrow
(
lastRotateLen
,
dir
,
&
UIView
::
GetY
,
&
UIView
::
GetHeightWithMargin
);
}
if
(
curView_
==
nullptr
)
{
return
UIView
::
OnRotateEndEvent
(
event
);
}
SwitchToPage
(
curIndex_
);
lastRotateLen_
=
0
;
isRotating_
=
false
;
return
UIView
::
OnRotateEndEvent
(
event
);
}
...
...
interfaces/kits/components/ui_abstract_scroll.h
浏览文件 @
da44ea90
...
...
@@ -428,6 +428,16 @@ protected:
deltaIndex_
++
;
}
void
InitDelta
();
void
RefreshRotate
(
int16_t
distance
)
{
lastRotate_
[
rotateIndex_
%
MAX_DELTA_SIZE
]
=
distance
;
rotateIndex_
++
;
}
void
InitRotate
();
virtual
void
CalculateDragDistance
(
Point
currentPos
,
Point
lastPos
,
uint8_t
dragDirection
,
...
...
@@ -440,6 +450,8 @@ protected:
int16_t
GetMaxDelta
()
const
;
int16_t
GetMaxRotate
()
const
;
void
RefreshAnimator
();
virtual
void
FixDistance
(
int16_t
&
distanceX
,
int16_t
&
distanceY
)
{}
...
...
@@ -448,11 +460,13 @@ protected:
uint16_t
reboundSize_
=
0
;
uint16_t
maxScrollDistance_
=
0
;
int16_t
lastDelta_
[
MAX_DELTA_SIZE
]
=
{
0
};
int16_t
lastRotate_
[
MAX_DELTA_SIZE
]
=
{
0
};
uint8_t
dragAccCoefficient_
=
DRAG_ACC_FACTOR
;
uint8_t
swipeAccCoefficient_
=
0
;
uint8_t
direction_
:
2
;
uint8_t
deltaIndex_
:
2
;
uint8_t
reserve_
:
4
;
uint8_t
rotateIndex_
:
2
;
uint8_t
reserve_
:
2
;
bool
throwDrag_
=
false
;
EasingFunc
easingFunc_
;
ListAnimatorCallback
animatorCallback_
;
...
...
@@ -461,7 +475,6 @@ protected:
uint8_t
rotateAccCoefficient_
=
0
;
float
rotateFactor_
;
int16_t
rotateThrowthreshold_
;
int16_t
lastRotateLen_
;
bool
isRotating_
;
#endif
bool
yScrollBarVisible_
=
false
;
...
...
interfaces/kits/components/ui_scroll_view.h
浏览文件 @
da44ea90
...
...
@@ -143,8 +143,6 @@ public:
}
#if ENABLE_ROTATE_INPUT
bool
OnRotateStartEvent
(
const
RotateEvent
&
event
)
override
;
bool
OnRotateEvent
(
const
RotateEvent
&
event
)
override
;
bool
OnRotateEndEvent
(
const
RotateEvent
&
event
)
override
;
...
...
interfaces/kits/components/ui_swipe_view.h
浏览文件 @
da44ea90
...
...
@@ -210,8 +210,6 @@ public:
bool
OnDragEndEvent
(
const
DragEvent
&
event
)
override
;
#if ENABLE_ROTATE_INPUT
bool
OnRotateStartEvent
(
const
RotateEvent
&
event
)
override
;
bool
OnRotateEvent
(
const
RotateEvent
&
event
)
override
;
bool
OnRotateEndEvent
(
const
RotateEvent
&
event
)
override
;
...
...
test/uitest/test_rotate_input/ui_test_rotate_input.cpp
浏览文件 @
da44ea90
...
...
@@ -14,6 +14,7 @@
*/
#include "ui_test_rotate_input.h"
#include "components/ui_label.h"
#include "components/ui_label_button.h"
#include "cstdio"
...
...
@@ -215,6 +216,8 @@ void UITestRotateInput::UIKit_Rotate_Event_List_001()
list_
->
SetThrowDrag
(
true
);
list_
->
SetRotateFactor
(
10
);
// 10 : rotate factor
list_
->
SetReboundSize
(
50
);
// 50 : rebound size
list_
->
SetIntercept
(
true
);
list_
->
SetLoopState
(
true
);
container_
->
Add
(
list_
);
SetLastPos
(
list_
);
}
...
...
@@ -243,6 +246,7 @@ void UITestRotateInput::UIKit_Rotate_Event_Scroll_View_002()
scroll_
->
SetThrowDrag
(
true
);
scroll_
->
SetOnTouchListener
(
this
);
scroll_
->
SetReboundSize
(
50
);
// 50 : rebound size
scroll_
->
SetIntercept
(
true
);
container_
->
Add
(
scroll_
);
SetTestLabelButton
(
label
,
scroll_
);
SetLastPos
(
scroll_
);
...
...
@@ -292,6 +296,7 @@ void UITestRotateInput::UIKit_Rotate_Event_Swipe_View_003()
swipe_
->
Add
(
btn7
);
swipe_
->
SetOnTouchListener
(
this
);
swipe_
->
SetRotateFactor
(
30
);
// 30 : rotate factor
swipe_
->
SetIntercept
(
true
);
container_
->
Add
(
swipe_
);
SetTestLabelButton
(
label
,
swipe_
);
SetLastPos
(
swipe_
);
...
...
@@ -332,6 +337,7 @@ void UITestRotateInput::UIKit_Rotate_Event_Time_Picker_005()
timePicker_
->
EnableSecond
(
true
);
timePicker_
->
SetPosition
(
0
,
label
->
GetY
()
+
g_blank
,
g_listW
,
g_listH
);
timePicker_
->
SetItemHeight
(
50
);
// 50 height
timePicker_
->
SetIntercept
(
true
);
UIView
*
hour
=
timePicker_
->
GetChildById
(
"hour"
);
if
(
hour
==
nullptr
)
{
...
...
@@ -436,24 +442,24 @@ void UITestRotateInput::SetTestLabelButton(UILabel* label, UIView* view)
}
CreateLabelButton
(
g_swipeW
+
g_blank
,
label
->
GetY
()
+
g_blank
,
listener1_
,
"factor: 0"
);
if
(
listener2_
==
nullptr
)
{
listener2_
=
static_cast
<
UIView
::
OnClickListener
*>
(
new
TestSetRotateFactorListener
(
view
,
15
));
// 15: rotate factor
listener2_
=
static_cast
<
UIView
::
OnClickListener
*>
(
new
TestSetRotateFactorListener
(
view
,
15
));
// 15: rotate factor
}
CreateLabelButton
(
g_swipeW
+
g_blank
,
lastY_
+
g_blank
,
listener2_
,
"factor: 15"
);
if
(
listener3_
==
nullptr
)
{
listener3_
=
static_cast
<
UIView
::
OnClickListener
*>
(
new
TestSetRotateFactorListener
(
view
,
-
15
));
// -15: rotate factor
listener3_
=
static_cast
<
UIView
::
OnClickListener
*>
(
new
TestSetRotateFactorListener
(
view
,
-
15
));
// -15: rotate factor
}
CreateLabelButton
(
g_swipeW
+
g_blank
,
lastY_
+
g_blank
,
listener3_
,
"factor: -15"
);
if
(
listener4_
==
nullptr
)
{
listener4_
=
static_cast
<
UIView
::
OnClickListener
*>
(
new
TestSetRotateFactorListener
(
view
,
30
));
// 30: rotate factor
listener4_
=
static_cast
<
UIView
::
OnClickListener
*>
(
new
TestSetRotateFactorListener
(
view
,
30
));
// 30: rotate factor
}
int16_t
x
=
lastX_
+
g_testButtonW
+
g_blank
;
CreateLabelButton
(
x
,
label
->
GetY
()
+
g_blank
,
listener4_
,
"factor: 30"
);
if
(
listener5_
==
nullptr
)
{
listener5_
=
static_cast
<
UIView
::
OnClickListener
*>
(
new
TestSetRotateFactorListener
(
view
,
-
30
));
// -30: rotate factor
listener5_
=
static_cast
<
UIView
::
OnClickListener
*>
(
new
TestSetRotateFactorListener
(
view
,
-
30
));
// -30: rotate factor
}
CreateLabelButton
(
x
,
lastY_
+
g_blank
,
listener5_
,
"factor: -30"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录