From 21e86c4220bf4a16b30574fb3728832d8491031c Mon Sep 17 00:00:00 2001 From: tofasthacker Date: Sun, 24 Sep 2023 22:17:11 -0400 Subject: [PATCH] laid down main frame work. Need to add app class --- src/displayapp/DisplayApp.cpp | 2 +- src/displayapp/screens/Music.cpp | 30 ++++++++++++++++++------------ src/displayapp/screens/Music.h | 3 ++- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 61cee716..4220ed76 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -535,7 +535,7 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio currentScreen = std::make_unique(lvgl); break; case Apps::Music: - currentScreen = std::make_unique(systemTask->nimble().music()); + currentScreen = std::make_unique(this, systemTask->nimble().music()); break; case Apps::Navigation: currentScreen = std::make_unique(systemTask->nimble().navigation()); diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp index 0763da0f..fe380763 100644 --- a/src/displayapp/screens/Music.cpp +++ b/src/displayapp/screens/Music.cpp @@ -47,7 +47,9 @@ inline void lv_img_set_src_arr(lv_obj_t* img, const lv_img_dsc_t* src_img) { * * TODO: Investigate Apple Media Service and AVRCPv1.6 support for seamless integration */ -Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) { + + +Music::Music(DisplayApp* app, Pinetime::Controllers::MusicService& music) : app {app}, musicService(music) { lv_obj_t* label; lv_style_init(&btn_style); @@ -251,14 +253,6 @@ void Music::OnObjectEvent(lv_obj_t* obj, lv_event_t event) { bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) { switch (event) { case TouchEvents::SwipeUp: { - lv_obj_set_hidden(btnVolDown, false); - lv_obj_set_hidden(btnVolUp, false); - - lv_obj_set_hidden(btnNext, true); - lv_obj_set_hidden(btnPrev, true); - return true; - } - case TouchEvents::SwipeDown: { if (lv_obj_get_hidden(btnNext)) { lv_obj_set_hidden(btnNext, false); lv_obj_set_hidden(btnPrev, false); @@ -266,14 +260,26 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) { lv_obj_set_hidden(btnVolUp, true); return true; } - return false; + else{ + lv_obj_set_hidden(btnVolDown, false); + lv_obj_set_hidden(btnVolUp, false); + + lv_obj_set_hidden(btnNext, true); + lv_obj_set_hidden(btnPrev, true); + } + + return true; + } + case TouchEvents::SwipeDown: { + app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down); + return true; } case TouchEvents::SwipeLeft: { - musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT); + app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::LeftAnim); return true; } case TouchEvents::SwipeRight: { - musicService.event(Controllers::MusicService::EVENT_MUSIC_PREV); + app->SetFullRefresh(DisplayApp::FullRefreshDirections::RightAnim); return true; } default: { diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h index 847c6e74..b73072bf 100644 --- a/src/displayapp/screens/Music.h +++ b/src/displayapp/screens/Music.h @@ -18,6 +18,7 @@ #pragma once #include +#include "displayapp/DisplayApp.h" #include #include #include "displayapp/screens/Screen.h" @@ -31,7 +32,7 @@ namespace Pinetime { namespace Screens { class Music : public Screen { public: - Music(Pinetime::Controllers::MusicService& music); + Music(DisplayApp* app, Pinetime::Controllers::MusicService& music); ~Music() override;