1 /*
2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ui_test_circle_progress.h"
17 #include "common/screen.h"
18 #include "components/ui_label.h"
19 #include "test_resource_config.h"
20
21 namespace OHOS {
22 namespace {
23 const int16_t LABEL_HEIGHT = 29;
24 const int16_t BUTTON_WIDTH = 120;
25 const int16_t BUTTON_HEIGHT = 40;
26 const int16_t DELTA_X_COORDINATE = 8;
27 const int16_t DELTA_X_COORDINATE_2 = 336;
28 const int16_t DELTA_Y_COORDINATE = 12;
29 const int16_t DELTA_Y_COORDINATE_2 = 19;
30 } // namespace
31
SetUp()32 void UITestCircleProgress::SetUp()
33 {
34 if (container_ == nullptr) {
35 positionX_ = 0;
36 positionY_ = 0;
37 container_ = new UIScrollView();
38 container_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
39 UIViewGroup* uiViewGroup = new UIViewGroup();
40 uiViewGroup->SetPosition(positionX_, positionY_, 320, 390); // 320: width; 390: height
41 container_->Add(uiViewGroup);
42 UILabel* label = new UILabel();
43 uiViewGroup->Add(label);
44 // 288: x-coordinate; 48: y-coordinate
45 label->SetPosition(TEXT_DISTANCE_TO_LEFT_SIDE, TEXT_DISTANCE_TO_TOP_SIDE, 288, 48);
46 label->SetText("UICircleProgress效果");
47 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
48 uiViewGroupFrame_ = new UIViewGroup();
49 uiViewGroup->Add(uiViewGroupFrame_);
50 // 288: width; 336: height
51 uiViewGroupFrame_->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE2, VIEW_DISTANCE_TO_TOP_SIDE, 288, 336);
52 uiViewGroupFrame_->SetStyle(STYLE_BORDER_COLOR, Color::White().full);
53 uiViewGroupFrame_->SetStyle(STYLE_BORDER_OPA, HALF_OPA_OPAQUE);
54 uiViewGroupFrame_->SetStyle(STYLE_BORDER_WIDTH, VIEW_STYLE_BORDER_WIDTH);
55 uiViewGroupFrame_->SetStyle(STYLE_BORDER_RADIUS, VIEW_STYLE_BORDER_RADIUS);
56 uiViewGroupFrame_->SetStyle(STYLE_BACKGROUND_OPA, 0);
57
58 circleProgress_ = new UICircleProgress();
59 circleProgress_->SetPosition(10, 10, 150, 150); // 10: x 10:y 150:width 150: height
60 circleProgress_->SetCenterPosition(75, 75); // 75: position x 75: position y
61 circleProgress_->SetRadius(50); // 50: radius
62 circleProgress_->SetValue(20); // 20: value
63 circleProgress_->SetStyle(STYLE_PADDING_LEFT, 10); // 10: value
64 circleProgress_->SetStyle(STYLE_PADDING_TOP, 5); // 5: value
65 uiViewGroupFrame_->Add(circleProgress_);
66 circleProgress_->LayoutCenterOfParent();
67 }
68
69 if (scroll_ == nullptr) {
70 scroll_ = new UIScrollView();
71 scroll_->SetPosition(336, 11); // 336: x-coordinate; 11: y-coordinate
72 scroll_->Resize(624, container_->GetHeight() - 11); // 624: width; // 11: decrease height
73 container_->Add(scroll_);
74 positionY_ = 0;
75 }
76 }
77
TearDown()78 void UITestCircleProgress::TearDown()
79 {
80 DeleteChildren(container_);
81 container_ = nullptr;
82 circleProgress_ = nullptr;
83 scroll_ = nullptr;
84 }
85
GetTestView()86 const UIView* UITestCircleProgress::GetTestView()
87 {
88 UIKit_CircleProgress_Test_UICircleProgress_001();
89 UIKit_CircleProgress_Test_SetValue_002();
90 UIKit_CircleProgress_Test_SetImage_003();
91 UIKit_CircleProgress_Test_SetStyle_004();
92 UIKit_CircleProgress_Test_GetStyle_005();
93 UIKit_CircleProgress_Test_SetCapType_006();
94 UIKit_CircleProgress_Test_SetStep_007();
95 UIKit_CircleProgress_Test_SetRange_008();
96 UIKit_CircleProgress_Test_EnableBackground_009();
97 UIKit_CircleProgress_Test_SetCenter_010();
98 UIKit_CircleProgress_Test_SetRadius_011();
99 UIKit_CircleProgress_Test_SetLineWidth_012();
100 UIKit_CircleProgress_Test_SetImagePosition_013();
101 UIKit_CircleProgress_Test_SetLineColor_014();
102 UIKit_CircleProgress_Test_SetAngle_015();
103
104 return container_;
105 }
106
SetUpLabel(const char * title,int16_t x,int16_t y) const107 void UITestCircleProgress::SetUpLabel(const char* title, int16_t x, int16_t y) const
108 {
109 UILabel* label = new UILabel();
110 scroll_->Add(label);
111 label->SetPosition(x, y, 288, 30); // 288: width; 30: height
112 label->SetText(title);
113 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
114 }
SetUpButton(UILabelButton * btn,const char * title,int16_t x,int16_t y)115 void UITestCircleProgress::SetUpButton(UILabelButton* btn, const char* title, int16_t x, int16_t y)
116 {
117 if (btn == nullptr) {
118 return;
119 }
120 scroll_->Add(btn);
121 btn->SetPosition(x, y, BUTTON_WIDHT2, BUTTON_HEIGHT2);
122 btn->SetText(title);
123 btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
124 btn->SetOnClickListener(this);
125 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
126 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
127 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE);
128 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
129 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
130 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
131 scroll_->Invalidate();
132 }
133
UIKit_CircleProgress_Test_UICircleProgress_001()134 void UITestCircleProgress::UIKit_CircleProgress_Test_UICircleProgress_001()
135 {
136 resetBtn_ = new UILabelButton();
137 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
138 positionY_ = 0;
139 SetUpLabel("创建环形进度条:", positionX_, positionY_);
140 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
141 SetUpButton(resetBtn_, "重置", positionX_, positionY_);
142 }
143
UIKit_CircleProgress_Test_SetRange_008()144 void UITestCircleProgress::UIKit_CircleProgress_Test_SetRange_008()
145 {
146 incMinProgressBtn_ = new UILabelButton();
147 decMinProgressBtn_ = new UILabelButton();
148 incMaxProgressBtn_ = new UILabelButton();
149 decMaxProgressBtn_ = new UILabelButton();
150 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
151 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
152 SetUpLabel("设置环形进度条范围:", positionX_, positionY_);
153 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
154 SetUpButton(incMinProgressBtn_, "下限+", positionX_, positionY_);
155 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
156 SetUpButton(decMinProgressBtn_, "下限-", positionX_, positionY_);
157 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
158 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE;
159 SetUpButton(incMaxProgressBtn_, "上限+", positionX_, positionY_);
160 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
161 SetUpButton(decMaxProgressBtn_, "上限-", positionX_, positionY_);
162 }
163
UIKit_CircleProgress_Test_SetValue_002()164 void UITestCircleProgress::UIKit_CircleProgress_Test_SetValue_002()
165 {
166 incProgressBtn_ = new UILabelButton();
167 decProgressBtn_ = new UILabelButton();
168 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
169 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
170 SetUpLabel("设置环形进度条当前值:", positionX_, positionY_);
171 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
172 SetUpButton(incProgressBtn_, "进度+", positionX_, positionY_);
173 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
174 SetUpButton(decProgressBtn_, "进度-", positionX_, positionY_);
175 }
176
UIKit_CircleProgress_Test_SetImage_003()177 void UITestCircleProgress::UIKit_CircleProgress_Test_SetImage_003()
178 {
179 imageBtn_ = new UILabelButton();
180 noImageBtn_ = new UILabelButton();
181 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
182 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
183 SetUpLabel("设置环形进度条图片:", positionX_, positionY_);
184 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
185 SetUpButton(imageBtn_, "设置图片", positionX_, positionY_);
186 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
187 SetUpButton(noImageBtn_, "取消图片", positionX_, positionY_);
188 }
189
UIKit_CircleProgress_Test_SetStyle_004()190 void UITestCircleProgress::UIKit_CircleProgress_Test_SetStyle_004()
191 {
192 setStyleBtn_ = new UILabelButton();
193 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
194 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
195 SetUpLabel("设置环形进度条样式:", positionX_, positionY_);
196 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
197 SetUpButton(setStyleBtn_, "设置样式", positionX_, positionY_);
198 }
199
UIKit_CircleProgress_Test_GetStyle_005()200 void UITestCircleProgress::UIKit_CircleProgress_Test_GetStyle_005()
201 {
202 getStyleBtn_ = new UILabelButton();
203 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
204 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
205 SetUpLabel("设置环形进度条样式:", positionX_, positionY_);
206 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
207 SetUpButton(getStyleBtn_, "设置样式", positionX_, positionY_);
208 }
209
UIKit_CircleProgress_Test_SetCapType_006()210 void UITestCircleProgress::UIKit_CircleProgress_Test_SetCapType_006()
211 {
212 roundCapBtn_ = new UILabelButton();
213 noneCapBtn_ = new UILabelButton();
214 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
215 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
216 SetUpLabel("设置环形进度条端点:", positionX_, positionY_);
217 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
218 SetUpButton(roundCapBtn_, "圆形端点", positionX_, positionY_);
219 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
220 SetUpButton(noneCapBtn_, "方形端点", positionX_, positionY_);
221 }
222
UIKit_CircleProgress_Test_SetStep_007()223 void UITestCircleProgress::UIKit_CircleProgress_Test_SetStep_007()
224 {
225 stepBtn_ = new UILabelButton();
226 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
227 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
228 SetUpLabel("设置环形进度条步长:", positionX_, positionY_);
229 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
230 SetUpButton(stepBtn_, "步长+", positionX_, positionY_);
231 }
232
UIKit_CircleProgress_Test_EnableBackground_009()233 void UITestCircleProgress::UIKit_CircleProgress_Test_EnableBackground_009()
234 {
235 enableBgBtn_ = new UILabelButton();
236 disableBgBtn_ = new UILabelButton();
237 positionX_ = DELTA_X_COORDINATE_2;
238 positionY_ = 0;
239 SetUpLabel("环形进度条隐藏背景:", positionX_, positionY_);
240 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
241 SetUpButton(enableBgBtn_, "设置背景", positionX_, positionY_);
242 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
243 SetUpButton(disableBgBtn_, "隐藏背景", positionX_, positionY_);
244 }
245
UIKit_CircleProgress_Test_SetCenter_010()246 void UITestCircleProgress::UIKit_CircleProgress_Test_SetCenter_010()
247 {
248 centerXBtn_ = new UILabelButton();
249 centerYBtn_ = new UILabelButton();
250 positionX_ = DELTA_X_COORDINATE_2;
251 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
252 SetUpLabel("设置环形进度条圆心:", positionX_, positionY_);
253 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
254 SetUpButton(centerXBtn_, "圆心X+", positionX_, positionY_);
255 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
256 SetUpButton(centerYBtn_, "圆心Y+", positionX_, positionY_);
257 }
258
UIKit_CircleProgress_Test_SetRadius_011()259 void UITestCircleProgress::UIKit_CircleProgress_Test_SetRadius_011()
260 {
261 incRadiusBtn_ = new UILabelButton();
262 decRadiusBtn_ = new UILabelButton();
263 positionX_ = DELTA_X_COORDINATE_2;
264 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
265 SetUpLabel("设置环形进度条半径:", positionX_, positionY_);
266 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
267 SetUpButton(incRadiusBtn_, "半径+", positionX_, positionY_);
268 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
269 SetUpButton(decRadiusBtn_, "半径-", positionX_, positionY_);
270 }
271
UIKit_CircleProgress_Test_SetLineWidth_012()272 void UITestCircleProgress::UIKit_CircleProgress_Test_SetLineWidth_012()
273 {
274 incWidthBtn_ = new UILabelButton();
275 decWidthBtn_ = new UILabelButton();
276 positionX_ = DELTA_X_COORDINATE_2;
277 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
278 SetUpLabel("设置环形进度条线宽:", positionX_, positionY_);
279 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
280 SetUpButton(incWidthBtn_, "线宽+", positionX_, positionY_);
281 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
282 SetUpButton(decWidthBtn_, "线宽-", positionX_, positionY_);
283 }
284
UIKit_CircleProgress_Test_SetImagePosition_013()285 void UITestCircleProgress::UIKit_CircleProgress_Test_SetImagePosition_013()
286 {
287 imgPosXBtn_ = new UILabelButton();
288 imgPosYBtn_ = new UILabelButton();
289 positionX_ = DELTA_X_COORDINATE_2;
290 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
291 SetUpLabel("设置环形进度条图片位置:", positionX_, positionY_);
292 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
293 SetUpButton(imgPosXBtn_, "图片X+", positionX_, positionY_);
294 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
295 SetUpButton(imgPosYBtn_, "图片Y+", positionX_, positionY_);
296 }
297
UIKit_CircleProgress_Test_SetLineColor_014()298 void UITestCircleProgress::UIKit_CircleProgress_Test_SetLineColor_014()
299 {
300 lineColorBtn_ = new UILabelButton();
301 positionX_ = DELTA_X_COORDINATE_2;
302 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
303 SetUpLabel("设置环形进度条前景线条颜色: ", positionX_, positionY_);
304 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
305 SetUpButton(lineColorBtn_, "前景绿色", positionX_, positionY_);
306 }
307
UIKit_CircleProgress_Test_SetAngle_015()308 void UITestCircleProgress::UIKit_CircleProgress_Test_SetAngle_015()
309 {
310 incStartAngleBtn_ = new UILabelButton();
311 decStartAngleBtn_ = new UILabelButton();
312 incEndAngleBtn_ = new UILabelButton();
313 decEndAngleBtn_ = new UILabelButton();
314 swapAngleBtn_ = new UILabelButton();
315 positionX_ = DELTA_X_COORDINATE_2;
316 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
317 SetUpLabel("设置环形进度条角度:", positionX_, positionY_);
318 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
319 SetUpButton(incStartAngleBtn_, "起始角度+", positionX_, positionY_);
320 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
321 SetUpButton(decStartAngleBtn_, "起始角度-", positionX_, positionY_);
322 positionX_ = DELTA_X_COORDINATE_2;
323 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE;
324 SetUpButton(incEndAngleBtn_, "结束角度+", positionX_, positionY_);
325 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
326 SetUpButton(decEndAngleBtn_, "结束角度-", positionX_, positionY_);
327 positionX_ = DELTA_X_COORDINATE_2;
328 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE;
329 SetUpButton(swapAngleBtn_, "转换方向", positionX_, positionY_);
330 }
331
OnClick(UIView & view,const ClickEvent & event)332 bool UITestCircleProgress::OnClick(UIView& view, const ClickEvent& event)
333 {
334 static uint16_t progress = 20; // 20: progress
335 static uint16_t step = 0;
336 static uint16_t width = 150; // 150: width
337 static uint16_t height = 150; // 150: height
338 static int16_t min = 0;
339 static int16_t max = 100; // 100: max value
340 static Point center = {75, 75}; // 75: position x 75: position y
341 static Point imgPos = {0, 0};
342 static int16_t startAngle = 0;
343 static int16_t endAngle = 360; // 360: end angle
344 static int16_t radius = 50; // 50: radius
345
346 if (&view == resetBtn_) {
347 circleProgress_->SetPosition(10, 10, 150, 150); // 10: x 10: y 150: width 150: height
348 progress = 100; // 100 progress
349 step = 0;
350 width = 150; // 150: width
351 height = 150; // 150: height
352 min = 0;
353 max = 100; // 100: max value
354 center = {75, 75}; // 75: position x 75: position y
355 startAngle = 0;
356 endAngle = 360; // 360: end angle
357 radius = 50; // 50: radius
358 imgPos = {0, 0};
359
360 circleProgress_->SetRange(max, min);
361 circleProgress_->SetValue(progress);
362 circleProgress_->SetCenterPosition(center.x, center.y);
363 circleProgress_->SetRadius(radius);
364 circleProgress_->SetStartAngle(startAngle);
365 circleProgress_->SetEndAngle(endAngle);
366 circleProgress_->SetStep(step);
367 circleProgress_->SetBackgroundStyle(StyleDefault::GetProgressBackgroundStyle());
368 circleProgress_->SetForegroundStyle(StyleDefault::GetProgressForegroundStyle());
369 circleProgress_->SetLineColor(Color::Red());
370 circleProgress_->SetForegroundStyle(STYLE_LINE_WIDTH, 40); // 40: value
371 circleProgress_->SetForegroundStyle(STYLE_LINE_OPA, 127); // 127: value
372 circleProgress_->SetBackgroundImagePosition(imgPos.x, imgPos.y);
373 circleProgress_->SetProgressImagePosition(imgPos.x, imgPos.y);
374 circleProgress_->SetImage(static_cast<ImageInfo*>(nullptr));
375 circleProgress_->EnableBackground(false);
376 circleProgress_->LayoutCenterOfParent();
377 } else if (&view == incProgressBtn_) {
378 progress++;
379 circleProgress_->SetValue(progress);
380 } else if (&view == decProgressBtn_) {
381 progress--;
382 circleProgress_->SetValue(progress);
383 } else if (&view == stepBtn_) {
384 step++;
385 circleProgress_->SetStep(step);
386 } else if (&view == incMinProgressBtn_) {
387 min++;
388 circleProgress_->SetRange(circleProgress_->GetRangeMax(), min);
389 } else if (&view == decMinProgressBtn_) {
390 min--;
391 circleProgress_->SetRange(circleProgress_->GetRangeMax(), min);
392 } else if (&view == incMaxProgressBtn_) {
393 max++;
394 circleProgress_->SetRange(max, circleProgress_->GetRangeMin());
395 } else if (&view == decMaxProgressBtn_) {
396 max--;
397 circleProgress_->SetRange(max, circleProgress_->GetRangeMin());
398 } else if (&view == imageBtn_) {
399 circleProgress_->SetImage(RED_IMAGE_PATH, BLUE_IMAGE_PATH);
400 } else if (&view == noImageBtn_) {
401 circleProgress_->SetImage(static_cast<char*>(nullptr));
402 } else if (&view == setStyleBtn_) {
403 Style style = StyleDefault::GetDefaultStyle();
404 style.lineColor_ = Color::White();
405 circleProgress_->SetBackgroundStyle(style);
406 style.lineColor_ = Color::Blue();
407 circleProgress_->SetForegroundStyle(style);
408 } else if (&view == getStyleBtn_) {
409 circleProgress_->SetBackgroundStyle(STYLE_LINE_COLOR, Color::Red().full);
410 circleProgress_->SetForegroundStyle(STYLE_LINE_COLOR, Color::Yellow().full);
411 } else if (&view == roundCapBtn_) {
412 circleProgress_->SetCapType(CapType::CAP_ROUND);
413 } else if (&view == noneCapBtn_) {
414 circleProgress_->SetCapType(CapType::CAP_NONE);
415 } else if (&view == enableBgBtn_) {
416 circleProgress_->EnableBackground(true);
417 } else if (&view == disableBgBtn_) {
418 circleProgress_->EnableBackground(false);
419 } else if (&view == incStartAngleBtn_) {
420 startAngle++;
421 circleProgress_->SetStartAngle(startAngle);
422 } else if (&view == decStartAngleBtn_) {
423 startAngle--;
424 circleProgress_->SetStartAngle(startAngle);
425 } else if (&view == incEndAngleBtn_) {
426 endAngle++;
427 circleProgress_->SetEndAngle(endAngle);
428 } else if (&view == decEndAngleBtn_) {
429 endAngle--;
430 circleProgress_->SetEndAngle(endAngle);
431 } else if (&view == swapAngleBtn_) {
432 int16_t angle = startAngle;
433 startAngle = endAngle;
434 endAngle = angle;
435 circleProgress_->SetStartAngle(startAngle);
436 circleProgress_->SetEndAngle(endAngle);
437 } else if (&view == centerXBtn_) {
438 center.x++;
439 circleProgress_->SetCenterPosition(center.x, circleProgress_->GetCenterPosition().y);
440 } else if (&view == centerYBtn_) {
441 center.y++;
442 circleProgress_->SetCenterPosition(circleProgress_->GetCenterPosition().x, center.y);
443 } else if (&view == incRadiusBtn_) {
444 radius++;
445 circleProgress_->SetRadius(radius);
446 } else if (&view == decRadiusBtn_) {
447 radius--;
448 circleProgress_->SetRadius(radius);
449 } else if (&view == incWidthBtn_) {
450 circleProgress_->SetBackgroundStyle(STYLE_LINE_WIDTH,
451 circleProgress_->GetBackgroundStyle(STYLE_LINE_WIDTH) + 1);
452 circleProgress_->SetForegroundStyle(STYLE_LINE_WIDTH,
453 circleProgress_->GetForegroundStyle(STYLE_LINE_WIDTH) + 1);
454 } else if (&view == decWidthBtn_) {
455 circleProgress_->SetBackgroundStyle(STYLE_LINE_WIDTH,
456 circleProgress_->GetBackgroundStyle(STYLE_LINE_WIDTH) - 1);
457 circleProgress_->SetForegroundStyle(STYLE_LINE_WIDTH,
458 circleProgress_->GetForegroundStyle(STYLE_LINE_WIDTH) - 1);
459 } else if (&view == imgPosXBtn_) {
460 imgPos.x++;
461 circleProgress_->SetBackgroundImagePosition(imgPos.x, imgPos.y);
462 circleProgress_->SetProgressImagePosition(imgPos.x, imgPos.y);
463 } else if (&view == imgPosXBtn_) {
464 imgPos.y++;
465 circleProgress_->SetBackgroundImagePosition(imgPos.x, imgPos.y);
466 circleProgress_->SetProgressImagePosition(imgPos.x, imgPos.y);
467 } else if (&view == lineColorBtn_) {
468 circleProgress_->SetLineColor(Color::Green());
469 }
470 container_->Invalidate();
471 return true;
472 }
473 } // namespace OHOS