1
0
Fork 0

Use lambda to reduce code duplication

This commit is contained in:
Riku Isokoski 2022-05-19 23:12:35 +03:00 committed by JF
parent 6cfb45e280
commit 955dda60c5

View file

@ -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);
}