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 UIKitCircleProgressTestUICircleProgress001();
89 UIKitCircleProgressTestSetValue002();
90 UIKitCircleProgressTestSetImage003();
91 UIKitCircleProgressTestSetStyle004();
92 UIKitCircleProgressTestGetStyle005();
93 UIKitCircleProgressTestSetCapType006();
94 UIKitCircleProgressTestSetStep007();
95 UIKitCircleProgressTestSetRange008();
96 UIKitCircleProgressTestEnableBackground009();
97 UIKitCircleProgressTestSetCenter010();
98 UIKitCircleProgressTestSetRadius011();
99 UIKitCircleProgressTestSetLineWidth012();
100 UIKitCircleProgressTestSetImagePosition013();
101 UIKitCircleProgressTestSetLineColor014();
102 UIKitCircleProgressTestSetAngle015();
103 UIKitCircleProgressTestHideRoundCap016();
104
105 return container_;
106 }
107
SetUpLabel(const char * title,int16_t x,int16_t y) const108 void UITestCircleProgress::SetUpLabel(const char* title, int16_t x, int16_t y) const
109 {
110 UILabel* label = new UILabel();
111 scroll_->Add(label);
112 label->SetPosition(x, y, 288, 30); // 288: width; 30: height
113 label->SetText(title);
114 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
115 }
SetUpButton(UILabelButton * btn,const char * title,int16_t x,int16_t y)116 void UITestCircleProgress::SetUpButton(UILabelButton* btn, const char* title, int16_t x, int16_t y)
117 {
118 if (btn == nullptr) {
119 return;
120 }
121 scroll_->Add(btn);
122 btn->SetPosition(x, y, BUTTON_WIDHT2, BUTTON_HEIGHT2);
123 btn->SetText(title);
124 btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
125 btn->SetOnClickListener(this);
126 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
127 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
128 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE);
129 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
130 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
131 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
132 scroll_->Invalidate();
133 }
134
UIKitCircleProgressTestUICircleProgress001()135 void UITestCircleProgress::UIKitCircleProgressTestUICircleProgress001()
136 {
137 resetBtn_ = new UILabelButton();
138 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
139 positionY_ = 0;
140 SetUpLabel("创建环形进度条:", positionX_, positionY_);
141 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
142 SetUpButton(resetBtn_, "重置", positionX_, positionY_);
143 }
144
UIKitCircleProgressTestSetRange008()145 void UITestCircleProgress::UIKitCircleProgressTestSetRange008()
146 {
147 incMinProgressBtn_ = new UILabelButton();
148 decMinProgressBtn_ = new UILabelButton();
149 incMaxProgressBtn_ = new UILabelButton();
150 decMaxProgressBtn_ = new UILabelButton();
151 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
152 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
153 SetUpLabel("设置环形进度条范围:", positionX_, positionY_);
154 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
155 SetUpButton(incMinProgressBtn_, "下限+", positionX_, positionY_);
156 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
157 SetUpButton(decMinProgressBtn_, "下限-", positionX_, positionY_);
158 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
159 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE;
160 SetUpButton(incMaxProgressBtn_, "上限+", positionX_, positionY_);
161 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
162 SetUpButton(decMaxProgressBtn_, "上限-", positionX_, positionY_);
163 }
164
UIKitCircleProgressTestSetValue002()165 void UITestCircleProgress::UIKitCircleProgressTestSetValue002()
166 {
167 incProgressBtn_ = new UILabelButton();
168 decProgressBtn_ = new UILabelButton();
169 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
170 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
171 SetUpLabel("设置环形进度条当前值:", positionX_, positionY_);
172 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
173 SetUpButton(incProgressBtn_, "进度+", positionX_, positionY_);
174 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
175 SetUpButton(decProgressBtn_, "进度-", positionX_, positionY_);
176 }
177
UIKitCircleProgressTestSetImage003()178 void UITestCircleProgress::UIKitCircleProgressTestSetImage003()
179 {
180 imageBtn_ = new UILabelButton();
181 noImageBtn_ = new UILabelButton();
182 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
183 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
184 SetUpLabel("设置环形进度条图片:", positionX_, positionY_);
185 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
186 SetUpButton(imageBtn_, "设置图片", positionX_, positionY_);
187 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
188 SetUpButton(noImageBtn_, "取消图片", positionX_, positionY_);
189 }
190
UIKitCircleProgressTestSetStyle004()191 void UITestCircleProgress::UIKitCircleProgressTestSetStyle004()
192 {
193 setStyleBtn_ = new UILabelButton();
194 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
195 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
196 SetUpLabel("设置环形进度条样式:", positionX_, positionY_);
197 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
198 SetUpButton(setStyleBtn_, "设置样式", positionX_, positionY_);
199 }
200
UIKitCircleProgressTestGetStyle005()201 void UITestCircleProgress::UIKitCircleProgressTestGetStyle005()
202 {
203 getStyleBtn_ = new UILabelButton();
204 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
205 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
206 SetUpLabel("设置环形进度条样式:", positionX_, positionY_);
207 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
208 SetUpButton(getStyleBtn_, "设置样式", positionX_, positionY_);
209 }
210
UIKitCircleProgressTestSetCapType006()211 void UITestCircleProgress::UIKitCircleProgressTestSetCapType006()
212 {
213 roundCapBtn_ = new UILabelButton();
214 noneCapBtn_ = new UILabelButton();
215 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
216 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
217 SetUpLabel("设置环形进度条端点:", positionX_, positionY_);
218 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
219 SetUpButton(roundCapBtn_, "圆形端点", positionX_, positionY_);
220 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
221 SetUpButton(noneCapBtn_, "方形端点", positionX_, positionY_);
222 }
223
UIKitCircleProgressTestSetStep007()224 void UITestCircleProgress::UIKitCircleProgressTestSetStep007()
225 {
226 stepBtn_ = new UILabelButton();
227 positionX_ = VIEW_DISTANCE_TO_LEFT_SIDE2;
228 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
229 SetUpLabel("设置环形进度条步长:", positionX_, positionY_);
230 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
231 SetUpButton(stepBtn_, "步长+", positionX_, positionY_);
232 }
233
UIKitCircleProgressTestEnableBackground009()234 void UITestCircleProgress::UIKitCircleProgressTestEnableBackground009()
235 {
236 enableBgBtn_ = new UILabelButton();
237 disableBgBtn_ = new UILabelButton();
238 positionX_ = DELTA_X_COORDINATE_2;
239 positionY_ = 0;
240 SetUpLabel("环形进度条隐藏背景:", positionX_, positionY_);
241 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
242 SetUpButton(enableBgBtn_, "设置背景", positionX_, positionY_);
243 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
244 SetUpButton(disableBgBtn_, "隐藏背景", positionX_, positionY_);
245 }
246
UIKitCircleProgressTestSetCenter010()247 void UITestCircleProgress::UIKitCircleProgressTestSetCenter010()
248 {
249 centerXBtn_ = new UILabelButton();
250 centerYBtn_ = new UILabelButton();
251 positionX_ = DELTA_X_COORDINATE_2;
252 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
253 SetUpLabel("设置环形进度条圆心:", positionX_, positionY_);
254 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
255 SetUpButton(centerXBtn_, "圆心X+", positionX_, positionY_);
256 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
257 SetUpButton(centerYBtn_, "圆心Y+", positionX_, positionY_);
258 }
259
UIKitCircleProgressTestSetRadius011()260 void UITestCircleProgress::UIKitCircleProgressTestSetRadius011()
261 {
262 incRadiusBtn_ = new UILabelButton();
263 decRadiusBtn_ = new UILabelButton();
264 positionX_ = DELTA_X_COORDINATE_2;
265 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
266 SetUpLabel("设置环形进度条半径:", positionX_, positionY_);
267 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
268 SetUpButton(incRadiusBtn_, "半径+", positionX_, positionY_);
269 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
270 SetUpButton(decRadiusBtn_, "半径-", positionX_, positionY_);
271 }
272
UIKitCircleProgressTestSetLineWidth012()273 void UITestCircleProgress::UIKitCircleProgressTestSetLineWidth012()
274 {
275 incWidthBtn_ = new UILabelButton();
276 decWidthBtn_ = new UILabelButton();
277 positionX_ = DELTA_X_COORDINATE_2;
278 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
279 SetUpLabel("设置环形进度条线宽:", positionX_, positionY_);
280 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
281 SetUpButton(incWidthBtn_, "线宽+", positionX_, positionY_);
282 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
283 SetUpButton(decWidthBtn_, "线宽-", positionX_, positionY_);
284 }
285
UIKitCircleProgressTestSetImagePosition013()286 void UITestCircleProgress::UIKitCircleProgressTestSetImagePosition013()
287 {
288 imgPosXBtn_ = new UILabelButton();
289 imgPosYBtn_ = new UILabelButton();
290 positionX_ = DELTA_X_COORDINATE_2;
291 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
292 SetUpLabel("设置环形进度条图片位置:", positionX_, positionY_);
293 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
294 SetUpButton(imgPosXBtn_, "图片X+", positionX_, positionY_);
295 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
296 SetUpButton(imgPosYBtn_, "图片Y+", positionX_, positionY_);
297 }
298
UIKitCircleProgressTestSetLineColor014()299 void UITestCircleProgress::UIKitCircleProgressTestSetLineColor014()
300 {
301 lineColorBtn_ = new UILabelButton();
302 positionX_ = DELTA_X_COORDINATE_2;
303 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
304 SetUpLabel("设置环形进度条前景线条颜色: ", positionX_, positionY_);
305 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
306 SetUpButton(lineColorBtn_, "前景绿色", positionX_, positionY_);
307 }
308
UIKitCircleProgressTestSetAngle015()309 void UITestCircleProgress::UIKitCircleProgressTestSetAngle015()
310 {
311 incStartAngleBtn_ = new UILabelButton();
312 decStartAngleBtn_ = new UILabelButton();
313 incEndAngleBtn_ = new UILabelButton();
314 decEndAngleBtn_ = new UILabelButton();
315 swapAngleBtn_ = new UILabelButton();
316 positionX_ = DELTA_X_COORDINATE_2;
317 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
318 SetUpLabel("设置环形进度条角度:", positionX_, positionY_);
319 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
320 SetUpButton(incStartAngleBtn_, "起始角度+", positionX_, positionY_);
321 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
322 SetUpButton(decStartAngleBtn_, "起始角度-", positionX_, positionY_);
323 positionX_ = DELTA_X_COORDINATE_2;
324 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE;
325 SetUpButton(incEndAngleBtn_, "结束角度+", positionX_, positionY_);
326 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
327 SetUpButton(decEndAngleBtn_, "结束角度-", positionX_, positionY_);
328 positionX_ = DELTA_X_COORDINATE_2;
329 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE;
330 SetUpButton(swapAngleBtn_, "转换方向", positionX_, positionY_);
331 }
332
UIKitCircleProgressTestHideRoundCap016()333 void UITestCircleProgress::UIKitCircleProgressTestHideRoundCap016()
334 {
335 showroundCap_ = new UILabelButton();
336 unshowroundCap_ = new UILabelButton();
337 positionX_ = DELTA_X_COORDINATE_2;
338 positionY_ += BUTTON_HEIGHT + DELTA_Y_COORDINATE_2;
339 SetUpLabel("进度为0是否显示圆形端点", positionX_, positionY_);
340 positionY_ += LABEL_HEIGHT + DELTA_X_COORDINATE;
341 SetUpButton(showroundCap_, "显示", positionX_, positionY_);
342 positionX_ += BUTTON_WIDTH + DELTA_Y_COORDINATE;
343 SetUpButton(unshowroundCap_, "不显示", positionX_, positionY_);
344 }
345
OnClick(UIView & view,const ClickEvent & event)346 bool UITestCircleProgress::OnClick(UIView& view, const ClickEvent& event)
347 {
348 static uint16_t progress = 20; // 20: progress
349 static uint16_t step = 0;
350 static uint16_t width = 150; // 150: width
351 static uint16_t height = 150; // 150: height
352 static int16_t min = 0;
353 static int16_t max = 100; // 100: max value
354 static Point center = {75, 75}; // 75: position x 75: position y
355 static Point imgPos = {0, 0};
356 static int16_t startAngle = 0;
357 static int16_t endAngle = 360; // 360: end angle
358 static int16_t radius = 50; // 50: radius
359
360 if (&view == resetBtn_) {
361 circleProgress_->SetPosition(10, 10, 150, 150); // 10: x 10: y 150: width 150: height
362 progress = 100; // 100 progress
363 step = 0;
364 width = 150; // 150: width
365 height = 150; // 150: height
366 min = 0;
367 max = 100; // 100: max value
368 center = {75, 75}; // 75: position x 75: position y
369 startAngle = 0;
370 endAngle = 360; // 360: end angle
371 radius = 50; // 50: radius
372 imgPos = {0, 0};
373
374 circleProgress_->SetRange(max, min);
375 circleProgress_->SetValue(progress);
376 circleProgress_->SetCenterPosition(center.x, center.y);
377 circleProgress_->SetRadius(radius);
378 circleProgress_->SetStartAngle(startAngle);
379 circleProgress_->SetEndAngle(endAngle);
380 circleProgress_->SetStep(step);
381 circleProgress_->SetBackgroundStyle(StyleDefault::GetProgressBackgroundStyle());
382 circleProgress_->SetForegroundStyle(StyleDefault::GetProgressForegroundStyle());
383 circleProgress_->SetLineColor(Color::Red());
384 circleProgress_->SetForegroundStyle(STYLE_LINE_WIDTH, 40); // 40: value
385 circleProgress_->SetForegroundStyle(STYLE_LINE_OPA, 127); // 127: value
386 circleProgress_->SetBackgroundImagePosition(imgPos.x, imgPos.y);
387 circleProgress_->SetProgressImagePosition(imgPos.x, imgPos.y);
388 circleProgress_->SetImage(static_cast<ImageInfo*>(nullptr));
389 circleProgress_->EnableBackground(false);
390 circleProgress_->LayoutCenterOfParent();
391 } else if (&view == incProgressBtn_) {
392 progress++;
393 circleProgress_->SetValue(progress);
394 } else if (&view == decProgressBtn_) {
395 progress--;
396 circleProgress_->SetValue(progress);
397 } else if (&view == stepBtn_) {
398 step++;
399 circleProgress_->SetStep(step);
400 } else if (&view == incMinProgressBtn_) {
401 min++;
402 circleProgress_->SetRange(circleProgress_->GetRangeMax(), min);
403 } else if (&view == decMinProgressBtn_) {
404 min--;
405 circleProgress_->SetRange(circleProgress_->GetRangeMax(), min);
406 } else if (&view == incMaxProgressBtn_) {
407 max++;
408 circleProgress_->SetRange(max, circleProgress_->GetRangeMin());
409 } else if (&view == decMaxProgressBtn_) {
410 max--;
411 circleProgress_->SetRange(max, circleProgress_->GetRangeMin());
412 } else if (&view == imageBtn_) {
413 circleProgress_->SetImage(RED_IMAGE_PATH, BLUE_IMAGE_PATH);
414 } else if (&view == noImageBtn_) {
415 circleProgress_->SetImage(static_cast<char*>(nullptr));
416 } else if (&view == setStyleBtn_) {
417 Style style = StyleDefault::GetDefaultStyle();
418 style.lineColor_ = Color::White();
419 circleProgress_->SetBackgroundStyle(style);
420 style.lineColor_ = Color::Blue();
421 circleProgress_->SetForegroundStyle(style);
422 } else if (&view == getStyleBtn_) {
423 circleProgress_->SetBackgroundStyle(STYLE_LINE_COLOR, Color::Red().full);
424 circleProgress_->SetForegroundStyle(STYLE_LINE_COLOR, Color::Yellow().full);
425 } else if (&view == roundCapBtn_) {
426 circleProgress_->SetCapType(CapType::CAP_ROUND);
427 } else if (&view == noneCapBtn_) {
428 circleProgress_->SetCapType(CapType::CAP_NONE);
429 } else if (&view == enableBgBtn_) {
430 circleProgress_->EnableBackground(true);
431 } else if (&view == disableBgBtn_) {
432 circleProgress_->EnableBackground(false);
433 } else if (&view == incStartAngleBtn_) {
434 startAngle++;
435 circleProgress_->SetStartAngle(startAngle);
436 } else if (&view == decStartAngleBtn_) {
437 startAngle--;
438 circleProgress_->SetStartAngle(startAngle);
439 } else if (&view == incEndAngleBtn_) {
440 endAngle++;
441 circleProgress_->SetEndAngle(endAngle);
442 } else if (&view == decEndAngleBtn_) {
443 endAngle--;
444 circleProgress_->SetEndAngle(endAngle);
445 } else if (&view == swapAngleBtn_) {
446 int16_t angle = startAngle;
447 startAngle = endAngle;
448 endAngle = angle;
449 circleProgress_->SetStartAngle(startAngle);
450 circleProgress_->SetEndAngle(endAngle);
451 } else if (&view == centerXBtn_) {
452 center.x++;
453 circleProgress_->SetCenterPosition(center.x, circleProgress_->GetCenterPosition().y);
454 } else if (&view == centerYBtn_) {
455 center.y++;
456 circleProgress_->SetCenterPosition(circleProgress_->GetCenterPosition().x, center.y);
457 } else if (&view == incRadiusBtn_) {
458 radius++;
459 circleProgress_->SetRadius(radius);
460 } else if (&view == decRadiusBtn_) {
461 radius--;
462 circleProgress_->SetRadius(radius);
463 } else if (&view == incWidthBtn_) {
464 circleProgress_->SetBackgroundStyle(STYLE_LINE_WIDTH,
465 circleProgress_->GetBackgroundStyle(STYLE_LINE_WIDTH) + 1);
466 circleProgress_->SetForegroundStyle(STYLE_LINE_WIDTH,
467 circleProgress_->GetForegroundStyle(STYLE_LINE_WIDTH) + 1);
468 } else if (&view == decWidthBtn_) {
469 circleProgress_->SetBackgroundStyle(STYLE_LINE_WIDTH,
470 circleProgress_->GetBackgroundStyle(STYLE_LINE_WIDTH) - 1);
471 circleProgress_->SetForegroundStyle(STYLE_LINE_WIDTH,
472 circleProgress_->GetForegroundStyle(STYLE_LINE_WIDTH) - 1);
473 } else if (&view == imgPosXBtn_) {
474 imgPos.x++;
475 circleProgress_->SetBackgroundImagePosition(imgPos.x, imgPos.y);
476 circleProgress_->SetProgressImagePosition(imgPos.x, imgPos.y);
477 } else if (&view == imgPosYBtn_) {
478 imgPos.y++;
479 circleProgress_->SetBackgroundImagePosition(imgPos.x, imgPos.y);
480 circleProgress_->SetProgressImagePosition(imgPos.x, imgPos.y);
481 } else if (&view == lineColorBtn_) {
482 circleProgress_->SetLineColor(Color::Green());
483 } else if (&view == showroundCap_) {
484 circleProgress_->SetCapType(CapType::CAP_ROUND);
485 } else if (&view == unshowroundCap_) {
486 circleProgress_->SetCapType(CapType::CAP_ROUND_UNSHOW);
487 }
488 container_->Invalidate();
489 return true;
490 }
491 } // namespace OHOS
492