diff options
Diffstat (limited to 'src/widgets/label/lv_label.c')
-rw-r--r-- | src/widgets/label/lv_label.c | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/src/widgets/label/lv_label.c b/src/widgets/label/lv_label.c index 91c802638..77c75739f 100644 --- a/src/widgets/label/lv_label.c +++ b/src/widgets/label/lv_label.c @@ -53,8 +53,8 @@ static void set_ofs_y_anim(void * obj, int32_t v); static size_t get_text_length(const char * text); static void copy_text_to_label(lv_label_t * label, const char * text); static lv_text_flag_t get_label_flags(lv_label_t * label); -static void calculate_x_coordinate(lv_coord_t * x, const lv_text_align_t align, const char * txt, - uint32_t length, const lv_font_t * font, lv_coord_t letter_space, lv_area_t * txt_coords); +static void calculate_x_coordinate(int32_t * x, const lv_text_align_t align, const char * txt, + uint32_t length, const lv_font_t * font, int32_t letter_space, lv_area_t * txt_coords); /********************** * STATIC VARIABLES @@ -304,17 +304,17 @@ void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t const uint32_t byte_id = _lv_text_encoded_get_byte_id(txt, char_id); /*Search the line of the index letter*/ - const lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); - const lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); + const int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); + const int32_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); - const lv_coord_t letter_height = lv_font_get_line_height(font); + const int32_t letter_height = lv_font_get_line_height(font); lv_area_t txt_coords; lv_obj_get_content_coords(obj, &txt_coords); - const lv_coord_t max_w = lv_area_get_width(&txt_coords); + const int32_t max_w = lv_area_get_width(&txt_coords); - lv_coord_t y = 0; + int32_t y = 0; uint32_t line_start = 0; uint32_t new_line_start = 0; while(txt[new_line_start] != '\0') { @@ -363,7 +363,7 @@ void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t #endif /*Calculate the x coordinate*/ - lv_coord_t x = lv_text_get_width(bidi_txt, visual_byte_pos, font, letter_space); + int32_t x = lv_text_get_width(bidi_txt, visual_byte_pos, font, letter_space); if(char_id != line_start) x += letter_space; uint32_t length = new_line_start - line_start; @@ -391,12 +391,12 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in) const char * txt = lv_label_get_text(obj); uint32_t line_start = 0; uint32_t new_line_start = 0; - lv_coord_t max_w = lv_area_get_width(&txt_coords); + int32_t max_w = lv_area_get_width(&txt_coords); const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); - const lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); - const lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); - const lv_coord_t letter_height = lv_font_get_line_height(font); - lv_coord_t y = 0; + const int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); + const int32_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); + const int32_t letter_height = lv_font_get_line_height(font); + int32_t y = 0; lv_text_flag_t flag = get_label_flags(label); if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT && !obj->w_layout) flag |= LV_TEXT_FLAG_FIT; @@ -431,7 +431,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in) #endif /*Calculate the x coordinate*/ - lv_coord_t x = 0; + int32_t x = 0; const lv_text_align_t align = lv_obj_calculate_style_text_align(obj, LV_PART_MAIN, label->text); uint32_t length = new_line_start - line_start; calculate_x_coordinate(&x, align, bidi_txt, length, font, letter_space, &txt_coords); @@ -447,7 +447,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in) uint32_t letter_next; _lv_text_encoded_letter_next_2(bidi_txt, &letter, &letter_next, &i); - lv_coord_t gw = lv_font_get_glyph_width(font, letter, letter_next); + int32_t gw = lv_font_get_glyph_width(font, letter, letter_next); /*Finish if the x position or the last char of the next line is reached*/ if(pos.x < x + gw || i + line_start == new_line_start || txt[i_act + line_start] == '\0') { @@ -492,17 +492,17 @@ bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos) lv_label_t * label = (lv_label_t *)obj; uint32_t line_start = 0; uint32_t new_line_start = 0; - const lv_coord_t max_w = lv_area_get_width(&txt_coords); + const int32_t max_w = lv_area_get_width(&txt_coords); const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); - const lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); - const lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); - const lv_coord_t letter_height = lv_font_get_line_height(font); + const int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); + const int32_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); + const int32_t letter_height = lv_font_get_line_height(font); lv_text_flag_t flag = get_label_flags(label); if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT && !obj->w_layout) flag |= LV_TEXT_FLAG_FIT; /*Search the line of the index letter*/ - lv_coord_t y = 0; + int32_t y = 0; while(txt[line_start] != '\0') { new_line_start += _lv_text_get_next_line(&txt[line_start], font, letter_space, max_w, NULL, flag); @@ -515,17 +515,17 @@ bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos) /*Calculate the x coordinate*/ const lv_text_align_t align = lv_obj_calculate_style_text_align(obj, LV_PART_MAIN, label->text); - lv_coord_t x = 0; + int32_t x = 0; if(align == LV_TEXT_ALIGN_CENTER) { - const lv_coord_t line_w = lv_text_get_width(&txt[line_start], new_line_start - line_start, font, letter_space); + const int32_t line_w = lv_text_get_width(&txt[line_start], new_line_start - line_start, font, letter_space); x += lv_area_get_width(&txt_coords) / 2 - line_w / 2; } else if(align == LV_TEXT_ALIGN_RIGHT) { - const lv_coord_t line_w = lv_text_get_width(&txt[line_start], new_line_start - line_start, font, letter_space); + const int32_t line_w = lv_text_get_width(&txt[line_start], new_line_start - line_start, font, letter_space); x += lv_area_get_width(&txt_coords) - line_w; } - lv_coord_t last_x = 0; + int32_t last_x = 0; uint32_t i = line_start; uint32_t i_current = i; uint32_t letter = '\0'; @@ -699,20 +699,20 @@ static void lv_label_event(const lv_obj_class_t * class_p, lv_event_t * e) * To avoid this add some extra draw area. * font_h / 4 is an empirical value. */ const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); - const lv_coord_t font_h = lv_font_get_line_height(font); + const int32_t font_h = lv_font_get_line_height(font); lv_event_set_ext_draw_size(e, font_h / 4); } else if(code == LV_EVENT_GET_SELF_SIZE) { lv_label_t * label = (lv_label_t *)obj; if(label->invalid_size_cache) { const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); - lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); - lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); + int32_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); + int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); lv_text_flag_t flag = LV_TEXT_FLAG_NONE; if(label->recolor != 0) flag |= LV_TEXT_FLAG_RECOLOR; if(label->expand != 0) flag |= LV_TEXT_FLAG_EXPAND; - lv_coord_t w = lv_obj_get_content_width(obj); + int32_t w = lv_obj_get_content_width(obj); if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT && !obj->w_layout) w = LV_COORD_MAX; else w = lv_obj_get_content_width(obj); @@ -785,7 +785,7 @@ static void draw_main(lv_event_t * e) } if(label->long_mode == LV_LABEL_LONG_WRAP) { - lv_coord_t s = lv_obj_get_scroll_top(obj); + int32_t s = lv_obj_get_scroll_top(obj); lv_area_move(&txt_coords, 0, -s); txt_coords.y2 = obj->coords.y2; } @@ -868,10 +868,10 @@ static void lv_label_refr_text(lv_obj_t * obj) lv_area_t txt_coords; lv_obj_get_content_coords(obj, &txt_coords); - lv_coord_t max_w = lv_area_get_width(&txt_coords); + int32_t max_w = lv_area_get_width(&txt_coords); const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); - lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); - lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); + int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); + int32_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); /*Calc. the height and longest line*/ lv_point_t size; @@ -1088,7 +1088,7 @@ static void lv_label_refr_text(lv_obj_t * obj) } else { lv_point_t p; - lv_coord_t y_overed; + int32_t y_overed; p.x = lv_area_get_width(&txt_coords) - (lv_font_get_glyph_width(font, '.', '.') + letter_space) * LV_LABEL_DOT_NUM; /*Shrink with dots*/ @@ -1277,15 +1277,15 @@ static lv_text_flag_t get_label_flags(lv_label_t * label) } /* Function created because of this pattern be used in multiple functions */ -static void calculate_x_coordinate(lv_coord_t * x, const lv_text_align_t align, const char * txt, uint32_t length, - const lv_font_t * font, lv_coord_t letter_space, lv_area_t * txt_coords) +static void calculate_x_coordinate(int32_t * x, const lv_text_align_t align, const char * txt, uint32_t length, + const lv_font_t * font, int32_t letter_space, lv_area_t * txt_coords) { if(align == LV_TEXT_ALIGN_CENTER) { - const lv_coord_t line_w = lv_text_get_width(txt, length, font, letter_space); + const int32_t line_w = lv_text_get_width(txt, length, font, letter_space); *x += lv_area_get_width(txt_coords) / 2 - line_w / 2; } else if(align == LV_TEXT_ALIGN_RIGHT) { - const lv_coord_t line_w = lv_text_get_width(txt, length, font, letter_space); + const int32_t line_w = lv_text_get_width(txt, length, font, letter_space); *x += lv_area_get_width(txt_coords) - line_w; } else { |