1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00
lvgl/src/lv_draw/lv_draw_label.h

81 lines
2.2 KiB
C
Raw Normal View History

/**
* @file lv_draw_label.h
*
*/
#ifndef LV_DRAW_LABEL_H
#define LV_DRAW_LABEL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_draw.h"
#include "../lv_misc/lv_bidi.h"
/*********************
* DEFINES
*********************/
#define LV_DRAW_LABEL_NO_TXT_SEL (0xFFFF)
/**********************
* TYPEDEFS
**********************/
2019-06-14 16:04:15 +02:00
typedef struct
{
uint16_t start;
uint16_t end;
}lv_draw_label_txt_sel_t;
2019-06-27 18:07:26 -04:00
/** Store some info to speed up drawing of very large texts
2019-06-14 16:04:15 +02:00
* It takes a lot of time to get the first visible character because
* all the previous characters needs to be checked to calculate the positions.
* This structure stores an earlier (e.g. at -1000 px) coordinate and the index of that line.
* Therefore the calculations can start from here.*/
typedef struct {
/** Index of the line at `y` coordinate*/
2019-06-14 14:57:59 +02:00
int32_t line_start;
2019-06-14 16:04:15 +02:00
2019-06-27 18:07:26 -04:00
/** Give the `y` coordinate of the first letter at `line start` index. Relative to the label's coordinates*/
2019-06-14 14:57:59 +02:00
int32_t y;
2019-06-14 16:04:15 +02:00
2019-06-27 18:07:26 -04:00
/** The 'y1' coordinate of the label when the hint was saved.
2019-06-14 16:04:15 +02:00
* Used to invalidate the hint if the label has moved too much. */
2019-06-14 14:57:59 +02:00
int32_t coord_y;
}lv_draw_label_hint_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Write a text
* @param coords coordinates of the label
* @param mask the label will be drawn only in this area
* @param style pointer to a style
2018-06-14 13:08:19 +02:00
* @param opa_scale scale down all opacities by the factor
* @param txt 0 terminated text to write
* @param flag settings for the text from 'txt_flag_t' enum
* @param offset text offset in x and y direction (NULL if unused)
2019-04-18 06:45:45 +02:00
* @param sel_start start index of selected area (`LV_LABEL_TXT_SEL_OFF` if none)
2019-11-11 19:42:10 +01:00
* @param bidi_dir base direction of the text
*/
2019-06-06 06:05:40 +02:00
void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale,
const char * txt, lv_txt_flag_t flag, lv_point_t * offset, lv_draw_label_txt_sel_t * sel,
lv_draw_label_hint_t * hint, lv_bidi_dir_t bidi_dir);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_DRAW_LABEL_H*/