Skip to content

Commit

Permalink
Adds scroll bar to music app
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveAmor committed Oct 4, 2023
1 parent 0f9f606 commit 2a498d7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/displayapp/screens/Music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
lv_obj_set_width(txtTrack, LV_HOR_RES - 12);
lv_label_set_text_static(txtTrack, "This is a very long getTrack name");

page1Indicator.Create();

/** Init animation */
imgDisc = lv_img_create(lv_scr_act(), nullptr);
lv_img_set_src_arr(imgDisc, &disc);
Expand Down Expand Up @@ -256,6 +258,8 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {

lv_obj_set_hidden(btnNext, true);
lv_obj_set_hidden(btnPrev, true);
page1Indicator.Delete();
page2Indicator.Create();
return true;
}
case TouchEvents::SwipeDown: {
Expand All @@ -264,6 +268,8 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
lv_obj_set_hidden(btnPrev, false);
lv_obj_set_hidden(btnVolDown, true);
lv_obj_set_hidden(btnVolUp, true);
page2Indicator.Delete();
page1Indicator.Create();
return true;
}
return false;
Expand Down
4 changes: 4 additions & 0 deletions src/displayapp/screens/Music.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <lvgl/src/lv_core/lv_obj.h>
#include <string>
#include "displayapp/screens/Screen.h"
#include "displayapp/widgets/PageIndicator.h"

namespace Pinetime {
namespace Controllers {
Expand Down Expand Up @@ -79,6 +80,9 @@ namespace Pinetime {

lv_task_t* taskRefresh;

Widgets::PageIndicator page1Indicator = Widgets::PageIndicator(0, 2);
Widgets::PageIndicator page2Indicator = Widgets::PageIndicator(1, 2);

/** Watchapp */
};
}
Expand Down
5 changes: 5 additions & 0 deletions src/displayapp/widgets/PageIndicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ void PageIndicator::Create() {
lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
lv_line_set_points(pageIndicator, pageIndicatorPoints, 2);
}

void PageIndicator::Delete() {
lv_obj_del(pageIndicatorBase);
lv_obj_del(pageIndicator);
}
1 change: 1 addition & 0 deletions src/displayapp/widgets/PageIndicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Pinetime {
public:
PageIndicator(uint8_t nCurrentScreen, uint8_t nScreens);
void Create();
void Delete();

private:
uint8_t nCurrentScreen;
Expand Down

0 comments on commit 2a498d7

Please sign in to comment.