From 94d384e508b67762cc868ecb4fece2ef6bbd7658 Mon Sep 17 00:00:00 2001 From: JustScott Date: Sun, 14 Jan 2024 10:15:13 -0600 Subject: [PATCH] Reformatted the code to comply with clang-format. --- src/displayapp/screens/Calendar.cpp | 126 ++++++++++++++-------------- src/displayapp/screens/Calendar.h | 3 +- 2 files changed, 64 insertions(+), 65 deletions(-) diff --git a/src/displayapp/screens/Calendar.cpp b/src/displayapp/screens/Calendar.cpp index 837970e452..fea6949689 100644 --- a/src/displayapp/screens/Calendar.cpp +++ b/src/displayapp/screens/Calendar.cpp @@ -23,75 +23,73 @@ using namespace Pinetime::Applications::Screens; Calendar::Calendar(Controllers::DateTime& dateTimeController) : dateTimeController {dateTimeController} { - // Create calendar object - calendar = lv_calendar_create(lv_scr_act(), NULL); - // Set size - lv_obj_set_size(calendar, LV_HOR_RES, LV_VER_RES); - // Set alignment - lv_obj_align(calendar, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -5); - // Disable clicks - lv_obj_set_click(calendar, false); - - // Set style of today's date - lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_RED); - - // Set style of inactive month's days - lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, lv_color_hex(0x505050)); - - // Get today's date - current.year = static_cast(dateTimeController.Year()); - current.month = static_cast(dateTimeController.Month()); - current.day = static_cast(dateTimeController.Day()); - - // Set today's date - lv_calendar_set_today_date(calendar, ¤t); - lv_calendar_set_showed_date(calendar, ¤t); + // Create calendar object + calendar = lv_calendar_create(lv_scr_act(), NULL); + // Set size + lv_obj_set_size(calendar, LV_HOR_RES, LV_VER_RES); + // Set alignment + lv_obj_align(calendar, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -5); + // Disable clicks + lv_obj_set_click(calendar, false); + + // Set style of today's date + lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_RED); + + // Set style of inactive month's days + lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, lv_color_hex(0x505050)); + + // Get today's date + current.year = static_cast(dateTimeController.Year()); + current.month = static_cast(dateTimeController.Month()); + current.day = static_cast(dateTimeController.Day()); + + // Set today's date + lv_calendar_set_today_date(calendar, ¤t); + lv_calendar_set_showed_date(calendar, ¤t); } bool Calendar::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - switch (event) { - case TouchEvents::SwipeLeft: { - if (current.month == 12) { - current.month = 1; - current.year++; - } - else{ - current.month++; - } - - lv_calendar_set_showed_date(calendar, ¤t); - return true; - } - case TouchEvents::SwipeRight: { - if (current.month == 1) { - current.month = 12; - current.year--; - } - else{ - current.month--; - } - - lv_calendar_set_showed_date(calendar, ¤t); - return true; - } - /* - case TouchEvents::SwipeUp: { - current.year++; - lv_calendar_set_showed_date(calendar, ¤t); - return true; - } - case TouchEvents::SwipeDown: { - current.year--; - lv_calendar_set_showed_date(calendar, ¤t); - return true; - } - */ - default: { - return false; - } + switch (event) { + case TouchEvents::SwipeLeft: { + if (current.month == 12) { + current.month = 1; + current.year++; + } else { + current.month++; + } + + lv_calendar_set_showed_date(calendar, ¤t); + return true; } + case TouchEvents::SwipeRight: { + if (current.month == 1) { + current.month = 12; + current.year--; + } else { + current.month--; + } + + lv_calendar_set_showed_date(calendar, ¤t); + return true; + } + /* + case TouchEvents::SwipeUp: { + current.year++; + lv_calendar_set_showed_date(calendar, ¤t); + return true; + } + case TouchEvents::SwipeDown: { + current.year--; + lv_calendar_set_showed_date(calendar, ¤t); + return true; + } + */ + default: { + return false; + } + } } Calendar::~Calendar() { - lv_obj_clean(lv_scr_act()); + lv_obj_clean(lv_scr_act()); } diff --git a/src/displayapp/screens/Calendar.h b/src/displayapp/screens/Calendar.h index b20edd732b..bbdc8322f2 100644 --- a/src/displayapp/screens/Calendar.h +++ b/src/displayapp/screens/Calendar.h @@ -23,7 +23,7 @@ #include "displayapp/screens/Screen.h" #include "components/datetime/DateTimeController.h" #include - + #include "Symbols.h" namespace Pinetime { @@ -37,6 +37,7 @@ namespace Pinetime { public: Calendar(Controllers::DateTime& dateTimeController); ~Calendar() override; + private: bool OnTouchEvent(TouchEvents event); Controllers::DateTime& dateTimeController;