Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
95865723
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,发现更多精彩内容 >>
提交
95865723
编写于
4月 30, 2021
作者:
G
guyuanzhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Description:fix components support margin padding
Sig:graphic Feature or Bugfix:Feature Binary Source:No
上级
3cb0bfae
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
891 addition
and
108 deletion
+891
-108
frameworks/components/ui_arc_label.cpp
frameworks/components/ui_arc_label.cpp
+7
-14
frameworks/components/ui_box_progress.cpp
frameworks/components/ui_box_progress.cpp
+23
-16
frameworks/components/ui_button.cpp
frameworks/components/ui_button.cpp
+2
-0
frameworks/components/ui_chart.cpp
frameworks/components/ui_chart.cpp
+3
-6
frameworks/components/ui_list.cpp
frameworks/components/ui_list.cpp
+16
-28
frameworks/components/ui_picker.cpp
frameworks/components/ui_picker.cpp
+15
-14
frameworks/components/ui_swipe_view.cpp
frameworks/components/ui_swipe_view.cpp
+7
-7
frameworks/components/ui_view.cpp
frameworks/components/ui_view.cpp
+2
-2
frameworks/layout/flex_layout.cpp
frameworks/layout/flex_layout.cpp
+6
-4
interfaces/kits/components/ui_arc_label.h
interfaces/kits/components/ui_arc_label.h
+11
-0
interfaces/kits/components/ui_button.h
interfaces/kits/components/ui_button.h
+2
-6
interfaces/kits/components/ui_label.h
interfaces/kits/components/ui_label.h
+2
-1
interfaces/kits/components/ui_list.h
interfaces/kits/components/ui_list.h
+2
-3
interfaces/kits/components/ui_swipe_view.h
interfaces/kits/components/ui_swipe_view.h
+4
-2
interfaces/kits/components/ui_view.h
interfaces/kits/components/ui_view.h
+47
-5
test/framework/BUILD.gn
test/framework/BUILD.gn
+1
-0
test/framework/src/ui_test_group.cpp
test/framework/src/ui_test_group.cpp
+2
-0
test/uitest/test_border_margin_padding/ui_test_border_margin_padding.cpp
...t_border_margin_padding/ui_test_border_margin_padding.cpp
+560
-0
test/uitest/test_border_margin_padding/ui_test_border_margin_padding.h
...est_border_margin_padding/ui_test_border_margin_padding.h
+178
-0
tools/qt/simulator/test/test.pro
tools/qt/simulator/test/test.pro
+1
-0
未找到文件。
frameworks/components/ui_arc_label.cpp
浏览文件 @
95865723
...
...
@@ -124,12 +124,8 @@ void UIArcLabel::OnDraw(const Rect& invalidatedArea)
}
Rect
trunc
=
invalidatedArea
;
OpacityType
opa
=
GetMixOpaScale
();
DrawRect
::
Draw
(
GetRect
(),
trunc
,
*
style_
,
opa
);
Rect
coords
=
GetContentRect
();
if
(
trunc
.
Intersect
(
trunc
,
coords
))
{
DrawArcText
(
trunc
,
opa
);
}
UIView
::
OnDraw
(
invalidatedArea
);
DrawArcText
(
trunc
,
opa
);
}
void
UIArcLabel
::
DrawArcText
(
const
Rect
&
mask
,
OpacityType
opaScale
)
...
...
@@ -139,8 +135,8 @@ void UIArcLabel::DrawArcText(const Rect& mask, OpacityType opaScale)
center
.
y
=
arcTextInfo_
.
arcCenter
.
y
+
GetRect
().
GetY
();
InitArcLabelText
();
UIFont
::
GetInstance
()
->
SetCurrentFontId
(
arcLabelText_
->
GetFontId
(),
arcLabelText_
->
GetFontSize
());
DrawLabel
::
DrawArcText
(
mask
,
arcLabelText_
->
GetText
(),
center
,
arcLabelText_
->
GetFontId
(),
arcTextInfo_
,
orientation_
,
*
style_
,
opaScale
);
DrawLabel
::
DrawArcText
(
mask
,
arcLabelText_
->
GetText
(),
center
,
arcLabelText_
->
GetFontId
(),
arcTextInfo_
,
orientation_
,
*
style_
,
opaScale
);
}
void
UIArcLabel
::
RefreshArcLabel
()
...
...
@@ -161,18 +157,15 @@ void UIArcLabel::ReMeasure()
UIFont
::
GetInstance
()
->
SetCurrentFontId
(
arcLabelText_
->
GetFontId
(),
arcLabelText_
->
GetFontSize
());
MeasureArcTextInfo
();
Rect
textRect
=
TypedText
::
GetArcTextRect
(
arcLabelText_
->
GetText
(),
arcCenter_
,
style_
->
letterSpace_
,
orientation_
,
Rect
textRect
=
TypedText
::
GetArcTextRect
(
arcLabelText_
->
GetText
(),
arcCenter_
,
style_
->
letterSpace_
,
orientation_
,
arcTextInfo_
);
int16_t
arcTextWidth
=
textRect
.
GetWidth
();
int16_t
arcTextHeight
=
textRect
.
GetHeight
();
SetPosition
(
textRect
.
GetX
(),
textRect
.
GetY
());
Resize
(
arcTextWidth
,
arcTextHeight
);
arcTextInfo_
.
arcCenter
.
x
=
arcCenter_
.
x
-
GetX
();
arcTextInfo_
.
arcCenter
.
y
=
arcCenter_
.
y
-
GetY
();
arcTextInfo_
.
arcCenter
.
x
=
arcCenter_
.
x
-
GetX
()
+
style_
->
borderWidth_
+
style_
->
paddingLeft_
;
arcTextInfo_
.
arcCenter
.
y
=
arcCenter_
.
y
-
GetY
()
+
style_
->
borderWidth_
+
style_
->
paddingTop_
;
textSize_
.
x
=
arcTextWidth
;
textSize_
.
y
=
arcTextHeight
;
Invalidate
();
...
...
frameworks/components/ui_box_progress.cpp
浏览文件 @
95865723
...
...
@@ -25,8 +25,11 @@ UIBoxProgress::UIBoxProgress()
SetDirection
(
Direction
::
DIR_LEFT_TO_RIGHT
);
}
void
UIBoxProgress
::
DrawValidRect
(
const
Image
*
image
,
const
Rect
&
rect
,
const
Rect
&
invalidatedArea
,
const
Style
&
style
,
uint16_t
radius
)
void
UIBoxProgress
::
DrawValidRect
(
const
Image
*
image
,
const
Rect
&
rect
,
const
Rect
&
invalidatedArea
,
const
Style
&
style
,
uint16_t
radius
)
{
Rect
cordsTmp
;
if
((
image
!=
nullptr
)
&&
(
image
->
GetSrcType
()
!=
IMG_SRC_UNKNOWN
))
{
...
...
@@ -65,8 +68,12 @@ void UIBoxProgress::DrawValidRect(const Image* image, const Rect& rect, const Re
}
}
void
UIBoxProgress
::
DrawRoundCap
(
const
Image
*
image
,
const
Point
&
imgPos
,
const
Rect
&
rect
,
const
Rect
&
invalidatedArea
,
uint16_t
radius
,
const
Style
&
style
)
void
UIBoxProgress
::
DrawRoundCap
(
const
Image
*
image
,
const
Point
&
imgPos
,
const
Rect
&
rect
,
const
Rect
&
invalidatedArea
,
uint16_t
radius
,
const
Style
&
style
)
{
Point
leftTop
;
Point
leftBottom
;
...
...
@@ -134,8 +141,11 @@ void UIBoxProgress::DrawRoundCap(const Image* image, const Point& imgPos, const
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
}
void
UIBoxProgress
::
GetBackgroundParam
(
Point
&
startPoint
,
int16_t
&
width
,
int16_t
&
height
,
uint16_t
&
radius
,
const
Style
&
style
)
void
UIBoxProgress
::
GetBackgroundParam
(
Point
&
startPoint
,
int16_t
&
width
,
int16_t
&
height
,
uint16_t
&
radius
,
const
Style
&
style
)
{
Rect
rect
=
GetOrigRect
();
// 2: Half of the gap
...
...
@@ -223,17 +233,14 @@ void UIBoxProgress::DrawForeground(const Rect& invalidatedArea, Rect& coords)
void
UIBoxProgress
::
OnDraw
(
const
Rect
&
invalidatedArea
)
{
DrawRect
::
Draw
(
GetOrigRect
(),
invalidatedArea
,
*
style_
,
opaScale_
);
Rect
trunc
(
invalidatedArea
);
if
(
trunc
.
Intersect
(
trunc
,
GetOrigRect
()))
{
if
(
enableBackground_
)
{
DrawBackground
(
trunc
);
}
UIView
::
OnDraw
(
invalidatedArea
);
if
(
enableBackground_
)
{
DrawBackground
(
invalidatedArea
);
}
if
((
lastValue_
-
rangeMin_
!=
0
)
||
(
foregroundStyle_
->
lineCap_
==
CapType
::
CAP_ROUND
))
{
Rect
coords
;
DrawForeground
(
trunc
,
coords
);
}
if
((
lastValue_
-
rangeMin_
!=
0
)
||
(
foregroundStyle_
->
lineCap_
==
CapType
::
CAP_ROUND
))
{
Rect
coords
;
DrawForeground
(
invalidatedArea
,
coords
);
}
}
}
// namespace OHOS
\ No newline at end of file
frameworks/components/ui_button.cpp
浏览文件 @
95865723
...
...
@@ -108,6 +108,7 @@ void UIButton::SetupThemeStyles()
buttonStyles_
[
PRESSED
]
=
&
(
theme
->
GetButtonStyle
().
pressed
);
buttonStyles_
[
INACTIVE
]
=
&
(
theme
->
GetButtonStyle
().
inactive
);
}
style_
=
buttonStyles_
[
RELEASED
];
}
int64_t
UIButton
::
GetStyle
(
uint8_t
key
)
const
...
...
@@ -143,6 +144,7 @@ void UIButton::SetStyleForState(uint8_t key, int64_t value, ButtonState state)
}
buttonStyleAllocFlag_
=
true
;
}
style_
=
buttonStyles_
[
RELEASED
];
int16_t
width
=
GetWidth
();
int16_t
height
=
GetHeight
();
buttonStyles_
[
state
]
->
SetStyle
(
key
,
value
);
...
...
frameworks/components/ui_chart.cpp
浏览文件 @
95865723
...
...
@@ -40,7 +40,7 @@ void UIChart::SetHeight(int16_t height)
needRefresh_
=
true
;
}
UIView
Group
::
SetHeight
(
height
);
UIView
::
SetHeight
(
height
);
xAxis_
.
SetHeight
(
height
);
xAxis_
.
UpdateAxis
();
yAxis_
.
SetHeight
(
height
);
...
...
@@ -49,7 +49,7 @@ void UIChart::SetHeight(int16_t height)
void
UIChart
::
SetWidth
(
int16_t
width
)
{
UIView
Group
::
SetWidth
(
width
);
UIView
::
SetWidth
(
width
);
xAxis_
.
SetWidth
(
width
);
yAxis_
.
SetWidth
(
width
);
xAxis_
.
UpdateAxis
();
...
...
@@ -59,10 +59,7 @@ void UIChart::SetWidth(int16_t width)
void
UIChart
::
OnDraw
(
const
Rect
&
invalidatedArea
)
{
UIViewGroup
::
OnDraw
(
invalidatedArea
);
Rect
rect
=
GetContentRect
();
if
(
rect
.
Intersect
(
rect
,
invalidatedArea
))
{
DrawDataSerials
(
rect
);
}
DrawDataSerials
(
invalidatedArea
);
}
bool
UIChart
::
AddDataSerial
(
UIChartDataSerial
*
dataSerial
)
...
...
frameworks/components/ui_list.cpp
浏览文件 @
95865723
...
...
@@ -369,13 +369,13 @@ bool UIList::ReCalculateDragEnd()
}
bool
UIList
::
MoveChildStepInner
(
int16_t
distance
,
int16_t
(
UIView
::*
pfnG
etXOrY
)()
const
,
int16_t
(
Rect
::*
pfnGetWidthOrHeight
)()
const
)
int16_t
(
UIView
::*
g
etXOrY
)()
const
,
int16_t
(
UIView
::*
getWidthOrHeight
)()
)
{
bool
popRet
=
false
;
bool
pushRet
=
false
;
if
(
distance
>
0
)
{
if
((
childrenHead_
==
nullptr
)
||
((
childrenHead_
->*
pfnG
etXOrY
)()
+
distance
>
0
))
{
if
((
childrenHead_
==
nullptr
)
||
((
childrenHead_
->*
g
etXOrY
)()
+
distance
>
0
))
{
uint16_t
index
=
GetIndexDec
(
topIndex_
);
if
(
index
==
topIndex_
)
{
return
false
;
...
...
@@ -387,15 +387,14 @@ bool UIList::MoveChildStepInner(int16_t distance,
PushFront
(
newView
);
pushRet
=
true
;
}
if
(
childrenTail_
!=
nullptr
&&
((
childrenTail_
->*
pfnGetXOrY
)()
+
distance
>
(
this
->
GetRelativeRect
().
*
pfnGetWidthOrHeight
)()))
{
if
(
childrenTail_
!=
nullptr
&&
((
childrenTail_
->*
getXOrY
)()
+
distance
>
(
this
->*
getWidthOrHeight
)()))
{
PopItem
(
childrenTail_
);
popRet
=
true
;
}
}
else
{
if
((
childrenTail_
==
nullptr
)
||
((
childrenTail_
->*
pfnGetXOrY
)()
+
(
childrenTail_
->
GetRelativeRect
().
*
pfnG
etWidthOrHeight
)()
+
distance
<
(
this
->
GetRelativeRect
().
*
pfnG
etWidthOrHeight
)()))
{
((
childrenTail_
->*
getXOrY
)()
+
(
childrenTail_
->*
g
etWidthOrHeight
)()
+
distance
<
(
this
->
*
g
etWidthOrHeight
)()))
{
UIView
*
newView
=
recycle_
.
GetView
(
GetIndexInc
(
bottomIndex_
));
if
(
newView
==
nullptr
)
{
return
false
;
...
...
@@ -403,8 +402,7 @@ bool UIList::MoveChildStepInner(int16_t distance,
PushBack
(
newView
);
pushRet
=
true
;
}
if
(
childrenHead_
&&
(
childrenHead_
->*
pfnGetXOrY
)()
+
distance
+
(
childrenHead_
->
GetRelativeRect
().
*
pfnGetWidthOrHeight
)()
<
0
)
{
if
(
childrenHead_
&&
(
childrenHead_
->*
getXOrY
)()
+
distance
+
(
childrenHead_
->*
getWidthOrHeight
)()
<
0
)
{
PopItem
(
childrenHead_
);
popRet
=
true
;
}
...
...
@@ -415,9 +413,9 @@ bool UIList::MoveChildStepInner(int16_t distance,
bool
UIList
::
MoveChildStep
(
int16_t
distance
)
{
if
(
direction_
==
VERTICAL
)
{
return
MoveChildStepInner
(
distance
,
&
UIView
::
GetY
,
&
Rect
::
GetHeight
);
return
MoveChildStepInner
(
distance
,
&
UIView
::
GetY
,
&
UIView
::
GetHeightWithMargin
);
}
else
{
return
MoveChildStepInner
(
distance
,
&
UIView
::
GetX
,
&
Rect
::
GetWidth
);
return
MoveChildStepInner
(
distance
,
&
UIView
::
GetX
,
&
UIView
::
GetWidthWithMargin
);
}
}
...
...
@@ -468,13 +466,9 @@ void UIList::PushBack(UIView* view)
SetHead
(
view
);
}
else
{
if
(
direction_
==
VERTICAL
)
{
view
->
SetPosition
(
view
->
GetStyle
(
STYLE_MARGIN_LEFT
),
childrenTail_
->
GetY
()
+
childrenTail_
->
GetRelativeRect
().
GetHeight
()
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
+
view
->
GetStyle
(
STYLE_MARGIN_TOP
));
view
->
SetPosition
(
0
,
childrenTail_
->
GetY
()
+
childrenTail_
->
GetHeightWithMargin
());
}
else
{
view
->
SetPosition
(
childrenTail_
->
GetX
()
+
childrenTail_
->
GetRelativeRect
().
GetWidth
()
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
+
view
->
GetStyle
(
STYLE_MARGIN_LEFT
),
view
->
GetStyle
(
STYLE_MARGIN_TOP
));
view
->
SetPosition
(
childrenTail_
->
GetX
()
+
childrenTail_
->
GetHeightWithMargin
(),
0
);
}
bottomIndex_
=
GetIndexInc
(
bottomIndex_
);
}
...
...
@@ -492,13 +486,9 @@ void UIList::PushFront(UIView* view)
SetHead
(
view
);
}
else
{
if
(
direction_
==
VERTICAL
)
{
view
->
SetPosition
(
view
->
GetStyle
(
STYLE_MARGIN_LEFT
),
GetChildrenHead
()
->
GetY
()
-
GetChildrenHead
()
->
GetStyle
(
STYLE_MARGIN_TOP
)
-
view
->
GetRelativeRect
().
GetHeight
()
-
view
->
GetStyle
(
STYLE_MARGIN_BOTTOM
));
view
->
SetPosition
(
0
,
GetChildrenHead
()
->
GetY
()
-
view
->
GetHeightWithMargin
());
}
else
{
view
->
SetPosition
(
GetChildrenHead
()
->
GetX
()
-
GetChildrenHead
()
->
GetStyle
(
STYLE_MARGIN_LEFT
)
-
view
->
GetRelativeRect
().
GetWidth
()
-
view
->
GetStyle
(
STYLE_MARGIN_RIGHT
),
view
->
GetStyle
(
STYLE_MARGIN_TOP
));
view
->
SetPosition
(
GetChildrenHead
()
->
GetX
()
-
view
->
GetWidthWithMargin
(),
0
);
}
topIndex_
=
GetIndexDec
(
topIndex_
);
}
...
...
@@ -525,7 +515,7 @@ void UIList::PopItem(UIView* view)
void
UIList
::
SetHead
(
UIView
*
view
)
{
if
(
view
!=
nullptr
)
{
view
->
SetPosition
(
view
->
GetStyle
(
STYLE_MARGIN_LEFT
),
view
->
GetStyle
(
STYLE_MARGIN_TOP
)
);
view
->
SetPosition
(
0
,
0
);
topIndex_
=
startIndex_
;
bottomIndex_
=
startIndex_
;
}
...
...
@@ -545,8 +535,7 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
if
((
onSelectedIndex_
!=
NULL_SELECT_INDEX
)
&&
(
selectPosition_
!=
0
))
{
if
(
direction_
==
VERTICAL
)
{
height
=
view
->
GetRelativeRect
().
GetHeight
();
if
((
GetChildrenHead
()
->
GetY
()
-
GetChildrenHead
()
->
GetStyle
(
STYLE_MARGIN_TOP
)
+
yOffset
>
selectPosition_
)
||
if
((
GetChildrenHead
()
->
GetY
()
+
yOffset
>
selectPosition_
)
||
(
childrenTail_
->
GetY
()
+
height
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_BOTTOM
)
+
yOffset
<
selectPosition_
))
{
onSelectedIndex_
=
NULL_SELECT_INDEX
;
...
...
@@ -557,8 +546,7 @@ void UIList::MoveChildByOffset(int16_t xOffset, int16_t yOffset)
}
}
else
{
width
=
view
->
GetRelativeRect
().
GetWidth
();
if
((
GetChildrenHead
()
->
GetX
()
-
GetChildrenHead
()
->
GetStyle
(
STYLE_MARGIN_LEFT
)
+
xOffset
>
selectPosition_
)
||
if
((
GetChildrenHead
()
->
GetX
()
+
xOffset
>
selectPosition_
)
||
(
childrenTail_
->
GetX
()
+
width
+
childrenTail_
->
GetStyle
(
STYLE_MARGIN_RIGHT
)
<
selectPosition_
))
{
onSelectedIndex_
=
NULL_SELECT_INDEX
;
onSelectedView_
=
nullptr
;
...
...
frameworks/components/ui_picker.cpp
浏览文件 @
95865723
...
...
@@ -23,8 +23,14 @@ namespace OHOS {
class
PickerListScrollListener
:
public
ListScrollListener
{
public:
PickerListScrollListener
(
UIPicker
*
picker
,
UIList
*
list
)
:
listView_
(
list
),
pickerView_
(
picker
),
selectView_
(
nullptr
),
lastSelectView_
(
nullptr
),
selectIndex_
(
0
),
isInitted_
(
false
){}
:
listView_
(
list
),
pickerView_
(
picker
),
selectView_
(
nullptr
),
lastSelectView_
(
nullptr
),
selectIndex_
(
0
),
isInitted_
(
false
)
{
}
virtual
~
PickerListScrollListener
()
{}
...
...
@@ -46,8 +52,7 @@ public:
if
(
pickerView_
->
highlightFontName_
==
nullptr
)
{
static_cast
<
UILabel
*>
(
view
)
->
SetFontId
(
pickerView_
->
highlightFontId_
);
}
else
{
static_cast
<
UILabel
*>
(
view
)
->
SetFont
(
pickerView_
->
highlightFontName_
,
pickerView_
->
highlightFontSize_
);
static_cast
<
UILabel
*>
(
view
)
->
SetFont
(
pickerView_
->
highlightFontName_
,
pickerView_
->
highlightFontSize_
);
}
lastSelectView_
=
view
;
selectIndex_
=
index
;
...
...
@@ -76,8 +81,7 @@ public:
if
(
pickerView_
->
highlightFontName_
==
nullptr
)
{
static_cast
<
UILabel
*>
(
view
)
->
SetFontId
(
pickerView_
->
highlightFontId_
);
}
else
{
static_cast
<
UILabel
*>
(
view
)
->
SetFont
(
pickerView_
->
highlightFontName_
,
pickerView_
->
highlightFontSize_
);
static_cast
<
UILabel
*>
(
view
)
->
SetFont
(
pickerView_
->
highlightFontName_
,
pickerView_
->
highlightFontSize_
);
}
listView_
->
Invalidate
();
...
...
@@ -184,7 +188,7 @@ UIPicker::~UIPicker()
ClearValues
();
Remove
(
&
list_
);
if
(
listListener_
!=
nullptr
)
{
delete
static_cast
<
PickerListScrollListener
*>
(
listListener_
);
delete
static_cast
<
PickerListScrollListener
*>
(
listListener_
);
listListener_
=
nullptr
;
}
...
...
@@ -293,12 +297,9 @@ void UIPicker::RefreshList()
textAdapter_
->
SetDirect
(
direct_
);
list_
.
SetHeight
(
height
);
list_
.
SetWidth
(
itemsWidth_
);
list_
.
SetPosition
(
GetWidth
()
/
2
-
list_
.
GetWidth
()
/
2
,
0
);
// 2: half
list_
.
LayoutCenterOfParent
();
list_
.
SetScrollBlankSize
((
height
-
itemsHeight_
)
/
2
);
// 2: half
list_
.
SetSelectPosition
(
height
/
2
);
// 2: half
list_
.
SetStyle
(
*
style_
);
list_
.
SetStyle
(
STYLE_BORDER_WIDTH
,
0
);
list_
.
SetStyle
(
STYLE_BACKGROUND_OPA
,
0
);
list_
.
SetSelectPosition
(
height
/
2
);
// 2: half
if
(
!
isSetAdaptered_
)
{
list_
.
SetAdapter
(
textAdapter_
);
isSetAdaptered_
=
true
;
...
...
@@ -342,7 +343,7 @@ bool UIPicker::RefreshSelected(uint16_t index)
listListener
->
SetInitStatus
(
false
);
// 2: half
int16_t
yOffset
=
(
list_
.
GetHeight
()
-
itemsHeight_
)
/
2
-
itemsHeight_
*
(
index
-
list_
.
GetChildrenHead
()
->
GetViewIndex
());
itemsHeight_
*
(
index
-
list_
.
GetChildrenHead
()
->
GetViewIndex
());
list_
.
SetScrollStateListener
(
nullptr
);
list_
.
ScrollBy
(
yOffset
-
list_
.
GetChildrenHead
()
->
GetY
());
list_
.
SetScrollStateListener
(
listListener
);
...
...
@@ -466,4 +467,4 @@ void UIPicker::SetTextFormatter(TextFormatter* formatter)
textAdapter_
->
SetTextFormatter
(
formatter
);
Refresh
();
}
}
}
// namespace OHOS
frameworks/components/ui_swipe_view.cpp
浏览文件 @
95865723
...
...
@@ -230,12 +230,12 @@ void UISwipeView::SwitchToPage(int16_t dst, bool needAnimator)
if
(
alignMode_
==
ALIGN_LEFT
)
{
xOffset
=
-
dstView
->
GetX
();
}
else
if
(
alignMode_
==
ALIGN_RIGHT
)
{
xOffset
=
GetWidth
()
-
(
dstView
->
GetX
()
+
dstView
->
GetWidth
());
xOffset
=
GetWidth
()
-
(
dstView
->
GetX
()
+
dstView
->
GetWidth
WithMargin
());
}
else
{
xOffset
=
(
GetWidth
()
>>
1
)
-
(
dstView
->
GetX
()
+
(
dstView
->
GetWidth
()
>>
1
));
xOffset
=
(
GetWidth
()
>>
1
)
-
(
dstView
->
GetX
()
+
(
dstView
->
GetWidth
WithMargin
()
>>
1
));
}
}
else
{
yOffset
=
(
GetHeight
()
>>
1
)
-
(
dstView
->
GetY
()
+
(
dstView
->
GetHeight
()
>>
1
));
yOffset
=
(
GetHeight
()
>>
1
)
-
(
dstView
->
GetY
()
+
(
dstView
->
GetHeight
WithMargin
()
>>
1
));
}
if
((
xOffset
!=
0
)
||
(
yOffset
!=
0
))
{
...
...
@@ -279,9 +279,9 @@ void UISwipeView::SortChild()
while
(
next
!=
nullptr
)
{
if
(
direction_
==
HORIZONTAL
)
{
next
->
SetX
(
pre
->
Get
X
()
+
pre
->
GetWidth
(
));
next
->
SetX
(
pre
->
Get
RelativeRect
().
GetRight
()
+
pre
->
GetStyle
(
STYLE_MARGIN_RIGHT
));
}
else
{
next
->
SetY
(
pre
->
Get
Y
()
+
pre
->
GetHeight
(
));
next
->
SetY
(
pre
->
Get
RelativeRect
().
GetBottom
()
+
pre
->
GetStyle
(
STYLE_MARGIN_BOTTOM
));
}
pre
=
next
;
next
->
SetViewIndex
(
index
);
...
...
@@ -375,9 +375,9 @@ void UISwipeView::RefreshCurrentViewInner(int16_t distance,
void
UISwipeView
::
RefreshCurrentView
(
int16_t
distance
)
{
if
(
direction_
==
HORIZONTAL
)
{
RefreshCurrentViewInner
(
distance
,
&
UIView
::
GetX
,
&
UIView
::
GetWidth
);
RefreshCurrentViewInner
(
distance
,
&
UIView
::
GetX
,
&
UIView
::
GetWidth
WithMargin
);
}
else
{
RefreshCurrentViewInner
(
distance
,
&
UIView
::
GetY
,
&
UIView
::
GetHeight
);
RefreshCurrentViewInner
(
distance
,
&
UIView
::
GetY
,
&
UIView
::
GetHeight
WithMargin
);
}
}
...
...
frameworks/components/ui_view.cpp
浏览文件 @
95865723
...
...
@@ -468,8 +468,8 @@ Rect UIView::GetOrigRect() const
int16_t
y
=
rect_
.
GetY
();
UIView
*
par
=
parent_
;
while
(
par
!=
nullptr
)
{
x
+=
par
->
Get
X
()
+
par
->
style_
->
paddingLeft_
+
par
->
style_
->
borderWidth_
;
y
+=
par
->
Get
Y
()
+
par
->
style_
->
paddingTop_
+
par
->
style_
->
borderWidth_
;
x
+=
par
->
Get
RelativeRect
().
GetX
()
+
par
->
GetStyle
(
STYLE_PADDING_LEFT
)
+
par
->
GetStyle
(
STYLE_BORDER_WIDTH
)
;
y
+=
par
->
Get
RelativeRect
().
GetY
()
+
par
->
GetStyle
(
STYLE_PADDING_TOP
)
+
par
->
GetStyle
(
STYLE_BORDER_WIDTH
)
;
par
=
par
->
parent_
;
}
return
Rect
(
x
,
y
,
x
+
rect_
.
GetWidth
()
-
1
,
y
+
rect_
.
GetHeight
()
-
1
);
...
...
frameworks/layout/flex_layout.cpp
浏览文件 @
95865723
...
...
@@ -296,9 +296,10 @@ void FlexLayout::LayoutHorizontal()
GetCrossAxisPosY
(
posY
,
count
,
rowsMaxHeight
,
child
);
if
(
direction_
==
LAYOUT_HOR_R
)
{
child
->
SetPosition
(
GetWidth
()
-
(
posX
-
left
)
-
child
->
GetRelativeRect
().
GetWidth
()
-
right
,
posY
);
child
->
SetPosition
(
GetWidth
()
-
posX
-
child
->
GetRelativeRect
().
GetWidth
()
-
right
,
posY
-
child
->
GetStyle
(
STYLE_MARGIN_TOP
));
}
else
{
child
->
SetPosition
(
posX
,
posY
);
child
->
SetPosition
(
posX
-
left
,
posY
-
child
->
GetStyle
(
STYLE_MARGIN_TOP
)
);
}
posX
+=
child
->
GetRelativeRect
().
GetWidth
()
+
right
+
interval
;
child
->
LayoutChildren
();
...
...
@@ -483,9 +484,10 @@ void FlexLayout::LayoutVertical()
GetCrossAxisPosX
(
posX
,
count
,
columnsMaxWidth
,
child
);
if
(
direction_
==
LAYOUT_VER_R
)
{
child
->
SetPosition
(
posX
,
GetHeight
()
-
(
posY
-
top
)
-
child
->
GetRelativeRect
().
GetHeight
()
-
bottom
);
child
->
SetPosition
(
posX
-
child
->
GetStyle
(
STYLE_MARGIN_LEFT
),
GetHeight
()
-
posY
-
child
->
GetRelativeRect
().
GetHeight
()
-
bottom
);
}
else
{
child
->
SetPosition
(
posX
,
posY
);
child
->
SetPosition
(
posX
-
child
->
GetStyle
(
STYLE_MARGIN_LEFT
),
posY
-
top
);
}
posY
+=
child
->
GetRelativeRect
().
GetHeight
()
+
bottom
+
interval
;
child
->
LayoutChildren
();
...
...
interfaces/kits/components/ui_arc_label.h
浏览文件 @
95865723
...
...
@@ -113,6 +113,17 @@ public:
return
UIView
::
GetHeight
();
}
/**
* @brief Sets the view style.
* @param style Indicates the view style.
* @since 1.0
* @version 1.0
*/
virtual
void
SetStyle
(
Style
&
style
)
override
{
UIView
::
SetStyle
(
style
);
}
/**
* @brief Sets a style.
*
...
...
interfaces/kits/components/ui_button.h
浏览文件 @
95865723
...
...
@@ -290,9 +290,7 @@ public:
void
SetWidth
(
int16_t
width
)
override
{
contentWidth_
=
width
;
Style
*
style
=
buttonStyles_
[
state_
];
UIView
::
SetWidth
(
width
+
(
style
->
paddingLeft_
+
style
->
paddingRight_
)
+
(
style
->
borderWidth_
*
2
));
/* 2: left and right border */
UIView
::
SetWidth
(
width
);
/* 2: left and right border */
}
/**
...
...
@@ -305,9 +303,7 @@ public:
void
SetHeight
(
int16_t
height
)
override
{
contentHeight_
=
height
;
Style
*
style
=
buttonStyles_
[
state_
];
UIView
::
SetHeight
(
height
+
(
style
->
paddingTop_
+
style
->
paddingBottom_
)
+
(
style
->
borderWidth_
*
2
));
/* 2: top and bottom border */
UIView
::
SetHeight
(
height
);
/* 2: top and bottom border */
}
/**
...
...
interfaces/kits/components/ui_label.h
浏览文件 @
95865723
...
...
@@ -421,6 +421,8 @@ public:
*/
void
SetY
(
int16_t
y
)
override
;
void
ReMeasure
()
override
;
protected:
Text
*
labelText_
;
void
RefreshLabel
();
...
...
@@ -430,7 +432,6 @@ protected:
private:
friend
class
LabelAnimator
;
void
ReMeasure
()
override
;
void
RemeasureForMarquee
(
int16_t
textWidth
);
bool
needRefresh_
:
1
;
...
...
interfaces/kits/components/ui_list.h
浏览文件 @
95865723
...
...
@@ -446,9 +446,8 @@ private:
void
PushFront
(
UIView
*
view
);
void
SetHead
(
UIView
*
view
);
bool
MoveChildStep
(
int16_t
distance
);
bool
MoveChildStepInner
(
int16_t
distance
,
int16_t
(
UIView
::*
pfnGetXOrY
)()
const
,
int16_t
(
Rect
::*
pfnGetWidthOrHeight
)()
const
);
bool
MoveChildStepInner
(
int16_t
distance
,
int16_t
(
UIView
::*
getXOrY
)()
const
,
int16_t
(
UIView
::*
getWidthOrHeight
)());
uint16_t
GetIndexInc
(
uint16_t
index
);
uint16_t
GetIndexDec
(
uint16_t
index
);
...
...
interfaces/kits/components/ui_swipe_view.h
浏览文件 @
95865723
...
...
@@ -360,8 +360,10 @@ protected:
private:
void
RefreshCurrentView
(
int16_t
distance
);
void
RefreshCurrentViewInner
(
int16_t
distance
,
int16_t
(
UIView
::*
pfnGetXOrY
)()
const
,
int16_t
(
UIView
::*
pfnGetWidthOrHeight
)());
void
RefreshCurrentViewInner
(
int16_t
distance
,
int16_t
(
UIView
::*
pfnGetXOrY
)()
const
,
int16_t
(
UIView
::*
pfnGetWidthOrHeight
)());
bool
isNeedLoop
();
void
MoveFirstChildToLast
();
void
MoveLastChildToFirst
();
...
...
interfaces/kits/components/ui_view.h
浏览文件 @
95865723
...
...
@@ -879,7 +879,12 @@ public:
* @since 1.0
* @version 1.0
*/
virtual
void
SetX
(
int16_t
x
)
{
rect_
.
SetX
(
x
);
}
virtual
void
SetX
(
int16_t
x
)
{
if
(
GetX
()
!=
x
)
{
rect_
.
SetX
(
x
+
GetStyle
(
STYLE_MARGIN_LEFT
));
}
}
/**
* @brief Sets a percentage that represents the proportion of the view's x-coordinate
...
...
@@ -896,7 +901,10 @@ public:
* @since 1.0
* @version 1.0
*/
int16_t
GetX
()
const
{
return
rect_
.
GetX
();
}
int16_t
GetX
()
const
{
return
rect_
.
GetX
()
-
GetStyle
(
STYLE_MARGIN_LEFT
);
}
/**
* @brief Sets the y-coordinate for the view.
...
...
@@ -904,7 +912,12 @@ public:
* @since 1.0
* @version 1.0
*/
virtual
void
SetY
(
int16_t
y
)
{
rect_
.
SetY
(
y
);
}
virtual
void
SetY
(
int16_t
y
)
{
if
(
GetY
()
!=
y
)
{
rect_
.
SetY
(
y
+
GetStyle
(
STYLE_MARGIN_TOP
));
}
}
/**
* @brief Sets a percentage that represents the proportion of the view's y-coordinate
...
...
@@ -921,7 +934,32 @@ public:
* @since 1.0
* @version 1.0
*/
int16_t
GetY
()
const
{
return
rect_
.
GetY
();
}
int16_t
GetY
()
const
{
return
rect_
.
GetY
()
-
GetStyle
(
STYLE_MARGIN_TOP
);
}
/**
* @brief 获取组件设置margin属性后margin的宽度,包括组件宽度加marginLeft 加 marginRight.
* @return margin的宽度
* @since 3.0
* @version 3.0
*/
int16_t
GetWidthWithMargin
()
{
return
GetRelativeRect
().
GetWidth
()
+
GetStyle
(
STYLE_MARGIN_LEFT
)
+
GetStyle
(
STYLE_MARGIN_RIGHT
);
}
/**
* @brief 获取组件设置margin属性后margin的高度度,包括组件宽度加marginTop 加 marginBottom.
* @return margin的高度
* @since 3.0
* @version 3.0
*/
int16_t
GetHeightWithMargin
()
{
return
GetRelativeRect
().
GetHeight
()
+
GetStyle
(
STYLE_MARGIN_TOP
)
+
GetStyle
(
STYLE_MARGIN_BOTTOM
);
}
/**
* @brief Sets the position for the view.
...
...
@@ -930,7 +968,11 @@ public:
* @since 1.0
* @version 1.0
*/
virtual
void
SetPosition
(
int16_t
x
,
int16_t
y
)
{
rect_
.
SetPosition
(
x
,
y
);
}
virtual
void
SetPosition
(
int16_t
x
,
int16_t
y
)
{
SetX
(
x
);
SetY
(
y
);
}
/**
* @brief Sets the position percentages for the view.
...
...
test/framework/BUILD.gn
浏览文件 @
95865723
...
...
@@ -60,6 +60,7 @@ test_sources = [
"../uitest/test_view_group/ui_test_view_group.cpp",
"../uitest/test_view_percent/ui_test_view_percent.cpp",
"../uitest/test_view_scale_rotate/ui_test_view_scale_rotate.cpp",
"../uitest/test_border_margin_padding/ui_test_border_margin_padding.cpp",
"src/test_ability.cpp",
"src/test_case_list_adapter.cpp",
"src/ui_test_app.cpp",
...
...
test/framework/src/ui_test_group.cpp
浏览文件 @
95865723
...
...
@@ -19,6 +19,7 @@
#include "test_animator/ui_test_animator.h"
#include "test_anti_aliasing/ui_test_anti_aliasing.h"
#include "test_arc_label/ui_test_arc_label.h"
#include "test_border_margin_padding/ui_test_border_margin_padding.h"
#include "test_button/ui_test_button.h"
#include "test_canvas/ui_test_canvas.h"
#include "test_chart/ui_test_chart_pillar.h"
...
...
@@ -141,6 +142,7 @@ void UITestGroup::SetUpTestCase()
#if ENABLE_FOCUS_MANAGER
testCaseList_
.
PushBack
(
TestCaseInfo
{
"FocusManager"
,
new
UITestFocusManager
()});
#endif
testCaseList_
.
PushBack
(
TestCaseInfo
{
"Border_Margin_Padding"
,
new
UITestBorderMarginPadding
()});
}
List
<
TestCaseInfo
>&
UITestGroup
::
GetTestCase
()
...
...
test/uitest/test_border_margin_padding/ui_test_border_margin_padding.cpp
0 → 100644
浏览文件 @
95865723
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "common/screen.h"
#include "components/text_adapter.h"
#include "components/ui_arc_label.h"
#include "components/ui_box_progress.h"
#include "components/ui_canvas.h"
#include "components/ui_circle_progress.h"
#include "components/ui_image_animator.h"
#include "components/ui_label_button.h"
#include "components/ui_list.h"
#include "components/ui_qrcode.h"
#include "components/ui_radio_button.h"
#include "components/ui_slider.h"
#include "components/ui_swipe_view.h"
#include "test_resource_config.h"
#include "ui_test_border_margin_padding.h"
namespace
OHOS
{
static
ImageAnimatorInfo
g_imageAnimatorInfo
[
4
]
=
{
{
IMAGE_ANIMATOR_0_PATH
,
{
84
,
108
},
116
,
116
,
IMG_SRC_FILE_PATH
},
{
IMAGE_ANIMATOR_1_PATH
,
{
84
,
108
},
116
,
116
,
IMG_SRC_FILE_PATH
},
{
IMAGE_ANIMATOR_2_PATH
,
{
84
,
108
},
116
,
116
,
IMG_SRC_FILE_PATH
},
{
IMAGE_ANIMATOR_3_PATH
,
{
84
,
108
},
116
,
116
,
IMG_SRC_FILE_PATH
},
};
void
UITestBorderMarginPadding
::
SetUp
()
{
container_
.
SetPosition
(
0
,
0
,
Screen
::
GetInstance
().
GetWidth
(),
Screen
::
GetInstance
().
GetHeight
()
-
BACK_BUTTON_HEIGHT
);
scroll_
.
SetPosition
(
0
,
0
,
Screen
::
GetInstance
().
GetWidth
()
-
BUTTON_GROUP_WIDTH
,
Screen
::
GetInstance
().
GetHeight
()
-
BACK_BUTTON_HEIGHT
);
scroll_
.
SetThrowDrag
(
true
);
scroll_
.
SetHorizontalScrollState
(
false
);
scroll_
.
SetScrollBlankSize
(
100
);
// 100 : blank size
layoutButton_
.
SetPosition
(
Screen
::
GetInstance
().
GetWidth
()
-
BUTTON_GROUP_WIDTH
,
0
,
BUTTON_GROUP_WIDTH
,
Screen
::
GetInstance
().
GetHeight
()
-
BACK_BUTTON_HEIGHT
);
layoutButton_
.
SetRows
(
3
);
// 3: rows
layoutButton_
.
SetCols
(
2
);
// 2: cols
listScroll_
=
new
ListLayout
(
ListLayout
::
VERTICAL
);
listScroll_
->
SetStyle
(
STYLE_BACKGROUND_OPA
,
OPA_OPAQUE
);
listScroll_
->
SetStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
Olive
().
full
);
listScroll_
->
SetPosition
(
0
,
0
,
Screen
::
GetInstance
().
GetWidth
()
-
BUTTON_GROUP_WIDTH
,
Screen
::
GetInstance
().
GetHeight
()
-
BACK_BUTTON_HEIGHT
);
scroll_
.
Add
(
listScroll_
);
container_
.
Add
(
&
scroll_
);
container_
.
Add
(
&
layoutButton_
);
margin_
.
Resize
(
64
,
64
);
// 64 : button size
border_
.
Resize
(
64
,
64
);
// 64 : button size
padding_
.
Resize
(
64
,
64
);
// 64 : button size
labelMargin_
.
SetLineBreakMode
(
UILabel
::
LINE_BREAK_ADAPT
);
labelMargin_
.
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
15
);
// 15: font size
labelMargin_
.
SetText
(
"margin ON/OFF"
);
labelMargin_
.
ReMeasure
();
labelBorder_
.
SetLineBreakMode
(
UILabel
::
LINE_BREAK_ADAPT
);
labelBorder_
.
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
15
);
// 15: font size
labelBorder_
.
SetText
(
"border ON/OFF"
);
labelBorder_
.
ReMeasure
();
labelPadding_
.
SetLineBreakMode
(
UILabel
::
LINE_BREAK_ADAPT
);
labelPadding_
.
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
15
);
// 15: font size
labelPadding_
.
SetText
(
"padding ON/OFF"
);
labelPadding_
.
ReMeasure
();
layoutButton_
.
Add
(
&
labelMargin_
);
layoutButton_
.
Add
(
&
margin_
);
layoutButton_
.
Add
(
&
labelBorder_
);
layoutButton_
.
Add
(
&
border_
);
layoutButton_
.
Add
(
&
labelPadding_
);
layoutButton_
.
Add
(
&
padding_
);
layoutButton_
.
LayoutChildren
();
BorderListener
*
borderListener_
=
new
BorderListener
(
this
);
border_
.
SetOnChangeListener
(
borderListener_
);
MarginListener
*
marginListener_
=
new
MarginListener
(
this
);
margin_
.
SetOnChangeListener
(
marginListener_
);
PaddingListener
*
paddingListener_
=
new
PaddingListener
(
this
);
padding_
.
SetOnChangeListener
(
paddingListener_
);
if
(
adapterData_
==
nullptr
)
{
adapterData_
=
new
List
<
const
char
*>
();
adapterData_
->
PushBack
(
"000"
);
adapterData_
->
PushBack
(
"111"
);
adapterData_
->
PushBack
(
"222"
);
adapterData_
->
PushBack
(
"333"
);
adapterData_
->
PushBack
(
"444"
);
adapterData_
->
PushBack
(
"555"
);
adapterData_
->
PushBack
(
"666"
);
adapterData_
->
PushBack
(
"777"
);
adapterData_
->
PushBack
(
"888"
);
adapterData_
->
PushBack
(
"999"
);
adapterData_
->
PushBack
(
"AAA"
);
adapterData_
->
PushBack
(
"BBB"
);
adapterData_
->
PushBack
(
"CCC"
);
}
}
void
UITestBorderMarginPadding
::
TearDown
()
{
if
(
borderListener_
!=
nullptr
)
{
delete
borderListener_
;
borderListener_
=
nullptr
;
}
if
(
marginListener_
!=
nullptr
)
{
delete
marginListener_
;
marginListener_
=
nullptr
;
}
if
(
paddingListener_
!=
nullptr
)
{
delete
paddingListener_
;
paddingListener_
=
nullptr
;
}
if
(
adapterData_
!=
nullptr
)
{
adapterData_
->
Clear
();
delete
adapterData_
;
adapterData_
=
nullptr
;
}
listScroll_
->
Remove
(
picker_
);
if
(
picker_
!=
nullptr
)
{
delete
picker_
;
picker_
=
nullptr
;
}
if
(
chart_
!=
nullptr
)
{
listScroll_
->
Remove
(
chart_
);
chart_
->
ClearDataSerial
();
delete
dataSerial_
;
dataSerial_
=
nullptr
;
delete
chart_
;
chart_
=
nullptr
;
}
layoutButton_
.
RemoveAll
();
container_
.
RemoveAll
();
DeleteChildren
(
listScroll_
);
listScroll_
=
nullptr
;
}
void
UITestBorderMarginPadding
::
ReloadTest
()
{
int16_t
heightBefor
=
listScroll_
->
GetHeight
();
int16_t
yBefor
=
listScroll_
->
GetY
();
scroll_
.
Remove
(
listScroll_
);
if
(
chart_
!=
nullptr
)
{
listScroll_
->
Remove
(
chart_
);
chart_
->
ClearDataSerial
();
delete
dataSerial_
;
dataSerial_
=
nullptr
;
delete
chart_
;
chart_
=
nullptr
;
}
if
(
picker_
!=
nullptr
)
{
listScroll_
->
Remove
(
picker_
);
delete
picker_
;
picker_
=
nullptr
;
}
DeleteChildren
(
listScroll_
);
listScroll_
=
new
ListLayout
(
ListLayout
::
VERTICAL
);
listScroll_
->
SetPosition
(
0
,
0
,
Screen
::
GetInstance
().
GetWidth
()
-
BUTTON_GROUP_WIDTH
,
Screen
::
GetInstance
().
GetHeight
()
-
BACK_BUTTON_HEIGHT
);
listScroll_
->
SetStyle
(
STYLE_BACKGROUND_OPA
,
OPA_OPAQUE
);
listScroll_
->
SetStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
Olive
().
full
);
scroll_
.
Add
(
listScroll_
);
GetTestView
();
int16_t
yAfter
=
listScroll_
->
GetHeight
()
*
yBefor
/
heightBefor
;
scroll_
.
ScrollBy
(
0
,
yAfter
);
container_
.
Invalidate
();
}
UIView
*
UITestBorderMarginPadding
::
GetTestView
()
{
UIKit_UITestBorderMarginPadding_Test_001
();
UIKit_UITestBorderMarginPadding_Test_002
();
UIKit_UITestBorderMarginPadding_Test_003
();
UIKit_UITestBorderMarginPadding_Test_004
();
UIKit_UITestBorderMarginPadding_Test_005
();
UIKit_UITestBorderMarginPadding_Test_006
();
UIKit_UITestBorderMarginPadding_Test_007
();
UIKit_UITestBorderMarginPadding_Test_008
();
UIKit_UITestBorderMarginPadding_Test_009
();
// UIKit_UITestBorderMarginPadding_Test_010();
UIKit_UITestBorderMarginPadding_Test_011
();
UIKit_UITestBorderMarginPadding_Test_012
();
UIKit_UITestBorderMarginPadding_Test_013
();
UIKit_UITestBorderMarginPadding_Test_014
();
UIKit_UITestBorderMarginPadding_Test_015
();
UIKit_UITestBorderMarginPadding_Test_016
();
UIKit_UITestBorderMarginPadding_Test_017
();
UIKit_UITestBorderMarginPadding_Test_018
();
return
&
container_
;
}
void
UITestBorderMarginPadding
::
AddTitle
(
const
char
*
text
)
{
UILabel
*
titleLabel
=
new
UILabel
();
titleLabel
->
SetLineBreakMode
(
UILabel
::
LINE_BREAK_ADAPT
);
titleLabel
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
FONT_DEFAULT_SIZE
);
titleLabel
->
SetText
(
text
);
listScroll_
->
Add
(
titleLabel
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_001
()
{
AddTitle
(
"UIView"
);
UIView
*
view
=
new
UIView
();
view
->
SetStyle
(
style_
);
view
->
Resize
(
200
,
100
);
// 200:size 100: size
listScroll_
->
Add
(
view
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_002
()
{
AddTitle
(
"UILabel"
);
UILabel
*
view
=
new
UILabel
();
view
->
SetStyle
(
style_
);
view
->
SetLineBreakMode
(
UILabel
::
LINE_BREAK_CLIP
);
view
->
SetAlign
(
TEXT_ALIGNMENT_CENTER
,
TEXT_ALIGNMENT_CENTER
);
view
->
Resize
(
200
,
100
);
// 200:size 100: size
view
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
FONT_DEFAULT_SIZE
);
view
->
SetText
(
"TEST UILABEL"
);
listScroll_
->
Add
(
view
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_003
()
{
AddTitle
(
"ArcLabel"
);
UIArcLabel
*
view
=
new
UIArcLabel
();
view
->
SetStyle
(
style_
);
view
->
SetArcTextCenter
(
180
,
180
);
// 180: text center
view
->
SetArcTextRadius
(
150
);
// 150: text radius
view
->
SetArcTextAngle
(
0
,
270
);
// 0: start angle 270: end angle
view
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
30
);
// 30: font size
view
->
SetText
(
"012345678ABCDEF0123456789ABCDE"
);
listScroll_
->
Add
(
view
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_004
()
{
AddTitle
(
"BoxProgress"
);
UIBoxProgress
*
boxProgress
=
new
UIBoxProgress
();
boxProgress
->
SetStyle
(
style_
);
boxProgress
->
SetPosition
(
10
,
10
,
100
,
10
);
// 10: x 10: y 100: width 10: height
boxProgress
->
SetValue
(
20
);
// 20: value
boxProgress
->
SetBackgroundStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
Yellow
().
full
);
boxProgress
->
SetForegroundStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
Green
().
full
);
listScroll_
->
Add
(
boxProgress
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_005
()
{
AddTitle
(
"UIViewGroup"
);
UIViewGroup
*
group
=
new
UIViewGroup
();
group
->
SetStyle
(
style_
);
group
->
Resize
(
200
,
100
);
// 200: size 100: size
listScroll_
->
Add
(
group
);
UIButton
*
button
=
new
UIButton
();
button
->
SetPosition
(
0
,
0
,
100
,
50
);
// 100: size 50: size
group
->
Add
(
button
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_006
()
{
AddTitle
(
"UICanvas"
);
UICanvas
*
canvas
=
new
UICanvas
();
canvas
->
SetStyle
(
style_
);
canvas
->
Resize
(
400
,
400
);
// 400: size
Paint
paint
;
paint
.
SetStrokeWidth
(
10
);
// 10: line width
// {10, 10}: Start point coordinates x, y; {300, 10}: end point coordinates x, y
canvas
->
DrawLine
({
10
,
10
},
{
300
,
10
},
paint
);
paint
.
SetStrokeColor
(
Color
::
Yellow
());
canvas
->
DrawCurve
({
100
,
50
},
{
150
,
50
},
{
150
,
50
},
{
150
,
100
},
paint
);
paint
.
SetStyle
(
Paint
::
PaintStyle
::
FILL_STYLE
);
paint
.
SetFillColor
(
Color
::
Yellow
());
paint
.
SetStrokeWidth
(
30
);
// 30: line width
// {10, 200}: left corner coordinates point, 50: width, 50: rectangle style
canvas
->
DrawRect
({
10
,
200
},
50
,
50
,
paint
);
paint
.
SetStyle
(
Paint
::
PaintStyle
::
STROKE_FILL_STYLE
);
paint
.
SetFillColor
(
Color
::
Yellow
());
paint
.
SetStrokeColor
(
Color
::
Blue
());
paint
.
SetStrokeWidth
(
10
);
// 10: line width
paint
.
SetOpacity
(
127
);
// 127: opacity
// {300, 100}: circle center coordinates, 30: circle radius
canvas
->
DrawCircle
({
300
,
100
},
30
,
paint
);
listScroll_
->
Add
(
canvas
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_007
()
{
AddTitle
(
"UIChart"
);
chart_
=
new
UIChartPolyline
();
chart_
->
SetStyle
(
style_
);
chart_
->
SetPosition
(
VIEW_DISTANCE_TO_LEFT_SIDE
,
VIEW_DISTANCE_TO_TOP_SIDE
);
chart_
->
SetWidth
(
454
);
// 454: width
chart_
->
SetHeight
(
250
);
// 250: height
dataSerial_
=
new
UIChartDataSerial
();
dataSerial_
->
SetMaxDataCount
(
5
);
// 5: number of data points
Point
pointArray
[
5
]
=
{{
0
,
2478
},
{
1
,
2600
},
{
2
,
3000
},
{
3
,
3200
},
{
4
,
3500
}};
dataSerial_
->
AddPoints
(
pointArray
,
5
);
// 5: number of data points
dataSerial_
->
SetLineColor
(
Color
::
Red
());
dataSerial_
->
SetFillColor
(
Color
::
Red
());
dataSerial_
->
EnableGradient
(
true
);
UIXAxis
&
xAxis
=
chart_
->
GetXAxis
();
UIYAxis
&
yAxis
=
chart_
->
GetYAxis
();
xAxis
.
SetMarkNum
(
5
);
// 5: number of scales
xAxis
.
SetDataRange
(
0
,
5
);
// 0: minimum value, 5: maximum value
yAxis
.
SetDataRange
(
0
,
5000
);
// 0: minimum value, 5000: maximum value
chart_
->
SetGradientOpacity
(
25
,
127
);
// 25: min opacity, 127: max opacity
chart_
->
AddDataSerial
(
dataSerial_
);
listScroll_
->
Add
(
chart_
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_008
()
{
AddTitle
(
"Button"
);
UIViewGroup
*
group
=
new
UIViewGroup
();
group
->
Resize
(
Screen
::
GetInstance
().
GetWidth
()
-
BUTTON_GROUP_WIDTH
,
200
);
// 200: button UIViewGroup height
UIButton
*
button
=
new
UIButton
();
button
->
SetStyleForState
(
STYLE_MARGIN_LEFT
,
style_
.
marginLeft_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_MARGIN_LEFT
,
style_
.
marginLeft_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_MARGIN_TOP
,
style_
.
marginTop_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_MARGIN_TOP
,
style_
.
marginTop_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_MARGIN_RIGHT
,
style_
.
marginRight_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_MARGIN_RIGHT
,
style_
.
marginRight_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_MARGIN_BOTTOM
,
style_
.
marginBottom_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_MARGIN_BOTTOM
,
style_
.
marginBottom_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_BORDER_WIDTH
,
style_
.
borderWidth_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_BORDER_WIDTH
,
style_
.
borderWidth_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_BORDER_OPA
,
style_
.
borderOpa_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_BORDER_OPA
,
style_
.
borderOpa_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_BORDER_COLOR
,
style_
.
borderColor_
.
full
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_BORDER_COLOR
,
style_
.
borderColor_
.
full
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_PADDING_LEFT
,
style_
.
paddingLeft_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_PADDING_LEFT
,
style_
.
paddingLeft_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_PADDING_TOP
,
style_
.
paddingTop_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_PADDING_TOP
,
style_
.
paddingTop_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_PADDING_RIGHT
,
style_
.
paddingRight_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_PADDING_RIGHT
,
style_
.
paddingRight_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_PADDING_BOTTOM
,
style_
.
paddingBottom_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_PADDING_BOTTOM
,
style_
.
paddingBottom_
,
UIButton
::
PRESSED
);
button
->
SetPosition
(
50
,
30
,
70
,
50
);
// 50: x 30: y 70: width 50: height
group
->
Add
(
button
);
UICheckBox
*
checkbox
=
new
UICheckBox
();
checkbox
->
SetStyle
(
style_
);
checkbox
->
SetPosition
(
200
,
30
,
50
,
50
);
// 200: x-coordinate, 30: y-coordinate, 50: size
group
->
Add
(
checkbox
);
UIRadioButton
*
radioButton
=
new
UIRadioButton
();
radioButton
->
SetStyle
(
style_
);
radioButton
->
SetPosition
(
350
,
30
,
50
,
50
);
// 350: x-coordinate, 30: y-coordinate, 50: size
group
->
Add
(
radioButton
);
UIToggleButton
*
toggleButton
=
new
UIToggleButton
();
toggleButton
->
SetStyle
(
style_
);
toggleButton
->
SetPosition
(
500
,
30
,
50
,
50
);
// 500: x-coordinate, 30: y-coordinate, 50: size
group
->
Add
(
toggleButton
);
listScroll_
->
Add
(
group
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_009
()
{
AddTitle
(
"UICircleProgress"
);
UICircleProgress
*
circleProgress
=
new
UICircleProgress
();
circleProgress
->
SetStyle
(
style_
);
circleProgress
->
Resize
(
150
,
150
);
// 150: width 150: height
circleProgress
->
SetCenterPosition
(
75
,
75
);
// 75: position x 75: position y
circleProgress
->
SetRadius
(
50
);
// 50: radius
circleProgress
->
SetValue
(
20
);
// 20: value
listScroll_
->
Add
(
circleProgress
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_010
()
{
AddTitle
(
"UIImageAnimatorView"
);
UIImageAnimatorView
*
imageAnimator
=
new
UIImageAnimatorView
();
imageAnimator
->
SetStyle
(
style_
);
imageAnimator
->
SetPosition
(
50
,
50
,
200
,
200
);
// 50 : offset 50 : offset 200 : offset 200: offset
imageAnimator
->
SetImageAnimatorSrc
(
g_imageAnimatorInfo
,
4
,
100
);
// 4: the number of images, 100: updating time
imageAnimator
->
Start
();
listScroll_
->
Add
(
imageAnimator
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_011
()
{
AddTitle
(
"UIImageView"
);
UIImageView
*
imageView
=
new
UIImageView
();
imageView
->
SetStyle
(
style_
);
imageView
->
SetWidth
(
50
);
// 50 : size
imageView
->
SetHeight
(
50
);
// 50 : size
imageView
->
SetSrc
(
BLUE_RGB888_IMAGE_PATH
);
listScroll_
->
Add
(
imageView
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_012
()
{
AddTitle
(
"UILabelButton"
);
UILabelButton
*
button
=
new
UILabelButton
();
button
->
SetStyleForState
(
STYLE_MARGIN_LEFT
,
style_
.
marginLeft_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_MARGIN_LEFT
,
style_
.
marginLeft_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_MARGIN_TOP
,
style_
.
marginTop_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_MARGIN_TOP
,
style_
.
marginTop_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_MARGIN_RIGHT
,
style_
.
marginRight_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_MARGIN_RIGHT
,
style_
.
marginRight_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_MARGIN_BOTTOM
,
style_
.
marginBottom_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_MARGIN_BOTTOM
,
style_
.
marginBottom_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_BORDER_WIDTH
,
style_
.
borderWidth_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_BORDER_WIDTH
,
style_
.
borderWidth_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_BORDER_OPA
,
style_
.
borderOpa_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_BORDER_OPA
,
style_
.
borderOpa_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_BORDER_COLOR
,
style_
.
borderColor_
.
full
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_BORDER_COLOR
,
style_
.
borderColor_
.
full
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_PADDING_LEFT
,
style_
.
paddingLeft_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_PADDING_LEFT
,
style_
.
paddingLeft_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_PADDING_TOP
,
style_
.
paddingTop_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_PADDING_TOP
,
style_
.
paddingTop_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_PADDING_RIGHT
,
style_
.
paddingRight_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_PADDING_RIGHT
,
style_
.
paddingRight_
,
UIButton
::
PRESSED
);
button
->
SetStyleForState
(
STYLE_PADDING_BOTTOM
,
style_
.
paddingBottom_
,
UIButton
::
RELEASED
);
button
->
SetStyleForState
(
STYLE_PADDING_BOTTOM
,
style_
.
paddingBottom_
,
UIButton
::
PRESSED
);
button
->
SetWidth
(
200
);
// 200 : size
button
->
SetHeight
(
50
);
// 50 : size
button
->
SetText
(
"Test UILabelButton"
);
listScroll_
->
Add
(
button
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_013
()
{
AddTitle
(
"UIList"
);
if
(
adapter_
==
nullptr
)
{
adapter_
=
new
TextAdapter
();
}
adapter_
->
SetData
(
adapterData_
);
adapter_
->
GetStyle
()
=
style_
;
UIList
*
list
=
new
UIList
(
UIList
::
VERTICAL
);
list
->
SetIntercept
(
true
);
list
->
SetStyle
(
style_
);
list
->
Resize
(
300
,
400
);
// 300 : size, 400 : size
list
->
SetAdapter
(
adapter_
);
listScroll_
->
Add
(
list
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_014
()
{
AddTitle
(
"UIPicker"
);
picker_
=
new
UIPicker
();
picker_
->
SetIntercept
(
true
);
picker_
->
SetStyle
(
style_
);
picker_
->
SetFontId
(
16
,
18
);
// 16:back font id 18:high light font id
picker_
->
SetItemHeight
(
50
);
// 50: height
picker_
->
SetTextColor
(
Color
::
White
(),
Color
::
Red
());
picker_
->
SetValues
(
-
5
,
20
);
// -5: start 20:end
picker_
->
Resize
(
300
,
400
);
// 300: picker size 400: picker size
listScroll_
->
Add
(
picker_
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_015
()
{
AddTitle
(
"UIQrcode"
);
UIQrcode
*
qrcode
=
new
UIQrcode
();
qrcode
->
SetStyle
(
style_
);
qrcode
->
Resize
(
60
,
60
);
// 60: height
qrcode
->
SetQrcodeInfo
(
"Hello
\n
鸿蒙轻量级GUI"
);
listScroll_
->
Add
(
qrcode
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_016
()
{
AddTitle
(
"UIScroll"
);
UIScrollView
*
scroll
=
new
UIScrollView
();
scroll
->
SetIntercept
(
true
);
scroll
->
SetStyle
(
style_
);
scroll
->
Resize
(
200
,
200
);
// 200: size
UILabelButton
*
button
=
new
UILabelButton
();
button
->
SetPosition
(
0
,
0
,
300
,
300
);
// 300: size
button
->
SetText
(
"button1"
);
scroll
->
Add
(
button
);
listScroll_
->
Add
(
scroll
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_017
()
{
AddTitle
(
"UISlider"
);
UISlider
*
slider
=
new
UISlider
();
slider
->
SetIntercept
(
true
);
slider
->
SetStyle
(
style_
);
slider
->
Resize
(
50
,
300
);
// 50: width; 300: height
slider
->
SetValidHeight
(
250
);
// 250: valid height;
slider
->
SetValue
(
20
);
// 20: progress bar current value
slider
->
SetDirection
(
UISlider
::
Direction
::
DIR_BOTTOM_TO_TOP
);
listScroll_
->
Add
(
slider
);
}
void
UITestBorderMarginPadding
::
UIKit_UITestBorderMarginPadding_Test_018
()
{
AddTitle
(
"UISwipe"
);
UISwipeView
*
swipe
=
new
UISwipeView
(
UISwipeView
::
HORIZONTAL
);
swipe
->
SetIntercept
(
true
);
swipe
->
SetStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
Red
().
full
);
swipe
->
Resize
(
200
,
200
);
// 200: size
swipe
->
SetBlankSize
(
100
);
// 100: is blank size
UILabel
*
view1
=
new
UILabel
();
view1
->
SetStyle
(
style_
);
view1
->
SetLineBreakMode
(
UILabel
::
LINE_BREAK_CLIP
);
view1
->
SetAlign
(
TEXT_ALIGNMENT_CENTER
,
TEXT_ALIGNMENT_CENTER
);
view1
->
SetPosition
(
0
,
0
,
150
,
150
);
// 150: size
view1
->
SetText
(
"label1"
);
swipe
->
Add
(
view1
);
UILabel
*
view2
=
new
UILabel
();
view2
->
SetStyle
(
style_
);
view2
->
SetLineBreakMode
(
UILabel
::
LINE_BREAK_CLIP
);
view2
->
SetAlign
(
TEXT_ALIGNMENT_CENTER
,
TEXT_ALIGNMENT_CENTER
);
view2
->
SetPosition
(
0
,
0
,
150
,
150
);
// 150: size
view2
->
SetText
(
"label2"
);
swipe
->
Add
(
view2
);
UILabel
*
view3
=
new
UILabel
();
view3
->
SetStyle
(
style_
);
view3
->
SetLineBreakMode
(
UILabel
::
LINE_BREAK_CLIP
);
view3
->
SetAlign
(
TEXT_ALIGNMENT_CENTER
,
TEXT_ALIGNMENT_CENTER
);
view3
->
SetPosition
(
0
,
0
,
150
,
150
);
// 150: size
view3
->
SetText
(
"label3"
);
swipe
->
Add
(
view3
);
listScroll_
->
Add
(
swipe
);
}
}
// namespace OHOS
test/uitest/test_border_margin_padding/ui_test_border_margin_padding.h
0 → 100644
浏览文件 @
95865723
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef UI_TEST_BORDER_MARGIN_PADDING_H
#define UI_TEST_BORDER_MARGIN_PADDING_H
#include "components/text_adapter.h"
#include "components/ui_chart.h"
#include "components/ui_label.h"
#include "components/ui_picker.h"
#include "components/ui_scroll_view.h"
#include "components/ui_toggle_button.h"
#include "layout/grid_layout.h"
#include "layout/list_layout.h"
#include "ui_test.h"
namespace
OHOS
{
class
BorderListener
;
class
MarginListener
;
class
PaddingListener
;
class
UITestBorderMarginPadding
:
public
UITest
{
public:
UITestBorderMarginPadding
()
{
style_
=
StyleDefault
::
GetDefaultStyle
();
style_
.
bgOpa_
=
OPA_OPAQUE
;
style_
.
bgColor_
=
Color
::
Gray
();
}
virtual
~
UITestBorderMarginPadding
()
{}
void
SetUp
()
override
;
void
TearDown
()
override
;
UIView
*
GetTestView
()
override
;
void
ReloadTest
();
void
UIKit_UITestBorderMarginPadding_Test_001
();
void
UIKit_UITestBorderMarginPadding_Test_002
();
void
UIKit_UITestBorderMarginPadding_Test_003
();
void
UIKit_UITestBorderMarginPadding_Test_004
();
void
UIKit_UITestBorderMarginPadding_Test_005
();
void
UIKit_UITestBorderMarginPadding_Test_006
();
void
UIKit_UITestBorderMarginPadding_Test_007
();
void
UIKit_UITestBorderMarginPadding_Test_008
();
void
UIKit_UITestBorderMarginPadding_Test_009
();
void
UIKit_UITestBorderMarginPadding_Test_010
();
void
UIKit_UITestBorderMarginPadding_Test_011
();
void
UIKit_UITestBorderMarginPadding_Test_012
();
void
UIKit_UITestBorderMarginPadding_Test_013
();
void
UIKit_UITestBorderMarginPadding_Test_014
();
void
UIKit_UITestBorderMarginPadding_Test_015
();
void
UIKit_UITestBorderMarginPadding_Test_016
();
void
UIKit_UITestBorderMarginPadding_Test_017
();
void
UIKit_UITestBorderMarginPadding_Test_018
();
Style
style_
;
private:
const
int16_t
TITLE_HEIGHT
=
29
;
const
int16_t
BUTTON_GROUP_WIDTH
=
250
;
UIScrollView
scroll_
;
GridLayout
layoutButton_
;
ListLayout
*
listScroll_
=
nullptr
;
UIViewGroup
container_
;
UILabel
labelMargin_
;
UIToggleButton
margin_
;
UILabel
labelBorder_
;
UIToggleButton
border_
;
UILabel
labelPadding_
;
UIToggleButton
padding_
;
MarginListener
*
marginListener_
=
nullptr
;
BorderListener
*
borderListener_
=
nullptr
;
PaddingListener
*
paddingListener_
=
nullptr
;
UIChartPolyline
*
chart_
=
nullptr
;
UIChartDataSerial
*
dataSerial_
=
nullptr
;
TextAdapter
*
adapter_
=
nullptr
;
List
<
const
char
*>*
adapterData_
=
nullptr
;
UIPicker
*
picker_
=
nullptr
;
void
AddTitle
(
const
char
*
text
);
};
class
MarginListener
:
public
UIToggleButton
::
OnChangeListener
{
public:
explicit
MarginListener
(
UITestBorderMarginPadding
*
view
)
{
view_
=
view
;
}
virtual
~
MarginListener
()
{}
virtual
bool
OnChange
(
UICheckBox
::
UICheckBoxState
state
)
{
if
(
state
==
UICheckBox
::
SELECTED
)
{
view_
->
style_
.
SetStyle
(
STYLE_MARGIN_LEFT
,
MARGIN_SIZE
);
view_
->
style_
.
SetStyle
(
STYLE_MARGIN_TOP
,
MARGIN_SIZE
);
view_
->
style_
.
SetStyle
(
STYLE_MARGIN_RIGHT
,
MARGIN_SIZE
);
view_
->
style_
.
SetStyle
(
STYLE_MARGIN_BOTTOM
,
MARGIN_SIZE
);
}
else
{
view_
->
style_
.
SetStyle
(
STYLE_MARGIN_LEFT
,
0
);
view_
->
style_
.
SetStyle
(
STYLE_MARGIN_TOP
,
0
);
view_
->
style_
.
SetStyle
(
STYLE_MARGIN_RIGHT
,
0
);
view_
->
style_
.
SetStyle
(
STYLE_MARGIN_BOTTOM
,
0
);
}
view_
->
ReloadTest
();
}
private:
static
constexpr
int16_t
MARGIN_SIZE
=
30
;
UITestBorderMarginPadding
*
view_
=
nullptr
;
};
class
BorderListener
:
public
UIToggleButton
::
OnChangeListener
{
public:
explicit
BorderListener
(
UITestBorderMarginPadding
*
view
)
{
view_
=
view
;
}
virtual
~
BorderListener
()
{}
virtual
bool
OnChange
(
UICheckBox
::
UICheckBoxState
state
)
{
if
(
state
==
UICheckBox
::
SELECTED
)
{
view_
->
style_
.
SetStyle
(
STYLE_BORDER_WIDTH
,
20
);
// 20: border width
view_
->
style_
.
SetStyle
(
STYLE_BORDER_OPA
,
OPA_OPAQUE
);
view_
->
style_
.
SetStyle
(
STYLE_BORDER_COLOR
,
Color
::
Blue
().
full
);
}
else
{
view_
->
style_
.
SetStyle
(
STYLE_BORDER_WIDTH
,
0
);
}
view_
->
ReloadTest
();
}
private:
UITestBorderMarginPadding
*
view_
=
nullptr
;
};
class
PaddingListener
:
public
UIToggleButton
::
OnChangeListener
{
public:
explicit
PaddingListener
(
UITestBorderMarginPadding
*
view
)
{
view_
=
view
;
}
virtual
~
PaddingListener
()
{}
virtual
bool
OnChange
(
UICheckBox
::
UICheckBoxState
state
)
{
if
(
state
==
UICheckBox
::
SELECTED
)
{
view_
->
style_
.
SetStyle
(
STYLE_PADDING_LEFT
,
PADDING_SIZE
);
view_
->
style_
.
SetStyle
(
STYLE_PADDING_TOP
,
PADDING_SIZE
);
view_
->
style_
.
SetStyle
(
STYLE_PADDING_RIGHT
,
PADDING_SIZE
);
view_
->
style_
.
SetStyle
(
STYLE_PADDING_BOTTOM
,
PADDING_SIZE
);
}
else
{
view_
->
style_
.
SetStyle
(
STYLE_PADDING_LEFT
,
0
);
view_
->
style_
.
SetStyle
(
STYLE_PADDING_TOP
,
0
);
view_
->
style_
.
SetStyle
(
STYLE_PADDING_RIGHT
,
0
);
view_
->
style_
.
SetStyle
(
STYLE_PADDING_BOTTOM
,
0
);
}
view_
->
ReloadTest
();
}
private:
static
constexpr
int16_t
PADDING_SIZE
=
30
;
UITestBorderMarginPadding
*
view_
=
nullptr
;
};
}
// namespace OHOS
#endif // UI_TEST_BORDER_MARGIN_PADDING_H
tools/qt/simulator/test/test.pro
浏览文件 @
95865723
...
...
@@ -30,6 +30,7 @@ SOURCES += \
..
/../../../
test
/
uitest
/
test_animator
/
ui_test_animator
.
cpp
\
..
/../../../
test
/
uitest
/
test_anti_aliasing
/
ui_test_anti_aliasing
.
cpp
\
..
/../../../
test
/
uitest
/
test_arc_label
/
ui_test_arc_label
.
cpp
\
..
/../../../
test
/
uitest
/
test_border_margin_padding
/
ui_test_border_margin_padding
.
cpp
\
..
/../../../
test
/
uitest
/
test_button
/
ui_test_button
.
cpp
\
..
/../../../
test
/
uitest
/
test_canvas
/
ui_test_canvas
.
cpp
\
..
/../../../
test
/
uitest
/
test_chart
/
ui_test_chart_pillar
.
cpp
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录