aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens/settings/SettingWatchFace.cpp
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2023-12-10 18:35:19 +0100
committerJF <JF002@users.noreply.github.com>2023-12-21 20:49:22 +0100
commit39bc166e549e8ccae75468aa2dd3613d51f54e27 (patch)
treef4f995bf75e1a8e6bd9db9d1e84b225f3c53d686 /src/displayapp/screens/settings/SettingWatchFace.cpp
parenta544da9ed174bc184176ae50bedda5dd51c06021 (diff)
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)
Diffstat (limited to 'src/displayapp/screens/settings/SettingWatchFace.cpp')
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp
index 5498d067..f052573c 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.cpp
+++ b/src/displayapp/screens/settings/SettingWatchFace.cpp
@@ -3,7 +3,6 @@
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/Screen.h"
#include "components/settings/Settings.h"
-#include "displayapp/WatchFaces.h"
using namespace Pinetime::Applications::Screens;
@@ -21,9 +20,11 @@ auto SettingWatchFace::CreateScreenList() const {
}
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app,
+ std::array<Screens::CheckboxList::Item, UserWatchFaceTypes::Count>&& watchfaceItems,
Pinetime::Controllers::Settings& settingsController,
Pinetime::Controllers::FS& filesystem)
: app {app},
+ watchfaceItems {std::move(watchfaceItems)},
settingsController {settingsController},
filesystem {filesystem},
screens {app, 0, CreateScreenList(), Screens::ScreenListModes::UpDown} {
@@ -40,7 +41,11 @@ bool SettingWatchFace::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
std::unique_ptr<Screen> SettingWatchFace::CreateScreen(unsigned int screenNum) const {
std::array<Screens::CheckboxList::Item, settingsPerScreen> watchfacesOnThisScreen;
for (int i = 0; i < settingsPerScreen; i++) {
- watchfacesOnThisScreen[i] = watchfaces[screenNum * settingsPerScreen + i];
+ if (i + (screenNum * settingsPerScreen) >= watchfaceItems.size()) {
+ watchfacesOnThisScreen[i] = {"", false};
+ } else {
+ watchfacesOnThisScreen[i] = watchfaceItems[i + (screenNum * settingsPerScreen)];
+ }
}
return std::make_unique<Screens::CheckboxList>(