diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-06-03 10:23:25 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-06-04 17:55:05 (GMT) |
| commit | 84f0c705e8cf4cd0823bbd86a31b43fc3a061e6d (patch) | |
| tree | 429d315b9ffeee417a1390fa0fb35d1153bab5c4 /src/displayapp/screens/ApplicationList.h | |
| parent | 3d3a0a1c4ba134d6ece47e24492685bb7d64465b (diff) | |
Use C++17 and preallocate blocks for tiled multi-screen menus
Diffstat (limited to 'src/displayapp/screens/ApplicationList.h')
| -rw-r--r-- | src/displayapp/screens/ApplicationList.h | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/displayapp/screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h index 3ff71b8..5517ed5 100644 --- a/src/displayapp/screens/ApplicationList.h +++ b/src/displayapp/screens/ApplicationList.h @@ -31,22 +31,37 @@ namespace Pinetime { Controllers::DateTime& dateTimeController; static constexpr int appsPerScreen = 6; - static constexpr std::array<Tile::Applications, appsPerScreen * 2> applications {{ - {Symbols::stopWatch, Apps::StopWatch}, - {Symbols::music, Apps::Music}, - {Symbols::shoe, Apps::Steps}, - {Symbols::heartBeat, Apps::HeartRate}, - {Symbols::hourGlass, Apps::Timer}, - {Symbols::clock, Apps::Alarm}, + static constexpr auto applications{[]() constexpr{ + constexpr Tile::Applications list[] = { + {Symbols::stopWatch, Apps::StopWatch}, + {Symbols::music, Apps::Music}, + {Symbols::shoe, Apps::Steps}, + {Symbols::heartBeat, Apps::HeartRate}, + {Symbols::hourGlass, Apps::Timer}, + {Symbols::clock, Apps::Alarm}, - {Symbols::chartLine, Apps::Jumpscore}, - {Symbols::map, Apps::Navigation}, - {Symbols::drum, Apps::Metronome}, - {Symbols::paintbrush, Apps::Paint}, - {Symbols::paddle, Apps::Paddle}, - {"2", Apps::Twos}, - }}; - static constexpr int nScreens = (applications.size() + appsPerScreen - 1) / appsPerScreen; + {Symbols::chartLine, Apps::Jumpscore}, + {Symbols::map, Apps::Navigation}, + {Symbols::drum, Apps::Metronome}, + {Symbols::paintbrush, Apps::Paint}, + {Symbols::paddle, Apps::Paddle}, + {"2", Apps::Twos} + }; + std::array<std::array<Tile::Applications, appsPerScreen>, ((std::size(list) + appsPerScreen - 1) / appsPerScreen)> 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(applications); ScreenList<nScreens> screens; }; } |
