Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
cba88301
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,发现更多精彩内容 >>
提交
cba88301
编写于
3月 29, 2021
作者:
Y
YueBiang
提交者:
benb365
3月 30, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix SetRotateFactor bug for UISwipeView
上级
dcbcbaf7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
57 addition
and
2 deletion
+57
-2
frameworks/components/ui_swipe_view.cpp
frameworks/components/ui_swipe_view.cpp
+6
-2
test/uitest/test_rotate_input/ui_test_rotate_input.cpp
test/uitest/test_rotate_input/ui_test_rotate_input.cpp
+50
-0
test/uitest/test_rotate_input/ui_test_rotate_input.h
test/uitest/test_rotate_input/ui_test_rotate_input.h
+1
-0
未找到文件。
frameworks/components/ui_swipe_view.cpp
浏览文件 @
cba88301
...
...
@@ -173,10 +173,14 @@ bool UISwipeView::OnDragEndEvent(const DragEvent& event)
#if ENABLE_ROTATE_INPUT
bool
UISwipeView
::
OnRotateEvent
(
const
RotateEvent
&
event
)
{
if
(
rotateFactor_
==
0
)
{
return
UIView
::
OnRotateEvent
(
event
);
}
if
(
event
.
GetRotate
()
!=
0
)
{
int8_t
sign
=
rotateFactor_
<
0
?
-
1
:
1
;
// 4 : need to fit for the device
if
(
MATH_ABS
(
event
.
GetRotate
())
>
blankSize_
/
(
4
*
static_cast
<
uint16_t
>
(
rotateFactor_
)))
{
SwitchToPage
(
curIndex_
-
event
.
GetRotate
());
if
(
MATH_ABS
(
event
.
GetRotate
())
>
blankSize_
/
(
4
*
static_cast
<
uint16_t
>
(
MATH_ABS
(
rotateFactor_
)
)))
{
SwitchToPage
(
curIndex_
-
sign
*
event
.
GetRotate
());
}
else
{
int16_t
tmp
=
event
.
GetRotate
()
*
rotateFactor_
;
DragXInner
(
tmp
);
...
...
test/uitest/test_rotate_input/ui_test_rotate_input.cpp
浏览文件 @
cba88301
...
...
@@ -35,6 +35,8 @@ static int16_t g_swipeH = 200;
static
int16_t
g_swipeW
=
400
;
static
int16_t
g_sliderW
=
40
;
static
int16_t
g_sliderH
=
300
;
static
int16_t
g_testButtonW
=
80
;
static
int16_t
g_testButtonH
=
40
;
static
const
char
*
g_pickerRange
[]
=
{
"A0"
,
"B1"
,
"C2"
,
"D3"
,
"E4"
,
"F5"
,
"G6"
,
"H7"
,
"I8"
,
"J9"
,
"K10"
,
"L11"
};
#if ENABLE_MOTOR
...
...
@@ -53,6 +55,31 @@ void Print(MotorType motorType)
}
#endif
class
TestSetRotateFactorListener
:
public
UIView
::
OnClickListener
{
public:
TestSetRotateFactorListener
(
UIView
*
view
,
int8_t
factor
)
:
view_
(
view
),
factor_
(
factor
)
{}
~
TestSetRotateFactorListener
()
{}
bool
OnClick
(
UIView
&
view
,
const
ClickEvent
&
event
)
override
{
switch
(
view_
->
GetViewType
())
{
case
UI_SWIPE_VIEW
:
static_cast
<
UISwipeView
*>
(
view_
)
->
SetRotateFactor
(
factor_
);
break
;
case
UI_SCROLL_VIEW
:
static_cast
<
UIScrollView
*>
(
view_
)
->
SetRotateFactor
(
factor_
);
break
;
default:
break
;
}
return
true
;
}
private:
UIView
*
view_
=
nullptr
;
int8_t
factor_
=
0
;
};
void
UITestRotateInput
::
SetUp
()
{
if
(
container_
==
nullptr
)
{
...
...
@@ -239,6 +266,18 @@ void UITestRotateInput::UIKit_Rotate_Event_Swipe_View_003()
swipe_
->
SetOnTouchListener
(
this
);
swipe_
->
SetRotateFactor
(
30
);
// 30 : rotate factor
container_
->
Add
(
swipe_
);
TestSetRotateFactorListener
*
listener1
=
new
TestSetRotateFactorListener
(
swipe_
,
0
);
CreateLabelButton
(
g_swipeW
+
g_blank
,
label
->
GetY
()
+
g_blank
,
listener1
,
"factor: 0"
);
TestSetRotateFactorListener
*
listener2
=
new
TestSetRotateFactorListener
(
swipe_
,
15
);
// 15: rotate factor
CreateLabelButton
(
g_swipeW
+
g_blank
,
lastY_
+
g_blank
,
listener2
,
"factor: 15"
);
TestSetRotateFactorListener
*
listener3
=
new
TestSetRotateFactorListener
(
swipe_
,
-
15
);
// -15: rotate factor
CreateLabelButton
(
g_swipeW
+
g_blank
,
lastY_
+
g_blank
,
listener3
,
"factor: -15"
);
TestSetRotateFactorListener
*
listener4
=
new
TestSetRotateFactorListener
(
swipe_
,
30
);
// 30: rotate factor
int16_t
x
=
lastX_
+
g_testButtonW
+
g_blank
;
CreateLabelButton
(
x
,
label
->
GetY
()
+
g_blank
,
listener4
,
"factor: 30"
);
TestSetRotateFactorListener
*
listener5
=
new
TestSetRotateFactorListener
(
swipe_
,
-
30
);
// 30: rotate factor
CreateLabelButton
(
x
,
lastY_
+
g_blank
,
listener5
,
"factor: -30"
);
SetLastPos
(
swipe_
);
}
...
...
@@ -357,5 +396,16 @@ void UITestRotateInput::SetLastPos(UIView* view)
lastX_
=
view
->
GetX
();
lastY_
=
view
->
GetY
()
+
view
->
GetHeight
();
}
void
UITestRotateInput
::
CreateLabelButton
(
int16_t
x
,
int16_t
y
,
UIView
::
OnClickListener
*
listener
,
const
char
*
text
)
{
UILabelButton
*
labelButton
=
new
UILabelButton
();
labelButton
->
SetPosition
(
x
,
y
,
g_testButtonW
,
g_testButtonH
);
labelButton
->
SetOnClickListener
(
listener
);
labelButton
->
SetText
(
text
);
labelButton
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
15
);
container_
->
Add
(
labelButton
);
SetLastPos
(
labelButton
);
}
}
// namespace OHOS
#endif
test/uitest/test_rotate_input/ui_test_rotate_input.h
浏览文件 @
cba88301
...
...
@@ -42,6 +42,7 @@ public:
private:
void
SetLastPos
(
UIView
*
view
);
void
CreateLabelButton
(
int16_t
x
,
int16_t
y
,
UIView
::
OnClickListener
*
listener
,
const
char
*
text
);
UIScrollView
*
container_
=
nullptr
;
UIList
*
list_
=
nullptr
;
UIScrollView
*
scroll_
=
nullptr
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录