Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 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, "");

pageIndicator.Create();

/** Init animation */
imgDisc = lv_img_create(lv_scr_act(), nullptr);
lv_img_set_src_arr(imgDisc, &disc);
Expand Down Expand Up @@ -253,9 +255,9 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents 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);
pageIndicator.SetPageIndicatorPosition(1);
return true;
}
case TouchEvents::SwipeDown: {
Expand All @@ -264,6 +266,7 @@ 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);
pageIndicator.SetPageIndicatorPosition(0);
return true;
}
return false;
Expand Down
3 changes: 3 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,8 @@ namespace Pinetime {

lv_task_t* taskRefresh;

Widgets::PageIndicator pageIndicator = Widgets::PageIndicator(0, 2);

/** Watchapp */
};
}
Expand Down
12 changes: 8 additions & 4 deletions src/displayapp/widgets/PageIndicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ void PageIndicator::Create() {
lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark);
lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints, 2);

pageIndicator = lv_line_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
SetPageIndicatorPosition(nCurrentScreen);
}

void PageIndicator::SetPageIndicatorPosition(uint8_t position) {
const int16_t indicatorSize = LV_VER_RES / nScreens;
const int16_t indicatorPos = indicatorSize * nCurrentScreen;
const int16_t indicatorPos = indicatorSize * position;

pageIndicatorPoints[0].x = LV_HOR_RES - 1;
pageIndicatorPoints[0].y = indicatorPos;
pageIndicatorPoints[1].x = LV_HOR_RES - 1;
pageIndicatorPoints[1].y = indicatorPos + indicatorSize;

pageIndicator = lv_line_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
lv_line_set_points(pageIndicator, pageIndicatorPoints, 2);
}
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 SetPageIndicatorPosition(uint8_t position);

private:
uint8_t nCurrentScreen;
Expand Down