1 /**
2  * @file lv_bar.h
3  *
4  */
5 
6 #ifndef LV_BAR_H
7 #define LV_BAR_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "../../lv_conf_internal.h"
17 
18 #if LV_USE_BAR != 0
19 
20 #include "../../core/lv_obj.h"
21 #include "../../misc/lv_anim.h"
22 #include "../label/lv_label.h"
23 
24 /*********************
25  *      DEFINES
26  *********************/
27 
28 /**********************
29  *      TYPEDEFS
30  **********************/
31 typedef enum {
32     LV_BAR_MODE_NORMAL,
33     LV_BAR_MODE_SYMMETRICAL,
34     LV_BAR_MODE_RANGE
35 } lv_bar_mode_t;
36 
37 typedef enum {
38     LV_BAR_ORIENTATION_AUTO,
39     LV_BAR_ORIENTATION_HORIZONTAL,
40     LV_BAR_ORIENTATION_VERTICAL
41 } lv_bar_orientation_t;
42 
43 LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_bar_class;
44 
45 /**********************
46  * GLOBAL PROTOTYPES
47  **********************/
48 
49 /**
50  * Create a bar object
51  * @param parent        pointer to an object, it will be the parent of the new bar
52  * @return              pointer to the created bar
53  */
54 lv_obj_t * lv_bar_create(lv_obj_t * parent);
55 
56 /*=====================
57  * Setter functions
58  *====================*/
59 
60 /**
61  * Set a new value on the bar
62  * @param obj           pointer to a bar object
63  * @param value         new value
64  * @param anim          LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
65  */
66 void lv_bar_set_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim);
67 
68 /**
69  * Set a new start value on the bar
70  * @param obj             pointer to a bar object
71  * @param start_value     new start value
72  * @param anim            LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
73  */
74 void lv_bar_set_start_value(lv_obj_t * obj, int32_t start_value, lv_anim_enable_t anim);
75 
76 /**
77  * Set minimum and the maximum values of a bar
78  * @param obj       pointer to the bar object
79  * @param min       minimum value
80  * @param max       maximum value
81  * @note If min is greater than max, the drawing direction becomes to the opposite direction.
82  */
83 void lv_bar_set_range(lv_obj_t * obj, int32_t min, int32_t max);
84 
85 /**
86  * Set the type of bar.
87  * @param obj       pointer to bar object
88  * @param mode      bar type from `lv_bar_mode_t`
89  */
90 void lv_bar_set_mode(lv_obj_t * obj, lv_bar_mode_t mode);
91 
92 /**
93  * Set the orientation of bar.
94  * @param obj           pointer to bar object
95  * @param orientation   bar orientation from `lv_bar_orientation_t`
96  */
97 void lv_bar_set_orientation(lv_obj_t * obj, lv_bar_orientation_t orientation);
98 
99 /*=====================
100  * Getter functions
101  *====================*/
102 
103 /**
104  * Get the value of a bar
105  * @param obj       pointer to a bar object
106  * @return          the value of the bar
107  */
108 int32_t lv_bar_get_value(const lv_obj_t * obj);
109 
110 /**
111  * Get the start value of a bar
112  * @param obj       pointer to a bar object
113  * @return          the start value of the bar
114  */
115 int32_t lv_bar_get_start_value(const lv_obj_t * obj);
116 
117 /**
118  * Get the minimum value of a bar
119  * @param obj       pointer to a bar object
120  * @return          the minimum value of the bar
121  */
122 int32_t lv_bar_get_min_value(const lv_obj_t * obj);
123 
124 /**
125  * Get the maximum value of a bar
126  * @param obj       pointer to a bar object
127  * @return          the maximum value of the bar
128  */
129 int32_t lv_bar_get_max_value(const lv_obj_t * obj);
130 
131 /**
132  * Get the type of bar.
133  * @param obj       pointer to bar object
134  * @return          bar type from `lv_bar_mode_t`
135  */
136 lv_bar_mode_t lv_bar_get_mode(lv_obj_t * obj);
137 
138 /**
139  * Get the orientation of bar.
140  * @param obj       pointer to bar object
141  * @return          bar orientation from `lv_bar_orientation_t`
142  */
143 lv_bar_orientation_t lv_bar_get_orientation(lv_obj_t * obj);
144 
145 /**
146  * Give the bar is in symmetrical mode or not
147  * @param obj       pointer to bar object
148  * @return          true: in symmetrical mode false : not in
149 */
150 bool lv_bar_is_symmetrical(lv_obj_t * obj);
151 
152 /**********************
153  *      MACROS
154  **********************/
155 
156 #endif /*LV_USE_BAR*/
157 
158 #ifdef __cplusplus
159 } /*extern "C"*/
160 #endif
161 
162 #endif /*LV_BAR_H*/
163