mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
roller, ddlist and lv_label_get_letter_on fixes
This commit is contained in:
parent
c35c84c7d0
commit
71e950614f
@ -142,8 +142,10 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->draw_arrow = copy_ext->draw_arrow;
|
||||
ext->stay_open = copy_ext->stay_open;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_ddlist);
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, lv_ddlist_get_style(copy, LV_DDLIST_STYLE_BG));
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SB, lv_ddlist_get_style(copy, LV_DDLIST_STYLE_SB));
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, lv_ddlist_get_style(copy, LV_DDLIST_STYLE_SEL));
|
||||
|
||||
}
|
||||
|
||||
LV_LOG_INFO("drop down list created");
|
||||
@ -773,13 +775,16 @@ static lv_res_t release_handler(lv_obj_t * ddlist)
|
||||
uint16_t new_opt = 0;
|
||||
const char * txt = lv_label_get_text(ext->label);
|
||||
uint32_t i = 0;
|
||||
uint32_t line_cnt = 0;
|
||||
uint32_t i_prev = 0;
|
||||
|
||||
uint32_t letter_cnt = 0;
|
||||
uint32_t letter;
|
||||
for(line_cnt = 0; line_cnt < letter_i; line_cnt++) {
|
||||
for(letter_cnt = 0; letter_cnt < letter_i; letter_cnt++) {
|
||||
letter = lv_txt_encoded_next(txt, &i);
|
||||
/*Count he lines to reach the clicked letter. But ignore the last '\n' because it
|
||||
* still belongs to the clicked line*/
|
||||
if(letter == '\n' && i != letter_i) new_opt++;
|
||||
if(letter == '\n' && i_prev != letter_i) new_opt++;
|
||||
i_prev = i;
|
||||
}
|
||||
|
||||
ext->sel_opt_id = new_opt;
|
||||
|
@ -585,14 +585,13 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
|
||||
|
||||
uint32_t i = line_start;
|
||||
uint32_t i_current = i;
|
||||
uint32_t i_act = i;
|
||||
uint32_t letter;
|
||||
uint32_t letter_next;
|
||||
|
||||
if(new_line_start > 0) {
|
||||
while(i <= new_line_start - 1) {
|
||||
/* Get the current letter.
|
||||
* Be careful 'i' already points to the next character*/
|
||||
while(i < new_line_start) {
|
||||
/* Get the current letter.*/
|
||||
letter = lv_txt_encoded_next(txt, &i);
|
||||
|
||||
/*Get the next letter too for kerning*/
|
||||
@ -606,12 +605,14 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
}
|
||||
|
||||
x += lv_font_get_glyph_width(font, letter, letter_next);
|
||||
if(pos->x < x) {
|
||||
i = i_current;
|
||||
|
||||
/*Finish if the x position or the last char of the line is reached*/
|
||||
if(pos->x < x || i == new_line_start) {
|
||||
i = i_act;
|
||||
break;
|
||||
}
|
||||
x += style->text.letter_space;
|
||||
i_current = i;
|
||||
i_act = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
|
||||
lv_coord_t font_h = lv_font_get_line_height(font);
|
||||
|
||||
if(sign == LV_SIGNAL_DRAG_END) {
|
||||
/*If dragged then align the list to there be an element in the middle*/
|
||||
/*If dragged then align the list to have an element in the middle*/
|
||||
lv_coord_t label_y1 = ext->ddlist.label->coords.y1 - roller->coords.y1;
|
||||
lv_coord_t label_unit = font_h + style_label->text.line_space;
|
||||
lv_coord_t mid = (roller->coords.y2 - roller->coords.y1) / 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user