2022-04-21 10:17:49 -04:00
|
|
|
#pragma once
|
|
|
|
#include <lvgl/lvgl.h>
|
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Applications {
|
|
|
|
namespace Widgets {
|
|
|
|
class Counter {
|
|
|
|
public:
|
2022-06-06 17:30:42 -04:00
|
|
|
Counter(int min, int max, lv_font_t& font);
|
2022-04-21 10:17:49 -04:00
|
|
|
|
|
|
|
void Create();
|
2022-06-06 17:30:42 -04:00
|
|
|
void UpBtnPressed();
|
|
|
|
void DownBtnPressed();
|
2022-04-21 10:17:49 -04:00
|
|
|
void SetValue(int newValue);
|
2022-05-19 05:08:23 -04:00
|
|
|
void HideControls();
|
|
|
|
void ShowControls();
|
2022-06-06 17:30:42 -04:00
|
|
|
void EnableTwelveHourMode();
|
|
|
|
void SetValueChangedEventCallback(void* userData, void (*handler)(void* userData));
|
2022-04-21 10:17:49 -04:00
|
|
|
|
|
|
|
int GetValue() const {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
lv_obj_t* GetObject() const {
|
|
|
|
return counterContainer;
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
void UpdateLabel();
|
2022-06-06 17:30:42 -04:00
|
|
|
void (*ValueChangedHandler)(void* userData) = nullptr;
|
2022-04-21 10:17:49 -04:00
|
|
|
|
|
|
|
lv_obj_t* counterContainer;
|
|
|
|
lv_obj_t* upBtn;
|
|
|
|
lv_obj_t* downBtn;
|
|
|
|
lv_obj_t* number;
|
2022-05-19 05:08:23 -04:00
|
|
|
lv_obj_t* upperLine;
|
|
|
|
lv_obj_t* lowerLine;
|
2022-05-18 16:16:00 -04:00
|
|
|
lv_point_t linePoints[2];
|
2022-04-21 10:17:49 -04:00
|
|
|
int value = 0;
|
|
|
|
int min;
|
|
|
|
int max;
|
2022-06-06 17:30:42 -04:00
|
|
|
bool twelveHourMode = false;
|
|
|
|
lv_font_t& font;
|
|
|
|
|
|
|
|
void* userData = nullptr;
|
2022-04-21 10:17:49 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|