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_imgbtn.h (3741B)

      1 /**
      2  * @file lv_imgbtn.h
      3  *
      4  */
      5 
      6 #ifndef LV_IMGBTN_H
      7 #define LV_IMGBTN_H
      8 
      9 #ifdef __cplusplus
     10 extern "C" {
     11 #endif
     12 
     13 /*********************
     14  *      INCLUDES
     15  *********************/
     16 #include "../../../lvgl.h"
     17 
     18 #if LV_USE_IMGBTN != 0
     19 
     20 /*********************
     21  *      DEFINES
     22  *********************/
     23 typedef enum {
     24     LV_IMGBTN_STATE_RELEASED,
     25     LV_IMGBTN_STATE_PRESSED,
     26     LV_IMGBTN_STATE_DISABLED,
     27     LV_IMGBTN_STATE_CHECKED_RELEASED,
     28     LV_IMGBTN_STATE_CHECKED_PRESSED,
     29     LV_IMGBTN_STATE_CHECKED_DISABLED,
     30     _LV_IMGBTN_STATE_NUM,
     31 } lv_imgbtn_state_t;
     32 
     33 /**********************
     34  *      TYPEDEFS
     35  **********************/
     36 /*Data of image button*/
     37 typedef struct {
     38     lv_obj_t obj;
     39     const void * img_src_mid[_LV_IMGBTN_STATE_NUM];   /*Store center images to each state*/
     40     const void * img_src_left[_LV_IMGBTN_STATE_NUM];  /*Store left side images to each state*/
     41     const void * img_src_right[_LV_IMGBTN_STATE_NUM]; /*Store right side images to each state*/
     42     lv_img_cf_t act_cf; /*Color format of the currently active image*/
     43 } lv_imgbtn_t;
     44 
     45 extern const lv_obj_class_t lv_imgbtn_class;
     46 
     47 /**********************
     48  * GLOBAL PROTOTYPES
     49  **********************/
     50 
     51 /**
     52  * Create an image button object
     53  * @param parent pointer to an object, it will be the parent of the new image button
     54  * @return pointer to the created image button
     55  */
     56 lv_obj_t * lv_imgbtn_create(lv_obj_t * parent);
     57 
     58 /*======================
     59  * Add/remove functions
     60  *=====================*/
     61 
     62 /*=====================
     63  * Setter functions
     64  *====================*/
     65 
     66 /**
     67  * Set images for a state of the image button
     68  * @param imgbtn pointer to an image button object
     69  * @param state for which state set the new image
     70  * @param src_left pointer to an image source for the left side of the button (a C array or path to
     71  * a file)
     72  * @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C
     73  * array or path to a file)
     74  * @param src_right pointer to an image source for the right side of the button (a C array or path
     75  * to a file)
     76  */
     77 void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * src_left, const void * src_mid,
     78                        const void * src_right);
     79 
     80 
     81 /**
     82  * Use this function instead of `lv_obj_add/clear_state` to set a state manually
     83  * @param imgbtn pointer to an image button object
     84  * @param state  the new state
     85  */
     86 void lv_imgbtn_set_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
     87 
     88 /*=====================
     89  * Getter functions
     90  *====================*/
     91 
     92 /**
     93  * Get the left image in a given state
     94  * @param imgbtn pointer to an image button object
     95  * @param state the state where to get the image (from `lv_btn_state_t`) `
     96  * @return pointer to the left image source (a C array or path to a file)
     97  */
     98 const void * lv_imgbtn_get_src_left(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
     99 
    100 /**
    101  * Get the middle image in a given state
    102  * @param imgbtn pointer to an image button object
    103  * @param state the state where to get the image (from `lv_btn_state_t`) `
    104  * @return pointer to the middle image source (a C array or path to a file)
    105  */
    106 const void * lv_imgbtn_get_src_middle(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
    107 
    108 /**
    109  * Get the right image in a given state
    110  * @param imgbtn pointer to an image button object
    111  * @param state the state where to get the image (from `lv_btn_state_t`) `
    112  * @return pointer to the left image source (a C array or path to a file)
    113  */
    114 const void * lv_imgbtn_get_src_right(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
    115 
    116 
    117 /*=====================
    118  * Other functions
    119  *====================*/
    120 
    121 /**********************
    122  *      MACROS
    123  **********************/
    124 
    125 #endif /*LV_USE_IMGBTN*/
    126 
    127 #ifdef __cplusplus
    128 } /*extern "C"*/
    129 #endif
    130 
    131 #endif /*LV_IMGBTN_H*/