Refactor pageindicator
Some checks failed
CI / build-firmware (push) Has been cancelled
CI / build-simulator (push) Has been cancelled
CI / get-base-ref-size (push) Has been cancelled
CI / Compare build size (push) Has been cancelled

This commit is contained in:
Steve Amor 2025-07-19 07:20:07 +01:00 committed by JF
parent 101f9626e3
commit 04afd22943
3 changed files with 7 additions and 12 deletions

View File

@ -257,7 +257,7 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
lv_obj_set_hidden(btnVolUp, false);
lv_obj_set_hidden(btnNext, true);
lv_obj_set_hidden(btnPrev, true);
pageIndicator.SetCurrentScreen(1);
pageIndicator.SetPageIndicatorPosition(1);
return true;
}
case TouchEvents::SwipeDown: {
@ -266,7 +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.SetCurrentScreen(0);
pageIndicator.SetPageIndicatorPosition(0);
return true;
}
return false;

View File

@ -16,6 +16,10 @@ void PageIndicator::Create() {
lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
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);
}
@ -28,13 +32,5 @@ void PageIndicator::SetPageIndicatorPosition(uint8_t position) {
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);
}
void PageIndicator::SetCurrentScreen(uint8_t nScreen) {
lv_obj_del(pageIndicator);
SetPageIndicatorPosition(nScreen);
}

View File

@ -8,10 +8,9 @@ namespace Pinetime {
public:
PageIndicator(uint8_t nCurrentScreen, uint8_t nScreens);
void Create();
void SetCurrentScreen(uint8_t nScreen);
void SetPageIndicatorPosition(uint8_t position);
private:
void SetPageIndicatorPosition(uint8_t position);
uint8_t nCurrentScreen;
uint8_t nScreens;