Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
c0beaa17
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,发现更多精彩内容 >>
提交
c0beaa17
编写于
7月 20, 2021
作者:
L
liqiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix SetCurrentPage animator bug
Change-Id: I24b742487a503a56cba8d127fee4520c701f609c
上级
002d84c6
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
99 addition
and
16 deletion
+99
-16
frameworks/components/ui_swipe_view.cpp
frameworks/components/ui_swipe_view.cpp
+25
-15
interfaces/kits/components/ui_swipe_view.h
interfaces/kits/components/ui_swipe_view.h
+1
-0
test/uitest/test_ui_swipe_view/ui_test_ui_swipe_view.cpp
test/uitest/test_ui_swipe_view/ui_test_ui_swipe_view.cpp
+69
-0
test/uitest/test_ui_swipe_view/ui_test_ui_swipe_view.h
test/uitest/test_ui_swipe_view/ui_test_ui_swipe_view.h
+4
-1
未找到文件。
frameworks/components/ui_swipe_view.cpp
浏览文件 @
c0beaa17
...
...
@@ -75,8 +75,32 @@ void UISwipeView::Remove(UIView* view)
Invalidate
();
}
void
UISwipeView
::
MoveHeadOrTailChild
()
{
if
(
loop_
)
{
if
(
direction_
==
HORIZONTAL
)
{
while
(
childrenHead_
->
GetX
()
>=
0
)
{
MoveLastChildToFirst
();
}
while
(
childrenTail_
->
GetX
()
+
childrenTail_
->
GetWidth
()
<=
GetWidth
())
{
MoveFirstChildToLast
();
}
}
else
{
while
(
childrenHead_
->
GetY
()
>=
0
)
{
MoveLastChildToFirst
();
}
while
(
childrenTail_
->
GetY
()
+
childrenTail_
->
GetHeight
()
<=
GetHeight
())
{
MoveFirstChildToLast
();
}
}
}
}
void
UISwipeView
::
SetCurrentPage
(
uint16_t
index
,
bool
needAnimator
)
{
if
(
needAnimator
)
{
MoveHeadOrTailChild
();
}
SwitchToPage
(
index
,
needAnimator
);
Invalidate
();
}
...
...
@@ -415,21 +439,7 @@ void UISwipeView::RefreshCurrentView(int16_t distance)
void
UISwipeView
::
MoveChildByOffset
(
int16_t
xOffset
,
int16_t
yOffset
)
{
UIViewGroup
::
MoveChildByOffset
(
xOffset
,
yOffset
);
if
(
direction_
==
HORIZONTAL
)
{
while
(
isNeedLoop
()
&&
(
childrenHead_
->
GetX
()
>
0
))
{
MoveLastChildToFirst
();
}
while
(
isNeedLoop
()
&&
(
childrenTail_
->
GetX
()
+
childrenTail_
->
GetWidth
()
<
GetWidth
()))
{
MoveFirstChildToLast
();
}
}
else
{
while
(
isNeedLoop
()
&&
(
childrenHead_
->
GetY
()
>
0
))
{
MoveLastChildToFirst
();
}
while
(
isNeedLoop
()
&&
(
childrenTail_
->
GetY
()
+
childrenTail_
->
GetHeight
()
<
GetHeight
()))
{
MoveFirstChildToLast
();
}
}
MoveHeadOrTailChild
();
}
bool
UISwipeView
::
isNeedLoop
()
...
...
interfaces/kits/components/ui_swipe_view.h
浏览文件 @
c0beaa17
...
...
@@ -329,6 +329,7 @@ protected:
void
StopAnimator
()
override
;
virtual
void
SwitchToPage
(
int16_t
dst
,
bool
needAnimator
=
true
);
void
MoveChildByOffset
(
int16_t
xOffset
,
int16_t
yOffset
)
override
;
void
MoveHeadOrTailChild
();
/**
* @brief Indicates that the animation duration is 12 ticks.
...
...
test/uitest/test_ui_swipe_view/ui_test_ui_swipe_view.cpp
浏览文件 @
c0beaa17
...
...
@@ -31,6 +31,7 @@ static int16_t g_swipeW = 400;
static
int16_t
g_swipeHorH
=
110
;
static
int16_t
g_deltaCoordinateY
=
19
;
static
int16_t
g_deltaCoordinateY2
=
37
;
static
uint16_t
g_MaxIndex
=
3
;
}
// namespace
void
UITestUISwipeView
::
SetUp
()
...
...
@@ -53,6 +54,8 @@ void UITestUISwipeView::TearDown()
removeHeadBtn_
=
nullptr
;
removeMidBtn_
=
nullptr
;
removeAllBtn_
=
nullptr
;
loopBtn_
=
nullptr
;
changePageBtn_
=
nullptr
;
lastX_
=
0
;
lastY_
=
0
;
}
...
...
@@ -70,6 +73,8 @@ const UIView* UITestUISwipeView::GetTestView()
UIKit_Swipe_View_Test_Ver_002
();
UIKit_Swipe_View_Test_Remove_001
();
UIKit_Swipe_View_Test_SetCurrentPage
();
return
container_
;
}
...
...
@@ -344,6 +349,55 @@ void UITestUISwipeView::UIKit_Swipe_View_Test_Align_001(UISwipeView::AlignMode a
SetLastPos
(
swipe
);
}
void
UITestUISwipeView
::
UIKit_Swipe_View_Test_SetCurrentPage
()
{
if
(
container_
==
nullptr
)
{
return
;
}
positionY_
+=
g_deltaCoordinateY
;
UILabel
*
label
=
GetTitleLabel
(
"UISwipeView切换页面"
);
container_
->
Add
(
label
);
positionY_
+=
g_deltaCoordinateY
;
label
->
SetPosition
(
TEXT_DISTANCE_TO_LEFT_SIDE
,
positionY_
);
positionY_
+=
g_deltaCoordinateY2
;
UISwipeView
*
swipe
=
new
UISwipeView
(
UISwipeView
::
HORIZONTAL
);
swipe
->
SetIntercept
(
true
);
swipe
->
SetStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
Red
().
full
);
swipe
->
SetPosition
(
TEXT_DISTANCE_TO_LEFT_SIDE
,
positionY_
,
g_swipeW
,
g_swipeH
);
swipe
->
SetLoopState
(
loop_
);
swipe
->
SetAnimatorTime
(
1000
);
// 100: mean animator drag time(ms)
currentSwipe_
=
swipe
;
container_
->
Add
(
swipe
);
UIView
*
view1
=
new
UIView
();
view1
->
SetStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
Red
().
full
);
view1
->
Resize
(
g_swipeW
,
g_swipeH
);
swipe
->
Add
(
view1
);
UIView
*
view2
=
new
UIView
();
view2
->
SetStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
White
().
full
);
view2
->
Resize
(
g_swipeW
,
g_swipeH
);
swipe
->
Add
(
view2
);
UIView
*
view3
=
new
UIView
();
view3
->
SetStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
Blue
().
full
);
view3
->
Resize
(
g_swipeW
,
g_swipeH
);
swipe
->
Add
(
view3
);
UIView
*
view4
=
new
UIView
();
view4
->
SetStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
Yellow
().
full
);
view4
->
Resize
(
g_swipeW
,
g_swipeH
);
swipe
->
Add
(
view4
);
if
(
loopBtn_
==
nullptr
)
{
loopBtn_
=
new
UILabelButton
();
}
if
(
changePageBtn_
==
nullptr
)
{
changePageBtn_
=
new
UILabelButton
();
}
positionX_
=
TEXT_DISTANCE_TO_LEFT_SIDE
+
swipe
->
GetWidth
()
+
20
;
// 20: is interval between button and swipe
positionY_
+=
g_deltaCoordinateY2
;
SetUpButton
(
loopBtn_
,
"设置循环 关 "
);
SetUpButton
(
changePageBtn_
,
"切换页面 "
);
}
bool
UITestUISwipeView
::
OnClick
(
UIView
&
view
,
const
ClickEvent
&
event
)
{
if
(
currentSwipe_
==
nullptr
)
{
...
...
@@ -371,6 +425,21 @@ bool UITestUISwipeView::OnClick(UIView& view, const ClickEvent& event)
currentSwipe_
->
Remove
(
view
);
}
else
if
(
&
view
==
removeAllBtn_
)
{
currentSwipe_
->
RemoveAll
();
}
else
if
(
&
view
==
loopBtn_
)
{
loop_
=
!
loop_
;
currentSwipe_
->
SetLoopState
(
loop_
);
if
(
!
loop_
)
{
loopBtn_
->
SetText
(
"设置循环 关 "
);
}
else
{
loopBtn_
->
SetText
(
"设置循环 开 "
);
}
}
else
if
(
&
view
==
changePageBtn_
)
{
uint16_t
currentIndex
=
currentSwipe_
->
GetCurrentPage
();
if
(
currentIndex
<
g_MaxIndex
)
{
currentSwipe_
->
SetCurrentPage
(
++
currentIndex
,
true
);
}
else
{
currentSwipe_
->
SetCurrentPage
(
0
,
true
);
}
}
currentSwipe_
->
Invalidate
();
btnNum_
++
;
...
...
test/uitest/test_ui_swipe_view/ui_test_ui_swipe_view.h
浏览文件 @
c0beaa17
...
...
@@ -38,6 +38,7 @@ public:
void
UIKit_Swipe_View_Test_Ver_002
();
void
UIKit_Swipe_View_Test_Remove_001
();
void
UIKit_Swipe_View_Test_Align_001
(
UISwipeView
::
AlignMode
alignMode
);
void
UIKit_Swipe_View_Test_SetCurrentPage
();
private:
void
SetUpButton
(
UILabelButton
*
btn
,
const
char
*
title
);
...
...
@@ -50,7 +51,9 @@ private:
UILabelButton
*
removeHeadBtn_
=
nullptr
;
UILabelButton
*
removeMidBtn_
=
nullptr
;
UILabelButton
*
removeAllBtn_
=
nullptr
;
UILabelButton
*
loopBtn_
=
nullptr
;
UILabelButton
*
changePageBtn_
=
nullptr
;
bool
loop_
=
false
;
int16_t
lastX_
=
0
;
int16_t
lastY_
=
0
;
int16_t
btnNum_
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录