text sel fix, if start > end
This commit is contained in:
@@ -831,10 +831,11 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
|
|||||||
uint8_t letter_height = lv_font_get_line_height(font);
|
uint8_t letter_height = lv_font_get_line_height(font);
|
||||||
lv_coord_t y = 0;
|
lv_coord_t y = 0;
|
||||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||||
|
lv_label_align_t align = lv_label_get_align(label);
|
||||||
|
|
||||||
if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
|
if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
|
||||||
if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND;
|
if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND;
|
||||||
if(ext->align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
|
if(align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
|
||||||
|
|
||||||
/*If the width will be expanded set the max length to very big */
|
/*If the width will be expanded set the max length to very big */
|
||||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND) {
|
if(ext->long_mode == LV_LABEL_LONG_EXPAND) {
|
||||||
@@ -854,11 +855,16 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
|
|||||||
/*Calculate the x coordinate*/
|
/*Calculate the x coordinate*/
|
||||||
lv_coord_t x = 0;
|
lv_coord_t x = 0;
|
||||||
lv_coord_t last_x = 0;
|
lv_coord_t last_x = 0;
|
||||||
if(ext->align == LV_LABEL_ALIGN_CENTER) {
|
if(align == LV_LABEL_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, style->text.letter_space, flag);
|
line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag);
|
||||||
x += lv_obj_get_width(label) / 2 - line_w / 2;
|
x += lv_obj_get_width(label) / 2 - line_w / 2;
|
||||||
}
|
}
|
||||||
|
else if(align == LV_LABEL_ALIGN_RIGHT) {
|
||||||
|
lv_coord_t line_w;
|
||||||
|
line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag);
|
||||||
|
x += lv_obj_get_width(label) - line_w;
|
||||||
|
}
|
||||||
|
|
||||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user