diff options
Diffstat (limited to 'src/displayapp/screens/settings')
| -rw-r--r-- | src/displayapp/screens/settings/Settings.cpp | 9 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/Settings.h | 58 |
2 files changed, 37 insertions, 30 deletions
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index 1c964c4..c3fbb4f 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -6,8 +6,6 @@ using namespace Pinetime::Applications::Screens; -constexpr std::array<List::Applications, Settings::entries.size()> Settings::entries; - auto Settings::CreateScreenList() const { std::array<std::function<std::unique_ptr<Screen>()>, nScreens> screens; for (size_t i = 0; i < screens.size(); i++) { @@ -33,10 +31,5 @@ bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } std::unique_ptr<Screen> Settings::CreateScreen(unsigned int screenNum) const { - std::array<List::Applications, entriesPerScreen> screens; - for (int i = 0; i < entriesPerScreen; i++) { - screens[i] = entries[screenNum * entriesPerScreen + i]; - } - - return std::make_unique<Screens::List>(screenNum, nScreens, app, settingsController, screens); + return std::make_unique<Screens::List>(screenNum, nScreens, app, settingsController, entries[screenNum]); } diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h index ad4bf08..96c9e4e 100644 --- a/src/displayapp/screens/settings/Settings.h +++ b/src/displayapp/screens/settings/Settings.h @@ -25,28 +25,42 @@ namespace Pinetime { Controllers::Settings& settingsController; static constexpr int entriesPerScreen = 4; - static constexpr std::array<List::Applications, entriesPerScreen * 4> entries {{ - {Symbols::sun, "Display", Apps::SettingDisplay}, - {Symbols::eye, "Wake Up", Apps::SettingWakeUp}, - {Symbols::clock, "Time format", Apps::SettingTimeFormat}, - {Symbols::home, "Watch face", Apps::SettingWatchFace}, - - {Symbols::shoe, "Steps", Apps::SettingSteps}, - {Symbols::clock, "Set date", Apps::SettingSetDate}, - {Symbols::clock, "Set time", Apps::SettingSetTime}, - {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}, - - {Symbols::clock, "Chimes", Apps::SettingChimes}, - {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold}, - {Symbols::check, "Firmware", Apps::FirmwareValidation}, - {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}, - - {Symbols::list, "About", Apps::SysInfo}, - {Symbols::none, "None", Apps::None}, - {Symbols::none, "None", Apps::None}, - {Symbols::none, "None", Apps::None}, - }}; - static constexpr int nScreens = (entries.size() + entriesPerScreen - 1) / entriesPerScreen; + static constexpr auto entries{[]() constexpr{ + using namespace Pinetime::Applications::Screens; + using namespace Pinetime::Applications; + constexpr List::Applications list[] = { + {Symbols::sun, "Display", Apps::SettingDisplay}, + {Symbols::eye, "Wake Up", Apps::SettingWakeUp}, + {Symbols::clock, "Time format", Apps::SettingTimeFormat}, + {Symbols::home, "Watch face", Apps::SettingWatchFace}, + + {Symbols::shoe, "Steps", Apps::SettingSteps}, + {Symbols::clock, "Set date", Apps::SettingSetDate}, + {Symbols::clock, "Set time", Apps::SettingSetTime}, + {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}, + + {Symbols::clock, "Chimes", Apps::SettingChimes}, + {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold}, + {Symbols::check, "Firmware", Apps::FirmwareValidation}, + {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}, + + {Symbols::list, "About", Apps::SysInfo}, + }; + std::array<std::array<List::Applications, entriesPerScreen>, ((std::size(list) + entriesPerScreen - 1) / entriesPerScreen)> r{};; + int idx = 0; + for (auto& f : r) { + for (auto& e : f) { + if (idx < std::size(list)) { + e = list[idx]; + } else { + e = { Symbols::none, "", Apps::None }; + } + idx++; + } + } + return r; + }()}; + static constexpr auto nScreens = std::size(entries); ScreenList<nScreens> screens; }; } |
