From f5328ec9eb9d55423b4e511910721d839cacadd8 Mon Sep 17 00:00:00 2001 From: JF Date: Fri, 14 Aug 2020 09:46:37 +0200 Subject: Refactor ScreenList to make it more generic : it can now contain any Screen type. Integrate this new ScreenList in SystemInfo. Add ApplicationList, which is a ScreenList of Tile. This allows to display a menu of more than 6 applications. --- src/DisplayApp/Screens/ApplicationList.cpp | 80 ++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/DisplayApp/Screens/ApplicationList.cpp (limited to 'src/DisplayApp/Screens/ApplicationList.cpp') diff --git a/src/DisplayApp/Screens/ApplicationList.cpp b/src/DisplayApp/Screens/ApplicationList.cpp new file mode 100644 index 00000000..c7c096f4 --- /dev/null +++ b/src/DisplayApp/Screens/ApplicationList.cpp @@ -0,0 +1,80 @@ +#include +#include +#include +#include "ApplicationList.h" +#include "Tile.h" +#include "Symbols.h" + +using namespace Pinetime::Applications::Screens; + +ApplicationList::ApplicationList(Pinetime::Applications::DisplayApp *app) : + Screen(app), + screens{app, { + [this]() -> std::unique_ptr { return CreateScreen1(); }, + //[this]() -> std::unique_ptr { return CreateScreen2(); }, + //[this]() -> std::unique_ptr { return CreateScreen3(); } + } + } {} + + +ApplicationList::~ApplicationList() { + lv_obj_clean(lv_scr_act()); +} + +bool ApplicationList::Refresh() { + if(running) + running = screens.Refresh(); + return running; +} + +bool ApplicationList::OnButtonPushed() { + running = false; + app->StartApp(Apps::Clock); + return true; +} + +bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) { + return screens.OnTouchEvent(event); +} + +std::unique_ptr ApplicationList::CreateScreen1() { + std::array applications { + {{Symbols::asterisk, Apps::Meter}, + {Symbols::tachometer, Apps::Gauge}, + {Symbols::clock, Apps::Clock}, + {Symbols::music, Apps::Music}, + {Symbols::list, Apps::SysInfo}, + {Symbols::sun, Apps::Brightness} + } + }; + + return std::unique_ptr(new Screens::Tile(app, applications)); +} + +std::unique_ptr ApplicationList::CreateScreen2() { + std::array applications { + {{"0", Apps::Meter}, + {"1", Apps::Gauge}, + {"2", Apps::Clock}, + {"3", Apps::Music}, + {"4", Apps::SysInfo}, + {"5", Apps::Brightness} + } + }; + + return std::unique_ptr(new Screens::Tile(app, applications)); +} + +std::unique_ptr ApplicationList::CreateScreen3() { + std::array applications { + {{"A", Apps::Meter}, + {"B", Apps::Gauge}, + {"C", Apps::Clock}, + {"D", Apps::Music}, + {"E", Apps::SysInfo}, + {"F", Apps::Brightness} + } + }; + + return std::unique_ptr(new Screens::Tile(app, applications)); +} -- cgit v1.2.3