From b561e7f3d0a232d57231869f0c69120741324b0f Mon Sep 17 00:00:00 2001 From: Diego Miguel Date: Sat, 5 Mar 2022 01:12:44 +0100 Subject: Implement CheckboxList screen --- src/displayapp/screens/CheckboxList.cpp | 115 ++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 src/displayapp/screens/CheckboxList.cpp (limited to 'src/displayapp/screens/CheckboxList.cpp') diff --git a/src/displayapp/screens/CheckboxList.cpp b/src/displayapp/screens/CheckboxList.cpp new file mode 100644 index 00000000..4da7826c --- /dev/null +++ b/src/displayapp/screens/CheckboxList.cpp @@ -0,0 +1,115 @@ +#include "displayapp/screens/CheckboxList.h" +#include "displayapp/DisplayApp.h" +#include "displayapp/screens/Styles.h" +#include "displayapp/screens/Symbols.h" + +using namespace Pinetime::Applications::Screens; + +namespace { + static void event_handler(lv_obj_t* obj, lv_event_t event) { + CheckboxList* screen = static_cast(obj->user_data); + screen->UpdateSelected(obj, event); + } + +} + +CheckboxList::CheckboxList(const uint8_t screenID, + const uint8_t numScreens, + DisplayApp* app, + Controllers::Settings& settingsController, + const char* optionsTitle, + const char* optionsSymbol, + void (Controllers::Settings::*SetOptionIndex)(uint8_t), + uint8_t (Controllers::Settings::*GetOptionIndex )() const, + std::array options) + : Screen(app), screenID {screenID}, settingsController {settingsController}, + SetOptionIndex {SetOptionIndex}, GetOptionIndex {GetOptionIndex}, + options {options} { + + settingsController.SetWatchfacesMenu(screenID); + + // Set the background to Black + lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); + + if (numScreens > 1) { + pageIndicatorBasePoints[0].x = LV_HOR_RES - 1; + pageIndicatorBasePoints[0].y = 0; + pageIndicatorBasePoints[1].x = LV_HOR_RES - 1; + pageIndicatorBasePoints[1].y = LV_VER_RES; + + pageIndicatorBase = lv_line_create(lv_scr_act(), NULL); + lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); + lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints, 2); + + const uint16_t indicatorSize = LV_VER_RES / numScreens; + const uint16_t indicatorPos = indicatorSize * screenID; + + pageIndicatorPoints[0].x = LV_HOR_RES - 1; + pageIndicatorPoints[0].y = indicatorPos; + pageIndicatorPoints[1].x = LV_HOR_RES - 1; + pageIndicatorPoints[1].y = indicatorPos + indicatorSize; + + pageIndicator = lv_line_create(lv_scr_act(), NULL); + lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); + lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_line_set_points(pageIndicator, pageIndicatorPoints, 2); + } + + lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr); + + lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); + lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); + lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); + lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); + + lv_obj_set_pos(container1, 10, 60); + lv_obj_set_width(container1, LV_HOR_RES - 20); + lv_obj_set_height(container1, LV_VER_RES - 50); + lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); + + lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_text_static(title, optionsTitle); + lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); + lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 10, 15); + + lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_label_set_text_static(icon, optionsSymbol); + lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); + lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); + + for (unsigned int i = 0; i < options.size(); i++) { + if (strcmp(options[i], "")) { + cbOption[i] = lv_checkbox_create(container1, nullptr); + lv_checkbox_set_text(cbOption[i], options[i]); + cbOption[i]->user_data = this; + lv_obj_set_event_cb(cbOption[i], event_handler); + SetRadioButtonStyle(cbOption[i]); + + if (static_cast((settingsController.*GetOptionIndex)() - MAXLISTITEMS*screenID) == i) { + lv_checkbox_set_checked(cbOption[i], true); + } + } + } +} + +CheckboxList::~CheckboxList() { + lv_obj_clean(lv_scr_act()); + settingsController.SaveSettings(); +} + +void CheckboxList::UpdateSelected(lv_obj_t* object, lv_event_t event) { + if (event == LV_EVENT_VALUE_CHANGED) { + for (unsigned int i = 0; i < options.size(); i++) { + if (strcmp(options[i], "")) { + if (object == cbOption[i]) { + lv_checkbox_set_checked(cbOption[i], true); + (settingsController.*SetOptionIndex)(MAXLISTITEMS*screenID + i); + } else { + lv_checkbox_set_checked(cbOption[i], false); + } + } + } + } +} -- cgit v1.2.3-70-g09d2 From 58bb0e77db34703b99522956de804a674ec81a23 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 11 Sep 2022 20:18:01 +0200 Subject: Fix formatting --- src/displayapp/DisplayApp.cpp | 2 +- src/displayapp/screens/CheckboxList.cpp | 14 +- src/displayapp/screens/Clock.cpp | 2 +- src/displayapp/screens/WatchFaceInfineat.cpp | 173 ++++++++++++--------- src/displayapp/screens/WatchFaceInfineat.h | 5 +- .../screens/settings/SettingWatchFace.cpp | 32 ++-- 6 files changed, 135 insertions(+), 93 deletions(-) (limited to 'src/displayapp/screens/CheckboxList.cpp') diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 0d4d7ca9..aa2c037e 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -93,7 +93,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd, alarmController {alarmController}, brightnessController {brightnessController}, touchHandler {touchHandler}, - filesystem{filesystem} { + filesystem {filesystem} { } void DisplayApp::Start(System::BootErrors error) { diff --git a/src/displayapp/screens/CheckboxList.cpp b/src/displayapp/screens/CheckboxList.cpp index 4da7826c..177a9718 100644 --- a/src/displayapp/screens/CheckboxList.cpp +++ b/src/displayapp/screens/CheckboxList.cpp @@ -1,7 +1,6 @@ #include "displayapp/screens/CheckboxList.h" #include "displayapp/DisplayApp.h" #include "displayapp/screens/Styles.h" -#include "displayapp/screens/Symbols.h" using namespace Pinetime::Applications::Screens; @@ -20,10 +19,13 @@ CheckboxList::CheckboxList(const uint8_t screenID, const char* optionsTitle, const char* optionsSymbol, void (Controllers::Settings::*SetOptionIndex)(uint8_t), - uint8_t (Controllers::Settings::*GetOptionIndex )() const, + uint8_t (Controllers::Settings::*GetOptionIndex)() const, std::array options) - : Screen(app), screenID {screenID}, settingsController {settingsController}, - SetOptionIndex {SetOptionIndex}, GetOptionIndex {GetOptionIndex}, + : Screen(app), + screenID {screenID}, + settingsController {settingsController}, + SetOptionIndex {SetOptionIndex}, + GetOptionIndex {GetOptionIndex}, options {options} { settingsController.SetWatchfacesMenu(screenID); @@ -87,7 +89,7 @@ CheckboxList::CheckboxList(const uint8_t screenID, lv_obj_set_event_cb(cbOption[i], event_handler); SetRadioButtonStyle(cbOption[i]); - if (static_cast((settingsController.*GetOptionIndex)() - MAXLISTITEMS*screenID) == i) { + if (static_cast((settingsController.*GetOptionIndex)() - MAXLISTITEMS * screenID) == i) { lv_checkbox_set_checked(cbOption[i], true); } } @@ -105,7 +107,7 @@ void CheckboxList::UpdateSelected(lv_obj_t* object, lv_event_t event) { if (strcmp(options[i], "")) { if (object == cbOption[i]) { lv_checkbox_set_checked(cbOption[i], true); - (settingsController.*SetOptionIndex)(MAXLISTITEMS*screenID + i); + (settingsController.*SetOptionIndex)(MAXLISTITEMS * screenID + i); } else { lv_checkbox_set_checked(cbOption[i], false); } diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index bb29d6a4..90b65ebd 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -33,7 +33,7 @@ Clock::Clock(DisplayApp* app, settingsController {settingsController}, heartRateController {heartRateController}, motionController {motionController}, - fs{fs}, + fs {fs}, screen {[this, &settingsController]() { switch (settingsController.GetClockFace()) { case 0: diff --git a/src/displayapp/screens/WatchFaceInfineat.cpp b/src/displayapp/screens/WatchFaceInfineat.cpp index a685bb54..e3ed1bf7 100644 --- a/src/displayapp/screens/WatchFaceInfineat.cpp +++ b/src/displayapp/screens/WatchFaceInfineat.cpp @@ -37,11 +37,11 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, settingsController {settingsController}, motionController {motionController} { lfs_file f = {}; - if(fs.FileOpen(&f, "/fonts/teko.bin", LFS_O_RDONLY) >= 0) { + if (fs.FileOpen(&f, "/fonts/teko.bin", LFS_O_RDONLY) >= 0) { font_teko = lv_font_load("F:/fonts/teko.bin"); } - if(fs.FileOpen(&f, "/fonts/bebas.bin", LFS_O_RDONLY) >= 0) { + if (fs.FileOpen(&f, "/fonts/bebas.bin", LFS_O_RDONLY) >= 0) { font_bebas = lv_font_load("F:/fonts/bebas.bin"); } @@ -65,8 +65,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_style_init(&line0Style); lv_style_set_line_width(&line0Style, LV_STATE_DEFAULT, 18); - lv_style_set_line_color(&line0Style, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines])); + lv_style_set_line_color(&line0Style, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines])); lv_obj_add_style(line0, LV_LINE_PART_MAIN, &line0Style); line0Points[0] = {30, 25}; line0Points[1] = {68, -8}; @@ -74,8 +75,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_style_init(&line1Style); lv_style_set_line_width(&line1Style, LV_STATE_DEFAULT, 15); - lv_style_set_line_color(&line1Style, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 1])); + lv_style_set_line_color(&line1Style, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 1])); lv_obj_add_style(line1, LV_LINE_PART_MAIN, &line1Style); line1Points[0] = {26, 167}; line1Points[1] = {43, 216}; @@ -83,8 +85,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_style_init(&line2Style); lv_style_set_line_width(&line2Style, LV_STATE_DEFAULT, 14); - lv_style_set_line_color(&line2Style, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 2])); + lv_style_set_line_color(&line2Style, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 2])); lv_obj_add_style(line2, LV_LINE_PART_MAIN, &line2Style); line2Points[0] = {27, 40}; line2Points[1] = {27, 196}; @@ -92,8 +95,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_style_init(&line3Style); lv_style_set_line_width(&line3Style, LV_STATE_DEFAULT, 22); - lv_style_set_line_color(&line3Style, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 3])); + lv_style_set_line_color(&line3Style, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 3])); lv_obj_add_style(line3, LV_LINE_PART_MAIN, &line3Style); line3Points[0] = {12, 182}; line3Points[1] = {65, 249}; @@ -101,8 +105,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_style_init(&line4Style); lv_style_set_line_width(&line4Style, LV_STATE_DEFAULT, 20); - lv_style_set_line_color(&line4Style, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 4])); + lv_style_set_line_color(&line4Style, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 4])); lv_obj_add_style(line4, LV_LINE_PART_MAIN, &line4Style); line4Points[0] = {17, 99}; line4Points[1] = {17, 144}; @@ -110,8 +115,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_style_init(&line5Style); lv_style_set_line_width(&line5Style, LV_STATE_DEFAULT, 18); - lv_style_set_line_color(&line5Style, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 5])); + lv_style_set_line_color(&line5Style, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 5])); lv_obj_add_style(line5, LV_LINE_PART_MAIN, &line5Style); line5Points[0] = {14, 81}; line5Points[1] = {40, 127}; @@ -119,8 +125,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_style_init(&line6Style); lv_style_set_line_width(&line6Style, LV_STATE_DEFAULT, 18); - lv_style_set_line_color(&line6Style, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 6])); + lv_style_set_line_color(&line6Style, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 6])); lv_obj_add_style(line6, LV_LINE_PART_MAIN, &line6Style); line6Points[0] = {14, 163}; line6Points[1] = {40, 118}; @@ -128,8 +135,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_style_init(&line7Style); lv_style_set_line_width(&line7Style, LV_STATE_DEFAULT, 52); - lv_style_set_line_color(&line7Style, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 7])); + lv_style_set_line_color(&line7Style, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 7])); lv_obj_add_style(line7, LV_LINE_PART_MAIN, &line7Style); line7Points[0] = {-20, 124}; line7Points[1] = {25, -11}; @@ -137,8 +145,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_style_init(&line8Style); lv_style_set_line_width(&line8Style, LV_STATE_DEFAULT, 48); - lv_style_set_line_color(&line8Style, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 8])); + lv_style_set_line_color(&line8Style, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 8])); lv_obj_add_style(line8, LV_LINE_PART_MAIN, &line8Style); line8Points[0] = {-29, 89}; line8Points[1] = {27, 254}; @@ -150,8 +159,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_style_init(&lineBatteryStyle); lv_style_set_line_width(&lineBatteryStyle, LV_STATE_DEFAULT, 24); - lv_style_set_line_color(&lineBatteryStyle, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 4])); + lv_style_set_line_color(&lineBatteryStyle, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 4])); lv_style_set_line_opa(&lineBatteryStyle, LV_STATE_DEFAULT, 190); lv_obj_add_style(lineBattery, LV_LINE_PART_MAIN, &lineBatteryStyle); lineBatteryPoints[0] = {27, 105}; @@ -160,13 +170,15 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, lv_obj_move_foreground(lineBattery); notificationIcon = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 7])); + lv_obj_set_style_local_bg_color(notificationIcon, + LV_BTN_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 7])); lv_obj_set_style_local_radius(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_obj_set_size(notificationIcon, 13, 13); lv_obj_set_hidden(notificationIcon, true); - if(!settingsController.GetInfineatShowSideCover()) { + if (!settingsController.GetInfineatShowSideCover()) { ToggleBatteryIndicatorColor(false); lv_obj_set_hidden(line0, true); lv_obj_set_hidden(line1, true); @@ -181,7 +193,7 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, timeContainer = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style_local_bg_opa(timeContainer, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - if(font_bebas != nullptr) { + if (font_bebas != nullptr) { lv_obj_set_size(timeContainer, 185, 185); lv_obj_align(timeContainer, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); } else { @@ -192,30 +204,27 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, labelHour = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_font(labelHour, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed); lv_label_set_text(labelHour, "01"); - if(font_bebas != nullptr) { + if (font_bebas != nullptr) { lv_obj_set_style_local_text_font(labelHour, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_bebas); lv_obj_align(labelHour, timeContainer, LV_ALIGN_IN_TOP_MID, 0, 0); - } - else { + } else { lv_obj_set_style_local_text_font(labelHour, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed); lv_obj_align(labelHour, timeContainer, LV_ALIGN_IN_TOP_MID, 0, 5); } labelMinutes = lv_label_create(lv_scr_act(), nullptr); - if(font_bebas != nullptr) { + if (font_bebas != nullptr) { lv_obj_set_style_local_text_font(labelMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_bebas); - } - else { + } else { lv_obj_set_style_local_text_font(labelMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed); } lv_label_set_text(labelMinutes, "00"); lv_obj_align(labelMinutes, timeContainer, LV_ALIGN_IN_BOTTOM_MID, 0, 0); labelTimeAmPm = lv_label_create(lv_scr_act(), nullptr); - if(font_teko != nullptr) { + if (font_teko != nullptr) { lv_obj_set_style_local_text_font(labelTimeAmPm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko); - } - else { + } else { lv_obj_set_style_local_text_font(labelTimeAmPm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20); } @@ -229,10 +238,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, labelDate = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); - if(font_teko != nullptr) { + if (font_teko != nullptr) { lv_obj_set_style_local_text_font(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko); - } - else { + } else { lv_obj_set_style_local_text_font(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20); } lv_obj_align(labelDate, dateContainer, LV_ALIGN_IN_TOP_MID, 0, 0); @@ -245,10 +253,9 @@ WatchFaceInfineat::WatchFaceInfineat(DisplayApp* app, stepValue = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); - if(font_teko != nullptr) { + if (font_teko != nullptr) { lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko); - } - else { + } else { lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20); } lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 10, 0); @@ -331,7 +338,7 @@ WatchFaceInfineat::~WatchFaceInfineat() { if (font_bebas != nullptr) { lv_font_free(font_bebas); } - if(font_teko != nullptr) { + if (font_teko != nullptr) { lv_font_free(font_teko); } @@ -410,28 +417,50 @@ void WatchFaceInfineat::UpdateSelected(lv_obj_t* object, lv_event_t event) { settingsController.SetInfineatColorIndex(colorIndex); } if (object == btnNextColor || object == btnPrevColor) { - lv_obj_set_style_local_line_color(line0, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 0])); - lv_obj_set_style_local_line_color(line1, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 1])); - lv_obj_set_style_local_line_color(line2, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 2])); - lv_obj_set_style_local_line_color(line3, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 3])); - lv_obj_set_style_local_line_color(line4, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 4])); - lv_obj_set_style_local_line_color(line5, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 5])); - lv_obj_set_style_local_line_color(line6, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 6])); - lv_obj_set_style_local_line_color(line7, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 7])); - lv_obj_set_style_local_line_color(line8, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 8])); - lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 4])); - lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[colorIndex*nLines + 7])); + lv_obj_set_style_local_line_color(line0, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 0])); + lv_obj_set_style_local_line_color(line1, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 1])); + lv_obj_set_style_local_line_color(line2, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 2])); + lv_obj_set_style_local_line_color(line3, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 3])); + lv_obj_set_style_local_line_color(line4, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 4])); + lv_obj_set_style_local_line_color(line5, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 5])); + lv_obj_set_style_local_line_color(line6, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 6])); + lv_obj_set_style_local_line_color(line7, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 7])); + lv_obj_set_style_local_line_color(line8, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 8])); + lv_obj_set_style_local_line_color(lineBattery, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 4])); + lv_obj_set_style_local_bg_color(notificationIcon, + LV_BTN_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[colorIndex * nLines + 7])); } } } @@ -516,7 +545,7 @@ void WatchFaceInfineat::Refresh() { // since Get() sets isUpdated to false. bool isBatteryUpdated = batteryPercentRemaining.IsUpdated(); bool isChargingUpdated = isCharging.IsUpdated(); - if (isCharging.Get()) { // Charging battery animation + if (isCharging.Get()) { // Charging battery animation chargingBatteryPercent += 1; if (chargingBatteryPercent > 100) { chargingBatteryPercent = batteryPercentRemaining.Get(); @@ -552,7 +581,7 @@ void WatchFaceInfineat::Refresh() { void WatchFaceInfineat::SetBatteryLevel(uint8_t batteryPercent) { // starting point (y) + Pine64 logo height * (100 - batteryPercent) / 100 - lineBatteryPoints[1] = {27, static_cast(105 + 32*(100-batteryPercent)/100)}; + lineBatteryPoints[1] = {27, static_cast(105 + 32 * (100 - batteryPercent) / 100)}; lv_line_set_points(lineBattery, lineBatteryPoints, 2); } @@ -564,9 +593,13 @@ void WatchFaceInfineat::ToggleBatteryIndicatorColor(bool showSideCover) { lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); } else { lv_obj_set_style_local_image_recolor_opa(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0); - lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 4])); - lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, - lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex()*nLines + 7])); + lv_obj_set_style_local_line_color(lineBattery, + LV_LINE_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 4])); + lv_obj_set_style_local_bg_color(notificationIcon, + LV_BTN_PART_MAIN, + LV_STATE_DEFAULT, + lv_color_hex(infineatColors.orange[settingsController.GetInfineatColorIndex() * nLines + 7])); } } diff --git a/src/displayapp/screens/WatchFaceInfineat.h b/src/displayapp/screens/WatchFaceInfineat.h index c71dfca3..c306b53c 100644 --- a/src/displayapp/screens/WatchFaceInfineat.h +++ b/src/displayapp/screens/WatchFaceInfineat.h @@ -34,7 +34,7 @@ namespace Pinetime { bool OnTouchEvent(TouchEvents event) override; bool OnButtonPushed() override; - void UpdateSelected(lv_obj_t *object, lv_event_t event); + void UpdateSelected(lv_obj_t* object, lv_event_t event); void CloseMenu(); void Refresh() override; @@ -47,8 +47,7 @@ namespace Pinetime { Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown; uint8_t currentDay = 0; uint32_t savedTick = 0; - uint8_t chargingBatteryPercent = 101; // not a mistake ;) - + uint8_t chargingBatteryPercent = 101; // not a mistake ;) DirtyValue batteryPercentRemaining {}; DirtyValue isCharging {}; diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index 788dd8e8..bd2f349c 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -17,14 +17,12 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pine settingsController {settingsController}, screens {app, settingsController.GetWatchfacesMenu(), - { - [this]() -> std::unique_ptr { - return CreateScreen1(); - }, - [this]() -> std::unique_ptr { - return CreateScreen2(); - } - }, + {[this]() -> std::unique_ptr { + return CreateScreen1(); + }, + [this]() -> std::unique_ptr { + return CreateScreen2(); + }}, Screens::ScreenListModes::UpDown} { } @@ -39,16 +37,26 @@ bool SettingWatchFace::OnTouchEvent(Pinetime::Applications::TouchEvents event) { std::unique_ptr SettingWatchFace::CreateScreen1() { std::array watchfaces {"Digital face", "Analog face", "PineTimeStyle", "Terminal"}; - return std::make_unique(0, 2, app, settingsController, title, - symbol, &Controllers::Settings::SetClockFace, + return std::make_unique(0, + 2, + app, + settingsController, + title, + symbol, + &Controllers::Settings::SetClockFace, &Controllers::Settings::GetClockFace, watchfaces); } std::unique_ptr SettingWatchFace::CreateScreen2() { std::array watchfaces {"Infineat face", "", "", ""}; - return std::make_unique(1, 2, app, settingsController, title, - symbol, &Controllers::Settings::SetClockFace, + return std::make_unique(1, + 2, + app, + settingsController, + title, + symbol, + &Controllers::Settings::SetClockFace, &Controllers::Settings::GetClockFace, watchfaces); } -- cgit v1.2.3-70-g09d2 From 56f315b94acc45e2175e030fca31cf8b56e36b93 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Tue, 27 Sep 2022 18:06:15 +0200 Subject: A few minors changes following the code review : rename fs -> filesystem, use std::array instead of raw array,... --- src/displayapp/DisplayAppRecovery.cpp | 2 +- src/displayapp/screens/CheckboxList.cpp | 6 +++--- src/displayapp/screens/CheckboxList.h | 14 +++++++------- src/displayapp/screens/Clock.cpp | 6 +++--- src/displayapp/screens/Clock.h | 4 ++-- src/displayapp/screens/WatchFaceInfineat.h | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/displayapp/screens/CheckboxList.cpp') diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp index 6ec67cea..e553aa87 100644 --- a/src/displayapp/DisplayAppRecovery.cpp +++ b/src/displayapp/DisplayAppRecovery.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include "components/fs/FS.h" #include "components/rle/RleDecoder.h" #include "touchhandler/TouchHandler.h" #include "displayapp/icons/infinitime/infinitime-nb.c" diff --git a/src/displayapp/screens/CheckboxList.cpp b/src/displayapp/screens/CheckboxList.cpp index 177a9718..d351a852 100644 --- a/src/displayapp/screens/CheckboxList.cpp +++ b/src/displayapp/screens/CheckboxList.cpp @@ -20,7 +20,7 @@ CheckboxList::CheckboxList(const uint8_t screenID, const char* optionsSymbol, void (Controllers::Settings::*SetOptionIndex)(uint8_t), uint8_t (Controllers::Settings::*GetOptionIndex)() const, - std::array options) + std::array options) : Screen(app), screenID {screenID}, settingsController {settingsController}, @@ -42,7 +42,7 @@ CheckboxList::CheckboxList(const uint8_t screenID, pageIndicatorBase = lv_line_create(lv_scr_act(), NULL); lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); - lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints, 2); + lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints.data(), 2); const uint16_t indicatorSize = LV_VER_RES / numScreens; const uint16_t indicatorPos = indicatorSize * screenID; @@ -55,7 +55,7 @@ CheckboxList::CheckboxList(const uint8_t screenID, pageIndicator = lv_line_create(lv_scr_act(), NULL); lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); - lv_line_set_points(pageIndicator, pageIndicatorPoints, 2); + lv_line_set_points(pageIndicator, pageIndicatorPoints.data(), 2); } lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr); diff --git a/src/displayapp/screens/CheckboxList.h b/src/displayapp/screens/CheckboxList.h index 6660acde..68280edd 100644 --- a/src/displayapp/screens/CheckboxList.h +++ b/src/displayapp/screens/CheckboxList.h @@ -14,6 +14,8 @@ namespace Pinetime { namespace Screens { class CheckboxList : public Screen { public: + static constexpr size_t MaxItems = 4; + CheckboxList(const uint8_t screenID, const uint8_t numScreens, DisplayApp* app, @@ -22,7 +24,7 @@ namespace Pinetime { const char* optionsSymbol, void (Controllers::Settings::*SetOptionIndex)(uint8_t), uint8_t (Controllers::Settings::*GetOptionIndex)() const, - std::array options); + std::array options); ~CheckboxList() override; @@ -35,12 +37,10 @@ namespace Pinetime { const char* optionsSymbol; void (Controllers::Settings::*SetOptionIndex)(uint8_t); uint8_t (Controllers::Settings::*GetOptionIndex)() const; - std::array options; - - lv_obj_t* cbOption[MAXLISTITEMS]; - - lv_point_t pageIndicatorBasePoints[2]; - lv_point_t pageIndicatorPoints[2]; + std::array options; + std::array cbOption; + std::array pageIndicatorBasePoints; + std::array pageIndicatorPoints; lv_obj_t* pageIndicatorBase; lv_obj_t* pageIndicator; }; diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 90b65ebd..443506e0 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -24,7 +24,7 @@ Clock::Clock(DisplayApp* app, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, Controllers::MotionController& motionController, - Controllers::FS& fs) + Controllers::FS& filesystem) : Screen(app), dateTimeController {dateTimeController}, batteryController {batteryController}, @@ -33,7 +33,7 @@ Clock::Clock(DisplayApp* app, settingsController {settingsController}, heartRateController {heartRateController}, motionController {motionController}, - fs {fs}, + filesystem {filesystem}, screen {[this, &settingsController]() { switch (settingsController.GetClockFace()) { case 0: @@ -118,5 +118,5 @@ std::unique_ptr Clock::WatchFaceInfineatScreen() { notificatioManager, settingsController, motionController, - fs); + filesystem); } diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h index 0cdc6028..b48c9ba2 100644 --- a/src/displayapp/screens/Clock.h +++ b/src/displayapp/screens/Clock.h @@ -29,7 +29,7 @@ namespace Pinetime { Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, Controllers::MotionController& motionController, - Controllers::FS& fs); + Controllers::FS& filesystem); ~Clock() override; bool OnTouchEvent(TouchEvents event) override; @@ -43,7 +43,7 @@ namespace Pinetime { Controllers::Settings& settingsController; Controllers::HeartRateController& heartRateController; Controllers::MotionController& motionController; - Controllers::FS& fs; + Controllers::FS& filesystem; std::unique_ptr screen; std::unique_ptr WatchFaceDigitalScreen(); diff --git a/src/displayapp/screens/WatchFaceInfineat.h b/src/displayapp/screens/WatchFaceInfineat.h index c306b53c..4a7dbebd 100644 --- a/src/displayapp/screens/WatchFaceInfineat.h +++ b/src/displayapp/screens/WatchFaceInfineat.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include -- cgit v1.2.3-70-g09d2 From 2400110900fbc69007f892295e734d083739bd0d Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Tue, 27 Sep 2022 21:04:40 +0200 Subject: CheckBoxList : remove unused constant MAXLISTITEMS (replaced by MaxItems). --- src/displayapp/screens/CheckboxList.cpp | 4 ++-- src/displayapp/screens/CheckboxList.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/displayapp/screens/CheckboxList.cpp') diff --git a/src/displayapp/screens/CheckboxList.cpp b/src/displayapp/screens/CheckboxList.cpp index d351a852..7c7e8565 100644 --- a/src/displayapp/screens/CheckboxList.cpp +++ b/src/displayapp/screens/CheckboxList.cpp @@ -89,7 +89,7 @@ CheckboxList::CheckboxList(const uint8_t screenID, lv_obj_set_event_cb(cbOption[i], event_handler); SetRadioButtonStyle(cbOption[i]); - if (static_cast((settingsController.*GetOptionIndex)() - MAXLISTITEMS * screenID) == i) { + if (static_cast((settingsController.*GetOptionIndex)() - MaxItems * screenID) == i) { lv_checkbox_set_checked(cbOption[i], true); } } @@ -107,7 +107,7 @@ void CheckboxList::UpdateSelected(lv_obj_t* object, lv_event_t event) { if (strcmp(options[i], "")) { if (object == cbOption[i]) { lv_checkbox_set_checked(cbOption[i], true); - (settingsController.*SetOptionIndex)(MAXLISTITEMS * screenID + i); + (settingsController.*SetOptionIndex)(MaxItems* screenID + i); } else { lv_checkbox_set_checked(cbOption[i], false); } diff --git a/src/displayapp/screens/CheckboxList.h b/src/displayapp/screens/CheckboxList.h index 68280edd..5bdd143e 100644 --- a/src/displayapp/screens/CheckboxList.h +++ b/src/displayapp/screens/CheckboxList.h @@ -3,12 +3,11 @@ #include #include #include +#include #include "displayapp/screens/Screen.h" #include "displayapp/Apps.h" #include "components/settings/Settings.h" -#define MAXLISTITEMS 4 - namespace Pinetime { namespace Applications { namespace Screens { -- cgit v1.2.3-70-g09d2 From 58586d0ad1ebeefd7a6f269089f467ccba2f468c Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Tue, 27 Sep 2022 21:10:01 +0200 Subject: Fix formatting in CheckBoxList.cpp. --- src/displayapp/screens/CheckboxList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/displayapp/screens/CheckboxList.cpp') diff --git a/src/displayapp/screens/CheckboxList.cpp b/src/displayapp/screens/CheckboxList.cpp index 7c7e8565..b89add43 100644 --- a/src/displayapp/screens/CheckboxList.cpp +++ b/src/displayapp/screens/CheckboxList.cpp @@ -107,7 +107,7 @@ void CheckboxList::UpdateSelected(lv_obj_t* object, lv_event_t event) { if (strcmp(options[i], "")) { if (object == cbOption[i]) { lv_checkbox_set_checked(cbOption[i], true); - (settingsController.*SetOptionIndex)(MaxItems* screenID + i); + (settingsController.*SetOptionIndex)(MaxItems * screenID + i); } else { lv_checkbox_set_checked(cbOption[i], false); } -- cgit v1.2.3-70-g09d2