Skip to content

Commit 9b22211

Browse files
Riksu9000JF002
authored andcommitted
Use PageIndicator in CheckboxList
1 parent d3ba184 commit 9b22211

File tree

2 files changed

+10
-29
lines changed

2 files changed

+10
-29
lines changed

src/displayapp/screens/CheckboxList.cpp

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,16 @@ CheckboxList::CheckboxList(const uint8_t screenID,
1919
uint32_t originalValue,
2020
std::function<void(uint32_t)> OnValueChanged,
2121
std::array<Item, MaxItems> options)
22-
: Screen(app), screenID {screenID}, OnValueChanged {std::move(OnValueChanged)}, options {options}, value {originalValue} {
22+
: Screen(app),
23+
screenID {screenID},
24+
OnValueChanged {std::move(OnValueChanged)},
25+
options {options},
26+
value {originalValue},
27+
pageIndicator(screenID, numScreens) {
2328
// Set the background to Black
2429
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
2530

26-
if (numScreens > 1) {
27-
pageIndicatorBasePoints[0].x = LV_HOR_RES - 1;
28-
pageIndicatorBasePoints[0].y = 0;
29-
pageIndicatorBasePoints[1].x = LV_HOR_RES - 1;
30-
pageIndicatorBasePoints[1].y = LV_VER_RES;
31-
32-
pageIndicatorBase = lv_line_create(lv_scr_act(), nullptr);
33-
lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
34-
lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
35-
lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints.data(), 2);
36-
37-
const uint16_t indicatorSize = LV_VER_RES / numScreens;
38-
const uint16_t indicatorPos = indicatorSize * screenID;
39-
40-
pageIndicatorPoints[0].x = LV_HOR_RES - 1;
41-
pageIndicatorPoints[0].y = indicatorPos;
42-
pageIndicatorPoints[1].x = LV_HOR_RES - 1;
43-
pageIndicatorPoints[1].y = indicatorPos + indicatorSize;
44-
45-
pageIndicator = lv_line_create(lv_scr_act(), nullptr);
46-
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
47-
lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
48-
lv_line_set_points(pageIndicator, pageIndicatorPoints.data(), 2);
49-
}
31+
pageIndicator.Create();
5032

5133
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
5234

src/displayapp/screens/CheckboxList.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <functional>
88
#include <lvgl/lvgl.h>
99
#include <memory>
10+
#include "displayapp/widgets/PageIndicator.h"
1011

1112
namespace Pinetime {
1213
namespace Applications {
@@ -35,11 +36,9 @@ namespace Pinetime {
3536
std::function<void(uint32_t)> OnValueChanged;
3637
std::array<Item, MaxItems> options;
3738
std::array<lv_obj_t*, MaxItems> cbOption;
38-
std::array<lv_point_t, 2> pageIndicatorBasePoints;
39-
std::array<lv_point_t, 2> pageIndicatorPoints;
40-
lv_obj_t* pageIndicatorBase;
41-
lv_obj_t* pageIndicator;
4239
uint32_t value;
40+
41+
Widgets::PageIndicator pageIndicator;
4342
};
4443
}
4544
}

0 commit comments

Comments
 (0)