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)
This commit is contained in:
committed by
JF
parent
a544da9ed1
commit
39bc166e54
@@ -7,7 +7,12 @@
|
||||
#include "displayapp/screens/Twos.h"
|
||||
#include "displayapp/screens/Tile.h"
|
||||
#include "displayapp/screens/ApplicationList.h"
|
||||
#include "displayapp/screens/Clock.h"
|
||||
#include "displayapp/screens/WatchFaceDigital.h"
|
||||
#include "displayapp/screens/WatchFaceAnalog.h"
|
||||
#include "displayapp/screens/WatchFaceCasioStyleG7710.h"
|
||||
#include "displayapp/screens/WatchFaceInfineat.h"
|
||||
#include "displayapp/screens/WatchFacePineTimeStyle.h"
|
||||
#include "displayapp/screens/WatchFaceTerminal.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Applications {
|
||||
@@ -21,16 +26,34 @@ namespace Pinetime {
|
||||
Screens::Screen* (*create)(AppControllers& controllers);
|
||||
};
|
||||
|
||||
struct WatchFaceDescription {
|
||||
WatchFace watchFace;
|
||||
const char* name;
|
||||
Screens::Screen* (*create)(AppControllers& controllers);
|
||||
bool (*isAvailable)(Controllers::FS& fileSystem);
|
||||
};
|
||||
|
||||
template <Apps t>
|
||||
consteval AppDescription CreateAppDescription() {
|
||||
return {AppTraits<t>::app, AppTraits<t>::icon, &AppTraits<t>::Create};
|
||||
}
|
||||
|
||||
template <WatchFace t>
|
||||
consteval WatchFaceDescription CreateWatchFaceDescription() {
|
||||
return {WatchFaceTraits<t>::watchFace, WatchFaceTraits<t>::name, &WatchFaceTraits<t>::Create, &WatchFaceTraits<t>::IsAvailable};
|
||||
}
|
||||
|
||||
template <template <Apps...> typename T, Apps... ts>
|
||||
consteval std::array<AppDescription, sizeof...(ts)> CreateAppDescriptions(T<ts...>) {
|
||||
return {CreateAppDescription<ts>()...};
|
||||
}
|
||||
|
||||
template <template <WatchFace...> typename T, WatchFace... ts>
|
||||
consteval std::array<WatchFaceDescription, sizeof...(ts)> CreateWatchFaceDescriptions(T<ts...>) {
|
||||
return {CreateWatchFaceDescription<ts>()...};
|
||||
}
|
||||
|
||||
constexpr auto userApps = CreateAppDescriptions(UserAppTypes {});
|
||||
constexpr auto userWatchFaces = CreateWatchFaceDescriptions(UserWatchFaceTypes {});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user