summaryrefslogtreecommitdiff
path: root/src/displayapp/widgets/Counter.h
blob: bc907c2a8b0f4d72d2b4c5dab69ee9c139c2e64d (plain)
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
#pragma once
#include <lvgl/lvgl.h>

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

        void Create();
        static void upBtnEventHandler(lv_obj_t* obj, lv_event_t event);
        static void downBtnEventHandler(lv_obj_t* obj, lv_event_t event);
        void Increment();
        void Decrement();
        void SetValue(int newValue);

        int GetValue() const {
          return value;
        }

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

      private:
        void UpdateLabel();

        lv_obj_t* counterContainer;
        lv_obj_t* upBtn;
        lv_obj_t* downBtn;
        lv_obj_t* number;
        lv_point_t linePoints[2];
        int value = 0;
        int min;
        int max;
      };
    }
  }
}