Checkbox list now receives a function pointer to call when the setting has changed. This allow to remove the dependency between CheckBoxList (UI component) with SettingController.

This commit is contained in:
Jean-François Milants
2022-10-02 21:05:15 +02:00
committed by JF
parent 6dd67eb5a2
commit cf8b422899
4 changed files with 37 additions and 51 deletions

View File

@@ -1,12 +1,12 @@
#pragma once
#include <lvgl/lvgl.h>
#include <cstdint>
#include <memory>
#include <array>
#include "displayapp/screens/Screen.h"
#include "displayapp/Apps.h"
#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
#include <array>
#include <cstdint>
#include <functional>
#include <lvgl/lvgl.h>
#include <memory>
namespace Pinetime {
namespace Applications {
@@ -14,34 +14,27 @@ namespace Pinetime {
class CheckboxList : public Screen {
public:
static constexpr size_t MaxItems = 4;
CheckboxList(const uint8_t screenID,
const uint8_t numScreens,
DisplayApp* app,
Controllers::Settings& settingsController,
const char* optionsTitle,
const char* optionsSymbol,
void (Controllers::Settings::*SetOptionIndex)(uint8_t),
uint8_t (Controllers::Settings::*GetOptionIndex)() const,
uint32_t originalValue,
std::function<void(uint32_t)>OnValueChanged,
std::array<const char*, MaxItems> options);
~CheckboxList() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
const uint8_t screenID;
Controllers::Settings& settingsController;
const char* optionsTitle;
const char* optionsSymbol;
void (Controllers::Settings::*SetOptionIndex)(uint8_t);
uint8_t (Controllers::Settings::*GetOptionIndex)() const;
std::function<void(uint32_t)>OnValueChanged;
std::array<const char*, MaxItems> options;
std::array<lv_obj_t*, MaxItems> cbOption;
std::array<lv_point_t, 2> pageIndicatorBasePoints;
std::array<lv_point_t, 2> pageIndicatorPoints;
lv_obj_t* pageIndicatorBase;
lv_obj_t* pageIndicator;
uint32_t newValue;
};
}
}