ref: 9196c18d376d4f18c686bcfec8550f9c8659d5ea
src/displayapp/screens/settings/Settings.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#include "displayapp/screens/settings/Settings.h" #include <lvgl/lvgl.h> #include <functional> #include "displayapp/Apps.h" #include "displayapp/DisplayApp.h" 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++) { screens[i] = [this, i]() -> std::unique_ptr<Screen> { return CreateScreen(i); }; } return screens; } Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) : app {app}, settingsController {settingsController}, screens {app, settingsController.GetSettingsMenu(), CreateScreenList(), Screens::ScreenListModes::UpDown} { } Settings::~Settings() { lv_obj_clean(lv_scr_act()); } bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) { return screens.OnTouchEvent(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); } |