Use lambda to reduce code duplication
This commit is contained in:
parent
6cfb45e280
commit
955dda60c5
|
@ -109,17 +109,18 @@ void Counter::Create() {
|
||||||
linePoints[0] = {0, 0};
|
linePoints[0] = {0, 0};
|
||||||
linePoints[1] = {width, 0};
|
linePoints[1] = {width, 0};
|
||||||
|
|
||||||
upperLine = lv_line_create(counterContainer, nullptr);
|
auto LineCreate = [&]() {
|
||||||
lv_line_set_points(upperLine, linePoints, 2);
|
lv_obj_t* line = lv_line_create(counterContainer, nullptr);
|
||||||
lv_obj_set_style_local_line_width(upperLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 1);
|
lv_line_set_points(line, linePoints, 2);
|
||||||
lv_obj_set_style_local_line_color(upperLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
lv_obj_set_style_local_line_width(line, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 1);
|
||||||
lv_obj_set_style_local_line_opa(upperLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_20);
|
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);
|
lv_obj_align(upperLine, upBtn, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
|
||||||
|
|
||||||
lowerLine = lv_line_create(counterContainer, nullptr);
|
lowerLine = LineCreate();
|
||||||
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);
|
|
||||||
lv_obj_align(lowerLine, downBtn, LV_ALIGN_OUT_TOP_MID, 0, -1);
|
lv_obj_align(lowerLine, downBtn, LV_ALIGN_OUT_TOP_MID, 0, -1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue