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_spinbox.h (4537B)

      1 /**
      2  * @file lv_spinbox.h
      3  *
      4  */
      5 
      6 #ifndef LV_SPINBOX_H
      7 #define LV_SPINBOX_H
      8 
      9 #ifdef __cplusplus
     10 extern "C" {
     11 #endif
     12 
     13 /*********************
     14  *      INCLUDES
     15  *********************/
     16 #include "../../../lvgl.h"
     17 
     18 #if LV_USE_SPINBOX
     19 
     20 /*Testing of dependencies*/
     21 #if LV_USE_TEXTAREA == 0
     22 #error "lv_spinbox: lv_ta is required. Enable it in lv_conf.h (LV_USE_TEXTAREA  1) "
     23 #endif
     24 
     25 /*********************
     26  *      DEFINES
     27  *********************/
     28 #define LV_SPINBOX_MAX_DIGIT_COUNT 10
     29 
     30 /**********************
     31  *      TYPEDEFS
     32  **********************/
     33 
     34 /*Data of spinbox*/
     35 typedef struct {
     36     lv_textarea_t ta;   /*Ext. of ancestor*/
     37     /*New data for this type*/
     38     int32_t value;
     39     int32_t range_max;
     40     int32_t range_min;
     41     int32_t step;
     42     uint16_t digit_count : 4;
     43     uint16_t dec_point_pos : 4; /*if 0, there is no separator and the number is an integer*/
     44     uint16_t rollover : 1;   // Set to true for rollover functionality
     45     uint16_t digit_step_dir : 2; // the direction the digit will step on encoder button press when editing
     46 } lv_spinbox_t;
     47 
     48 extern const lv_obj_class_t lv_spinbox_class;
     49 
     50 /**********************
     51  * GLOBAL PROTOTYPES
     52  **********************/
     53 
     54 /**
     55  * Create a Spinbox object
     56  * @param parent pointer to an object, it will be the parent of the new spinbox
     57  * @return pointer to the created spinbox
     58  */
     59 lv_obj_t * lv_spinbox_create(lv_obj_t * parent);
     60 
     61 /*=====================
     62  * Setter functions
     63  *====================*/
     64 
     65 /**
     66  * Set spinbox value
     67  * @param obj pointer to spinbox
     68  * @param i value to be set
     69  */
     70 void lv_spinbox_set_value(lv_obj_t * obj, int32_t i);
     71 
     72 /**
     73  * Set spinbox rollover function
     74  * @param obj pointer to spinbox
     75  * @param b true or false to enable or disable (default)
     76  */
     77 void lv_spinbox_set_rollover(lv_obj_t * obj, bool b);
     78 
     79 /**
     80  * Set spinbox digit format (digit count and decimal format)
     81  * @param obj pointer to spinbox
     82  * @param digit_count number of digit excluding the decimal separator and the sign
     83  * @param separator_position number of digit before the decimal point. If 0, decimal point is not
     84  * shown
     85  */
     86 void lv_spinbox_set_digit_format(lv_obj_t * obj, uint8_t digit_count, uint8_t separator_position);
     87 
     88 /**
     89  * Set spinbox step
     90  * @param obj pointer to spinbox
     91  * @param step steps on increment/decrement. Can be 1, 10, 100, 1000, etc the digit that will change.
     92  */
     93 void lv_spinbox_set_step(lv_obj_t * obj, uint32_t step);
     94 
     95 /**
     96  * Set spinbox value range
     97  * @param obj pointer to spinbox
     98  * @param range_min maximum value, inclusive
     99  * @param range_max minimum value, inclusive
    100  */
    101 void lv_spinbox_set_range(lv_obj_t * obj, int32_t range_min, int32_t range_max);
    102 
    103 /**
    104  * Set cursor position to a specific digit for edition
    105  * @param obj pointer to spinbox
    106  * @param pos selected position in spinbox
    107  */
    108 void lv_spinbox_set_pos(lv_obj_t * obj, uint8_t pos);
    109 
    110 /**
    111  * Set direction of digit step when clicking an encoder button while in editing mode
    112  * @param obj pointer to spinbox
    113  * @param direction the direction (LV_DIR_RIGHT or LV_DIR_LEFT)
    114  */
    115 void lv_spinbox_set_digit_step_direction(lv_obj_t * obj, lv_dir_t direction);
    116 
    117 /*=====================
    118  * Getter functions
    119  *====================*/
    120 
    121 /**
    122  * Get spinbox rollover function status
    123  * @param obj pointer to spinbox
    124  */
    125 bool lv_spinbox_get_rollover(lv_obj_t * obj);
    126 
    127 /**
    128  * Get the spinbox numeral value (user has to convert to float according to its digit format)
    129  * @param obj pointer to spinbox
    130  * @return value integer value of the spinbox
    131  */
    132 int32_t lv_spinbox_get_value(lv_obj_t * obj);
    133 
    134 /**
    135  * Get the spinbox step value (user has to convert to float according to its digit format)
    136  * @param obj pointer to spinbox
    137  * @return value integer step value of the spinbox
    138  */
    139 int32_t lv_spinbox_get_step(lv_obj_t * obj);
    140 
    141 /*=====================
    142  * Other functions
    143  *====================*/
    144 
    145 /**
    146  * Select next lower digit for edition by dividing the step by 10
    147  * @param obj pointer to spinbox
    148  */
    149 void lv_spinbox_step_next(lv_obj_t * obj);
    150 
    151 /**
    152  * Select next higher digit for edition by multiplying the step by 10
    153  * @param obj pointer to spinbox
    154  */
    155 void lv_spinbox_step_prev(lv_obj_t * obj);
    156 
    157 /**
    158  * Increment spinbox value by one step
    159  * @param obj pointer to spinbox
    160  */
    161 void lv_spinbox_increment(lv_obj_t * obj);
    162 
    163 /**
    164  * Decrement spinbox value by one step
    165  * @param obj pointer to spinbox
    166  */
    167 void lv_spinbox_decrement(lv_obj_t * obj);
    168 
    169 /**********************
    170  *      MACROS
    171  **********************/
    172 
    173 #endif /*LV_USE_SPINBOX*/
    174 
    175 #ifdef __cplusplus
    176 } /*extern "C"*/
    177 #endif
    178 #endif /*LV_SPINBOX_H*/