From 04afd22943cf4d6a826e09cf5fd246886ee7cacf Mon Sep 17 00:00:00 2001 From: Steve Amor Date: Sat, 19 Jul 2025 07:20:07 +0100 Subject: Refactor pageindicator --- src/displayapp/widgets/PageIndicator.cpp | 12 ++++-------- src/displayapp/widgets/PageIndicator.h | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'src/displayapp/widgets') diff --git a/src/displayapp/widgets/PageIndicator.cpp b/src/displayapp/widgets/PageIndicator.cpp index 5d9815da..cee979f2 100644 --- a/src/displayapp/widgets/PageIndicator.cpp +++ b/src/displayapp/widgets/PageIndicator.cpp @@ -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); -} diff --git a/src/displayapp/widgets/PageIndicator.h b/src/displayapp/widgets/PageIndicator.h index b9d3117b..b9aaffe4 100644 --- a/src/displayapp/widgets/PageIndicator.h +++ b/src/displayapp/widgets/PageIndicator.h @@ -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; -- cgit v1.2.3-70-g09d2