Skip to content

Commit 04afd22

Browse files
SteveAmorJF002
authored andcommitted
Refactor pageindicator
1 parent 101f962 commit 04afd22

3 files changed

Lines changed: 7 additions & 12 deletions

File tree

src/displayapp/screens/Music.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
257257
lv_obj_set_hidden(btnVolUp, false);
258258
lv_obj_set_hidden(btnNext, true);
259259
lv_obj_set_hidden(btnPrev, true);
260-
pageIndicator.SetCurrentScreen(1);
260+
pageIndicator.SetPageIndicatorPosition(1);
261261
return true;
262262
}
263263
case TouchEvents::SwipeDown: {
@@ -266,7 +266,7 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
266266
lv_obj_set_hidden(btnPrev, false);
267267
lv_obj_set_hidden(btnVolDown, true);
268268
lv_obj_set_hidden(btnVolUp, true);
269-
pageIndicator.SetCurrentScreen(0);
269+
pageIndicator.SetPageIndicatorPosition(0);
270270
return true;
271271
}
272272
return false;

src/displayapp/widgets/PageIndicator.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ void PageIndicator::Create() {
1616
lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
1717
lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark);
1818
lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints, 2);
19+
20+
pageIndicator = lv_line_create(lv_scr_act(), nullptr);
21+
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
22+
lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
1923
SetPageIndicatorPosition(nCurrentScreen);
2024
}
2125

@@ -28,13 +32,5 @@ void PageIndicator::SetPageIndicatorPosition(uint8_t position) {
2832
pageIndicatorPoints[1].x = LV_HOR_RES - 1;
2933
pageIndicatorPoints[1].y = indicatorPos + indicatorSize;
3034

31-
pageIndicator = lv_line_create(lv_scr_act(), nullptr);
32-
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
33-
lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
3435
lv_line_set_points(pageIndicator, pageIndicatorPoints, 2);
3536
}
36-
37-
void PageIndicator::SetCurrentScreen(uint8_t nScreen) {
38-
lv_obj_del(pageIndicator);
39-
SetPageIndicatorPosition(nScreen);
40-
}

src/displayapp/widgets/PageIndicator.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ namespace Pinetime {
88
public:
99
PageIndicator(uint8_t nCurrentScreen, uint8_t nScreens);
1010
void Create();
11-
void SetCurrentScreen(uint8_t nScreen);
11+
void SetPageIndicatorPosition(uint8_t position);
1212

1313
private:
14-
void SetPageIndicatorPosition(uint8_t position);
1514
uint8_t nCurrentScreen;
1615
uint8_t nScreens;
1716

0 commit comments

Comments
 (0)