Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
017b82b7
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,发现更多精彩内容 >>
提交
017b82b7
编写于
6月 08, 2021
作者:
Y
YueBiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs of scroll bar
Signed-off-by:
N
YueBiang
<
suyue7@huawei.com
>
上级
1eccea2e
变更
27
显示空白变更内容
内联
并排
Showing
27 changed file
with
447 addition
and
446 deletion
+447
-446
frameworks/common/screen.cpp
frameworks/common/screen.cpp
+1
-5
frameworks/components/ui_abstract_scroll.cpp
frameworks/components/ui_abstract_scroll.cpp
+84
-77
frameworks/components/ui_abstract_scroll_bar.cpp
frameworks/components/ui_abstract_scroll_bar.cpp
+4
-53
frameworks/components/ui_abstract_scroll_bar.h
frameworks/components/ui_abstract_scroll_bar.h
+1
-7
frameworks/components/ui_arc_scroll_bar.cpp
frameworks/components/ui_arc_scroll_bar.cpp
+17
-4
frameworks/components/ui_arc_scroll_bar.h
frameworks/components/ui_arc_scroll_bar.h
+7
-12
frameworks/components/ui_box_scroll_bar.cpp
frameworks/components/ui_box_scroll_bar.cpp
+10
-0
frameworks/components/ui_list.cpp
frameworks/components/ui_list.cpp
+17
-33
frameworks/components/ui_scroll_view.cpp
frameworks/components/ui_scroll_view.cpp
+29
-176
interfaces/innerkits/engines/gfx/gfx_engine_manager.h
interfaces/innerkits/engines/gfx/gfx_engine_manager.h
+11
-0
interfaces/kits/common/screen.h
interfaces/kits/common/screen.h
+0
-8
interfaces/kits/components/ui_abstract_scroll.h
interfaces/kits/components/ui_abstract_scroll.h
+3
-14
interfaces/kits/components/ui_list.h
interfaces/kits/components/ui_list.h
+7
-6
interfaces/kits/components/ui_scroll_view.h
interfaces/kits/components/ui_scroll_view.h
+1
-28
interfaces/kits/components/ui_swipe_view.h
interfaces/kits/components/ui_swipe_view.h
+4
-0
test/framework/BUILD.gn
test/framework/BUILD.gn
+1
-0
test/framework/include/test_resource_config.h
test/framework/include/test_resource_config.h
+1
-0
test/framework/src/ui_test_group.cpp
test/framework/src/ui_test_group.cpp
+2
-0
test/uitest/test_event_injector/ui_test_event_injector.cpp
test/uitest/test_event_injector/ui_test_event_injector.cpp
+1
-1
test/uitest/test_rotate_input/ui_test_rotate_input.cpp
test/uitest/test_rotate_input/ui_test_rotate_input.cpp
+1
-1
test/uitest/test_scroll_bar/ui_test_scroll_bar.cpp
test/uitest/test_scroll_bar/ui_test_scroll_bar.cpp
+182
-0
test/uitest/test_scroll_bar/ui_test_scroll_bar.h
test/uitest/test_scroll_bar/ui_test_scroll_bar.h
+47
-0
test/uitest/test_ui_scroll_view/ui_test_ui_scroll_view.cpp
test/uitest/test_ui_scroll_view/ui_test_ui_scroll_view.cpp
+1
-2
test/unittest/components/ui_scroll_bar_test.cpp
test/unittest/components/ui_scroll_bar_test.cpp
+13
-15
test/unittest/components/ui_scroll_view_unit_test.cpp
test/unittest/components/ui_scroll_view_unit_test.cpp
+0
-4
tools/qt/simulator/config/faces/default/fore.png
tools/qt/simulator/config/faces/default/fore.png
+0
-0
tools/qt/simulator/test/test.pro
tools/qt/simulator/test/test.pro
+2
-0
未找到文件。
frameworks/common/screen.cpp
浏览文件 @
017b82b7
...
...
@@ -66,10 +66,6 @@ bool Screen::GetCurrentScreenBitmap(ImageInfo& info)
ScreenShape
Screen
::
GetScreenShape
()
{
#if RECTANGLE_SCREEN
return
ScreenShape
::
RECTANGLE
;
#else
return
ScreenShape
::
CIRCLE
;
#endif
return
BaseGfxEngine
::
GetInstance
()
->
GetScreenShape
();
}
}
// namespace OHOS
frameworks/components/ui_abstract_scroll.cpp
浏览文件 @
017b82b7
...
...
@@ -15,20 +15,11 @@
#include "components/ui_abstract_scroll.h"
#include "animator/interpolation.h"
#include "common/screen.h"
#include "components/ui_abstract_scroll_bar.h"
#include "graphic_timer.h"
#if RECTANGLE_SCREEN
#include "components/ui_box_scroll_bar.h"
#define BAR_OP(obj, op, ...) \
do { \
obj.yScrollBar_->op(__VA_ARGS__); \
obj.xScrollBar_->op(__VA_ARGS__); \
} while (0)
#else
#include "components/ui_arc_scroll_bar.h"
#
define BAR_OP(obj, op, ...) obj.yScrollBar_->op(__VA_ARGS__)
#
endif
#
include "components/ui_box_scroll_bar.h"
#
include "graphic_timer.h"
namespace
{
#if ENABLE_ROTATE_INPUT
...
...
@@ -84,17 +75,33 @@ private:
bezielY
=
Interpolation
::
GetBezierY
(
bezielY
/
OPA_OPAQUE
,
0
,
BEZIER_CONTROL_POINT_Y_1
,
BEZIER_CONTROL_POINT_X_2
,
1
);
opa
=
static_cast
<
uint8_t
>
(
bezielY
*
opa
);
BAR_OP
(
scrollView_
,
SetOpacity
,
opa
);
if
(
scrollView_
.
yScrollBarVisible_
)
{
scrollView_
.
yScrollBar_
->
SetOpacity
(
opa
);
}
if
(
scrollView_
.
xScrollBarVisible_
)
{
scrollView_
.
xScrollBar_
->
SetOpacity
(
opa
);
}
scrollView_
.
Invalidate
();
}
void
OnStop
(
UIView
&
view
)
override
{
if
(
isEaseIn_
)
{
BAR_OP
(
scrollView_
,
SetOpacity
,
OPA_OPAQUE
);
if
(
scrollView_
.
yScrollBarVisible_
)
{
scrollView_
.
yScrollBar_
->
SetOpacity
(
OPA_OPAQUE
);
}
if
(
Screen
::
GetInstance
().
GetScreenShape
()
==
ScreenShape
::
RECTANGLE
&&
scrollView_
.
xScrollBarVisible_
)
{
scrollView_
.
xScrollBar_
->
SetOpacity
(
OPA_OPAQUE
);
}
timer_
.
Start
();
// The timer is triggered when animation stops.
}
else
{
BAR_OP
(
scrollView_
,
SetOpacity
,
OPA_TRANSPARENT
);
if
(
scrollView_
.
yScrollBarVisible_
)
{
scrollView_
.
yScrollBar_
->
SetOpacity
(
OPA_TRANSPARENT
);
}
if
(
scrollView_
.
xScrollBarVisible_
)
{
scrollView_
.
xScrollBar_
->
SetOpacity
(
OPA_TRANSPARENT
);
}
}
scrollView_
.
Invalidate
();
}
...
...
@@ -123,27 +130,6 @@ UIAbstractScroll::UIAbstractScroll()
easingFunc_
(
EasingEquation
::
CubicEaseOut
),
scrollAnimator_
(
&
animatorCallback_
,
this
,
0
,
true
)
{
#if RECTANGLE_SCREEN
xScrollBar_
=
new
UIBoxScrollBar
();
if
(
xScrollBar_
==
nullptr
)
{
GRAPHIC_LOGE
(
"new UIBoxScrollBar fail"
);
return
;
}
yScrollBar_
=
new
UIBoxScrollBar
();
#else
yScrollBar_
=
new
UIArcScrollBar
();
#endif
if
(
yScrollBar_
==
nullptr
)
{
GRAPHIC_LOGE
(
"new ScrollBar fail"
);
return
;
}
#if DEFAULT_ANIMATION
barEaseInOutAnimator_
=
new
BarEaseInOutAnimator
(
*
this
);
if
(
barEaseInOutAnimator_
==
nullptr
)
{
GRAPHIC_LOGE
(
"new BarEaseInOutAnimator fail"
);
return
;
}
#endif
#if ENABLE_FOCUS_MANAGER
focusable_
=
true
;
#endif
...
...
@@ -160,15 +146,19 @@ UIAbstractScroll::UIAbstractScroll()
UIAbstractScroll
::~
UIAbstractScroll
()
{
#if DEFAULT_ANIMATION
if
(
barEaseInOutAnimator_
!=
nullptr
)
{
delete
barEaseInOutAnimator_
;
barEaseInOutAnimator_
=
nullptr
;
}
#endif
#if RECTANGLE_SCREEN
if
(
xScrollBar_
!=
nullptr
)
{
delete
xScrollBar_
;
xScrollBar_
=
nullptr
;
#endif
}
if
(
yScrollBar_
!=
nullptr
)
{
delete
yScrollBar_
;
yScrollBar_
=
nullptr
;
}
}
void
UIAbstractScroll
::
MoveChildByOffset
(
int16_t
offsetX
,
int16_t
offsetY
)
...
...
@@ -185,21 +175,6 @@ void UIAbstractScroll::MoveChildByOffset(int16_t offsetX, int16_t offsetY)
view
->
SetPosition
(
x
,
y
);
view
=
view
->
GetNextSibling
();
}
Rect
childrenRect
=
GetAllChildRelativeRect
();
/* calculate scrollBar's the proportion of foreground */
int16_t
totalLen
=
childrenRect
.
GetHeight
()
+
2
*
scrollBlankSize_
;
// 2: two blank space on both sizes
int16_t
len
=
GetHeight
();
yScrollBar_
->
SetForegroundProportion
(
static_cast
<
float
>
(
len
)
/
totalLen
);
/* calculate scrolling progress */
yScrollBar_
->
SetScrollProgress
(
static_cast
<
float
>
(
scrollBlankSize_
-
childrenRect
.
GetTop
())
/
(
totalLen
-
len
));
#if RECTANGLE_SCREEN
/* so do x-bar */
totalLen
=
childrenRect
.
GetWidth
()
+
2
*
scrollBlankSize_
;
// 2: two blank space on both sizes
len
=
GetWidth
();
xScrollBar_
->
SetForegroundProportion
(
static_cast
<
float
>
(
len
)
/
totalLen
);
xScrollBar_
->
SetScrollProgress
(
static_cast
<
float
>
(
scrollBlankSize_
-
childrenRect
.
GetLeft
())
/
(
totalLen
-
len
));
#endif
Invalidate
();
}
...
...
@@ -319,14 +294,46 @@ void UIAbstractScroll::ListAnimatorCallback::Callback(UIView* view)
}
}
void
UIAbstractScroll
::
SetXScrollBarVisible
(
bool
visible
)
{
if
(
Screen
::
GetInstance
().
GetScreenShape
()
==
ScreenShape
::
CIRCLE
)
{
return
;
}
else
if
(
visible
&&
xScrollBar_
==
nullptr
)
{
xScrollBar_
=
new
UIBoxScrollBar
();
}
xScrollBarVisible_
=
visible
;
#if DEFAULT_ANIMATION
if
(
xScrollBarVisible_
&&
barEaseInOutAnimator_
==
nullptr
)
{
barEaseInOutAnimator_
=
new
BarEaseInOutAnimator
(
*
this
);
}
#endif
}
void
UIAbstractScroll
::
SetYScrollBarVisible
(
bool
visible
)
{
yScrollBarVisible_
=
visible
;
if
(
yScrollBarVisible_
&&
yScrollBar_
==
nullptr
)
{
if
(
Screen
::
GetInstance
().
GetScreenShape
()
==
ScreenShape
::
CIRCLE
)
{
yScrollBar_
=
new
UIArcScrollBar
();
}
else
{
yScrollBar_
=
new
UIBoxScrollBar
();
}
}
#if DEFAULT_ANIMATION
if
(
yScrollBarVisible_
&&
barEaseInOutAnimator_
==
nullptr
)
{
barEaseInOutAnimator_
=
new
BarEaseInOutAnimator
(
*
this
);
}
#endif
}
void
UIAbstractScroll
::
OnPostDraw
(
BufferInfo
&
gfxDstBuffer
,
const
Rect
&
invalidatedArea
)
{
Rect
scrollRect
=
GetRect
();
uint8_t
opa
=
GetMixOpaScale
();
#if RECTANGLE_SCREEN
if
(
Screen
::
GetInstance
().
GetScreenShape
()
==
ScreenShape
::
RECTANGLE
)
{
if
(
yScrollBarVisible_
)
{
yScrollBar_
->
SetPosition
(
scrollRect
.
GetRight
()
-
SCROLL_BAR_WIDTH
+
1
,
scrollRect
.
GetTop
(),
SCROLL_BAR_WIDTH
,
scrollRect
.
GetHeight
());
yScrollBar_
->
SetPosition
(
scrollRect
.
GetRight
()
-
SCROLL_BAR_WIDTH
+
1
,
scrollRect
.
GetTop
()
,
SCROLL_BAR_WIDTH
,
scrollRect
.
GetHeight
());
yScrollBar_
->
OnDraw
(
gfxDstBuffer
,
invalidatedArea
,
opa
);
}
if
(
xScrollBarVisible_
)
{
...
...
@@ -334,14 +341,14 @@ void UIAbstractScroll::OnPostDraw(BufferInfo& gfxDstBuffer, const Rect& invalida
scrollRect
.
GetWidth
()
-
SCROLL_BAR_WIDTH
,
SCROLL_BAR_WIDTH
);
xScrollBar_
->
OnDraw
(
gfxDstBuffer
,
invalidatedArea
,
opa
);
}
#else
}
else
{
if
(
yScrollBarVisible_
)
{
int16_t
x
=
scrollRect
.
GetX
()
+
(
GetWidth
()
/
2
);
// 2: half
int16_t
y
=
scrollRect
.
GetY
()
+
(
GetHeight
()
/
2
);
// 2: half
yScrollBar_
->
SetPosition
(
x
,
y
,
SCROLL_BAR_WIDTH
,
GetWidth
()
/
2
);
// 2: half
yScrollBar_
->
OnDraw
(
gfxDstBuffer
,
invalidatedArea
,
opa
);
}
#endif
}
UIView
::
OnPostDraw
(
gfxDstBuffer
,
invalidatedArea
);
}
...
...
frameworks/components/ui_abstract_scroll_bar.cpp
浏览文件 @
017b82b7
...
...
@@ -14,60 +14,11 @@
*/
#include "components/ui_abstract_scroll_bar.h"
#include "gfx_utils/graphic_log.h"
#include "themes/theme_manager.h"
namespace
OHOS
{
UIAbstractScrollBar
::
UIAbstractScrollBar
()
:
backgroundStyleAllocFlag_
(
false
),
foregroundStyleAllocFlag_
(
false
)
UIAbstractScrollBar
::
UIAbstractScrollBar
()
{
Theme
*
theme
=
ThemeManager
::
GetInstance
().
GetCurrent
();
if
(
theme
!=
nullptr
)
{
backgroundStyle_
=
&
(
theme
->
GetProgressBackgroundStyle
());
foregroundStyle_
=
&
(
theme
->
GetProgressForegroundStyle
());
}
else
{
backgroundStyle_
=
&
(
StyleDefault
::
GetProgressBackgroundStyle
());
foregroundStyle_
=
&
(
StyleDefault
::
GetProgressForegroundStyle
());
}
}
UIAbstractScrollBar
::~
UIAbstractScrollBar
()
{
if
(
backgroundStyleAllocFlag_
)
{
delete
backgroundStyle_
;
backgroundStyle_
=
nullptr
;
backgroundStyleAllocFlag_
=
false
;
}
if
(
foregroundStyleAllocFlag_
)
{
delete
foregroundStyle_
;
foregroundStyle_
=
nullptr
;
foregroundStyleAllocFlag_
=
false
;
}
}
void
UIAbstractScrollBar
::
SetBackgroundStyle
(
const
Style
&
backroundStyle
)
{
if
(
!
backgroundStyleAllocFlag_
)
{
backgroundStyle_
=
new
Style
();
if
(
backgroundStyle_
==
nullptr
)
{
GRAPHIC_LOGE
(
"new Style fail"
);
return
;
}
backgroundStyleAllocFlag_
=
true
;
}
*
backgroundStyle_
=
backroundStyle
;
}
void
UIAbstractScrollBar
::
SetForegroundStyle
(
const
Style
&
foregroundStyle
)
{
if
(
!
foregroundStyleAllocFlag_
)
{
foregroundStyle_
=
new
Style
();
if
(
foregroundStyle_
==
nullptr
)
{
GRAPHIC_LOGE
(
"new Style fail"
);
return
;
}
foregroundStyleAllocFlag_
=
true
;
}
*
foregroundStyle_
=
foregroundStyle
;
backgroundStyle_
=
&
(
StyleDefault
::
GetScrollBarBackgroundStyle
());
foregroundStyle_
=
&
(
StyleDefault
::
GetScrollBarForegroundStyle
());
}
}
// namespace OHOS
frameworks/components/ui_abstract_scroll_bar.h
浏览文件 @
017b82b7
...
...
@@ -25,16 +25,12 @@ class UIAbstractScrollBar : public HeapBase {
public:
UIAbstractScrollBar
();
virtual
~
UIAbstractScrollBar
();
virtual
~
UIAbstractScrollBar
()
{}
;
virtual
void
SetPosition
(
int16_t
x
,
int16_t
y
,
int16_t
width
,
int16_t
height
)
{}
virtual
void
OnDraw
(
BufferInfo
&
gfxDstBuffer
,
const
Rect
&
invalidatedArea
,
uint8_t
backgroundOpa
)
{}
void
SetBackgroundStyle
(
const
Style
&
backroundStyle
);
void
SetForegroundStyle
(
const
Style
&
foregroundStyle
);
void
SetScrollProgress
(
float
scrollProgress
)
{
scrollProgress_
=
scrollProgress
;
...
...
@@ -59,8 +55,6 @@ public:
}
protected:
bool
backgroundStyleAllocFlag_
:
1
;
bool
foregroundStyleAllocFlag_
:
1
;
uint8_t
opacity_
=
OPA_TRANSPARENT
;
float
scrollProgress_
=
0
;
float
foregroundProportion_
=
0
;
...
...
frameworks/components/ui_arc_scroll_bar.cpp
浏览文件 @
017b82b7
...
...
@@ -18,7 +18,21 @@
#include "draw/draw_arc.h"
#include "engines/gfx/gfx_engine_manager.h"
namespace
{
constexpr
uint16_t
START_ANGLE_IN_DEGREE
=
60
;
constexpr
uint16_t
END_ANGLE_IN_DEGREE
=
120
;
constexpr
uint16_t
SCROLL_BAR_WIDTH
=
4
;
constexpr
uint16_t
SCROLL_BAR_MIN_ARC
=
10
;
}
// namespace
namespace
OHOS
{
UIArcScrollBar
::
UIArcScrollBar
()
:
radius_
(
0
),
width_
(
SCROLL_BAR_WIDTH
),
startAngle_
(
START_ANGLE_IN_DEGREE
),
endAngle_
(
END_ANGLE_IN_DEGREE
),
center_
({
0
,
0
})
{}
void
UIArcScrollBar
::
SetPosition
(
int16_t
x
,
int16_t
y
,
int16_t
width
,
int16_t
radius
)
{
if
((
width
>
0
)
&&
(
radius
>
0
))
{
...
...
@@ -40,6 +54,9 @@ void UIArcScrollBar::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedAre
void
UIArcScrollBar
::
DrawForeground
(
BufferInfo
&
gfxDstBuffer
,
const
Rect
&
invalidatedArea
,
uint8_t
backgroundOpa
)
{
uint16_t
foregoundAngleRange
=
foregroundProportion_
*
(
END_ANGLE_IN_DEGREE
-
START_ANGLE_IN_DEGREE
);
if
(
foregoundAngleRange
<
SCROLL_BAR_MIN_ARC
)
{
foregoundAngleRange
=
SCROLL_BAR_MIN_ARC
;
}
int16_t
minAngle
=
START_ANGLE_IN_DEGREE
;
int16_t
maxAngle
=
END_ANGLE_IN_DEGREE
-
foregoundAngleRange
;
int16_t
startAngle
=
minAngle
+
scrollProgress_
*
(
maxAngle
-
minAngle
);
...
...
@@ -54,8 +71,6 @@ void UIArcScrollBar::DrawForeground(BufferInfo& gfxDstBuffer, const Rect& invali
arcInfo
.
center
=
center_
;
arcInfo
.
startAngle
=
MATH_MAX
(
startAngle
,
START_ANGLE_IN_DEGREE
);
arcInfo
.
endAngle
=
MATH_MIN
(
endAngle
,
END_ANGLE_IN_DEGREE
);
foregroundStyle_
->
lineCap_
=
CapType
::
CAP_ROUND
;
foregroundStyle_
->
lineWidth_
=
width_
;
BaseGfxEngine
::
GetInstance
()
->
DrawArc
(
gfxDstBuffer
,
arcInfo
,
invalidatedArea
,
*
foregroundStyle_
,
backgroundOpa
,
foregroundStyle_
->
lineCap_
);
}
...
...
@@ -67,8 +82,6 @@ void UIArcScrollBar::DrawBackground(BufferInfo& gfxDstBuffer, const Rect& invali
arcInfo
.
center
=
center_
;
arcInfo
.
startAngle
=
START_ANGLE_IN_DEGREE
;
arcInfo
.
endAngle
=
END_ANGLE_IN_DEGREE
;
backgroundStyle_
->
lineCap_
=
CapType
::
CAP_ROUND
;
backgroundStyle_
->
lineWidth_
=
width_
;
BaseGfxEngine
::
GetInstance
()
->
DrawArc
(
gfxDstBuffer
,
arcInfo
,
invalidatedArea
,
*
backgroundStyle_
,
backgroundOpa
,
backgroundStyle_
->
lineCap_
);
}
...
...
frameworks/components/ui_arc_scroll_bar.h
浏览文件 @
017b82b7
...
...
@@ -21,7 +21,7 @@
namespace
OHOS
{
class
UIArcScrollBar
:
public
UIAbstractScrollBar
{
public:
UIArcScrollBar
()
=
default
;
UIArcScrollBar
();
virtual
~
UIArcScrollBar
()
=
default
;
...
...
@@ -29,19 +29,14 @@ public:
void
OnDraw
(
BufferInfo
&
gfxDstBuffer
,
const
Rect
&
invalidatedArea
,
uint8_t
backgroundOpa
)
override
;
protected:
void
DrawForeground
(
BufferInfo
&
gfxDstBuffer
,
const
Rect
&
invalidatedArea
,
uint8_t
backgroundOpa
);
void
DrawBackground
(
BufferInfo
&
gfxDstBuffer
,
const
Rect
&
invalidatedArea
,
uint8_t
backgroundOpa
);
protected:
static
constexpr
uint16_t
START_ANGLE_IN_DEGREE
=
60
;
static
constexpr
uint16_t
END_ANGLE_IN_DEGREE
=
120
;
static
constexpr
uint16_t
SCROLL_BAR_WIDTH
=
5
;
int16_t
radius_
=
0
;
int16_t
width_
=
SCROLL_BAR_WIDTH
;
uint16_t
startAngle_
=
START_ANGLE_IN_DEGREE
;
uint16_t
endAngle_
=
END_ANGLE_IN_DEGREE
;
Point
center_
=
{
0
,
0
};
int16_t
radius_
;
int16_t
width_
;
uint16_t
startAngle_
;
uint16_t
endAngle_
;
Point
center_
;
};
}
// namespace OHOS
#endif // GRAPHIC_LITE_UI_ARC_SCROLL_BAR_H
frameworks/components/ui_box_scroll_bar.cpp
浏览文件 @
017b82b7
...
...
@@ -18,6 +18,10 @@
#include "draw/draw_rect.h"
#include "engines/gfx/gfx_engine_manager.h"
namespace
{
constexpr
uint16_t
SCROLL_BAR_MIN_LEN
=
10
;
}
// namespace
namespace
OHOS
{
void
UIBoxScrollBar
::
SetPosition
(
int16_t
x
,
int16_t
y
,
int16_t
width
,
int16_t
height
)
{
...
...
@@ -38,12 +42,18 @@ void UIBoxScrollBar::OnDraw(BufferInfo& gfxDstBuffer, const Rect& invalidatedAre
/* Draw foreground */
if
(
backgroundRect_
.
GetWidth
()
<
backgroundRect_
.
GetHeight
())
{
int16_t
forgroundHeight
=
foregroundProportion_
*
backgroundRect_
.
GetHeight
();
if
(
forgroundHeight
<
SCROLL_BAR_MIN_LEN
)
{
forgroundHeight
=
SCROLL_BAR_MIN_LEN
;
}
int16_t
forgroundTop
=
backgroundRect_
.
GetTop
()
+
scrollProgress_
*
(
backgroundRect_
.
GetHeight
()
-
forgroundHeight
);
rect
.
SetRect
(
backgroundRect_
.
GetLeft
(),
forgroundTop
,
backgroundRect_
.
GetRight
(),
forgroundTop
+
forgroundHeight
-
1
);
}
else
{
int16_t
forgroundWidth
=
foregroundProportion_
*
backgroundRect_
.
GetWidth
();
if
(
forgroundWidth
<
SCROLL_BAR_MIN_LEN
)
{
forgroundWidth
=
SCROLL_BAR_MIN_LEN
;
}
int16_t
forgroundLeft
=
backgroundRect_
.
GetLeft
()
+
scrollProgress_
*
(
backgroundRect_
.
GetWidth
()
-
forgroundWidth
);
rect
.
SetRect
(
forgroundLeft
,
backgroundRect_
.
GetTop
(),
forgroundLeft
+
forgroundWidth
-
1
,
...
...
frameworks/components/ui_list.cpp
浏览文件 @
017b82b7
...
...
@@ -77,6 +77,9 @@ void UIList::Recycle::InitRecycle()
FillActiveView
();
listView_
->
Invalidate
();
hasInitialiszed_
=
true
;
if
(
listView_
->
xScrollBarVisible_
||
listView_
->
yScrollBarVisible_
)
{
MesureAdapterRelativeRect
();
}
}
UIView
*
UIList
::
Recycle
::
GetView
(
int16_t
index
)
...
...
@@ -158,7 +161,6 @@ UIList::UIList(uint8_t direction)
selectPosition_
(
0
),
onSelectedIndex_
(
0
),
recycle_
(
this
),
hasMeasuredAdapterRect_
(
false
),
scrollListener_
(
nullptr
)
{
#if ENABLE_ROTATE_INPUT
...
...
@@ -498,12 +500,6 @@ void UIList::SetAdapter(AbstractAdapter* adapter)
{
recycle_
.
SetAdapter
(
adapter
);
recycle_
.
InitRecycle
();
if
(
xScrollBarVisible_
||
yScrollBarVisible_
)
{
recycle_
.
MesureAdapterRelativeRect
();
hasMeasuredAdapterRect_
=
true
;
}
else
{
hasMeasuredAdapterRect_
=
false
;
}
}
UIView
*
UIList
::
GetSelectView
()
...
...
@@ -735,12 +731,6 @@ void UIList::ScrollTo(uint16_t index)
onSelectedView_
=
nullptr
;
SetStartIndex
(
index
);
recycle_
.
InitRecycle
();
if
(
xScrollBarVisible_
||
yScrollBarVisible_
)
{
recycle_
.
MesureAdapterRelativeRect
();
hasMeasuredAdapterRect_
=
true
;
}
else
{
hasMeasuredAdapterRect_
=
false
;
}
}
void
UIList
::
RefreshList
()
...
...
@@ -772,12 +762,6 @@ void UIList::RefreshList()
startIndex_
=
topIndex
;
}
recycle_
.
InitRecycle
();
if
(
xScrollBarVisible_
||
yScrollBarVisible_
)
{
recycle_
.
MesureAdapterRelativeRect
();
hasMeasuredAdapterRect_
=
true
;
}
else
{
hasMeasuredAdapterRect_
=
false
;
}
startIndex_
=
tmpStartIndex
;
if
(
direction_
==
VERTICAL
)
{
...
...
@@ -796,27 +780,27 @@ void UIList::RemoveAll()
void
UIList
::
SetXScrollBarVisible
(
bool
visible
)
{
bool
lastVisible
=
xScrollBarVisible_
;
UIAbstractScroll
::
SetXScrollBarVisible
(
visible
);
if
(
!
recycle_
.
HasInitialiszed
()
||
!
xScrollBarVisible_
)
{
hasMeasuredAdapterRect_
=
false
;
return
;
}
if
(
!
hasMeasuredAdapterRect_
)
{
if
(
!
lastVisible
&&
xScrollBarVisible_
)
{
if
(
recycle_
.
HasInitialiszed
())
{
recycle_
.
MesureAdapterRelativeRect
();
hasMeasuredAdapterRect_
=
true
;
}
else
{
recycle_
.
InitRecycle
();
}
}
}
void
UIList
::
SetYScrollBarVisible
(
bool
visible
)
{
bool
lastVisible
=
yScrollBarVisible_
;
UIAbstractScroll
::
SetYScrollBarVisible
(
visible
);
if
(
!
recycle_
.
HasInitialiszed
()
||
!
yScrollBarVisible_
)
{
hasMeasuredAdapterRect_
=
false
;
return
;
}
if
(
!
hasMeasuredAdapterRect_
)
{
if
(
!
lastVisible
&&
yScrollBarVisible_
)
{
if
(
recycle_
.
HasInitialiszed
())
{
recycle_
.
MesureAdapterRelativeRect
();
hasMeasuredAdapterRect_
=
true
;
}
else
{
recycle_
.
InitRecycle
();
}
}
}
...
...
frameworks/components/ui_scroll_view.cpp
浏览文件 @
017b82b7
...
...
@@ -14,6 +14,7 @@
*/
#include "components/ui_scroll_view.h"
#include "components/ui_abstract_scroll_bar.h"
#include "dock/focus_manager.h"
#include "dock/vibrator_manager.h"
#include "draw/draw_rect.h"
...
...
@@ -30,12 +31,8 @@ constexpr float DEFAULT_VIBRATOR_LEN = 1.0;
namespace
OHOS
{
UIScrollView
::
UIScrollView
()
:
xSliderPos_
({
0
,
0
}),
ySliderPos_
({
0
,
0
}),
scrollBarWidth_
(
DEFAULT_BAR_WIDTH
),
xScrollable_
(
true
),
:
xScrollable_
(
true
),
yScrollable_
(
true
),
minScrollBarLen_
(
DEFAULT_MIN_BAR_LEN
),
scrollListener_
(
nullptr
)
{
#if ENABLE_ROTATE_INPUT
...
...
@@ -50,10 +47,6 @@ UIScrollView::UIScrollView()
focusable_
=
true
;
#endif
direction_
=
HORIZONTAL_AND_VERTICAL
;
xSlider_
.
SetVisible
(
false
);
ySlider_
.
SetVisible
(
false
);
xSlider_
.
SetStyle
(
StyleDefault
::
GetBrightStyle
());
ySlider_
.
SetStyle
(
StyleDefault
::
GetBrightStyle
());
}
bool
UIScrollView
::
OnDragEvent
(
const
DragEvent
&
event
)
...
...
@@ -62,7 +55,6 @@ bool UIScrollView::OnDragEvent(const DragEvent& event)
UIAbstractScroll
::
StopAnimator
();
}
Drag
(
event
);
RefreshAnimator
();
return
UIView
::
OnDragEvent
(
event
);
}
...
...
@@ -141,7 +133,6 @@ bool UIScrollView::OnRotateEvent(const RotateEvent& event)
lastVibratorRotateLen_
=
totalRotateLen_
;
}
#endif
RefreshAnimator
();
return
UIView
::
OnRotateEvent
(
event
);
}
...
...
@@ -200,20 +191,12 @@ bool UIScrollView::DragXInner(int16_t distance)
}
else
{
int16_t
childRight
=
childRect
.
GetRight
();
int16_t
scrollWidth
=
GetWidth
();
if
(
yScrollable_
&&
ySlider_
.
IsVisible
())
{
if
(
childRight
<
scrollWidth
-
ySlider_
.
GetWidth
()
-
(
scrollBlankSize_
+
reboundSize
))
{
distance
=
0
;
}
else
if
(
childRight
+
distance
<
scrollWidth
-
ySlider_
.
GetWidth
()
-
(
scrollBlankSize_
+
reboundSize
))
{
distance
=
scrollWidth
-
ySlider_
.
GetWidth
()
-
(
scrollBlankSize_
+
reboundSize
)
-
childRight
;
}
}
else
{
if
(
childRight
<
scrollWidth
-
(
scrollBlankSize_
+
reboundSize
))
{
distance
=
0
;
}
else
if
(
childRight
+
distance
<
scrollWidth
-
(
scrollBlankSize_
+
reboundSize
))
{
distance
=
scrollWidth
-
(
scrollBlankSize_
+
reboundSize
)
-
childRight
-
1
;
}
}
}
return
MoveOffset
(
distance
,
0
);
}
...
...
@@ -239,21 +222,12 @@ bool UIScrollView::DragYInner(int16_t distance)
}
else
{
int16_t
childBottom
=
childRect
.
GetBottom
();
int16_t
scrollHeight
=
GetHeight
();
if
(
xScrollable_
&&
xSlider_
.
IsVisible
())
{
if
(
childBottom
<
scrollHeight
-
xSlider_
.
GetHeight
()
-
(
scrollBlankSize_
+
reboundSize
))
{
distance
=
0
;
}
else
if
(
childBottom
+
distance
<
scrollHeight
-
xSlider_
.
GetHeight
()
-
(
scrollBlankSize_
+
reboundSize
))
{
distance
=
scrollHeight
-
xSlider_
.
GetHeight
()
-
(
scrollBlankSize_
+
reboundSize
)
-
childBottom
;
}
}
else
{
if
(
childBottom
<
scrollHeight
-
(
scrollBlankSize_
+
reboundSize
))
{
distance
=
0
;
}
else
if
(
childBottom
+
distance
<
scrollHeight
-
(
scrollBlankSize_
+
reboundSize
))
{
distance
=
scrollHeight
-
(
scrollBlankSize_
+
reboundSize
)
-
childBottom
-
1
;
}
}
}
return
MoveOffset
(
0
,
distance
);
}
...
...
@@ -267,8 +241,10 @@ bool UIScrollView::MoveOffset(int16_t offsetX, int16_t offsetY)
scrollListener_
->
SetScrollState
(
OnScrollListener
::
SCROLL_STATE_MOVE
);
}
UIAbstractScroll
::
MoveChildByOffset
(
offsetX
,
offsetY
);
if
(
xScrollBarVisible_
||
yScrollBarVisible_
)
{
RefreshScrollBar
();
}
Invalidate
();
RefreshScrollBarPosition
();
return
true
;
}
return
false
;
...
...
@@ -276,148 +252,25 @@ bool UIScrollView::MoveOffset(int16_t offsetX, int16_t offsetY)
void
UIScrollView
::
RefreshScrollBar
()
{
Rect
childRect
=
GetAllChildRelativeRect
();
if
(
xScrollable_
&&
(
childRect
.
GetWidth
()
<=
GetWidth
()))
{
xSliderPos_
.
y
=
GetHeight
()
-
scrollBarWidth_
;
xSlider_
.
SetHeight
(
scrollBarWidth_
);
// y scroll bar is on, x scroll bar width should be group width - scroll bar width
if
(
yScrollable_
)
{
xSlider_
.
SetWidth
(
GetWidth
()
-
scrollBarWidth_
);
}
else
{
xSlider_
.
SetWidth
(
GetWidth
());
}
}
if
(
yScrollable_
&&
(
childRect
.
GetHeight
()
<=
GetHeight
()))
{
ySliderPos_
.
x
=
GetWidth
()
-
scrollBarWidth_
;
ySliderPos_
.
y
=
0
;
ySlider_
.
SetWidth
(
scrollBarWidth_
);
// x scroll bar is on, y scroll bar height should be group height - scroll bar width
if
(
xScrollable_
)
{
ySlider_
.
SetHeight
(
GetHeight
()
-
scrollBarWidth_
);
}
else
{
ySlider_
.
SetHeight
(
GetHeight
());
}
}
float
multiple
;
// child width is larger than group width, resize the x scroll bar width
if
(
xScrollable_
&&
(
childRect
.
GetWidth
()
>
GetWidth
())
&&
(
childRect
.
GetWidth
()
!=
0
))
{
int16_t
groupWidth
=
GetWidth
();
int16_t
xWidth
;
if
(
yScrollable_
)
{
multiple
=
static_cast
<
float
>
(
groupWidth
-
scrollBarWidth_
)
/
childRect
.
GetWidth
();
xWidth
=
static_cast
<
int16_t
>
((
groupWidth
-
scrollBarWidth_
)
*
multiple
);
}
else
{
multiple
=
static_cast
<
float
>
(
groupWidth
)
/
childRect
.
GetWidth
();
xWidth
=
static_cast
<
int16_t
>
(
groupWidth
*
multiple
);
}
if
(
xWidth
<
minScrollBarLen_
)
{
xWidth
=
minScrollBarLen_
;
}
xSliderPos_
.
x
=
GetXScrollOffset
(
childRect
);
xSliderPos_
.
y
=
GetHeight
()
-
scrollBarWidth_
;
xSlider_
.
SetWidth
(
xWidth
);
xSlider_
.
SetHeight
(
scrollBarWidth_
);
}
// child height is larger than group height, resize the y scroll height
if
(
yScrollable_
&&
(
childRect
.
GetHeight
()
>
GetHeight
())
&&
(
childRect
.
GetHeight
()
!=
0
))
{
int16_t
groupHeight
=
GetHeight
();
int16_t
yHeight
;
if
(
xScrollable_
)
{
multiple
=
static_cast
<
float
>
(
groupHeight
-
scrollBarWidth_
)
/
childRect
.
GetHeight
();
yHeight
=
static_cast
<
int16_t
>
((
groupHeight
-
scrollBarWidth_
)
*
multiple
);
}
else
{
multiple
=
static_cast
<
float
>
(
groupHeight
)
/
childRect
.
GetHeight
();
yHeight
=
static_cast
<
int16_t
>
(
groupHeight
*
multiple
);
}
// scroll bar may be too small, keep it min size
if
(
yHeight
<
minScrollBarLen_
)
{
yHeight
=
minScrollBarLen_
;
}
ySliderPos_
.
x
=
GetWidth
()
-
scrollBarWidth_
;
ySliderPos_
.
y
=
GetYScrollOffset
(
childRect
);
ySlider_
.
SetHeight
(
yHeight
);
ySlider_
.
SetWidth
(
scrollBarWidth_
);
Rect
childrenRect
=
GetAllChildRelativeRect
();
/* calculate scrollBar's the proportion of foreground */
int16_t
totalLen
=
childrenRect
.
GetHeight
()
+
2
*
scrollBlankSize_
;
// 2: two blank space on both sizes
int16_t
len
=
GetHeight
();
if
(
yScrollBarVisible_
)
{
yScrollBar_
->
SetForegroundProportion
(
static_cast
<
float
>
(
len
)
/
totalLen
);
/* calculate scrolling progress */
yScrollBar_
->
SetScrollProgress
(
static_cast
<
float
>
(
scrollBlankSize_
-
childrenRect
.
GetTop
())
/
(
totalLen
-
len
));
}
if
(
xScrollBarVisible_
)
{
/* so do x-bar */
totalLen
=
childrenRect
.
GetWidth
()
+
2
*
scrollBlankSize_
;
// 2: two blank space on both sizes
len
=
GetWidth
();
xScrollBar_
->
SetForegroundProportion
(
static_cast
<
float
>
(
len
)
/
totalLen
);
xScrollBar_
->
SetScrollProgress
(
static_cast
<
float
>
(
scrollBlankSize_
-
childrenRect
.
GetLeft
())
/
(
totalLen
-
len
));
}
}
void
UIScrollView
::
RefreshScrollBarPosition
()
{
if
(
!
xSlider_
.
IsVisible
()
&&
!
ySlider_
.
IsVisible
())
{
return
;
}
Rect
childRect
=
GetAllChildRelativeRect
();
if
((
childRect
.
GetWidth
()
==
0
)
||
(
childRect
.
GetHeight
()
==
0
))
{
return
;
}
if
(
xScrollable_
)
{
int16_t
xOffset
=
GetXScrollOffset
(
childRect
);
xSliderPos_
.
x
=
xOffset
;
Invalidate
();
}
if
(
yScrollable_
)
{
int16_t
yOffset
=
GetYScrollOffset
(
childRect
);
ySliderPos_
.
y
=
yOffset
;
Invalidate
();
}
}
int16_t
UIScrollView
::
GetXScrollOffset
(
const
Rect
&
childRect
)
{
Rect
scrollRect
=
GetRelativeRect
();
int16_t
xOffset
;
int16_t
scrollBarOffset
=
0
;
if
(
yScrollable_
)
{
scrollBarOffset
=
scrollBarWidth_
;
}
int16_t
childRectLeft
=
childRect
.
GetLeft
();
int16_t
childRectWidth
=
childRect
.
GetWidth
();
int16_t
scrollRectWidth
=
scrollRect
.
GetWidth
();
int16_t
xSliderWidth
=
xSlider_
.
GetWidth
();
if
((
childRectLeft
>=
0
)
||
(
childRectWidth
-
scrollRectWidth
+
scrollBarOffset
==
0
))
{
xOffset
=
0
;
}
else
{
float
multiple
=
static_cast
<
float
>
(
scrollRectWidth
-
scrollBarOffset
-
xSliderWidth
)
/
(
childRectWidth
-
scrollRectWidth
+
scrollBarOffset
);
xOffset
=
static_cast
<
int16_t
>
(
-
childRectLeft
*
multiple
);
}
return
xOffset
;
}
int16_t
UIScrollView
::
GetYScrollOffset
(
const
Rect
&
childRect
)
{
Rect
scrollRect
=
GetRelativeRect
();
int16_t
yOffset
;
int16_t
scrollBarOffset
=
0
;
if
(
xScrollable_
)
{
scrollBarOffset
=
scrollBarWidth_
;
}
int16_t
childRectTop
=
childRect
.
GetTop
();
int16_t
childRectHeight
=
childRect
.
GetHeight
();
int16_t
scrollRectHeight
=
scrollRect
.
GetHeight
();
int16_t
ySliderHeight
=
ySlider_
.
GetHeight
();
if
((
childRectTop
>=
0
)
||
(
childRectHeight
-
scrollRectHeight
+
scrollBarOffset
==
0
))
{
yOffset
=
0
;
}
else
{
float
multiple
=
static_cast
<
float
>
(
scrollRectHeight
-
scrollBarOffset
-
ySliderHeight
)
/
(
childRectHeight
-
scrollRectHeight
+
scrollBarOffset
);
yOffset
=
static_cast
<
int16_t
>
(
-
childRectTop
*
multiple
);
}
return
yOffset
;
}
void
UIScrollView
::
OnChildChanged
()
{
RefreshScrollBar
();
RefreshAnimator
();
}
void
UIScrollView
::
CalculateReboundDistance
(
int16_t
&
dragDistanceX
,
int16_t
&
dragDistanceY
)
...
...
interfaces/innerkits/engines/gfx/gfx_engine_manager.h
浏览文件 @
017b82b7
...
...
@@ -138,6 +138,16 @@ public:
return
height_
;
}
virtual
void
SetScreenShape
(
ScreenShape
screenShape
)
{
screenShape_
=
screenShape
;
}
virtual
ScreenShape
GetScreenShape
()
{
return
screenShape_
;
}
static
BaseGfxEngine
*
GetInstance
()
{
return
baseEngine_
;
...
...
@@ -156,6 +166,7 @@ protected:
static
BaseGfxEngine
*
baseEngine_
;
uint16_t
width_
=
HORIZONTAL_RESOLUTION
;
uint16_t
height_
=
VERTICAL_RESOLUTION
;
ScreenShape
screenShape_
=
RECTANGLE
;
};
}
...
...
interfaces/kits/common/screen.h
浏览文件 @
017b82b7
...
...
@@ -39,14 +39,6 @@
#include "gfx_utils/image_info.h"
namespace
OHOS
{
/**
* @brief Enumerates screen shapes.
*/
enum
ScreenShape
{
RECTANGLE
=
0
,
// rectangular screen
CIRCLE
// circular screen
};
/**
* @brief Represents the screen info of the device.
*
...
...
interfaces/kits/components/ui_abstract_scroll.h
浏览文件 @
017b82b7
...
...
@@ -38,7 +38,6 @@
#include "animator/animator.h"
#include "animator/easing_equation.h"
#include "common/screen.h"
#include "components/ui_view_group.h"
namespace
OHOS
{
...
...
@@ -267,19 +266,9 @@ public:
}
#endif
void
SetXScrollBarVisible
(
bool
visible
)
{
if
(
Screen
::
GetInstance
().
GetScreenShape
()
==
ScreenShape
::
CIRCLE
)
{
xScrollBarVisible_
=
false
;
return
;
}
xScrollBarVisible_
=
visible
;
}
void
SetXScrollBarVisible
(
bool
visible
);
void
SetYScrollBarVisible
(
bool
visible
)
{
yScrollBarVisible_
=
visible
;
}
void
SetYScrollBarVisible
(
bool
visible
);
void
OnPostDraw
(
BufferInfo
&
gfxDstBuffer
,
const
Rect
&
invalidatedArea
)
override
;
...
...
@@ -299,7 +288,7 @@ protected:
/* the maximum number of historical drag data */
static
constexpr
uint8_t
MAX_DELTA_Y_SIZE
=
3
;
static
constexpr
uint16_t
SCROLL_BAR_WIDTH
=
5
;
static
constexpr
uint16_t
SCROLL_BAR_WIDTH
=
4
;
static
constexpr
uint8_t
MAX_ROTATE_FACTOR
=
128
;
class
ListAnimatorCallback
:
public
AnimatorCallback
{
...
...
interfaces/kits/components/ui_list.h
浏览文件 @
017b82b7
...
...
@@ -410,6 +410,7 @@ protected:
private:
friend
class
UIPicker
;
friend
class
Recycle
;
class
Recycle
:
public
HeapBase
{
public:
explicit
Recycle
(
UIList
*
list
)
:
adapter_
(
nullptr
),
listView_
(
list
),
hasInitialiszed_
(
false
)
{}
...
...
@@ -418,9 +419,15 @@ private:
UIView
*
GetView
(
int16_t
index
);
void
SetAdapter
(
AbstractAdapter
*
adapter
)
{
hasInitialiszed_
=
false
;
adapter_
=
adapter
;
}
bool
HasInitialiszed
()
{
return
hasInitialiszed_
;
}
void
AddScrapView
(
UIView
*
view
)
{
scrapView_
.
PushBack
(
view
);
...
...
@@ -436,11 +443,6 @@ private:
scrapView_
.
Clear
();
}
bool
HasInitialiszed
()
{
return
hasInitialiszed_
;
}
Rect
GetAdapterItemsReletiveRect
();
void
MoveAdapterItemsRelativeRect
(
int16_t
x
,
int16_t
y
);
void
MesureAdapterRelativeRect
();
...
...
@@ -486,7 +488,6 @@ private:
uint16_t
selectPosition_
;
int16_t
onSelectedIndex_
;
Recycle
recycle_
;
bool
hasMeasuredAdapterRect_
;
ListScrollListener
*
scrollListener_
;
void
CalculateReboundDistance
(
int16_t
&
dragDistanceX
,
int16_t
&
dragDistanceY
)
override
;
};
...
...
interfaces/kits/components/ui_scroll_view.h
浏览文件 @
017b82b7
...
...
@@ -166,19 +166,6 @@ public:
*/
void
ScrollBy
(
int16_t
xDistance
,
int16_t
yDistance
);
/**
* @brief Sets the width for this scroll bar.
*
* @param width Indicates the width to set. The default value is {@link DEFAULT_BAR_WIDTH}.
* @since 1.0
* @version 1.0
*/
void
SetScrollbarWidth
(
uint8_t
width
)
{
scrollBarWidth_
=
width
;
minScrollBarLen_
=
scrollBarWidth_
*
MIN_BAR_MULTIPLE
;
}
/**
* @brief Sets whether a horizontal scroll is enabled.
*
...
...
@@ -241,8 +228,6 @@ public:
scrollListener_
=
scrollListener
;
}
void
RefreshScrollBar
();
protected:
void
StopAnimator
()
override
;
bool
DragXInner
(
int16_t
distance
)
override
;
...
...
@@ -250,23 +235,11 @@ protected:
private:
void
Drag
(
const
DragEvent
&
event
);
void
RefreshScrollBarPosition
();
bool
MoveOffset
(
int16_t
offsetX
,
int16_t
offsetY
);
int16_t
GetXScrollOffset
(
const
Rect
&
childRect
);
int16_t
GetYScrollOffset
(
const
Rect
&
childRect
);
void
OnChildChanged
()
override
;
void
CalculateReboundDistance
(
int16_t
&
dragDistanceX
,
int16_t
&
dragDistanceY
)
override
;
static
constexpr
uint8_t
DEFAULT_BAR_WIDTH
=
5
;
static
constexpr
uint8_t
MIN_BAR_MULTIPLE
=
2
;
static
constexpr
uint8_t
DEFAULT_MIN_BAR_LEN
=
DEFAULT_BAR_WIDTH
*
MIN_BAR_MULTIPLE
;
UIView
xSlider_
;
UIView
ySlider_
;
Point
xSliderPos_
;
Point
ySliderPos_
;
int16_t
scrollBarWidth_
;
void
RefreshScrollBar
();
bool
xScrollable_
;
bool
yScrollable_
;
int16_t
minScrollBarLen_
;
OnScrollListener
*
scrollListener_
;
#if ENABLE_ROTATE_INPUT
int16_t
lastRotateLen_
;
...
...
interfaces/kits/components/ui_swipe_view.h
浏览文件 @
017b82b7
...
...
@@ -318,6 +318,10 @@ public:
*/
static
constexpr
uint8_t
VERTICAL
=
1
;
void
SetXScrollBarVisible
(
bool
visible
)
=
delete
;
void
SetYScrollBarVisible
(
bool
visible
)
=
delete
;
protected:
bool
DragXInner
(
int16_t
distance
)
override
;
bool
DragYInner
(
int16_t
distance
)
override
;
...
...
test/framework/BUILD.gn
浏览文件 @
017b82b7
...
...
@@ -45,6 +45,7 @@ test_sources = [
"../uitest/test_render/ui_test_render.cpp",
"../uitest/test_rotate_input/ui_test_rotate_input.cpp",
"../uitest/test_screenshot/ui_test_screenshot.cpp",
"../uitest/test_scroll_bar/ui_test_scroll_bar.cpp",
"../uitest/test_slider/ui_test_slider.cpp",
"../uitest/test_texture_mapper/ui_test_texture_mapper.cpp",
"../uitest/test_transform/ui_test_transform.cpp",
...
...
test/framework/include/test_resource_config.h
浏览文件 @
017b82b7
...
...
@@ -66,5 +66,6 @@ namespace OHOS {
#define VIDEO_SOURCE_DIRECTORY (IMAGE_DIR "video.mp4")
#define TEST_RIGHT_ARROW (IMAGE_DIR "ic_arrow_right.png")
#define TEST_BACK_LEFT_ARROW (IMAGE_DIR "ic_back.png")
#define TEST_CIRCLE_FORE_IMAGE (FACE_DIR "fore.png")
}
// namespace OHOS
#endif // TEST_RESOURCE_CONFIG_H
test/framework/src/ui_test_group.cpp
浏览文件 @
017b82b7
...
...
@@ -53,6 +53,7 @@
#include "test_screenshot/ui_test_screenshot.h"
#endif
#include "test_digital_clock/ui_test_digital_clock.h"
#include "test_scroll_bar/ui_test_scroll_bar.h"
#include "test_slider/ui_test_slider.h"
#include "test_texture_mapper/ui_test_texture_mapper.h"
#include "test_transform/ui_test_transform.h"
...
...
@@ -145,6 +146,7 @@ void UITestGroup::SetUpTestCase()
testCaseList_
.
PushBack
(
TestCaseInfo
{
"FocusManager"
,
new
UITestFocusManager
()});
#endif
testCaseList_
.
PushBack
(
TestCaseInfo
{
"Border_Margin_Padding"
,
new
UITestBorderMarginPadding
()});
testCaseList_
.
PushBack
(
TestCaseInfo
{
"ScrollBar"
,
new
UITestScrollBar
()});
}
List
<
TestCaseInfo
>&
UITestGroup
::
GetTestCase
()
...
...
test/uitest/test_event_injector/ui_test_event_injector.cpp
浏览文件 @
017b82b7
...
...
@@ -16,9 +16,9 @@
#include "graphic_config.h"
#if ENABLE_DEBUG
#include "common/screen.h"
#include "components/root_view.h"
#include "dfx/event_injector.h"
#include "engines/gfx/gfx_engine_manager.h"
#include "ui_test_event_injector.h"
#include <string>
#if ENABLE_WINDOW
...
...
test/uitest/test_rotate_input/ui_test_rotate_input.cpp
浏览文件 @
017b82b7
...
...
@@ -14,12 +14,12 @@
*/
#include "ui_test_rotate_input.h"
#include "common/screen.h"
#include "components/ui_label.h"
#include "components/ui_label_button.h"
#include "cstdio"
#include "dock/focus_manager.h"
#include "dock/vibrator_manager.h"
#include "engines/gfx/gfx_engine_manager.h"
#if ENABLE_ROTATE_INPUT
namespace
OHOS
{
...
...
test/uitest/test_scroll_bar/ui_test_scroll_bar.cpp
0 → 100644
浏览文件 @
017b82b7
/*
* Copyright (c) 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 "ui_test_scroll_bar.h"
#include "components/ui_label_button.h"
#include "engines/gfx/gfx_engine_manager.h"
#include "test_resource_config.h"
namespace
{
constexpr
int16_t
LABEL_WIDTH
=
150
;
constexpr
int16_t
LABEL_HEIGHT
=
74
;
constexpr
int16_t
LABEL_INTERVAL
=
50
;
constexpr
int16_t
LABEL_LEFT_INTERVAL
=
125
;
constexpr
int16_t
VIEW_WIDTH
=
400
;
constexpr
int16_t
VIEW_HEIGHT
=
400
;
}
namespace
OHOS
{
void
UITestScrollBar
::
SetUp
()
{
BaseGfxEngine
::
GetInstance
()
->
SetScreenShape
(
ScreenShape
::
CIRCLE
);
if
(
container_
==
nullptr
)
{
container_
=
new
UIViewGroup
();
}
if
(
scrollView_
==
nullptr
)
{
scrollView_
=
new
UIScrollView
();
}
if
(
list_
==
nullptr
)
{
list_
=
new
UIList
();
}
if
(
foreImg1_
==
nullptr
)
{
foreImg1_
=
new
UIImageView
();
}
if
(
foreImg2_
==
nullptr
)
{
foreImg2_
=
new
UIImageView
();
}
if
(
adapter_
==
nullptr
)
{
adapter_
=
new
TextAdapter
();
}
if
(
adapterData_
==
nullptr
)
{
adapterData_
=
new
List
<
const
char
*>
();
adapterData_
->
PushBack
(
"abcd0"
);
adapterData_
->
PushBack
(
"abcd1"
);
adapterData_
->
PushBack
(
"abcd2"
);
adapterData_
->
PushBack
(
"abcd3"
);
adapterData_
->
PushBack
(
"abcd4"
);
adapterData_
->
PushBack
(
"abcd5"
);
adapterData_
->
PushBack
(
"abcd6"
);
adapterData_
->
PushBack
(
"abcd7"
);
adapterData_
->
PushBack
(
"abcd8"
);
adapterData_
->
PushBack
(
"abcd9"
);
adapterData_
->
PushBack
(
"abcd10"
);
adapterData_
->
PushBack
(
"abcd11"
);
adapterData_
->
PushBack
(
"abcd12"
);
adapterData_
->
PushBack
(
"abcd13"
);
adapterData_
->
PushBack
(
"abcd14"
);
adapterData_
->
PushBack
(
"abcd15"
);
}
container_
->
SetPosition
(
0
,
0
,
Screen
::
GetInstance
().
GetWidth
(),
Screen
::
GetInstance
().
GetHeight
());
container_
->
Add
(
scrollView_
);
scrollView_
->
SetPosition
(
0
,
0
,
VIEW_WIDTH
,
VIEW_HEIGHT
);
scrollView_
->
SetYScrollBarVisible
(
true
);
scrollView_
->
SetHorizontalScrollState
(
false
);
scrollView_
->
SetReboundSize
(
50
);
// 50: rebound size
container_
->
Add
(
list_
);
list_
->
SetPosition
(
450
,
0
,
VIEW_WIDTH
,
VIEW_HEIGHT
);
// 450: x
list_
->
SetYScrollBarVisible
(
true
);
list_
->
SetReboundSize
(
50
);
// 50: rebound size
}
void
UITestScrollBar
::
TearDown
()
{
DeleteChildren
(
container_
);
container_
=
nullptr
;
scrollView_
=
nullptr
;
list_
=
nullptr
;
foreImg1_
=
nullptr
;
foreImg2_
=
nullptr
;
if
(
adapterData_
!=
nullptr
)
{
adapterData_
->
Clear
();
delete
adapterData_
;
adapterData_
=
nullptr
;
}
if
(
adapter_
!=
nullptr
)
{
delete
adapter_
;
adapter_
=
nullptr
;
}
BaseGfxEngine
::
GetInstance
()
->
SetScreenShape
(
ScreenShape
::
RECTANGLE
);
}
const
UIView
*
UITestScrollBar
::
GetTestView
()
{
UIKit_ScrollBar_TEST_Scroll_view_001
();
UIKit_ScrollBar_TEST_List_001
();
return
container_
;
}
void
UITestScrollBar
::
UIKit_ScrollBar_TEST_Scroll_view_001
()
{
UILabelButton
*
label1
=
new
UILabelButton
();
scrollView_
->
Add
(
label1
);
label1
->
LayoutTopOfParent
(
LABEL_INTERVAL
);
label1
->
LayoutLeftOfParent
(
LABEL_LEFT_INTERVAL
);
label1
->
SetWidth
(
LABEL_WIDTH
);
label1
->
SetHeight
(
LABEL_HEIGHT
);
label1
->
SetViewId
(
"label1"
);
label1
->
SetText
(
"label1"
);
UILabelButton
*
label2
=
new
UILabelButton
();
scrollView_
->
Add
(
label2
);
label2
->
LayoutBottomToSibling
(
"label1"
,
LABEL_INTERVAL
);
label2
->
LayoutLeftOfParent
(
LABEL_LEFT_INTERVAL
);
label2
->
SetWidth
(
LABEL_WIDTH
);
label2
->
SetHeight
(
LABEL_HEIGHT
);
label2
->
SetViewId
(
"label2"
);
label2
->
SetText
(
"label2"
);
UILabelButton
*
label3
=
new
UILabelButton
();
scrollView_
->
Add
(
label3
);
label3
->
LayoutBottomToSibling
(
"label2"
,
LABEL_INTERVAL
);
label3
->
LayoutLeftOfParent
(
LABEL_LEFT_INTERVAL
);
label3
->
SetWidth
(
LABEL_WIDTH
);
label3
->
SetHeight
(
LABEL_HEIGHT
);
label3
->
SetViewId
(
"label3"
);
label3
->
SetText
(
"label3"
);
UILabelButton
*
label4
=
new
UILabelButton
();
scrollView_
->
Add
(
label4
);
label4
->
LayoutBottomToSibling
(
"label3"
,
LABEL_INTERVAL
);
label4
->
LayoutLeftOfParent
(
LABEL_LEFT_INTERVAL
);
label4
->
SetWidth
(
LABEL_WIDTH
);
label4
->
SetHeight
(
LABEL_HEIGHT
);
label4
->
SetViewId
(
"label4"
);
label4
->
SetText
(
"label4"
);
UILabelButton
*
label5
=
new
UILabelButton
();
scrollView_
->
Add
(
label5
);
label5
->
LayoutBottomToSibling
(
"label4"
,
LABEL_INTERVAL
);
label5
->
LayoutLeftOfParent
(
LABEL_LEFT_INTERVAL
);
label5
->
SetWidth
(
LABEL_WIDTH
);
label5
->
SetHeight
(
LABEL_HEIGHT
);
label5
->
SetViewId
(
"label5"
);
label5
->
SetText
(
"label5"
);
foreImg1_
->
SetSrc
(
TEST_CIRCLE_FORE_IMAGE
);
container_
->
Add
(
foreImg1_
);
foreImg1_
->
SetPosition
(
0
,
0
);
}
void
UITestScrollBar
::
UIKit_ScrollBar_TEST_List_001
()
{
adapter_
->
SetLineBreakMode
(
UILabel
::
LINE_BREAK_CLIP
);
adapter_
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
FONT_DEFAULT_SIZE
);
adapter_
->
SetHeight
(
LABEL_HEIGHT
);
adapter_
->
SetWidth
(
VIEW_WIDTH
);
adapter_
->
SetData
(
adapterData_
);
list_
->
SetAdapter
(
adapter_
);
list_
->
SetIntercept
(
true
);
list_
->
SetYScrollBarVisible
(
true
);
foreImg2_
->
SetSrc
(
TEST_CIRCLE_FORE_IMAGE
);
container_
->
Add
(
foreImg2_
);
foreImg2_
->
SetPosition
(
450
,
0
);
// 450: x
}
}
// namespace OHOS
test/uitest/test_scroll_bar/ui_test_scroll_bar.h
0 → 100644
浏览文件 @
017b82b7
/*
* Copyright (c) 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_SCROLL_BAR_H
#define UI_TEST_SCROLL_BAR_H
#include "components/text_adapter.h"
#include "components/ui_image_view.h"
#include "components/ui_list.h"
#include "components/ui_scroll_view.h"
#include "ui_test.h"
namespace
OHOS
{
class
UITestScrollBar
:
public
UITest
{
public:
UITestScrollBar
()
{}
~
UITestScrollBar
()
{}
void
SetUp
()
override
;
void
TearDown
()
override
;
const
UIView
*
GetTestView
()
override
;
void
UIKit_ScrollBar_TEST_Scroll_view_001
();
void
UIKit_ScrollBar_TEST_List_001
();
private:
UIViewGroup
*
container_
=
nullptr
;
UIScrollView
*
scrollView_
=
nullptr
;
UIList
*
list_
=
nullptr
;
UIImageView
*
foreImg1_
=
nullptr
;
UIImageView
*
foreImg2_
=
nullptr
;
List
<
const
char
*>*
adapterData_
=
nullptr
;
TextAdapter
*
adapter_
=
nullptr
;
};
// namespace OHOS
}
#endif // UI_TEST_SCROLL_BAR_H
test/uitest/test_ui_scroll_view/ui_test_ui_scroll_view.cpp
浏览文件 @
017b82b7
...
...
@@ -201,7 +201,6 @@ void UITestUIScrollView::UIKit_UIScrollView_Test_bar_004()
scroll
->
SetPosition
(
positionX_
,
positionY_
,
g_scrollW
,
g_scrollH
);
VISIBLE_XBAR
(
true
);
scroll
->
SetYScrollBarVisible
(
true
);
scroll
->
SetScrollbarWidth
(
20
);
// 20: means scroll bar width
container_
->
Add
(
scroll
);
UIButton
*
button1
=
new
UIButton
();
button1
->
SetPosition
(
0
,
0
,
g_smallButtonW
,
g_smallButtonH
);
...
...
test/unittest/components/ui_scroll_bar_test.cpp
浏览文件 @
017b82b7
...
...
@@ -118,29 +118,27 @@ HWTEST_F(ScrollBarTest, UIScrollBarSetPosition, TestSize.Level0)
EXPECT_NE
(
boxBar
.
GetWidth
(),
ZERO_LEN
);
}
HWTEST_F
(
ScrollBarTest
,
UIScrollBar
S
etBarStyle
,
TestSize
.
Level0
)
HWTEST_F
(
ScrollBarTest
,
UIScrollBar
G
etBarStyle
,
TestSize
.
Level0
)
{
Style
&
defaultBackStyle
=
StyleDefault
::
GetProgressBackgroundStyle
();
Style
&
defaultForeStyle
=
StyleDefault
::
GetProgressForegroundStyle
();
Style
testStyle
;
Style
&
defaultBackStyle
=
StyleDefault
::
GetScrollBarBackgroundStyle
();
Style
&
defaultForeStyle
=
StyleDefault
::
GetScrollBarForegroundStyle
();
TestArcScrollBarTest
arcBar
;
TestBoxScrollBarTest
boxBar
;
EXPECT_EQ
(
arcBar
.
GetBackStyle
()
->
GetStyle
(
STYLE_LINE_COLOR
),
defaultBackStyle
.
GetStyle
(
STYLE_LINE_COLOR
));
EXPECT_EQ
(
arcBar
.
GetForeStyle
()
->
GetStyle
(
STYLE_LINE_COLOR
),
defaultForeStyle
.
GetStyle
(
STYLE_LINE_COLOR
));
arcBar
.
SetBackgroundStyle
(
testStyle
);
EXPECT_EQ
(
arcBar
.
GetBackStyle
()
->
GetStyle
(
STYLE_LINE_COLOR
),
testStyle
.
GetStyle
(
STYLE_LINE_COLOR
));
arcBar
.
SetForegroundStyle
(
testStyle
);
EXPECT_EQ
(
arcBar
.
GetForeStyle
()
->
GetStyle
(
STYLE_LINE_COLOR
),
defaultForeStyle
.
GetStyle
(
STYLE_LINE_COLOR
));
EXPECT_EQ
(
arcBar
.
GetBackStyle
()
->
GetStyle
(
STYLE_LINE_OPA
),
defaultBackStyle
.
GetStyle
(
STYLE_LINE_OPA
));
EXPECT_EQ
(
arcBar
.
GetForeStyle
()
->
GetStyle
(
STYLE_LINE_OPA
),
defaultForeStyle
.
GetStyle
(
STYLE_LINE_OPA
));
TestBoxScrollBarTest
boxBar
;
EXPECT_EQ
(
boxBar
.
GetBackStyle
()
->
GetStyle
(
STYLE_LINE_COLOR
),
defaultBackStyle
.
GetStyle
(
STYLE_LINE_COLOR
));
EXPECT_EQ
(
boxBar
.
GetForeStyle
()
->
GetStyle
(
STYLE_LINE_COLOR
),
defaultForeStyle
.
GetStyle
(
STYLE_LINE_COLOR
));
EXPECT_EQ
(
boxBar
.
GetBackStyle
()
->
GetStyle
(
STYLE_BACKGROUND_COLOR
),
defaultBackStyle
.
GetStyle
(
STYLE_BACKGROUND_COLOR
));
EXPECT_EQ
(
boxBar
.
GetForeStyle
()
->
GetStyle
(
STYLE_BACKGROUND_COLOR
),
defaultForeStyle
.
GetStyle
(
STYLE_BACKGROUND_COLOR
));
boxBar
.
SetBackgroundStyle
(
testStyle
);
EXPECT_EQ
(
boxBar
.
GetBackStyle
()
->
GetStyle
(
STYLE_LINE_COLOR
),
testStyle
.
GetStyle
(
STYLE_LINE_COLOR
));
boxBar
.
SetForegroundStyle
(
testStyle
);
EXPECT_EQ
(
boxBar
.
GetForeStyle
()
->
GetStyle
(
STYLE_LINE_COLOR
),
defaultForeStyle
.
GetStyle
(
STYLE_LINE_COLOR
));
EXPECT_EQ
(
boxBar
.
GetBackStyle
()
->
GetStyle
(
STYLE_BACKGROUND_OPA
),
defaultBackStyle
.
GetStyle
(
STYLE_BACKGROUND_OPA
));
EXPECT_EQ
(
boxBar
.
GetForeStyle
()
->
GetStyle
(
STYLE_BACKGROUND_OPA
),
defaultForeStyle
.
GetStyle
(
STYLE_BACKGROUND_OPA
));
}
HWTEST_F
(
ScrollBarTest
,
UIScrollBarSetForegroundProportion
,
TestSize
.
Level0
)
...
...
test/unittest/components/ui_scroll_view_unit_test.cpp
浏览文件 @
017b82b7
...
...
@@ -19,10 +19,6 @@
using
namespace
testing
::
ext
;
namespace
OHOS
{
namespace
{
constexpr
uint8_t
DEFAULT_BAR_WIDTH
=
5
;
}
class
ScrollViewTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
();
...
...
tools/qt/simulator/config/faces/default/fore.png
0 → 100644
浏览文件 @
017b82b7
4.5 KB
tools/qt/simulator/test/test.pro
浏览文件 @
017b82b7
...
...
@@ -56,6 +56,7 @@ SOURCES += \
..
/../../../
test
/
uitest
/
test_qrcode
/
ui_test_qrcode
.
cpp
\
..
/../../../
test
/
uitest
/
test_render
/
ui_test_render
.
cpp
\
..
/../../../
test
/
uitest
/
test_rotate_input
/
ui_test_rotate_input
.
cpp
\
..
/../../../
test
/
uitest
/
test_scroll_bar
/
ui_test_scroll_bar
.
cpp
\
..
/../../../
test
/
uitest
/
test_slider
/
ui_test_slider
.
cpp
\
..
/../../../
test
/
uitest
/
test_texture_mapper
/
ui_test_texture_mapper
.
cpp
\
..
/../../../
test
/
uitest
/
test_transform
/
ui_test_transform
.
cpp
\
...
...
@@ -112,6 +113,7 @@ HEADERS += \
..
/../../../
test
/
uitest
/
test_qrcode
/
ui_test_qrcode
.
cpp
\
..
/../../../
test
/
uitest
/
test_render
/
ui_test_render
.
h
\
..
/../../../
test
/
uitest
/
test_rotate_input
/
ui_test_rotate_input
.
h
\
..
/../../../
test
/
uitest
/
test_scroll_bar
/
ui_test_scroll_bar
.
h
\
..
/../../../
test
/
uitest
/
test_slider
/
ui_test_slider
.
h
\
..
/../../../
test
/
uitest
/
test_texture_mapper
/
ui_test_texture_mapper
.
h
\
..
/../../../
test
/
uitest
/
test_transform
/
ui_test_transform
.
h
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录