InfiniTime.git

ref: e5b73212f6addcfdb5e306df63d7135e543c4f8d

src/displayapp/widgets/Counter.h


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <lvgl/lvgl.h>

namespace Pinetime {
  namespace Applications {
    namespace Widgets {
      class Counter {
      public:
        Counter(int min, int max, lv_font_t& font);

        void Create();
        void UpBtnPressed();
        void DownBtnPressed();
        void SetValue(int newValue);
        void HideControls();
        void ShowControls();
        void EnableTwelveHourMode();
        void EnableMonthMode();
        void SetMax(int newMax);
        void SetValueChangedEventCallback(void* userData, void (*handler)(void* userData));

        int GetValue() const {
          return value;
        }

        lv_obj_t* GetObject() const {
          return counterContainer;
        };

      private:
        void UpdateLabel();
        void (*ValueChangedHandler)(void* userData) = nullptr;

        lv_obj_t* counterContainer;
        lv_obj_t* upBtn;
        lv_obj_t* downBtn;
        lv_obj_t* number;
        lv_obj_t* upperLine;
        lv_obj_t* lowerLine;
        lv_point_t linePoints[2];
        int min;
        int max;
        int value;
        const int leadingZeroCount;
        bool twelveHourMode = false;
        bool monthMode = false;
        lv_font_t& font;

        void* userData = nullptr;
      };
    }
  }
}