refactor(txt) rename _lv_txt_get_width to lv_txt_get_width
related to #2228
This commit is contained in:
@@ -197,14 +197,14 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||||||
|
|
||||||
/*Align to middle*/
|
/*Align to middle*/
|
||||||
if(dsc->align == LV_TEXT_ALIGN_CENTER) {
|
if(dsc->align == LV_TEXT_ALIGN_CENTER) {
|
||||||
line_width = _lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||||
|
|
||||||
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
/*Align to the right*/
|
/*Align to the right*/
|
||||||
else if(dsc->align == LV_TEXT_ALIGN_RIGHT) {
|
else if(dsc->align == LV_TEXT_ALIGN_RIGHT) {
|
||||||
line_width = _lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||||
pos.x += lv_area_get_width(coords) - line_width;
|
pos.x += lv_area_get_width(coords) - line_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,7 +364,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||||||
/*Align to middle*/
|
/*Align to middle*/
|
||||||
if(dsc->align == LV_TEXT_ALIGN_CENTER) {
|
if(dsc->align == LV_TEXT_ALIGN_CENTER) {
|
||||||
line_width =
|
line_width =
|
||||||
_lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||||
|
|
||||||
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
||||||
|
|
||||||
@@ -372,7 +372,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||||||
/*Align to the right*/
|
/*Align to the right*/
|
||||||
else if(dsc->align == LV_TEXT_ALIGN_RIGHT) {
|
else if(dsc->align == LV_TEXT_ALIGN_RIGHT) {
|
||||||
line_width =
|
line_width =
|
||||||
_lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||||
pos.x += lv_area_get_width(coords) - line_width;
|
pos.x += lv_area_get_width(coords) - line_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ static void refr_img(lv_obj_t * obj)
|
|||||||
if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) {
|
if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) {
|
||||||
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
|
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
|
||||||
header.h = lv_font_get_line_height(font);
|
header.h = lv_font_get_line_height(font);
|
||||||
header.w = _lv_txt_get_width(src, (uint16_t)strlen(src), font, 0, LV_TEXT_FLAG_NONE);
|
header.w = lv_txt_get_width(src, (uint16_t)strlen(src), font, 0, LV_TEXT_FLAG_NONE);
|
||||||
header.always_zero = 0;
|
header.always_zero = 0;
|
||||||
header.cf = LV_IMG_CF_ALPHA_1BIT;
|
header.cf = LV_IMG_CF_ALPHA_1BIT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ void lv_anim_start(lv_anim_t * a)
|
|||||||
a->time_orig = a->time;
|
a->time_orig = a->time;
|
||||||
a->run_round = anim_run_round;
|
a->run_round = anim_run_round;
|
||||||
lv_memcpy(new_anim, a, sizeof(lv_anim_t));
|
lv_memcpy(new_anim, a, sizeof(lv_anim_t));
|
||||||
|
if(a->var == a) new_anim->var = new_anim;
|
||||||
|
|
||||||
/*Set the start value*/
|
/*Set the start value*/
|
||||||
if(new_anim->early_apply) {
|
if(new_anim->early_apply) {
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t *
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Calculate the longest line*/
|
/*Calculate the longest line*/
|
||||||
lv_coord_t act_line_length = _lv_txt_get_width(&text[line_start], new_line_start - line_start, font, letter_space,
|
lv_coord_t act_line_length = lv_txt_get_width(&text[line_start], new_line_start - line_start, font, letter_space,
|
||||||
flag);
|
flag);
|
||||||
|
|
||||||
size_res->x = LV_MAX(act_line_length, size_res->x);
|
size_res->x = LV_MAX(act_line_length, size_res->x);
|
||||||
@@ -353,7 +353,7 @@ uint32_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
|||||||
* @param flags settings for the text from 'txt_flag_t' enum
|
* @param flags settings for the text from 'txt_flag_t' enum
|
||||||
* @return length of a char_num long text
|
* @return length of a char_num long text
|
||||||
*/
|
*/
|
||||||
lv_coord_t _lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t * font, lv_coord_t letter_space,
|
lv_coord_t lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t * font, lv_coord_t letter_space,
|
||||||
lv_text_flag_t flag)
|
lv_text_flag_t flag)
|
||||||
{
|
{
|
||||||
if(txt == NULL) return 0;
|
if(txt == NULL) return 0;
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ uint32_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coor
|
|||||||
* @param flags settings for the text from 'txt_flag_t' enum
|
* @param flags settings for the text from 'txt_flag_t' enum
|
||||||
* @return length of a char_num long text
|
* @return length of a char_num long text
|
||||||
*/
|
*/
|
||||||
lv_coord_t _lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t * font, lv_coord_t letter_space,
|
lv_coord_t lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t * font, lv_coord_t letter_space,
|
||||||
lv_text_flag_t flag);
|
lv_text_flag_t flag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -370,18 +370,18 @@ void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*Calculate the x coordinate*/
|
/*Calculate the x coordinate*/
|
||||||
lv_coord_t x = _lv_txt_get_width(bidi_txt, visual_byte_pos, font, letter_space, flag);
|
lv_coord_t x = lv_txt_get_width(bidi_txt, visual_byte_pos, font, letter_space, flag);
|
||||||
if(char_id != line_start) x += letter_space;
|
if(char_id != line_start) x += letter_space;
|
||||||
|
|
||||||
if(align == LV_TEXT_ALIGN_CENTER) {
|
if(align == LV_TEXT_ALIGN_CENTER) {
|
||||||
lv_coord_t line_w;
|
lv_coord_t line_w;
|
||||||
line_w = _lv_txt_get_width(bidi_txt, new_line_start - line_start, font, letter_space, flag);
|
line_w = lv_txt_get_width(bidi_txt, new_line_start - line_start, font, letter_space, flag);
|
||||||
x += lv_area_get_width(&txt_coords) / 2 - line_w / 2;
|
x += lv_area_get_width(&txt_coords) / 2 - line_w / 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
||||||
lv_coord_t line_w;
|
lv_coord_t line_w;
|
||||||
line_w = _lv_txt_get_width(bidi_txt, new_line_start - line_start, font, letter_space, flag);
|
line_w = lv_txt_get_width(bidi_txt, new_line_start - line_start, font, letter_space, flag);
|
||||||
|
|
||||||
x += lv_area_get_width(&txt_coords) - line_w;
|
x += lv_area_get_width(&txt_coords) - line_w;
|
||||||
}
|
}
|
||||||
@@ -455,12 +455,12 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in)
|
|||||||
lv_coord_t x = 0;
|
lv_coord_t x = 0;
|
||||||
if(align == LV_TEXT_ALIGN_CENTER) {
|
if(align == LV_TEXT_ALIGN_CENTER) {
|
||||||
lv_coord_t line_w;
|
lv_coord_t line_w;
|
||||||
line_w = _lv_txt_get_width(bidi_txt, new_line_start - line_start, font, letter_space, flag);
|
line_w = lv_txt_get_width(bidi_txt, new_line_start - line_start, font, letter_space, flag);
|
||||||
x += lv_area_get_width(&txt_coords) / 2 - line_w / 2;
|
x += lv_area_get_width(&txt_coords) / 2 - line_w / 2;
|
||||||
}
|
}
|
||||||
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
||||||
lv_coord_t line_w;
|
lv_coord_t line_w;
|
||||||
line_w = _lv_txt_get_width(bidi_txt, new_line_start - line_start, font, letter_space, flag);
|
line_w = lv_txt_get_width(bidi_txt, new_line_start - line_start, font, letter_space, flag);
|
||||||
x += lv_area_get_width(&txt_coords) - line_w;
|
x += lv_area_get_width(&txt_coords) - line_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,12 +556,12 @@ bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos)
|
|||||||
lv_coord_t last_x = 0;
|
lv_coord_t last_x = 0;
|
||||||
if(align == LV_TEXT_ALIGN_CENTER) {
|
if(align == LV_TEXT_ALIGN_CENTER) {
|
||||||
lv_coord_t line_w;
|
lv_coord_t line_w;
|
||||||
line_w = _lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, letter_space, flag);
|
line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, letter_space, flag);
|
||||||
x += lv_area_get_width(&txt_coords) / 2 - line_w / 2;
|
x += lv_area_get_width(&txt_coords) / 2 - line_w / 2;
|
||||||
}
|
}
|
||||||
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
||||||
lv_coord_t line_w;
|
lv_coord_t line_w;
|
||||||
line_w = _lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, letter_space, flag);
|
line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, letter_space, flag);
|
||||||
x += lv_area_get_width(&txt_coords) - line_w;
|
x += lv_area_get_width(&txt_coords) - line_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user