lv_label_no_break: fixes

This commit is contained in:
Gabor Kiss-Vamosi
2018-07-25 06:12:05 +02:00
parent 1fa77fa5d7
commit 818cd278b2
3 changed files with 13 additions and 5 deletions

View File

@@ -365,6 +365,9 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
} }
} }
if((flag & LV_TXT_FLAG_NO_BREAK) && (letter == '\n' || letter == '\r')) continue;
lv_color_t color = style->text.color; lv_color_t color = style->text.color;
if(cmd_state == CMD_STATE_IN) color = recolor; if(cmd_state == CMD_STATE_IN) color = recolor;

View File

@@ -195,10 +195,13 @@ lv_coord_t lv_txt_get_width(const char * txt, uint16_t length,
continue; continue;
} }
} }
width += lv_font_get_width(font, letter);
width += letter_space;
}
/*If NO_BREAK is set and '\n' or '\r' found then ignore this letter */
if(((flag & LV_TXT_FLAG_NO_BREAK) == 0) || (letter != '\n' && letter != '\r')) {
width += lv_font_get_width(font, letter);
width += letter_space;
}
}
width -= letter_space; /*Trim the last letter space. Important if the text is center aligned */ width -= letter_space; /*Trim the last letter space. Important if the text is center aligned */
} }

View File

@@ -516,8 +516,10 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, lv_point_t * pos)
/*Search the line of the index letter */; /*Search the line of the index letter */;
while(txt[line_start] != '\0') { while(txt[line_start] != '\0') {
new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag); new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag);
if(pos->y <= y + letter_height) break; /*The line is found (stored in 'line_start')*/
y += letter_height + style->text.line_space; if(pos->y <= y + letter_height) break; /*The line is found (stored in 'line_start')*/
y += letter_height + style->text.line_space;
line_start = new_line_start; line_start = new_line_start;
} }