Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
1d5e643d
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,发现更多精彩内容 >>
提交
1d5e643d
编写于
4月 29, 2021
作者:
Y
YueBiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix slider bugs
上级
6441b10a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
84 addition
and
37 deletion
+84
-37
frameworks/components/ui_box_progress.cpp
frameworks/components/ui_box_progress.cpp
+60
-20
frameworks/components/ui_slider.cpp
frameworks/components/ui_slider.cpp
+12
-12
interfaces/kits/components/ui_slider.h
interfaces/kits/components/ui_slider.h
+4
-0
test/uitest/test_slider/ui_test_slider.cpp
test/uitest/test_slider/ui_test_slider.cpp
+8
-5
未找到文件。
frameworks/components/ui_box_progress.cpp
浏览文件 @
1d5e643d
...
@@ -107,31 +107,71 @@ void UIBoxProgress::DrawRoundCap(const Image* image, const Point& imgPos, const
...
@@ -107,31 +107,71 @@ void UIBoxProgress::DrawRoundCap(const Image* image, const Point& imgPos, const
Style
capStyle
=
style
;
Style
capStyle
=
style
;
capStyle
.
lineWidth_
=
radius
;
capStyle
.
lineWidth_
=
radius
;
capStyle
.
lineColor_
=
style
.
bgColor_
;
capStyle
.
lineColor_
=
style
.
bgColor_
;
capStyle
.
lineOpa_
=
style
.
bgOpa_
;
if
((
image
!=
nullptr
)
&&
(
image
->
GetSrcType
()
!=
IMG_SRC_UNKNOWN
))
{
capStyle
.
lineOpa_
=
style
.
imageOpa_
;
}
else
{
capStyle
.
lineOpa_
=
style
.
bgOpa_
;
}
ArcInfo
arcInfo
=
{{
0
}};
ArcInfo
arcInfo
=
{{
0
}};
arcInfo
.
radius
=
radius
;
arcInfo
.
radius
=
radius
;
arcInfo
.
imgPos
=
imgPos
;
arcInfo
.
imgPos
=
imgPos
;
arcInfo
.
imgSrc
=
image
;
arcInfo
.
imgSrc
=
image
;
arcInfo
.
center
=
leftTop
;
if
(
rect
.
GetWidth
()
%
2
==
0
)
{
// 2: determine the odd or even number of the width
arcInfo
.
startAngle
=
THREE_QUARTER_IN_DEGREE
;
arcInfo
.
center
=
leftTop
;
arcInfo
.
endAngle
=
0
;
arcInfo
.
startAngle
=
THREE_QUARTER_IN_DEGREE
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
arcInfo
.
endAngle
=
0
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
arcInfo
.
center
=
leftBottom
;
arcInfo
.
startAngle
=
SEMICIRCLE_IN_DEGREE
;
arcInfo
.
center
=
leftBottom
;
arcInfo
.
endAngle
=
THREE_QUARTER_IN_DEGREE
;
arcInfo
.
startAngle
=
SEMICIRCLE_IN_DEGREE
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
arcInfo
.
endAngle
=
THREE_QUARTER_IN_DEGREE
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
arcInfo
.
center
=
rightTop
;
arcInfo
.
startAngle
=
0
;
arcInfo
.
center
=
rightTop
;
arcInfo
.
endAngle
=
THREE_QUARTER_IN_DEGREE
;
arcInfo
.
startAngle
=
0
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
arcInfo
.
endAngle
=
QUARTER_IN_DEGREE
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
arcInfo
.
center
=
rightBottom
;
arcInfo
.
startAngle
=
THREE_QUARTER_IN_DEGREE
;
arcInfo
.
center
=
rightBottom
;
arcInfo
.
endAngle
=
SEMICIRCLE_IN_DEGREE
;
arcInfo
.
startAngle
=
QUARTER_IN_DEGREE
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
arcInfo
.
endAngle
=
SEMICIRCLE_IN_DEGREE
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
}
else
{
switch
(
direction_
)
{
case
Direction
::
DIR_LEFT_TO_RIGHT
:
case
Direction
::
DIR_RIGHT_TO_LEFT
:
{
arcInfo
.
center
=
leftTop
;
arcInfo
.
startAngle
=
SEMICIRCLE_IN_DEGREE
;
arcInfo
.
endAngle
=
0
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
arcInfo
.
center
=
leftBottom
;
arcInfo
.
startAngle
=
0
;
arcInfo
.
endAngle
=
SEMICIRCLE_IN_DEGREE
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
break
;
}
case
Direction
::
DIR_TOP_TO_BOTTOM
:
case
Direction
::
DIR_BOTTOM_TO_TOP
:
{
arcInfo
.
center
=
leftTop
;
arcInfo
.
startAngle
=
THREE_QUARTER_IN_DEGREE
;
arcInfo
.
endAngle
=
QUARTER_IN_DEGREE
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
arcInfo
.
center
=
leftBottom
;
arcInfo
.
startAngle
=
QUARTER_IN_DEGREE
;
arcInfo
.
endAngle
=
THREE_QUARTER_IN_DEGREE
;
DrawArc
::
GetInstance
()
->
Draw
(
arcInfo
,
invalidatedArea
,
capStyle
,
opaScale_
,
CapType
::
CAP_NONE
);
break
;
}
default:
GRAPHIC_LOGE
(
"UIBoxProgress: DrawRoundCap direction Err!
\n
"
);
break
;
}
}
}
}
void
UIBoxProgress
::
GetBackgroundParam
(
Point
&
startPoint
,
int16_t
&
width
,
int16_t
&
height
,
uint16_t
&
radius
,
void
UIBoxProgress
::
GetBackgroundParam
(
Point
&
startPoint
,
int16_t
&
width
,
int16_t
&
height
,
uint16_t
&
radius
,
...
...
frameworks/components/ui_slider.cpp
浏览文件 @
1d5e643d
...
@@ -30,16 +30,16 @@ UISlider::UISlider()
...
@@ -30,16 +30,16 @@ UISlider::UISlider()
touchable_
=
true
;
touchable_
=
true
;
draggable_
=
true
;
draggable_
=
true
;
dragParentInstead_
=
false
;
dragParentInstead_
=
false
;
SetCapType
(
CapType
::
CAP_ROUND
);
Theme
*
theme
=
ThemeManager
::
GetInstance
().
GetCurrent
();
if
(
theme
!=
nullptr
)
{
knobStyle_
=
&
(
theme
->
GetSliderKnobStyle
());
}
else
{
knobStyle_
=
&
(
StyleDefault
::
GetSliderKnobStyle
());
}
#if ENABLE_FOCUS_MANAGER
#if ENABLE_FOCUS_MANAGER
focusable_
=
true
;
focusable_
=
true
;
#endif
#endif
SetBackgroundStyle
(
STYLE_LINE_CAP
,
CapType
::
CAP_ROUND
);
SetBackgroundStyle
(
STYLE_BACKGROUND_OPA
,
BACKGROUND_OPA
);
SetBackgroundStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
Black
().
full
);
SetForegroundStyle
(
STYLE_LINE_CAP
,
CapType
::
CAP_ROUND
);
SetForegroundStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
GetColorFromRGB
(
FOREGROUND_COLOR_R
,
FOREGROUND_COLOR_G
,
FOREGROUND_COLOR_B
).
full
);
}
}
UISlider
::~
UISlider
()
UISlider
::~
UISlider
()
...
@@ -220,7 +220,7 @@ void UISlider::DrawForeground(const Rect& invalidatedArea, Rect& coords)
...
@@ -220,7 +220,7 @@ void UISlider::DrawForeground(const Rect& invalidatedArea, Rect& coords)
switch
(
direction_
)
{
switch
(
direction_
)
{
case
Direction
::
DIR_LEFT_TO_RIGHT
:
{
case
Direction
::
DIR_LEFT_TO_RIGHT
:
{
length
=
GetCurrentPos
(
progressWidth_
-
1
);
length
=
GetCurrentPos
(
progressWidth_
+
1
);
coords
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth
-
1
,
coords
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth
-
1
,
startPoint
.
y
+
progressHeight_
-
1
);
startPoint
.
y
+
progressHeight_
-
1
);
...
@@ -230,7 +230,7 @@ void UISlider::DrawForeground(const Rect& invalidatedArea, Rect& coords)
...
@@ -230,7 +230,7 @@ void UISlider::DrawForeground(const Rect& invalidatedArea, Rect& coords)
break
;
break
;
}
}
case
Direction
::
DIR_RIGHT_TO_LEFT
:
{
case
Direction
::
DIR_RIGHT_TO_LEFT
:
{
length
=
GetCurrentPos
(
progressWidth_
-
1
);
length
=
GetCurrentPos
(
progressWidth_
+
1
);
coords
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth
-
1
,
coords
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth
-
1
,
startPoint
.
y
+
progressHeight_
-
1
);
startPoint
.
y
+
progressHeight_
-
1
);
...
@@ -240,17 +240,17 @@ void UISlider::DrawForeground(const Rect& invalidatedArea, Rect& coords)
...
@@ -240,17 +240,17 @@ void UISlider::DrawForeground(const Rect& invalidatedArea, Rect& coords)
break
;
break
;
}
}
case
Direction
::
DIR_TOP_TO_BOTTOM
:
{
case
Direction
::
DIR_TOP_TO_BOTTOM
:
{
length
=
GetCurrentPos
(
progressHeight_
-
1
);
length
=
GetCurrentPos
(
progressHeight_
+
1
);
coords
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth_
-
1
,
coords
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth_
-
1
,
startPoint
.
y
+
progressHeight
-
1
);
startPoint
.
y
+
progressHeight
-
1
);
top
=
startPoint
.
y
-
radius
+
1
;
top
=
startPoint
.
y
-
radius
-
1
;
bottom
=
top
+
length
;
bottom
=
top
+
length
;
rect
=
Rect
(
startPoint
.
x
,
top
,
startPoint
.
x
+
progressWidth_
-
1
,
bottom
);
rect
=
Rect
(
startPoint
.
x
,
top
,
startPoint
.
x
+
progressWidth_
-
1
,
bottom
);
break
;
break
;
}
}
case
Direction
::
DIR_BOTTOM_TO_TOP
:
{
case
Direction
::
DIR_BOTTOM_TO_TOP
:
{
length
=
GetCurrentPos
(
progressHeight_
-
1
);
length
=
GetCurrentPos
(
progressHeight_
+
1
);
coords
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth_
-
1
,
coords
.
SetRect
(
startPoint
.
x
,
startPoint
.
y
,
startPoint
.
x
+
progressWidth_
-
1
,
startPoint
.
y
+
progressHeight
-
1
);
startPoint
.
y
+
progressHeight
-
1
);
...
...
interfaces/kits/components/ui_slider.h
浏览文件 @
1d5e643d
...
@@ -343,6 +343,10 @@ protected:
...
@@ -343,6 +343,10 @@ protected:
bool
InitImage
()
override
;
bool
InitImage
()
override
;
private:
private:
static
constexpr
int8_t
BACKGROUND_OPA
=
38
;
static
constexpr
uint8_t
FOREGROUND_COLOR_R
=
0x1f
;
static
constexpr
uint8_t
FOREGROUND_COLOR_G
=
0x71
;
static
constexpr
uint8_t
FOREGROUND_COLOR_B
=
0xff
;
#if ENABLE_SLIDER_KNOB
#if ENABLE_SLIDER_KNOB
void
DrawKnob
(
const
Rect
&
invalidatedArea
,
const
Rect
&
foregroundRect
);
void
DrawKnob
(
const
Rect
&
invalidatedArea
,
const
Rect
&
foregroundRect
);
#else
#else
...
...
test/uitest/test_slider/ui_test_slider.cpp
浏览文件 @
1d5e643d
...
@@ -479,30 +479,33 @@ bool UITestSlider::ExpandClick1(UIView& view, const ClickEvent& event)
...
@@ -479,30 +479,33 @@ bool UITestSlider::ExpandClick1(UIView& view, const ClickEvent& event)
g_height
=
DEFAULT_WIDTH
;
g_height
=
DEFAULT_WIDTH
;
slider_
->
SetValidHeight
(
g_height
);
slider_
->
SetValidHeight
(
g_height
);
slider_
->
SetValidWidth
(
g_width
);
slider_
->
SetValidWidth
(
g_width
);
slider_
->
LayoutCenterOfParent
();
slider_
->
Resize
(
g_width
,
g_height
);
slider_
->
Resize
(
g_width
,
g_height
);
slider_
->
SetDirection
(
UISlider
::
Direction
::
DIR_LEFT_TO_RIGHT
);
slider_
->
SetDirection
(
UISlider
::
Direction
::
DIR_LEFT_TO_RIGHT
);
slider_
->
LayoutCenterOfParent
();
}
else
if
(
&
view
==
dirR2LBtn_
)
{
}
else
if
(
&
view
==
dirR2LBtn_
)
{
g_width
=
DEFAULT_HEIGHT
;
g_width
=
DEFAULT_HEIGHT
;
g_height
=
DEFAULT_WIDTH
;
g_height
=
DEFAULT_WIDTH
;
slider_
->
SetValidHeight
(
g_height
);
slider_
->
SetValidHeight
(
g_height
);
slider_
->
SetValidWidth
(
g_width
);
slider_
->
SetValidWidth
(
g_width
);
slider_
->
LayoutCenterOfParent
();
slider_
->
Resize
(
g_width
,
g_height
);
slider_
->
Resize
(
g_width
,
g_height
);
slider_
->
SetDirection
(
UISlider
::
Direction
::
DIR_RIGHT_TO_LEFT
);
slider_
->
SetDirection
(
UISlider
::
Direction
::
DIR_RIGHT_TO_LEFT
);
slider_
->
LayoutCenterOfParent
();
}
else
if
(
&
view
==
dirT2BBtn_
)
{
}
else
if
(
&
view
==
dirT2BBtn_
)
{
g_width
=
DEFAULT_WIDTH
;
g_width
=
DEFAULT_WIDTH
;
g_height
=
DEFAULT_HEIGHT
;
g_height
=
DEFAULT_HEIGHT
;
slider_
->
SetValidHeight
(
g_height
);
slider_
->
SetValidWidth
(
g_width
);
slider_
->
Resize
(
g_width
,
g_height
);
slider_
->
Resize
(
g_width
,
g_height
);
slider_
->
SetDirection
(
UISlider
::
Direction
::
DIR_TOP_TO_BOTTOM
);
slider_
->
SetDirection
(
UISlider
::
Direction
::
DIR_TOP_TO_BOTTOM
);
slider_
->
LayoutCenterOfParent
();
}
else
if
(
&
view
==
dirB2TBtn_
)
{
}
else
if
(
&
view
==
dirB2TBtn_
)
{
g_width
=
DEFAULT_WIDTH
;
g_width
=
DEFAULT_WIDTH
;
g_height
=
DEFAULT_HEIGHT
;
g_height
=
DEFAULT_HEIGHT
;
slider_
->
SetValidHeight
(
g_height
);
slider_
->
SetValidHeight
(
g_height
);
slider_
->
SetValidWidth
(
g_width
);
slider_
->
SetValidWidth
(
g_width
);
slider_
->
LayoutCenterOfParent
();
slider_
->
Resize
(
g_width
,
g_height
);
slider_
->
Resize
(
g_width
,
g_height
);
slider_
->
SetDirection
(
UISlider
::
Direction
::
DIR_BOTTOM_TO_TOP
);
slider_
->
SetDirection
(
UISlider
::
Direction
::
DIR_BOTTOM_TO_TOP
);
slider_
->
LayoutCenterOfParent
();
}
else
{
}
else
{
ExpandClick2
(
view
,
event
);
ExpandClick2
(
view
,
event
);
}
}
...
@@ -529,9 +532,9 @@ bool UITestSlider::ExpandClick2(UIView& view, const ClickEvent& event)
...
@@ -529,9 +532,9 @@ bool UITestSlider::ExpandClick2(UIView& view, const ClickEvent& event)
#endif
#endif
}
else
if
(
&
view
==
setStyleBtn_
)
{
}
else
if
(
&
view
==
setStyleBtn_
)
{
Style
style
=
StyleDefault
::
GetDefaultStyle
();
Style
style
=
StyleDefault
::
GetDefaultStyle
();
style
.
bgColor_
=
Color
::
White
();
style
.
bgColor_
=
Color
::
Green
();
slider_
->
SetBackgroundStyle
(
style
);
slider_
->
SetBackgroundStyle
(
style
);
style
.
bgColor_
=
Color
::
Blue
();
style
.
bgColor_
=
Color
::
Red
();
slider_
->
SetForegroundStyle
(
style
);
slider_
->
SetForegroundStyle
(
style
);
style
.
bgColor_
=
Color
::
Gray
();
style
.
bgColor_
=
Color
::
Gray
();
#if ENABLE_SLIDER_KNOB
#if ENABLE_SLIDER_KNOB
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录