summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
authorRiku Isokoski <riksu9000@gmail.com>2022-05-19 12:08:47 +0300
committerJF <JF002@users.noreply.github.com>2022-06-06 21:28:03 +0200
commit254c85246e8bb0c79a83c291323f06c2af3f9618 (patch)
tree05adbd3cb023275ef0da8955c97b8f135f687f06 /src/displayapp/screens
parent4a40d29279f7f8445fb88d604ef6a424a033f1ea (diff)
Timer: Replace time label with Counter control hiding functionality
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/Timer.cpp22
-rw-r--r--src/displayapp/screens/Timer.h1
2 files changed, 11 insertions, 12 deletions
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
index 1cff1d64..a1df662a 100644
--- a/src/displayapp/screens/Timer.cpp
+++ b/src/displayapp/screens/Timer.cpp
@@ -12,11 +12,11 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController) : Screen(app), timerController {timerController} {
- time = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
- lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- lv_label_set_text_static(time, "00:00");
- lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -29);
+ lv_obj_t* colonLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(colonLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
+ lv_obj_set_style_local_text_color(colonLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
+ lv_label_set_text_static(colonLabel, ":");
+ lv_obj_align(colonLabel, lv_scr_act(), LV_ALIGN_CENTER, 0, -29);
minuteCounter.Create();
secondCounter.Create();
@@ -49,19 +49,20 @@ Timer::~Timer() {
void Timer::Refresh() {
if (timerController.IsRunning()) {
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
- lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
+ minuteCounter.SetValue(seconds / 60);
+ secondCounter.SetValue(seconds % 60);
}
}
void Timer::SetTimerRunning() {
- lv_obj_set_hidden(minuteCounter.GetObject(), true);
- lv_obj_set_hidden(secondCounter.GetObject(), true);
+ minuteCounter.HideControls();
+ secondCounter.HideControls();
lv_label_set_text_static(txtPlayPause, "Pause");
}
void Timer::SetTimerStopped() {
- lv_obj_set_hidden(minuteCounter.GetObject(), false);
- lv_obj_set_hidden(secondCounter.GetObject(), false);
+ minuteCounter.ShowControls();
+ secondCounter.ShowControls();
lv_label_set_text_static(txtPlayPause, "Start");
}
@@ -84,7 +85,6 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
}
void Timer::SetDone() {
- lv_label_set_text_static(time, "00:00");
minuteCounter.SetValue(0);
secondCounter.SetValue(0);
SetTimerStopped();
diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h
index 2dcc5973..2797a4fa 100644
--- a/src/displayapp/screens/Timer.h
+++ b/src/displayapp/screens/Timer.h
@@ -23,7 +23,6 @@ namespace Pinetime::Applications::Screens {
void SetTimerRunning();
void SetTimerStopped();
Controllers::TimerController& timerController;
- lv_obj_t* time;
lv_obj_t* msecTime;
lv_obj_t* btnPlayPause;
lv_obj_t* txtPlayPause;