@@ -18,7 +18,7 @@ CheckboxList::CheckboxList(const uint8_t screenID,
1818 const char * optionsSymbol,
1919 uint32_t originalValue,
2020 std::function<void (uint32_t )> OnValueChanged,
21- std::array<const char* , MaxItems> options)
21+ std::array<Item , MaxItems> options)
2222 : Screen(app), screenID {screenID}, OnValueChanged {std::move (OnValueChanged)}, options {options}, value {originalValue} {
2323 // Set the background to Black
2424 lv_obj_set_style_local_bg_color (lv_scr_act (), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
@@ -72,9 +72,12 @@ CheckboxList::CheckboxList(const uint8_t screenID,
7272 lv_obj_align (icon, title, LV_ALIGN_OUT_LEFT_MID, -10 , 0 );
7373
7474 for (unsigned int i = 0 ; i < options.size (); i++) {
75- if (strcmp (options[i], " " )) {
75+ if (strcmp (options[i]. name , " " )) {
7676 cbOption[i] = lv_checkbox_create (container1, nullptr );
77- lv_checkbox_set_text (cbOption[i], options[i]);
77+ lv_checkbox_set_text (cbOption[i], options[i].name );
78+ if (!options[i].enabled ) {
79+ lv_checkbox_set_disabled (cbOption[i]);
80+ }
7881 cbOption[i]->user_data = this ;
7982 lv_obj_set_event_cb (cbOption[i], event_handler);
8083 SetRadioButtonStyle (cbOption[i]);
@@ -94,13 +97,16 @@ CheckboxList::~CheckboxList() {
9497void CheckboxList::UpdateSelected (lv_obj_t * object, lv_event_t event) {
9598 if (event == LV_EVENT_VALUE_CHANGED) {
9699 for (unsigned int i = 0 ; i < options.size (); i++) {
97- if (strcmp (options[i], " " )) {
100+ if (strcmp (options[i]. name , " " )) {
98101 if (object == cbOption[i]) {
99102 lv_checkbox_set_checked (cbOption[i], true );
100103 value = MaxItems * screenID + i;
101104 } else {
102105 lv_checkbox_set_checked (cbOption[i], false );
103106 }
107+ if (!options[i].enabled ) {
108+ lv_checkbox_set_disabled (cbOption[i]);
109+ }
104110 }
105111 }
106112 }
0 commit comments