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.h | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/displayapp/screens/CheckboxList.h (limited to 'src/displayapp/screens/CheckboxList.h') diff --git a/src/displayapp/screens/CheckboxList.h b/src/displayapp/screens/CheckboxList.h new file mode 100644 index 00000000..6660acde --- /dev/null +++ b/src/displayapp/screens/CheckboxList.h @@ -0,0 +1,49 @@ +#pragma once + +#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 { + class CheckboxList : public Screen { + public: + 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); + + ~CheckboxList() override; + + void UpdateSelected(lv_obj_t* object, lv_event_t event); + + private: + const uint8_t screenID; + Controllers::Settings& settingsController; + const char* optionsTitle; + 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]; + lv_obj_t* pageIndicatorBase; + lv_obj_t* pageIndicator; + }; + } + } +} -- 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.h') 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.h') 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