diff options
| author | Riku Isokoski <riksu9000@gmail.com> | 2022-05-20 09:28:27 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-06-07 03:08:43 (GMT) |
| commit | 1a1de7af5e0ed29cb6906bb7155aa8b6752c57a0 (patch) | |
| tree | 764b6772a8a5eabdef5c6b540c66eaf60d386748 | |
| parent | d4224e1ce2f6825f07e23a0b1ec1963bfa03f37c (diff) | |
Replace magic values with appsPerScreen and entriesPerScreen
| -rw-r--r-- | src/displayapp/screens/ApplicationList.cpp | 6 | ||||
| -rw-r--r-- | src/displayapp/screens/ApplicationList.h | 10 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/Settings.cpp | 6 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/Settings.h | 5 |
4 files changed, 17 insertions, 10 deletions
diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp index f04b9ef..5284433 100644 --- a/src/displayapp/screens/ApplicationList.cpp +++ b/src/displayapp/screens/ApplicationList.cpp @@ -38,9 +38,9 @@ bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } std::unique_ptr<Screen> ApplicationList::CreateScreen(unsigned int screenNum) const { - std::array<Tile::Applications, 6> apps; - for (int i = 0; i < 6; i++) { - apps[i] = applications[screenNum * 6 + i]; + std::array<Tile::Applications, appsPerScreen> apps; + for (int i = 0; i < appsPerScreen; i++) { + apps[i] = applications[screenNum * appsPerScreen + i]; } return std::make_unique<Screens::Tile>(screenNum, nScreens, app, settingsController, batteryController, dateTimeController, apps); diff --git a/src/displayapp/screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h index ac11a9b..dfd9119 100644 --- a/src/displayapp/screens/ApplicationList.h +++ b/src/displayapp/screens/ApplicationList.h @@ -30,7 +30,8 @@ namespace Pinetime { Pinetime::Controllers::Battery& batteryController; Controllers::DateTime& dateTimeController; - static constexpr std::array<Tile::Applications, 13> applications {{ + static constexpr int appsPerScreen = 6; + static constexpr std::array<Tile::Applications, appsPerScreen * 3> applications {{ {Symbols::stopWatch, Apps::StopWatch}, {Symbols::clock, Apps::Alarm}, {Symbols::hourGlass, Apps::Timer}, @@ -46,8 +47,13 @@ namespace Pinetime { {Symbols::map, Apps::Navigation}, {Symbols::drum, Apps::Jumpscore}, + {Symbols::none, Apps::None}, + {Symbols::none, Apps::None}, + {Symbols::none, Apps::None}, + {Symbols::none, Apps::None}, + {Symbols::none, Apps::None}, }}; - static constexpr int nScreens = (applications.size() + 5) / 6; + static constexpr int nScreens = (applications.size() + appsPerScreen - 1) / appsPerScreen; ScreenList<nScreens> screens; }; } diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index 98d8c22..1c964c4 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -33,9 +33,9 @@ bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } std::unique_ptr<Screen> Settings::CreateScreen(unsigned int screenNum) const { - std::array<List::Applications, 4> screens; - for (int i = 0; i < 4; i++) { - screens[i] = entries[screenNum * 4 + i]; + 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); diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h index 4ef507a..ad4bf08 100644 --- a/src/displayapp/screens/settings/Settings.h +++ b/src/displayapp/screens/settings/Settings.h @@ -24,7 +24,8 @@ namespace Pinetime { Controllers::Settings& settingsController; - static constexpr std::array<List::Applications, 16> entries {{ + 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}, @@ -45,7 +46,7 @@ namespace Pinetime { {Symbols::none, "None", Apps::None}, {Symbols::none, "None", Apps::None}, }}; - static constexpr int nScreens = (entries.size() + 3) / 4; + static constexpr int nScreens = (entries.size() + entriesPerScreen - 1) / entriesPerScreen; ScreenList<nScreens> screens; }; } |
