Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
7a31a93b
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,发现更多精彩内容 >>
提交
7a31a93b
编写于
3月 26, 2021
作者:
G
guyuanzhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Description:fix UIList margin support
Sig:graphic Feature or Bugfix:Feature Binary Source:No
上级
28a89fab
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
23 deletion
+42
-23
frameworks/components/ui_list.cpp
frameworks/components/ui_list.cpp
+42
-23
未找到文件。
frameworks/components/ui_list.cpp
浏览文件 @
7a31a93b
...
@@ -214,7 +214,7 @@ bool UIList::OnRotateEvent(const RotateEvent& event)
...
@@ -214,7 +214,7 @@ bool UIList::OnRotateEvent(const RotateEvent& event)
#endif
#endif
if
(
!
throwDrag_
||
((
MATH_ABS
(
tmpRotateLen
)
<
(
midPointX
/
rotateThreshold_
))
&&
if
(
!
throwDrag_
||
((
MATH_ABS
(
tmpRotateLen
)
<
(
midPointX
/
rotateThreshold_
))
&&
(
MATH_ABS
(
tmpRotateLen
)
<
(
midPointY
/
rotateThreshold_
))))
{
(
MATH_ABS
(
tmpRotateLen
)
<
(
midPointY
/
rotateThreshold_
))))
{
ScrollBy
(
tmpRotateLen
);
ScrollBy
(
tmpRotateLen
);
if
(
event
.
GetRotate
()
==
0
)
{
if
(
event
.
GetRotate
()
==
0
)
{
isReCalculateDragEnd_
=
false
;
isReCalculateDragEnd_
=
false
;
...
@@ -282,17 +282,20 @@ bool UIList::DragXInner(int16_t distance)
...
@@ -282,17 +282,20 @@ bool UIList::DragXInner(int16_t distance)
return
MoveOffset
(
distance
);
return
MoveOffset
(
distance
);
}
}
if
(
distance
>
0
)
{
if
(
distance
>
0
)
{
if
(
childrenHead_
&&
(
childrenHead_
->
GetX
()
+
distance
>
scrollBlankSize_
+
reboundSize
))
{
if
(
childrenHead_
&&
(
childrenHead_
->
GetX
()
+
distance
>
distance
=
scrollBlankSize_
+
reboundSize
-
childrenHead_
->
GetX
();
scrollBlankSize_
+
reboundSize
+
childrenHead_
->
GetStyle
(
STYLE_MARGIN_LEFT
)))
{
distance
=
scrollBlankSize_
+
reboundSize
+
childrenHead_
->
GetStyle
(
STYLE_MARGIN_LEFT
)
-
childrenHead_
->
GetX
();
}
}
}
else
{
}
else
{
if
(
childrenTail_
)
{
if
(
childrenTail_
)
{
if
(
childrenTail_
->
GetRelativeRect
().
GetRight
()
<=
listWidth
-
scrollBlankSize_
-
reboundSize
)
{
if
(
childrenTail_
->
GetRelativeRect
().
GetRight
()
<=
listWidth
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
))
{
distance
=
0
;
distance
=
0
;
}
else
if
(
listWidth
-
(
childrenTail_
->
GetX
()
+
childrenTail_
->
GetRelativeRect
().
GetWidth
()
+
distance
)
>
}
else
if
(
listWidth
-
(
childrenTail_
->
GetX
()
+
childrenTail_
->
GetRelativeRect
().
GetWidth
()
+
distance
)
>
scrollBlankSize_
+
reboundSize
)
{
scrollBlankSize_
+
reboundSize
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
)
{
distance
=
listWidth
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
GetX
()
-
distance
=
listWidth
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
GetX
()
-
childrenTail_
->
GetRelativeRect
().
GetWidth
();
childrenTail_
->
GetRelativeRect
().
GetWidth
()
-
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
;
}
}
}
}
}
}
...
@@ -321,17 +324,20 @@ bool UIList::DragYInner(int16_t distance)
...
@@ -321,17 +324,20 @@ bool UIList::DragYInner(int16_t distance)
return
MoveOffset
(
distance
);
return
MoveOffset
(
distance
);
}
}
if
(
distance
>
0
)
{
if
(
distance
>
0
)
{
if
(
childrenHead_
&&
(
childrenHead_
->
GetY
()
+
distance
>
scrollBlankSize_
+
reboundSize
))
{
if
(
childrenHead_
&&
(
childrenHead_
->
GetY
()
+
distance
>
distance
=
scrollBlankSize_
+
reboundSize
-
childrenHead_
->
GetY
();
scrollBlankSize_
+
reboundSize
+
childrenHead_
->
GetStyle
(
STYLE_MARGIN_TOP
)))
{
distance
=
scrollBlankSize_
+
reboundSize
+
childrenHead_
->
GetStyle
(
STYLE_MARGIN_TOP
)
-
childrenHead_
->
GetY
();
}
}
}
else
{
}
else
{
if
(
childrenTail_
)
{
if
(
childrenTail_
)
{
if
(
childrenTail_
->
GetRelativeRect
().
GetBottom
()
<=
listHeigh
-
scrollBlankSize_
-
reboundSize
)
{
if
(
childrenTail_
->
GetRelativeRect
().
GetBottom
()
<=
listHeigh
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
))
{
distance
=
0
;
distance
=
0
;
}
else
if
(
listHeigh
-
(
childrenTail_
->
GetY
()
+
childrenTail_
->
GetRelativeRect
().
GetHeight
()
+
distance
)
>
}
else
if
(
listHeigh
-
(
childrenTail_
->
GetY
()
+
childrenTail_
->
GetRelativeRect
().
GetHeight
()
+
distance
)
>
scrollBlankSize_
+
reboundSize
)
{
scrollBlankSize_
+
reboundSize
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
)
{
distance
=
listHeigh
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
GetY
()
-
distance
=
listHeigh
-
scrollBlankSize_
-
reboundSize
-
childrenTail_
->
GetY
()
-
childrenTail_
->
GetRelativeRect
().
GetHeight
();
childrenTail_
->
GetRelativeRect
().
GetHeight
()
-
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
;
}
}
}
}
}
}
...
@@ -423,7 +429,7 @@ bool UIList::MoveChildStepInner(int16_t distance,
...
@@ -423,7 +429,7 @@ bool UIList::MoveChildStepInner(int16_t distance,
}
else
{
}
else
{
if
((
childrenTail_
==
nullptr
)
||
if
((
childrenTail_
==
nullptr
)
||
((
childrenTail_
->*
pfnGetXOrY
)()
+
(
childrenTail_
->
GetRelativeRect
().
*
pfnGetWidthOrHeight
)()
+
distance
<
((
childrenTail_
->*
pfnGetXOrY
)()
+
(
childrenTail_
->
GetRelativeRect
().
*
pfnGetWidthOrHeight
)()
+
distance
<
(
this
->
GetRelativeRect
().
*
pfnGetWidthOrHeight
)()))
{
(
this
->
GetRelativeRect
().
*
pfnGetWidthOrHeight
)()))
{
UIView
*
newView
=
recycle_
.
GetView
(
GetIndexInc
(
bottomIndex_
));
UIView
*
newView
=
recycle_
.
GetView
(
GetIndexInc
(
bottomIndex_
));
if
(
newView
==
nullptr
)
{
if
(
newView
==
nullptr
)
{
return
false
;
return
false
;
...
@@ -496,9 +502,13 @@ void UIList::PushBack(UIView* view)
...
@@ -496,9 +502,13 @@ void UIList::PushBack(UIView* view)
SetHead
(
view
);
SetHead
(
view
);
}
else
{
}
else
{
if
(
direction_
==
VERTICAL
)
{
if
(
direction_
==
VERTICAL
)
{
view
->
SetPosition
(
0
,
childrenTail_
->
GetY
()
+
childrenTail_
->
GetRelativeRect
().
GetHeight
());
view
->
SetPosition
(
view
->
GetStyle
(
STYLE_MARGIN_LEFT
),
childrenTail_
->
GetY
()
+
childrenTail_
->
GetRelativeRect
().
GetHeight
()
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
+
view
->
GetStyle
(
STYLE_MARGIN_TOP
));
}
else
{
}
else
{
view
->
SetPosition
(
childrenTail_
->
GetX
()
+
childrenTail_
->
GetRelativeRect
().
GetWidth
(),
0
);
view
->
SetPosition
(
childrenTail_
->
GetX
()
+
childrenTail_
->
GetRelativeRect
().
GetWidth
()
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
+
view
->
GetStyle
(
STYLE_MARGIN_LEFT
),
view
->
GetStyle
(
STYLE_MARGIN_TOP
));
}
}
bottomIndex_
=
GetIndexInc
(
bottomIndex_
);
bottomIndex_
=
GetIndexInc
(
bottomIndex_
);
}
}
...
@@ -516,9 +526,13 @@ void UIList::PushFront(UIView* view)
...
@@ -516,9 +526,13 @@ void UIList::PushFront(UIView* view)
SetHead
(
view
);
SetHead
(
view
);
}
else
{
}
else
{
if
(
direction_
==
VERTICAL
)
{
if
(
direction_
==
VERTICAL
)
{
view
->
SetPosition
(
0
,
GetChildrenHead
()
->
GetY
()
-
view
->
GetRelativeRect
().
GetHeight
());
view
->
SetPosition
(
view
->
GetStyle
(
STYLE_MARGIN_LEFT
),
GetChildrenHead
()
->
GetY
()
-
GetChildrenHead
()
->
GetStyle
(
STYLE_MARGIN_TOP
)
-
view
->
GetRelativeRect
().
GetHeight
()
-
view
->
GetStyle
(
STYLE_MARGIN_BOTTOM
));
}
else
{
}
else
{
view
->
SetPosition
(
GetChildrenHead
()
->
GetX
()
-
view
->
GetRelativeRect
().
GetWidth
(),
0
);
view
->
SetPosition
(
GetChildrenHead
()
->
GetX
()
-
GetChildrenHead
()
->
GetStyle
(
STYLE_MARGIN_LEFT
)
-
view
->
GetRelativeRect
().
GetWidth
()
-
view
->
GetStyle
(
STYLE_MARGIN_RIGHT
),
view
->
GetStyle
(
STYLE_MARGIN_TOP
));
}
}
topIndex_
=
GetIndexDec
(
topIndex_
);
topIndex_
=
GetIndexDec
(
topIndex_
);
}
}
...
@@ -545,7 +559,7 @@ void UIList::PopItem(UIView* view)
...
@@ -545,7 +559,7 @@ void UIList::PopItem(UIView* view)
void
UIList
::
SetHead
(
UIView
*
view
)
void
UIList
::
SetHead
(
UIView
*
view
)
{
{
if
(
view
!=
nullptr
)
{
if
(
view
!=
nullptr
)
{
view
->
SetPosition
(
0
,
0
);
view
->
SetPosition
(
view
->
GetStyle
(
STYLE_MARGIN_LEFT
),
view
->
GetStyle
(
STYLE_MARGIN_TOP
)
);
topIndex_
=
startIndex_
;
topIndex_
=
startIndex_
;
bottomIndex_
=
startIndex_
;
bottomIndex_
=
startIndex_
;
}
}
...
@@ -565,8 +579,10 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
...
@@ -565,8 +579,10 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
if
((
onSelectedIndex_
!=
NULL_SELECT_INDEX
)
&&
(
selectPosition_
!=
0
))
{
if
((
onSelectedIndex_
!=
NULL_SELECT_INDEX
)
&&
(
selectPosition_
!=
0
))
{
if
(
direction_
==
VERTICAL
)
{
if
(
direction_
==
VERTICAL
)
{
height
=
view
->
GetRelativeRect
().
GetHeight
();
height
=
view
->
GetRelativeRect
().
GetHeight
();
if
((
GetChildrenHead
()
->
GetY
()
+
yOffset
>
selectPosition_
)
||
if
((
GetChildrenHead
()
->
GetY
()
-
GetChildrenHead
()
->
GetStyle
(
STYLE_MARGIN_TOP
)
+
yOffset
>
(
childrenTail_
->
GetY
()
+
height
+
yOffset
<
selectPosition_
))
{
selectPosition_
)
||
(
childrenTail_
->
GetY
()
+
height
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
+
yOffset
<
selectPosition_
))
{
onSelectedIndex_
=
NULL_SELECT_INDEX
;
onSelectedIndex_
=
NULL_SELECT_INDEX
;
onSelectedView_
=
nullptr
;
onSelectedView_
=
nullptr
;
if
(
scrollListener_
!=
nullptr
)
{
if
(
scrollListener_
!=
nullptr
)
{
...
@@ -575,8 +591,9 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
...
@@ -575,8 +591,9 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
}
}
}
else
{
}
else
{
width
=
view
->
GetRelativeRect
().
GetWidth
();
width
=
view
->
GetRelativeRect
().
GetWidth
();
if
((
GetChildrenHead
()
->
GetX
()
+
xOffset
>
selectPosition_
)
||
if
((
GetChildrenHead
()
->
GetX
()
-
GetChildrenHead
()
->
GetStyle
(
STYLE_MARGIN_LEFT
)
+
xOffset
>
(
childrenTail_
->
GetX
()
+
width
<
selectPosition_
))
{
selectPosition_
)
||
(
childrenTail_
->
GetX
()
+
width
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
<
selectPosition_
))
{
onSelectedIndex_
=
NULL_SELECT_INDEX
;
onSelectedIndex_
=
NULL_SELECT_INDEX
;
onSelectedView_
=
nullptr
;
onSelectedView_
=
nullptr
;
if
(
scrollListener_
!=
nullptr
)
{
if
(
scrollListener_
!=
nullptr
)
{
...
@@ -594,7 +611,8 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
...
@@ -594,7 +611,8 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
if
(
direction_
==
VERTICAL
)
{
if
(
direction_
==
VERTICAL
)
{
height
=
view
->
GetRelativeRect
().
GetHeight
();
height
=
view
->
GetRelativeRect
().
GetHeight
();
/* Views may be the same but have different indexes because of view recycling. */
/* Views may be the same but have different indexes because of view recycling. */
if
((
y
<=
selectPosition_
)
&&
(
y
+
height
>=
selectPosition_
)
&&
if
((
y
-
view
->
GetStyle
(
STYLE_PADDING_TOP
)
<=
selectPosition_
)
&&
(
y
+
view
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
+
height
>=
selectPosition_
)
&&
((
onSelectedView_
!=
view
)
||
(
onSelectedIndex_
!=
view
->
GetViewIndex
())))
{
((
onSelectedView_
!=
view
)
||
(
onSelectedIndex_
!=
view
->
GetViewIndex
())))
{
onSelectedIndex_
=
view
->
GetViewIndex
();
onSelectedIndex_
=
view
->
GetViewIndex
();
onSelectedView_
=
view
;
onSelectedView_
=
view
;
...
@@ -605,7 +623,8 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
...
@@ -605,7 +623,8 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
}
}
}
else
{
}
else
{
width
=
view
->
GetRelativeRect
().
GetWidth
();
width
=
view
->
GetRelativeRect
().
GetWidth
();
if
((
x
<=
selectPosition_
)
&&
(
x
+
width
>=
selectPosition_
)
&&
if
((
x
-
view
->
GetStyle
(
STYLE_MARGIN_LEFT
)
<=
selectPosition_
)
&&
(
x
+
width
+
view
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
>=
selectPosition_
)
&&
((
onSelectedView_
!=
view
)
||
(
onSelectedIndex_
!=
view
->
GetViewIndex
())))
{
((
onSelectedView_
!=
view
)
||
(
onSelectedIndex_
!=
view
->
GetViewIndex
())))
{
onSelectedIndex_
=
view
->
GetViewIndex
();
onSelectedIndex_
=
view
->
GetViewIndex
();
onSelectedView_
=
view
;
onSelectedView_
=
view
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录