diff --git a/src/displayapp/widgets/Counter.cpp b/src/displayapp/widgets/Counter.cpp index 7c8bf7b1..25384cbc 100644 --- a/src/displayapp/widgets/Counter.cpp +++ b/src/displayapp/widgets/Counter.cpp @@ -40,6 +40,21 @@ void Counter::SetValue(int newValue) { UpdateLabel(); } +void Counter::HideControls() { + lv_obj_set_hidden(upBtn, true); + lv_obj_set_hidden(downBtn, true); + lv_obj_set_hidden(upperLine, true); + lv_obj_set_hidden(lowerLine, true); + lv_obj_set_style_local_bg_opa(counterContainer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); +} +void Counter::ShowControls() { + lv_obj_set_hidden(upBtn, false); + lv_obj_set_hidden(downBtn, false); + lv_obj_set_hidden(upperLine, false); + lv_obj_set_hidden(lowerLine, false); + lv_obj_set_style_local_bg_opa(counterContainer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER); +} + void Counter::UpdateLabel() { lv_label_set_text_fmt(number, "%.2i", value); } @@ -92,14 +107,14 @@ void Counter::Create() { linePoints[0] = {0, 0}; linePoints[1] = {width, 0}; - lv_obj_t* upperLine = lv_line_create(counterContainer, nullptr); + 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); lv_obj_align(upperLine, upBtn, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); - lv_obj_t* lowerLine = lv_line_create(counterContainer, nullptr); + 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); diff --git a/src/displayapp/widgets/Counter.h b/src/displayapp/widgets/Counter.h index bc907c2a..eee6e7b6 100644 --- a/src/displayapp/widgets/Counter.h +++ b/src/displayapp/widgets/Counter.h @@ -14,6 +14,8 @@ namespace Pinetime { void Increment(); void Decrement(); void SetValue(int newValue); + void HideControls(); + void ShowControls(); int GetValue() const { return value; @@ -30,6 +32,8 @@ namespace Pinetime { lv_obj_t* upBtn; lv_obj_t* downBtn; lv_obj_t* number; + lv_obj_t* upperLine; + lv_obj_t* lowerLine; lv_point_t linePoints[2]; int value = 0; int min;