diff options
| author | Riku Isokoski <riksu9000@gmail.com> | 2022-05-19 23:12:35 +0300 |
|---|---|---|
| committer | JF <JF002@users.noreply.github.com> | 2022-06-06 21:28:03 +0200 |
| commit | 955dda60c5a58ff905da012307b1fbb2b973c467 (patch) | |
| tree | 2b3e193008faf26e79836561905ae4aae6fc0299 /src | |
| parent | 6cfb45e280fa9653e860a8e112092740faa9842e (diff) | |
Use lambda to reduce code duplication
Diffstat (limited to 'src')
| -rw-r--r-- | src/displayapp/widgets/Counter.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/displayapp/widgets/Counter.cpp b/src/displayapp/widgets/Counter.cpp index 92af89f4..ecf39613 100644 --- a/src/displayapp/widgets/Counter.cpp +++ b/src/displayapp/widgets/Counter.cpp @@ -109,17 +109,18 @@ void Counter::Create() { linePoints[0] = {0, 0}; linePoints[1] = {width, 0}; - upperLine = lv_line_create(counterContainer, nullptr); - lv_line_set_points(upperLine, linePoints, 2); - lv_obj_set_style_local_line_width(upperLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 1); - lv_obj_set_style_local_line_color(upperLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_line_opa(upperLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_20); + auto LineCreate = [&]() { + lv_obj_t* line = lv_line_create(counterContainer, nullptr); + lv_line_set_points(line, linePoints, 2); + lv_obj_set_style_local_line_width(line, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 1); + lv_obj_set_style_local_line_color(line, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_local_line_opa(line, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_20); + return line; + }; + + upperLine = LineCreate(); lv_obj_align(upperLine, upBtn, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); - lowerLine = lv_line_create(counterContainer, nullptr); - lv_line_set_points(lowerLine, linePoints, 2); - lv_obj_set_style_local_line_width(lowerLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 1); - lv_obj_set_style_local_line_color(lowerLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_line_opa(lowerLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_20); + lowerLine = LineCreate(); lv_obj_align(lowerLine, downBtn, LV_ALIGN_OUT_TOP_MID, 0, -1); } |
