diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-05-10 22:57:13 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-05-10 22:57:13 (GMT) |
| commit | 20bf019ed739231714620010248f7e9e409aa919 (patch) | |
| tree | f487545ba633086678c6e0b2c6b0a85f40929612 /src/displayapp/screens/Timer.h | |
| parent | 2f0858fa0561d09d59ab4435c0b4342794738a77 (diff) | |
Remove redundant code in Timer App; inline CreateButtons
Diffstat (limited to 'src/displayapp/screens/Timer.h')
| -rw-r--r-- | src/displayapp/screens/Timer.h | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h index cb5aeb2..dd55602 100644 --- a/src/displayapp/screens/Timer.h +++ b/src/displayapp/screens/Timer.h @@ -19,13 +19,6 @@ namespace Pinetime::Applications::Screens { void Refresh() override; void RefreshRunning(); - inline void SetDone() { - lv_label_set_text_static(time, "00:00"); - RefreshRunning(); - secondsToSet = 0; - minutesToSet = 0; - CreateButtons(); - } private: static void btnEventHandler(lv_obj_t* obj, lv_event_t event); inline void OnButtonEvent(lv_obj_t* obj, lv_event_t event) { @@ -76,7 +69,44 @@ namespace Pinetime::Applications::Screens { } } } - void CreateButtons(); + + inline void CreateButtons() { + if (btnMinutesUp != nullptr) { + return; + } + + btnMinutesUp = lv_btn_create(lv_scr_act(), nullptr); + btnMinutesUp->user_data = this; + lv_obj_set_event_cb(btnMinutesUp, btnEventHandler); + lv_obj_set_size(btnMinutesUp, 60, 40); + lv_obj_align(btnMinutesUp, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, -85); + txtMUp = lv_label_create(btnMinutesUp, nullptr); + lv_label_set_text_static(txtMUp, "+"); + + btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr); + btnMinutesDown->user_data = this; + lv_obj_set_event_cb(btnMinutesDown, btnEventHandler); + lv_obj_set_size(btnMinutesDown, 60, 40); + lv_obj_align(btnMinutesDown, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, +35); + txtMDown = lv_label_create(btnMinutesDown, nullptr); + lv_label_set_text_static(txtMDown, "-"); + + btnSecondsUp = lv_btn_create(lv_scr_act(), nullptr); + btnSecondsUp->user_data = this; + lv_obj_set_event_cb(btnSecondsUp, btnEventHandler); + lv_obj_set_size(btnSecondsUp, 60, 40); + lv_obj_align(btnSecondsUp, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -20, -85); + txtSUp = lv_label_create(btnSecondsUp, nullptr); + lv_label_set_text_static(txtSUp, "+"); + + btnSecondsDown = lv_btn_create(lv_scr_act(), nullptr); + btnSecondsDown->user_data = this; + lv_obj_set_event_cb(btnSecondsDown, btnEventHandler); + lv_obj_set_size(btnSecondsDown, 60, 40); + lv_obj_align(btnSecondsDown, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -20, +35); + txtSDown = lv_label_create(btnSecondsDown, nullptr); + lv_label_set_text_static(txtSDown, "-"); + } inline void DeleteButtons() { lv_obj_del(btnSecondsDown); btnSecondsDown = nullptr; |
