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_span.h (6594B)

      1 /**
      2  * @file lv_span.h
      3  *
      4  */
      5 
      6 #ifndef LV_SPAN_H
      7 #define LV_SPAN_H
      8 
      9 #ifdef __cplusplus
     10 extern "C" {
     11 #endif
     12 
     13 /*********************
     14  *      INCLUDES
     15  *********************/
     16 #include "../../../lvgl.h"
     17 
     18 #if LV_USE_SPAN != 0
     19 
     20 /*********************
     21  *      DEFINES
     22  *********************/
     23 #ifndef LV_SPAN_SNIPPET_STACK_SIZE
     24 #define LV_SPAN_SNIPPET_STACK_SIZE 64
     25 #endif
     26 
     27 /**********************
     28  *      TYPEDEFS
     29  **********************/
     30 enum {
     31     LV_SPAN_OVERFLOW_CLIP,
     32     LV_SPAN_OVERFLOW_ELLIPSIS,
     33 };
     34 typedef uint8_t lv_span_overflow_t;
     35 
     36 enum {
     37     LV_SPAN_MODE_FIXED,     /**< fixed the obj size*/
     38     LV_SPAN_MODE_EXPAND,    /**< Expand the object size to the text size*/
     39     LV_SPAN_MODE_BREAK,     /**< Keep width, break the too long lines and expand height*/
     40 };
     41 typedef uint8_t lv_span_mode_t;
     42 
     43 typedef struct {
     44     char * txt;             /* a pointer to display text */
     45     lv_obj_t * spangroup;   /* a pointer to spangroup */
     46     lv_style_t style;       /* display text style */
     47     uint8_t static_flag : 1;/* the text is static flag */
     48 } lv_span_t;
     49 
     50 /** Data of label*/
     51 typedef struct {
     52     lv_obj_t obj;
     53     int32_t lines;
     54     lv_coord_t indent;      /* first line indent */
     55     lv_coord_t cache_w;     /* the cache automatically calculates the width */
     56     lv_coord_t cache_h;     /* similar cache_w */
     57     lv_ll_t  child_ll;
     58     uint8_t mode : 2;       /* details see lv_span_mode_t */
     59     uint8_t overflow : 1;   /* details see lv_span_overflow_t */
     60     uint8_t refresh : 1;    /* the spangroup need refresh cache_w and cache_h */
     61 } lv_spangroup_t;
     62 
     63 extern const lv_obj_class_t lv_spangroup_class;
     64 
     65 /**********************
     66  * GLOBAL PROTOTYPES
     67  **********************/
     68 
     69 /**
     70  * Create a spangroup object
     71  * @param par pointer to an object, it will be the parent of the new spangroup
     72  * @return pointer to the created spangroup
     73  */
     74 lv_obj_t * lv_spangroup_create(lv_obj_t * par);
     75 
     76 /**
     77  * Create a span string descriptor and add to spangroup.
     78  * @param obj pointer to a spangroup object.
     79  * @return pointer to the created span.
     80  */
     81 lv_span_t * lv_spangroup_new_span(lv_obj_t * obj);
     82 
     83 /**
     84  * Remove the span from the spangroup and free memory.
     85  * @param obj pointer to a spangroup object.
     86  * @param span pointer to a span.
     87  */
     88 void lv_spangroup_del_span(lv_obj_t * obj, lv_span_t * span);
     89 
     90 /*=====================
     91  * Setter functions
     92  *====================*/
     93 
     94 /**
     95  * Set a new text for a span. Memory will be allocated to store the text by the span.
     96  * @param span pointer to a span.
     97  * @param text pointer to a text.
     98  */
     99 void lv_span_set_text(lv_span_t * span, const char * text);
    100 
    101 /**
    102  * Set a static text. It will not be saved by the span so the 'text' variable
    103  * has to be 'alive' while the span exist.
    104  * @param span pointer to a span.
    105  * @param text pointer to a text.
    106  */
    107 void lv_span_set_text_static(lv_span_t * span, const char * text);
    108 
    109 /**
    110  * Set the align of the spangroup.
    111  * @param obj pointer to a spangroup object.
    112  * @param align see lv_text_align_t for details.
    113  */
    114 void lv_spangroup_set_align(lv_obj_t * obj, lv_text_align_t align);
    115 
    116 /**
    117  * Set the overflow of the spangroup.
    118  * @param obj pointer to a spangroup object.
    119  * @param overflow see lv_span_overflow_t for details.
    120  */
    121 void lv_spangroup_set_overflow(lv_obj_t * obj, lv_span_overflow_t overflow);
    122 
    123 /**
    124  * Set the indent of the spangroup.
    125  * @param obj pointer to a spangroup object.
    126  * @param indent The first line indentation
    127  */
    128 void lv_spangroup_set_indent(lv_obj_t * obj, lv_coord_t indent);
    129 
    130 /**
    131  * Set the mode of the spangroup.
    132  * @param obj pointer to a spangroup object.
    133  * @param mode see lv_span_mode_t for details.
    134  */
    135 void lv_spangroup_set_mode(lv_obj_t * obj, lv_span_mode_t mode);
    136 
    137 /**
    138  * Set lines of the spangroup.
    139  * @param obj pointer to a spangroup object.
    140  * @param lines max lines that can be displayed in LV_SPAN_MODE_BREAK mode. < 0 means no limit.
    141  */
    142 void lv_spangroup_set_lines(lv_obj_t * obj, int32_t lines);
    143 
    144 /*=====================
    145  * Getter functions
    146  *====================*/
    147 
    148 /**
    149  * Get a spangroup child by its index.
    150  *
    151  * @param obj   The spangroup object
    152  * @param id    the index of the child.
    153  *              0: the oldest (firstly created) child
    154  *              1: the second oldest
    155  *              child count-1: the youngest
    156  *              -1: the youngest
    157  *              -2: the second youngest
    158  * @return      The child span at index `id`, or NULL if the ID does not exist
    159  */
    160 lv_span_t * lv_spangroup_get_child(const lv_obj_t * obj, int32_t id);
    161 
    162 /**
    163  *
    164  * @param obj   The spangroup object to get the child count of.
    165  * @return      The span count of the spangroup.
    166  */
    167 uint32_t lv_spangroup_get_child_cnt(const lv_obj_t * obj);
    168 
    169 /**
    170  * get the align of the spangroup.
    171  * @param obj pointer to a spangroup object.
    172  * @return the align value.
    173  */
    174 lv_text_align_t lv_spangroup_get_align(lv_obj_t * obj);
    175 
    176 /**
    177  * get the overflow of the spangroup.
    178  * @param obj pointer to a spangroup object.
    179  * @return the overflow value.
    180  */
    181 lv_span_overflow_t lv_spangroup_get_overflow(lv_obj_t * obj);
    182 
    183 /**
    184  * get the indent of the spangroup.
    185  * @param obj pointer to a spangroup object.
    186  * @return the indent value.
    187  */
    188 lv_coord_t lv_spangroup_get_indent(lv_obj_t * obj);
    189 
    190 /**
    191  * get the mode of the spangroup.
    192  * @param obj pointer to a spangroup object.
    193  */
    194 lv_span_mode_t lv_spangroup_get_mode(lv_obj_t * obj);
    195 
    196 /**
    197  * get lines of the spangroup.
    198  * @param obj pointer to a spangroup object.
    199  * @return the lines value.
    200  */
    201 int32_t lv_spangroup_get_lines(lv_obj_t * obj);
    202 
    203 /**
    204  * get max line height of all span in the spangroup.
    205  * @param obj pointer to a spangroup object.
    206  */
    207 lv_coord_t lv_spangroup_get_max_line_h(lv_obj_t * obj);
    208 
    209 /**
    210  * get the text content width when all span of spangroup on a line.
    211  * @param obj pointer to a spangroup object.
    212  * @param max_width if text content width >= max_width, return max_width
    213  * to reduce computation, if max_width == 0, returns the text content width.
    214  * @return text content width or max_width.
    215  */
    216 uint32_t lv_spangroup_get_expand_width(lv_obj_t * obj, uint32_t max_width);
    217 
    218 /**
    219  * get the text content height with width fixed.
    220  * @param obj pointer to a spangroup object.
    221  */
    222 lv_coord_t lv_spangroup_get_expand_height(lv_obj_t * obj, lv_coord_t width);
    223 
    224 
    225 /*=====================
    226  * Other functions
    227  *====================*/
    228 
    229 /**
    230  * update the mode of the spangroup.
    231  * @param obj pointer to a spangroup object.
    232  */
    233 void lv_spangroup_refr_mode(lv_obj_t * obj);
    234 
    235 /**********************
    236  *      MACROS
    237  **********************/
    238 
    239 #endif /*LV_USE_SPAN*/
    240 
    241 #ifdef __cplusplus
    242 } /* extern "C" */
    243 #endif
    244 
    245 #endif /*LV_SPAN_H*/