Skip to content

Commit

Permalink
Adds page indicator to music app
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveAmor committed Dec 1, 2024
1 parent 79ee886 commit 72bc736
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/displayapp/screens/Music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
btnVolDown->user_data = this;
lv_obj_set_event_cb(btnVolDown, event_handler);
lv_obj_set_size(btnVolDown, 76, 76);
lv_obj_align(btnVolDown, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_obj_align(btnVolDown, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 3, 0);
lv_obj_add_style(btnVolDown, LV_STATE_DEFAULT, &btn_style);
label = lv_label_create(btnVolDown, nullptr);
lv_label_set_text_static(label, Symbols::volumDown);
Expand All @@ -69,7 +69,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
btnVolUp->user_data = this;
lv_obj_set_event_cb(btnVolUp, event_handler);
lv_obj_set_size(btnVolUp, 76, 76);
lv_obj_align(btnVolUp, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
lv_obj_align(btnVolUp, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
lv_obj_add_style(btnVolUp, LV_STATE_DEFAULT, &btn_style);
label = lv_label_create(btnVolUp, nullptr);
lv_label_set_text_static(label, Symbols::volumUp);
Expand All @@ -79,7 +79,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
btnPrev->user_data = this;
lv_obj_set_event_cb(btnPrev, event_handler);
lv_obj_set_size(btnPrev, 76, 76);
lv_obj_align(btnPrev, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_obj_align(btnPrev, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 3, 0);
lv_obj_add_style(btnPrev, LV_STATE_DEFAULT, &btn_style);
label = lv_label_create(btnPrev, nullptr);
lv_label_set_text_static(label, Symbols::stepBackward);
Expand All @@ -88,7 +88,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
btnNext->user_data = this;
lv_obj_set_event_cb(btnNext, event_handler);
lv_obj_set_size(btnNext, 76, 76);
lv_obj_align(btnNext, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
lv_obj_align(btnNext, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
lv_obj_add_style(btnNext, LV_STATE_DEFAULT, &btn_style);
label = lv_label_create(btnNext, nullptr);
lv_label_set_text_static(label, Symbols::stepForward);
Expand Down 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"
#include "displayapp/apps/Apps.h"
#include "displayapp/Controllers.h"
#include "Symbols.h"
Expand Down Expand Up @@ -82,6 +83,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 72bc736

Please sign in to comment.