Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
0535f290
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,发现更多精彩内容 >>
提交
0535f290
编写于
9月 23, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 23, 2021
浏览文件
操作
浏览文件
下载
差异文件
!429 修复list组件设置margin为负数时滑动卡住问题
Merge pull request !429 from guyuanzhang/margin
上级
ba0e7cd1
e5eaf963
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
69 addition
and
36 deletion
+69
-36
frameworks/components/ui_list.cpp
frameworks/components/ui_list.cpp
+62
-32
interfaces/kits/components/ui_list.h
interfaces/kits/components/ui_list.h
+7
-4
未找到文件。
frameworks/components/ui_list.cpp
浏览文件 @
0535f290
...
...
@@ -282,20 +282,18 @@ bool UIList::DragXInner(int16_t distance)
return
MoveOffset
(
distance
,
0
);
}
if
(
distance
>
0
)
{
if
(
childrenHead_
&&
((
childrenHead_
->
GetX
()
+
distance
)
>
(
scrollBlankSize_
+
reboundSize
+
childrenHead_
->
GetStyle
(
STYLE_MARGIN_LEFT
))))
{
distance
=
scrollBlankSize_
+
reboundSize
+
childrenHead_
->
GetStyle
(
STYLE_MARGIN_LEFT
)
-
childrenHead_
->
GetX
();
if
(
childrenHead_
&&
((
childrenHead_
->
GetX
()
+
distance
)
>
(
scrollBlankSize_
+
reboundSize
)))
{
distance
=
scrollBlankSize_
+
reboundSize
-
childrenHead_
->
GetX
();
}
}
else
{
if
(
childrenTail_
)
{
if
(
childrenTail_
->
GetRelativeRect
().
GetRight
()
<=
(
listWidth
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
))
)
{
if
(
childrenTail_
->
GetRelativeRect
().
GetRight
()
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
<
listWidth
-
scrollBlankSize_
-
reboundSize
)
{
distance
=
0
;
}
else
if
((
listWidth
-
childrenTail_
->
GetX
()
-
childrenTail_
->
GetRelativeRect
().
GetWidth
()
-
distance
)
>
(
scrollBlankSize_
+
reboundSize
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
))
{
distance
=
listWidth
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
Get
X
()
-
childrenTail_
->
Get
RelativeRect
().
GetWidth
()
-
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
;
}
else
if
((
childrenTail_
->
GetRelativeRect
().
GetRight
()
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
+
distance
)
<=
(
listWidth
-
scrollBlankSize_
-
reboundSize
))
{
distance
=
listWidth
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
Get
RelativeRect
().
GetRight
()
-
childrenTail_
->
Get
Style
(
STYLE_MARGIN_RIGHT
)
-
1
;
}
}
}
...
...
@@ -324,20 +322,18 @@ bool UIList::DragYInner(int16_t distance)
return
MoveOffset
(
0
,
distance
);
}
if
(
distance
>
0
)
{
if
(
childrenHead_
&&
((
childrenHead_
->
GetY
()
+
distance
)
>
(
scrollBlankSize_
+
reboundSize
+
childrenHead_
->
GetStyle
(
STYLE_MARGIN_TOP
))))
{
distance
=
scrollBlankSize_
+
reboundSize
+
childrenHead_
->
GetStyle
(
STYLE_MARGIN_TOP
)
-
childrenHead_
->
GetY
();
if
(
childrenHead_
&&
((
childrenHead_
->
GetY
()
+
distance
)
>
(
scrollBlankSize_
+
reboundSize
)))
{
distance
=
scrollBlankSize_
+
reboundSize
-
childrenHead_
->
GetY
();
}
}
else
{
if
(
childrenTail_
)
{
if
(
childrenTail_
->
GetRelativeRect
().
GetBottom
()
<=
(
listHeight
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
))
)
{
if
(
childrenTail_
->
GetRelativeRect
().
GetBottom
()
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
<
listHeight
-
scrollBlankSize_
-
reboundSize
)
{
distance
=
0
;
}
else
if
((
listHeight
-
childrenTail_
->
GetY
()
-
childrenTail_
->
GetRelativeRect
().
GetHeight
()
-
distance
)
>
(
scrollBlankSize_
+
reboundSize
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
))
{
distance
=
listHeight
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
Get
Y
()
-
childrenTail_
->
Get
RelativeRect
().
GetHeight
()
-
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
;
}
else
if
((
childrenTail_
->
GetRelativeRect
().
GetBottom
()
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
+
distance
)
<=
(
listHeight
-
scrollBlankSize_
-
reboundSize
))
{
distance
=
listHeight
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
Get
RelativeRect
().
GetBottom
()
-
childrenTail_
->
Get
Style
(
STYLE_MARGIN_BOTTOM
)
-
1
;
}
}
}
...
...
@@ -414,14 +410,12 @@ bool UIList::ReCalculateDragEnd()
return
true
;
}
bool
UIList
::
MoveChildStepInner
(
int16_t
distance
,
int16_t
(
UIView
::*
getXOrY
)()
const
,
int16_t
(
UIView
::*
getWidthOrHeight
)())
bool
UIList
::
MoveChildStepVertical
(
int16_t
distance
)
{
bool
popRet
=
false
;
bool
pushRet
=
false
;
if
(
distance
>
0
)
{
if
((
childrenHead_
==
nullptr
)
||
(
(
childrenHead_
->*
getXOrY
)
()
+
distance
>
0
))
{
if
((
childrenHead_
==
nullptr
)
||
(
childrenHead_
->
GetRelativeRect
().
GetTop
()
+
distance
>
0
))
{
uint16_t
index
=
GetIndexDec
(
topIndex_
);
if
(
index
==
topIndex_
)
{
return
false
;
...
...
@@ -433,14 +427,12 @@ bool UIList::MoveChildStepInner(int16_t distance,
PushFront
(
newView
);
pushRet
=
true
;
}
if
(
childrenTail_
!=
nullptr
&&
(
(
childrenTail_
->*
getXOrY
)()
+
distance
>
(
this
->*
getWidthOrHeight
)
()))
{
if
(
childrenTail_
!=
nullptr
&&
(
childrenTail_
->
GetRelativeRect
().
GetTop
()
+
distance
>
GetHeight
()))
{
PopItem
(
childrenTail_
);
popRet
=
true
;
}
}
else
{
if
((
childrenTail_
==
nullptr
)
||
((
childrenTail_
->*
getXOrY
)()
+
(
childrenTail_
->*
getWidthOrHeight
)()
+
distance
<
(
this
->*
getWidthOrHeight
)()))
{
if
(
childrenTail_
==
nullptr
||
(
childrenTail_
->
GetRelativeRect
().
GetBottom
()
+
distance
<
GetHeight
()))
{
UIView
*
newView
=
recycle_
.
GetView
(
GetIndexInc
(
bottomIndex_
));
if
(
newView
==
nullptr
)
{
return
false
;
...
...
@@ -448,7 +440,45 @@ bool UIList::MoveChildStepInner(int16_t distance,
PushBack
(
newView
);
pushRet
=
true
;
}
if
(
childrenHead_
&&
(
childrenHead_
->*
getXOrY
)()
+
distance
+
(
childrenHead_
->*
getWidthOrHeight
)()
<
0
)
{
if
(
childrenHead_
&&
(
childrenHead_
->
GetRelativeRect
().
GetBottom
()
+
distance
<
0
))
{
PopItem
(
childrenHead_
);
popRet
=
true
;
}
}
return
(
popRet
||
pushRet
);
}
bool
UIList
::
MoveChildStepHorizontal
(
int16_t
distance
)
{
bool
popRet
=
false
;
bool
pushRet
=
false
;
if
(
distance
>
0
)
{
if
((
childrenHead_
==
nullptr
)
||
(
childrenHead_
->
GetRelativeRect
().
GetLeft
()
+
distance
>
0
))
{
uint16_t
index
=
GetIndexDec
(
topIndex_
);
if
(
index
==
topIndex_
)
{
return
false
;
}
UIView
*
newView
=
recycle_
.
GetView
(
index
);
if
(
newView
==
nullptr
)
{
return
false
;
}
PushFront
(
newView
);
pushRet
=
true
;
}
if
(
childrenTail_
!=
nullptr
&&
(
childrenTail_
->
GetRelativeRect
().
GetLeft
()
+
distance
>
GetWidth
()))
{
PopItem
(
childrenTail_
);
popRet
=
true
;
}
}
else
{
if
(
childrenTail_
==
nullptr
||
(
childrenTail_
->
GetRelativeRect
().
GetRight
()
+
distance
<
GetWidth
()))
{
UIView
*
newView
=
recycle_
.
GetView
(
GetIndexInc
(
bottomIndex_
));
if
(
newView
==
nullptr
)
{
return
false
;
}
PushBack
(
newView
);
pushRet
=
true
;
}
if
(
childrenHead_
&&
(
childrenHead_
->
GetRelativeRect
().
GetRight
()
+
distance
<
0
))
{
PopItem
(
childrenHead_
);
popRet
=
true
;
}
...
...
@@ -459,9 +489,9 @@ bool UIList::MoveChildStepInner(int16_t distance,
bool
UIList
::
MoveChildStep
(
int16_t
distance
)
{
if
(
direction_
==
VERTICAL
)
{
return
MoveChildStep
Inner
(
distance
,
&
UIView
::
GetY
,
&
UIView
::
GetHeightWithMargin
);
return
MoveChildStep
Vertical
(
distance
);
}
else
{
return
MoveChildStep
Inner
(
distance
,
&
UIView
::
GetX
,
&
UIView
::
GetWidthWithMargin
);
return
MoveChildStep
Horizontal
(
distance
);
}
}
...
...
@@ -583,7 +613,7 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
height
=
view
->
GetRelativeRect
().
GetHeight
();
if
((
view
->
GetY
()
+
yOffset
>
selectPosition_
)
||
(
childrenTail_
->
GetY
()
+
height
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
+
yOffset
<
selectPosition_
))
{
selectPosition_
))
{
onSelectedIndex_
=
NULL_SELECT_INDEX
;
onSelectedView_
=
nullptr
;
if
(
scrollListener_
!=
nullptr
)
{
...
...
interfaces/kits/components/ui_list.h
浏览文件 @
0535f290
...
...
@@ -342,7 +342,8 @@ public:
}
/**
* @brief 设置自动对齐动画时长,单位为毫秒,默认为100毫秒。该功能依赖EnableAutoAlign()方法,自动对齐设置为true情况下才生效。
* @brief
* 设置自动对齐动画时长,单位为毫秒,默认为100毫秒。该功能依赖EnableAutoAlign()方法,自动对齐设置为true情况下才生效。
*
* @param value 自动对齐动画时长,0表示无动画。
* @since 3.0
...
...
@@ -361,7 +362,7 @@ public:
* position partly (but not all of it).
* false means list item will move front when its position crosses the line of select
* position (no matter how many it crosses).
*
*
* @since 3.0
* @version 3.0
*/
...
...
@@ -391,6 +392,7 @@ public:
static
constexpr
int8_t
NULL_SELECT_INDEX
=
-
1
;
UIView
*
onSelectedView_
;
protected:
static
constexpr
int16_t
RECALCULATE_DRAG_DISTANCE
=
10
;
static
constexpr
int16_t
RECALCULATE_DRAG_TIMES
=
10
;
...
...
@@ -437,6 +439,7 @@ private:
Rect
GetAdapterItemsReletiveRect
();
void
MoveAdapterItemsRelativeRect
(
int16_t
x
,
int16_t
y
);
void
MesureAdapterRelativeRect
();
private:
friend
class
UIList
;
void
FillActiveView
();
...
...
@@ -453,8 +456,8 @@ private:
void
PushFront
(
UIView
*
view
);
void
SetHead
(
UIView
*
view
);
bool
MoveChildStep
(
int16_t
distance
);
bool
MoveChildStepInner
(
int16_t
distance
,
int16_t
(
UIView
::*
getXOrY
)()
const
,
int16_t
(
UIView
::*
getWidthOrHeight
)()
);
bool
MoveChildStepVertical
(
int16_t
distance
);
bool
MoveChildStepHorizontal
(
int16_t
distance
);
uint16_t
GetIndexInc
(
uint16_t
index
);
uint16_t
GetIndexDec
(
uint16_t
index
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录