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_draw_label.h (2834B)

      1 /**
      2  * @file lv_draw_label.h
      3  *
      4  */
      5 
      6 #ifndef LV_DRAW_LABEL_H
      7 #define LV_DRAW_LABEL_H
      8 
      9 #ifdef __cplusplus
     10 extern "C" {
     11 #endif
     12 
     13 /*********************
     14  *      INCLUDES
     15  *********************/
     16 #include "../misc/lv_bidi.h"
     17 #include "../misc/lv_txt.h"
     18 #include "../misc/lv_color.h"
     19 #include "../misc/lv_style.h"
     20 
     21 /*********************
     22  *      DEFINES
     23  *********************/
     24 #define LV_DRAW_LABEL_NO_TXT_SEL (0xFFFF)
     25 
     26 /**********************
     27  *      TYPEDEFS
     28  **********************/
     29 
     30 typedef struct {
     31     const lv_font_t * font;
     32     uint32_t sel_start;
     33     uint32_t sel_end;
     34     lv_color_t color;
     35     lv_color_t sel_color;
     36     lv_color_t sel_bg_color;
     37     lv_coord_t line_space;
     38     lv_coord_t letter_space;
     39     lv_coord_t ofs_x;
     40     lv_coord_t ofs_y;
     41     lv_opa_t opa;
     42     lv_base_dir_t bidi_dir;
     43     lv_text_align_t align;
     44     lv_text_flag_t flag;
     45     lv_text_decor_t decor : 3;
     46     lv_blend_mode_t blend_mode: 3;
     47 } lv_draw_label_dsc_t;
     48 
     49 /** Store some info to speed up drawing of very large texts
     50  * It takes a lot of time to get the first visible character because
     51  * all the previous characters needs to be checked to calculate the positions.
     52  * This structure stores an earlier (e.g. at -1000 px) coordinate and the index of that line.
     53  * Therefore the calculations can start from here.*/
     54 typedef struct _lv_draw_label_hint_t {
     55     /** Index of the line at `y` coordinate*/
     56     int32_t line_start;
     57 
     58     /** Give the `y` coordinate of the first letter at `line start` index. Relative to the label's coordinates*/
     59     int32_t y;
     60 
     61     /** The 'y1' coordinate of the label when the hint was saved.
     62      * Used to invalidate the hint if the label has moved too much.*/
     63     int32_t coord_y;
     64 } lv_draw_label_hint_t;
     65 
     66 struct _lv_draw_ctx_t;
     67 /**********************
     68  * GLOBAL PROTOTYPES
     69  **********************/
     70 
     71 LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc);
     72 
     73 /**
     74  * Write a text
     75  * @param coords coordinates of the label
     76  * @param mask the label will be drawn only in this area
     77  * @param dsc pointer to draw descriptor
     78  * @param txt `\0` terminated text to write
     79  * @param hint pointer to a `lv_draw_label_hint_t` variable.
     80  * It is managed by the draw to speed up the drawing of very long texts (thousands of lines).
     81  */
     82 LV_ATTRIBUTE_FAST_MEM void lv_draw_label(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc,
     83                                          const lv_area_t * coords, const char * txt, lv_draw_label_hint_t * hint);
     84 
     85 void lv_draw_letter(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc,  const lv_point_t * pos_p,
     86                     uint32_t letter);
     87 
     88 /***********************
     89  * GLOBAL VARIABLES
     90  ***********************/
     91 
     92 /**********************
     93  *      MACROS
     94  **********************/
     95 
     96 #ifdef __cplusplus
     97 } /*extern "C"*/
     98 #endif
     99 
    100 #endif /*LV_DRAW_LABEL_H*/