mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
minor fixes
This commit is contained in:
parent
44e502ecb3
commit
5b47f7b563
@ -572,7 +572,7 @@ bool lv_obj_handle_self_size_chg(struct _lv_obj_t * obj)
|
||||
{
|
||||
lv_coord_t w_set = lv_obj_get_style_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t h_set = lv_obj_get_style_height(obj, LV_PART_MAIN);
|
||||
if(w_set != LV_SIZE_CONTENT && h_set == LV_SIZE_CONTENT) return false;
|
||||
if(w_set != LV_SIZE_CONTENT && h_set != LV_SIZE_CONTENT) return false;
|
||||
|
||||
lv_obj_refr_size(obj);
|
||||
return true;
|
||||
|
@ -322,7 +322,7 @@ void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t
|
||||
|
||||
if(label->recolor != 0) flag |= LV_TEXT_FLAG_RECOLOR;
|
||||
if(label->expand != 0) flag |= LV_TEXT_FLAG_EXPAND;
|
||||
if(label->long_mode == LV_LABEL_LONG_WRAP) flag |= LV_TEXT_FLAG_FIT;
|
||||
if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT) flag |= LV_TEXT_FLAG_FIT;
|
||||
|
||||
uint32_t byte_id = _lv_txt_encoded_get_byte_id(txt, char_id);
|
||||
|
||||
@ -420,6 +420,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in)
|
||||
|
||||
if(label->recolor != 0) flag |= LV_TEXT_FLAG_RECOLOR;
|
||||
if(label->expand != 0) flag |= LV_TEXT_FLAG_EXPAND;
|
||||
if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT) flag |= LV_TEXT_FLAG_FIT;
|
||||
|
||||
lv_text_align_t align = lv_obj_get_style_text_align(obj, LV_PART_MAIN);
|
||||
|
||||
@ -538,6 +539,7 @@ bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos)
|
||||
|
||||
if(label->recolor != 0) flag |= LV_TEXT_FLAG_RECOLOR;
|
||||
if(label->expand != 0) flag |= LV_TEXT_FLAG_EXPAND;
|
||||
if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT) flag |= LV_TEXT_FLAG_FIT;
|
||||
|
||||
/*Search the line of the index letter*/;
|
||||
while(txt[line_start] != '\0') {
|
||||
@ -770,9 +772,11 @@ static void lv_label_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
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;
|
||||
if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT) flag |= LV_TEXT_FLAG_FIT;
|
||||
|
||||
lv_coord_t w = lv_obj_get_style_width(obj, LV_PART_MAIN);
|
||||
if(w == LV_SIZE_CONTENT) w = LV_COORD_MAX;
|
||||
else w = lv_obj_get_width(obj);
|
||||
|
||||
lv_txt_get_size(&size, label->text, font, letter_space, line_space, w, flag);
|
||||
|
||||
@ -809,6 +813,7 @@ static void draw_main(lv_event_t * e)
|
||||
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;
|
||||
if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT) flag |= LV_TEXT_FLAG_FIT;
|
||||
|
||||
lv_draw_label_dsc_t label_draw_dsc;
|
||||
lv_draw_label_dsc_init(&label_draw_dsc);
|
||||
@ -896,10 +901,12 @@ static void lv_label_refr_text(lv_obj_t * obj)
|
||||
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;
|
||||
if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT) flag |= LV_TEXT_FLAG_FIT;
|
||||
|
||||
lv_txt_get_size(&size, label->text, font, letter_space, line_space, max_w, flag);
|
||||
|
||||
lv_obj_handle_self_size_chg(obj)
|
||||
;
|
||||
lv_obj_handle_self_size_chg(obj);
|
||||
|
||||
/*In scroll mode start an offset animations*/
|
||||
if(label->long_mode == LV_LABEL_LONG_SCROLL) {
|
||||
uint16_t anim_speed = lv_obj_get_style_anim_speed(obj, LV_PART_MAIN);
|
||||
|
@ -405,7 +405,10 @@ void lv_textarea_set_cursor_pos(lv_obj_t * obj, int32_t pos)
|
||||
lv_obj_get_coords(ta->label, &label_cords);
|
||||
|
||||
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_SCROLLABLE)) {
|
||||
/*Check the top*/
|
||||
/*The text area needs to have it's final size to see if the cursor is out of the area or not*/
|
||||
lv_obj_update_layout(obj);
|
||||
|
||||
/*Check the top*/
|
||||
lv_coord_t font_h = lv_font_get_line_height(font);
|
||||
if(cur_pos.y < lv_obj_get_scroll_top(obj)) {
|
||||
lv_obj_scroll_to_y(obj, cur_pos.y, LV_ANIM_ON);
|
||||
@ -477,13 +480,14 @@ void lv_textarea_set_one_line(lv_obj_t * obj, bool en)
|
||||
lv_coord_t font_h = lv_font_get_line_height(font);
|
||||
|
||||
ta->one_line = 1;
|
||||
lv_obj_set_width(ta->label, LV_SIZE_CONTENT);
|
||||
|
||||
lv_obj_set_content_height(obj, font_h);
|
||||
lv_label_set_long_mode(ta->label, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_scroll_to(obj, 0, 0, LV_ANIM_OFF);
|
||||
}
|
||||
else {
|
||||
ta->one_line = 0;
|
||||
lv_label_set_long_mode(ta->label, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_width(ta->label, lv_pct(100));
|
||||
|
||||
lv_obj_set_height(obj, LV_DPI_DEF);
|
||||
lv_obj_scroll_to(obj, 0, 0, LV_ANIM_OFF);
|
||||
@ -809,8 +813,9 @@ static void lv_textarea_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
||||
ta->placeholder_txt = NULL;
|
||||
|
||||
ta->label = lv_label_create(obj);
|
||||
lv_label_set_long_mode(ta->label, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_width(ta->label, lv_pct(100));
|
||||
lv_label_set_text(ta->label, "");
|
||||
lv_label_set_long_mode(ta->label, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
|
||||
|
||||
start_cursor_blink(obj);
|
||||
@ -859,7 +864,6 @@ static void lv_textarea_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
else if(code == LV_EVENT_SIZE_CHANGED) {
|
||||
/*Set the label width according to the text area width*/
|
||||
if(ta->label) {
|
||||
lv_obj_set_width(ta->label, lv_obj_get_content_width(obj));
|
||||
lv_obj_set_pos(ta->label, 0, 0);
|
||||
lv_label_set_text(ta->label, NULL); /*Refresh the label*/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user