acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
lv_slider.h (5112B)
1 /** 2 * @file lv_slider.h 3 * 4 */ 5 6 #ifndef LV_SLIDER_H 7 #define LV_SLIDER_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_SLIDER != 0 19 20 /*Testing of dependencies*/ 21 #if LV_USE_BAR == 0 22 #error "lv_slider: lv_bar is required. Enable it in lv_conf.h (LV_USE_BAR 1)" 23 #endif 24 25 #include "../core/lv_obj.h" 26 #include "lv_bar.h" 27 28 /********************* 29 * DEFINES 30 *********************/ 31 32 /********************** 33 * TYPEDEFS 34 **********************/ 35 36 enum { 37 LV_SLIDER_MODE_NORMAL = LV_BAR_MODE_NORMAL, 38 LV_SLIDER_MODE_SYMMETRICAL = LV_BAR_MODE_SYMMETRICAL, 39 LV_SLIDER_MODE_RANGE = LV_BAR_MODE_RANGE 40 }; 41 typedef uint8_t lv_slider_mode_t; 42 43 typedef struct { 44 lv_bar_t bar; /*Add the ancestor's type first*/ 45 lv_area_t left_knob_area; 46 lv_area_t right_knob_area; 47 int32_t * value_to_set; /*Which bar value to set*/ 48 uint8_t dragging : 1; /*1: the slider is being dragged*/ 49 uint8_t left_knob_focus : 1; /*1: with encoder now the right knob can be adjusted*/ 50 } lv_slider_t; 51 52 extern const lv_obj_class_t lv_slider_class; 53 54 /** 55 * `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_slider_class` 56 * Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` 57 */ 58 typedef enum { 59 LV_SLIDER_DRAW_PART_KNOB, /**< The main (right) knob's rectangle*/ 60 LV_SLIDER_DRAW_PART_KNOB_LEFT, /**< The left knob's rectangle*/ 61 } lv_slider_draw_part_type_t; 62 63 /********************** 64 * GLOBAL PROTOTYPES 65 **********************/ 66 67 /** 68 * Create a slider object 69 * @param parent pointer to an object, it will be the parent of the new slider. 70 * @return pointer to the created slider 71 */ 72 lv_obj_t * lv_slider_create(lv_obj_t * parent); 73 74 /*===================== 75 * Setter functions 76 *====================*/ 77 78 /** 79 * Set a new value on the slider 80 * @param obj pointer to a slider object 81 * @param value the new value 82 * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 83 */ 84 static inline void lv_slider_set_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim) 85 { 86 lv_bar_set_value(obj, value, anim); 87 } 88 89 /** 90 * Set a new value for the left knob of a slider 91 * @param obj pointer to a slider object 92 * @param value new value 93 * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 94 */ 95 static inline void lv_slider_set_left_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim) 96 { 97 lv_bar_set_start_value(obj, value, anim); 98 } 99 100 /** 101 * Set minimum and the maximum values of a bar 102 * @param obj pointer to the slider object 103 * @param min minimum value 104 * @param max maximum value 105 */ 106 static inline void lv_slider_set_range(lv_obj_t * obj, int32_t min, int32_t max) 107 { 108 lv_bar_set_range(obj, min, max); 109 } 110 111 /** 112 * Set the mode of slider. 113 * @param obj pointer to a slider object 114 * @param mode the mode of the slider. See ::lv_slider_mode_t 115 */ 116 static inline void lv_slider_set_mode(lv_obj_t * obj, lv_slider_mode_t mode) 117 { 118 lv_bar_set_mode(obj, (lv_bar_mode_t)mode); 119 } 120 121 /*===================== 122 * Getter functions 123 *====================*/ 124 125 /** 126 * Get the value of the main knob of a slider 127 * @param obj pointer to a slider object 128 * @return the value of the main knob of the slider 129 */ 130 static inline int32_t lv_slider_get_value(const lv_obj_t * obj) 131 { 132 return lv_bar_get_value(obj); 133 } 134 135 /** 136 * Get the value of the left knob of a slider 137 * @param obj pointer to a slider object 138 * @return the value of the left knob of the slider 139 */ 140 static inline int32_t lv_slider_get_left_value(const lv_obj_t * obj) 141 { 142 return lv_bar_get_start_value(obj); 143 } 144 145 /** 146 * Get the minimum value of a slider 147 * @param obj pointer to a slider object 148 * @return the minimum value of the slider 149 */ 150 static inline int32_t lv_slider_get_min_value(const lv_obj_t * obj) 151 { 152 return lv_bar_get_min_value(obj); 153 } 154 155 /** 156 * Get the maximum value of a slider 157 * @param obj pointer to a slider object 158 * @return the maximum value of the slider 159 */ 160 static inline int32_t lv_slider_get_max_value(const lv_obj_t * obj) 161 { 162 return lv_bar_get_max_value(obj); 163 } 164 165 /** 166 * Give the slider is being dragged or not 167 * @param obj pointer to a slider object 168 * @return true: drag in progress false: not dragged 169 */ 170 bool lv_slider_is_dragged(const lv_obj_t * obj); 171 172 /** 173 * Get the mode of the slider. 174 * @param obj pointer to a bar object 175 * @return see ::lv_slider_mode_t 176 */ 177 static inline lv_slider_mode_t lv_slider_get_mode(lv_obj_t * slider) 178 { 179 lv_bar_mode_t mode = lv_bar_get_mode(slider); 180 if(mode == LV_BAR_MODE_SYMMETRICAL) return LV_SLIDER_MODE_SYMMETRICAL; 181 else if(mode == LV_BAR_MODE_RANGE) return LV_SLIDER_MODE_RANGE; 182 else return LV_SLIDER_MODE_NORMAL; 183 } 184 185 /********************** 186 * MACROS 187 **********************/ 188 189 #endif /*LV_USE_SLIDER*/ 190 191 #ifdef __cplusplus 192 } /*extern "C"*/ 193 #endif 194 195 #endif /*LV_SLIDER_H*/