From 39bc166e549e8ccae75468aa2dd3613d51f54e27 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 10 Dec 2023 18:35:19 +0100 Subject: Watch face selection at build time Watch faces can now be selected at buid time. It's implemented in a similar way than the selection of user apps, using a list of watch face description that is generated at build time (consteval, constexpr) --- src/displayapp/screens/settings/SettingWatchFace.h | 23 ++++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/displayapp/screens/settings/SettingWatchFace.h') diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h index 45a50e3d..66559c73 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.h +++ b/src/displayapp/screens/settings/SettingWatchFace.h @@ -19,7 +19,10 @@ namespace Pinetime { class SettingWatchFace : public Screen { public: - SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController, Pinetime::Controllers::FS& filesystem); + SettingWatchFace(DisplayApp* app, + std::array&& watchfaceItems, + Pinetime::Controllers::Settings& settingsController, + Pinetime::Controllers::FS& filesystem); ~SettingWatchFace() override; bool OnTouchEvent(TouchEvents event) override; @@ -29,26 +32,16 @@ namespace Pinetime { auto CreateScreenList() const; std::unique_ptr CreateScreen(unsigned int screenNum) const; + static constexpr int settingsPerScreen = 4; + std::array watchfaceItems; + static constexpr int nScreens = UserWatchFaceTypes::Count > 0 ? (UserWatchFaceTypes ::Count - 1) / settingsPerScreen + 1 : 1; + Controllers::Settings& settingsController; Pinetime::Controllers::FS& filesystem; static constexpr const char* title = "Watch face"; static constexpr const char* symbol = Symbols::home; - static constexpr int settingsPerScreen = 4; - - // Increment this when more space is needed - static constexpr int nScreens = 2; - - std::array watchfaces { - {{"Digital face", true}, - {"Analog face", true}, - {"PineTimeStyle", true}, - {"Terminal", true}, - {"Infineat face", Applications::Screens::WatchFaceInfineat::IsAvailable(filesystem)}, - {"Casio G7710", Applications::Screens::WatchFaceCasioStyleG7710::IsAvailable(filesystem)}, - {"", false}, - {"", false}}}; ScreenList screens; }; } -- cgit v1.2.3-70-g09d2