This commit is contained in:
Gabor Kiss-Vamosi
2021-05-05 17:16:35 +02:00
8 changed files with 46 additions and 67 deletions
-1
View File
@@ -55,7 +55,6 @@ menu "LVGL configuration"
config LV_COLOR_CHROMA_KEY_HEX config LV_COLOR_CHROMA_KEY_HEX
hex "Images pixels with this color will not be drawn (if they are chroma keyed)." hex "Images pixels with this color will not be drawn (if they are chroma keyed)."
depends on LV_COLOR_SCREEN_TRANSP
range 0x000000 0xFFFFFF range 0x000000 0xFFFFFF
default 0x00FF00 default 0x00FF00
help help
+6 -22
View File
@@ -685,19 +685,17 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED | LV_STATE_FOCUS_KEY); lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED | LV_STATE_FOCUS_KEY);
} }
else if(code == LV_EVENT_SIZE_CHANGED) { else if(code == LV_EVENT_SIZE_CHANGED) {
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
lv_obj_refr_size(child);
lv_obj_refr_pos(child);
}
lv_coord_t align = lv_obj_get_style_align(obj, LV_PART_MAIN); lv_coord_t align = lv_obj_get_style_align(obj, LV_PART_MAIN);
uint16_t layout = lv_obj_get_style_layout(obj, LV_PART_MAIN); uint16_t layout = lv_obj_get_style_layout(obj, LV_PART_MAIN);
if(layout || align) { if(layout || align) {
lv_obj_mark_layout_as_dirty(obj); lv_obj_mark_layout_as_dirty(obj);
} }
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
lv_obj_mark_layout_as_dirty(child);
}
} }
else if(code == LV_EVENT_CHILD_CHANGED) { else if(code == LV_EVENT_CHILD_CHANGED) {
lv_coord_t w = lv_obj_get_style_width(obj, LV_PART_MAIN); lv_coord_t w = lv_obj_get_style_width(obj, LV_PART_MAIN);
@@ -723,20 +721,6 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
lv_coord_t d = lv_obj_calculate_ext_draw_size(obj, LV_PART_MAIN); lv_coord_t d = lv_obj_calculate_ext_draw_size(obj, LV_PART_MAIN);
*s = LV_MAX(*s, d); *s = LV_MAX(*s, d);
} }
else if(code == LV_EVENT_STYLE_CHANGED) {
/*Padding might have changed so the layout should be recalculated*/
uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
lv_obj_t * child = lv_obj_get_child(obj, i);
lv_obj_refr_size(child);
lv_obj_refr_pos(child);
}
lv_obj_mark_layout_as_dirty(obj);
lv_obj_refresh_ext_draw_size(obj);
}
else if(code == LV_EVENT_DRAW_MAIN || code == LV_EVENT_DRAW_POST || code == LV_EVENT_COVER_CHECK) { else if(code == LV_EVENT_DRAW_MAIN || code == LV_EVENT_DRAW_POST || code == LV_EVENT_COVER_CHECK) {
lv_obj_draw(e); lv_obj_draw(e);
} }
-1
View File
@@ -164,7 +164,6 @@ typedef struct _lv_obj_t {
void * user_data; void * user_data;
#endif #endif
lv_area_t coords; lv_area_t coords;
lv_point_t self_size;
lv_obj_flag_t flags; lv_obj_flag_t flags;
lv_state_t state; lv_state_t state;
uint16_t layout_inv :1; uint16_t layout_inv :1;
+12 -9
View File
@@ -87,6 +87,7 @@ void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y)
bool lv_obj_refr_size(lv_obj_t * obj) bool lv_obj_refr_size(lv_obj_t * obj)
{ {
LV_ASSERT_OBJ(obj, MY_CLASS); LV_ASSERT_OBJ(obj, MY_CLASS);
/*If the width or height is set by a layout do not modify them*/ /*If the width or height is set by a layout do not modify them*/
@@ -190,7 +191,6 @@ bool lv_obj_refr_size(lv_obj_t * obj)
/*Invalidate the new area*/ /*Invalidate the new area*/
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
/*Be sure the bottom side is not remains scrolled in*/ /*Be sure the bottom side is not remains scrolled in*/
/*With snapping the content can't be scrolled in*/ /*With snapping the content can't be scrolled in*/
if(lv_obj_get_scroll_snap_y(obj) == LV_SCROLL_SNAP_NONE) { if(lv_obj_get_scroll_snap_y(obj) == LV_SCROLL_SNAP_NONE) {
@@ -592,22 +592,25 @@ void lv_obj_get_content_coords(const lv_obj_t * obj, lv_area_t * area)
lv_coord_t lv_obj_get_self_width(struct _lv_obj_t * obj) lv_coord_t lv_obj_get_self_width(struct _lv_obj_t * obj)
{ {
return obj->self_size.x; lv_point_t p = {0, LV_COORD_MIN};
lv_event_send((lv_obj_t * )obj, LV_EVENT_REFR_SELF_SIZE, &p);
return p.x;
} }
lv_coord_t lv_obj_get_self_height(struct _lv_obj_t * obj) lv_coord_t lv_obj_get_self_height(struct _lv_obj_t * obj)
{ {
return obj->self_size.y; lv_point_t p = {LV_COORD_MIN, 0};
lv_event_send((lv_obj_t * )obj, LV_EVENT_REFR_SELF_SIZE, &p);
return p.y;
} }
bool lv_obj_refresh_self_size(struct _lv_obj_t * obj) bool lv_obj_refresh_self_size(struct _lv_obj_t * obj)
{ {
lv_obj_update_layout(obj); lv_coord_t w_set = lv_obj_get_style_width(obj, LV_PART_MAIN);
obj->self_size.x = 0; lv_coord_t h_set = lv_obj_get_style_height(obj, LV_PART_MAIN);
obj->self_size.y = 0; if(w_set != LV_SIZE_CONTENT && h_set != LV_SIZE_CONTENT) return false;
lv_event_send(obj, LV_EVENT_REFR_SELF_SIZE, &obj->self_size);
lv_obj_refr_size(obj); lv_obj_mark_layout_as_dirty(obj);
return true; return true;
} }
@@ -944,7 +947,7 @@ static void layout_update_core(lv_obj_t * obj)
if(obj->layout_inv == 0) return; if(obj->layout_inv == 0) return;
if(lv_obj_get_screen(obj) != obj) obj->layout_inv = 0; obj->layout_inv = 0;
lv_obj_refr_size(obj); lv_obj_refr_size(obj);
lv_obj_refr_pos(obj); lv_obj_refr_pos(obj);
+4 -4
View File
@@ -173,14 +173,15 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style
lv_part_t part = lv_obj_style_get_selector_part(selector); lv_part_t part = lv_obj_style_get_selector_part(selector);
if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ANY || (prop & LV_STYLE_PROP_LAYOUT_REFR))) { if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ANY || (prop & LV_STYLE_PROP_LAYOUT_REFR))) {
lv_event_send(obj, LV_EVENT_STYLE_CHANGED, NULL); /*To update layout*/ lv_event_send(obj, LV_EVENT_STYLE_CHANGED, NULL);
if(obj->parent) obj->parent->layout_inv = 1; lv_obj_mark_layout_as_dirty(obj);
} }
if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ANY || (prop & LV_STYLE_PROP_PARENT_LAYOUT_REFR))) { if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ANY || (prop & LV_STYLE_PROP_PARENT_LAYOUT_REFR))) {
lv_obj_t * parent = lv_obj_get_parent(obj); lv_obj_t * parent = lv_obj_get_parent(obj);
if(parent) lv_obj_mark_layout_as_dirty(parent); if(parent) lv_obj_mark_layout_as_dirty(parent);
} }
else if(prop & LV_STYLE_PROP_EXT_DRAW) {
if(prop == LV_STYLE_PROP_ANY || (prop & LV_STYLE_PROP_EXT_DRAW)) {
lv_obj_refresh_ext_draw_size(obj); lv_obj_refresh_ext_draw_size(obj);
} }
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
@@ -791,7 +792,6 @@ static void trans_anim_ready_cb(lv_anim_t * a)
if(lv_style_is_empty(obj->styles[i].style)) { if(lv_style_is_empty(obj->styles[i].style)) {
lv_obj_remove_style(obj, obj_style->style, obj_style->selector); lv_obj_remove_style(obj, obj_style->style, obj_style->selector);
//trans_del(obj, obj_style->part, prop, NULL);
} }
break; break;
+4 -1
View File
@@ -362,7 +362,10 @@ static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, i
if(grow_size) { if(grow_size) {
lv_coord_t s = 0; lv_coord_t s = 0;
for(i = 0; i < t->grow_item_cnt; i++) { for(i = 0; i < t->grow_item_cnt; i++) {
if(t->grow_dsc[i].item == item) s = t->grow_dsc[i].final_size; if(t->grow_dsc[i].item == item) {
s = t->grow_dsc[i].final_size;
break;
}
} }
lv_area_t old_coords; lv_area_t old_coords;
lv_area_copy(&old_coords, &item->coords); lv_area_copy(&old_coords, &item->coords);
+1 -1
View File
@@ -643,7 +643,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
} }
#if LV_USE_BTN #if LV_USE_BTN
else if(lv_obj_check_type(obj, &lv_btn_class)) { else if(lv_obj_check_type(obj, &lv_btn_class)) {
lv_obj_add_style(obj, &styles->btn, 0); lv_obj_add_style(obj, &styles->btn, 0);
lv_obj_add_style(obj, &styles->bg_color_primary, 0); lv_obj_add_style(obj, &styles->bg_color_primary, 0);
+19 -28
View File
@@ -46,7 +46,6 @@ static void lv_label_revert_dots(lv_obj_t * label);
static bool lv_label_set_dot_tmp(lv_obj_t * label, char * data, uint32_t len); static bool lv_label_set_dot_tmp(lv_obj_t * label, char * data, uint32_t len);
static char * lv_label_get_dot_tmp(lv_obj_t * label); static char * lv_label_get_dot_tmp(lv_obj_t * label);
static void lv_label_dot_tmp_free(lv_obj_t * label); static void lv_label_dot_tmp_free(lv_obj_t * label);
static void get_txt_coords(const lv_obj_t * label, lv_area_t * area);
static void set_ofs_x_anim(void * obj, int32_t v); static void set_ofs_x_anim(void * obj, int32_t v);
static void set_ofs_y_anim(void * obj, int32_t v); static void set_ofs_y_anim(void * obj, int32_t v);
@@ -307,7 +306,7 @@ void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t
} }
lv_area_t txt_coords; lv_area_t txt_coords;
get_txt_coords(obj, &txt_coords); lv_obj_get_content_coords(obj, &txt_coords);
lv_label_t * label = (lv_label_t *)obj; lv_label_t * label = (lv_label_t *)obj;
uint32_t line_start = 0; uint32_t line_start = 0;
@@ -404,7 +403,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in)
pos.y = pos_in->y - lv_obj_get_style_pad_top(obj, LV_PART_MAIN); pos.y = pos_in->y - lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
lv_area_t txt_coords; lv_area_t txt_coords;
get_txt_coords(obj, &txt_coords); lv_obj_get_content_coords(obj, &txt_coords);
const char * txt = lv_label_get_text(obj); const char * txt = lv_label_get_text(obj);
uint32_t line_start = 0; uint32_t line_start = 0;
uint32_t new_line_start = 0; uint32_t new_line_start = 0;
@@ -523,7 +522,7 @@ bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos)
LV_ASSERT_NULL(pos); LV_ASSERT_NULL(pos);
lv_area_t txt_coords; lv_area_t txt_coords;
get_txt_coords(obj, &txt_coords); lv_obj_get_content_coords(obj, &txt_coords);
const char * txt = lv_label_get_text(obj); const char * txt = lv_label_get_text(obj);
lv_label_t * label = (lv_label_t*)obj; lv_label_t * label = (lv_label_t*)obj;
uint32_t line_start = 0; uint32_t line_start = 0;
@@ -772,11 +771,10 @@ 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; lv_text_flag_t flag = LV_TEXT_FLAG_NONE;
if(label->recolor != 0) flag |= LV_TEXT_FLAG_RECOLOR; if(label->recolor != 0) flag |= LV_TEXT_FLAG_RECOLOR;
if(label->expand != 0) flag |= LV_TEXT_FLAG_EXPAND; if(label->expand != 0) flag |= LV_TEXT_FLAG_EXPAND;
if(lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT && !obj->w_layout) flag |= LV_TEXT_FLAG_FIT;
lv_coord_t w = lv_obj_get_style_width(obj, LV_PART_MAIN); lv_coord_t w = lv_obj_get_content_width(obj);
if(flag & LV_TEXT_FLAG_FIT) w = LV_COORD_MAX; 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_width(obj); else w = lv_obj_get_content_width(obj);
lv_txt_get_size(&size, label->text, font, letter_space, line_space, w, flag); lv_txt_get_size(&size, label->text, font, letter_space, line_space, w, flag);
@@ -803,11 +801,7 @@ static void draw_main(lv_event_t * e)
const lv_area_t * clip_area = lv_event_get_param(e); const lv_area_t * clip_area = lv_event_get_param(e);
lv_area_t txt_coords; lv_area_t txt_coords;
get_txt_coords(obj, &txt_coords); lv_obj_get_content_coords(obj, &txt_coords);
lv_area_t txt_clip;
bool is_common = _lv_area_intersect(&txt_clip, clip_area, &txt_coords);
if(!is_common) return;
lv_text_align_t align = lv_obj_get_style_text_align(obj, LV_PART_MAIN); lv_text_align_t align = lv_obj_get_style_text_align(obj, LV_PART_MAIN);
lv_text_flag_t flag = LV_TEXT_FLAG_NONE; lv_text_flag_t flag = LV_TEXT_FLAG_NONE;
@@ -820,6 +814,7 @@ static void draw_main(lv_event_t * e)
label_draw_dsc.ofs_x = label->offset.x; label_draw_dsc.ofs_x = label->offset.x;
label_draw_dsc.ofs_y = label->offset.y; label_draw_dsc.ofs_y = label->offset.y;
label_draw_dsc.flag = flag; label_draw_dsc.flag = flag;
lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_draw_dsc); lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_draw_dsc);
@@ -851,6 +846,16 @@ static void draw_main(lv_event_t * e)
lv_draw_label_hint_t * hint = NULL; lv_draw_label_hint_t * hint = NULL;
#endif #endif
lv_area_t txt_clip;
bool is_common = _lv_area_intersect(&txt_clip, clip_area, clip_area);
if(!is_common) return;
if(label->long_mode == LV_LABEL_LONG_WRAP) {
lv_coord_t s = lv_obj_get_scroll_top(obj);
lv_area_move(&txt_coords, 0, -s);
txt_coords.y2 = obj->coords.y2;
}
lv_draw_label(&txt_coords, &txt_clip, &label_draw_dsc, label->text, hint); lv_draw_label(&txt_coords, &txt_clip, &label_draw_dsc, label->text, hint);
if(label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR) { if(label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR) {
@@ -890,7 +895,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
#endif #endif
lv_area_t txt_coords; lv_area_t txt_coords;
get_txt_coords(obj, &txt_coords); lv_obj_get_content_coords(obj, &txt_coords);
lv_coord_t max_w = lv_area_get_width(&txt_coords); lv_coord_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_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 line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
@@ -1226,20 +1231,6 @@ static void lv_label_dot_tmp_free(lv_obj_t * obj)
label->dot.tmp_ptr = NULL; label->dot.tmp_ptr = NULL;
} }
static void get_txt_coords(const lv_obj_t * obj, lv_area_t * area)
{
lv_obj_get_coords(obj, area);
lv_coord_t left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
area->x1 += left;
area->x2 -= right;
area->y1 += top;
area->y2 -= bottom;
}
static void set_ofs_x_anim(void * obj, int32_t v) static void set_ofs_x_anim(void * obj, int32_t v)
{ {