mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2026-05-14 00:16:18 +02:00
Refactor pageindicator
This commit is contained in:
parent
101f9626e3
commit
04afd22943
@ -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;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user