perf(theme): optimize the order of function calls (#5971)

This commit is contained in:
Gabor Kiss-Vamosi
2024-04-10 09:09:06 +02:00
committed by GitHub
parent 1f37da22db
commit 0143320f1f
3 changed files with 27 additions and 27 deletions
+15 -15
View File
@@ -727,8 +727,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
LV_UNUSED(th);
my_theme_t * theme = theme_def;
lv_obj_t * parent = lv_obj_get_parent(obj);
if(lv_obj_get_parent(obj) == NULL) {
if(parent == NULL) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
@@ -737,20 +738,19 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
if(lv_obj_check_type(obj, &lv_obj_class)) {
#if LV_USE_TABVIEW
lv_obj_t * parent = lv_obj_get_parent(obj);
/*Tabview content area*/
if(parent && lv_obj_check_type(parent, &lv_tabview_class) && lv_obj_get_index(obj) == 1) {
if(lv_obj_check_type(parent, &lv_tabview_class) && lv_obj_get_child(parent, 1) == obj) {
return;
}
/*Tabview button container*/
else if(lv_obj_check_type(parent, &lv_tabview_class) && lv_obj_get_index(obj) == 0) {
else if(lv_obj_check_type(parent, &lv_tabview_class) && lv_obj_get_child(parent, 0) == obj) {
lv_obj_add_style(obj, &theme->styles.bg_color_white, 0);
lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.tab_bg_focus, LV_STATE_FOCUS_KEY);
return;
}
/*Tabview pages*/
else if(parent && lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) {
else if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) {
lv_obj_add_style(obj, &theme->styles.pad_normal, 0);
lv_obj_add_style(obj, &theme->styles.rotary_scroll, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
@@ -761,13 +761,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#if LV_USE_WIN
/*Header*/
if(lv_obj_get_index(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
if(lv_obj_check_type(parent, &lv_win_class) && lv_obj_get_child(parent, 0) == obj) {
lv_obj_add_style(obj, &theme->styles.bg_color_grey, 0);
lv_obj_add_style(obj, &theme->styles.pad_tiny, 0);
return;
}
/*Content*/
else if(lv_obj_get_index(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
else if(lv_obj_check_type(parent, &lv_win_class) && lv_obj_get_child(parent, 1) == obj) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
lv_obj_add_style(obj, &theme->styles.pad_normal, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
@@ -777,7 +777,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#endif
#if LV_USE_CALENDAR
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_calendar_class)) {
if(lv_obj_check_type(parent, &lv_calendar_class)) {
/*No style*/
return;
}
@@ -791,9 +791,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
else if(lv_obj_check_type(obj, &lv_button_class)) {
#if LV_USE_TABVIEW
lv_obj_t * parent = lv_obj_get_parent(obj);
if(parent && lv_obj_get_index(parent) == 0) { /*Tabview header*/
if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) {
lv_obj_t * tv = lv_obj_get_parent(parent); /*parent is the tabview header*/
if(tv && lv_obj_get_child(tv, 0) == parent) { /*The button is on the tab view header*/
if(lv_obj_check_type(tv, &lv_tabview_class)) {
lv_obj_add_style(obj, &theme->styles.pressed, LV_STATE_PRESSED);
lv_obj_add_style(obj, &theme->styles.bg_color_primary_muted, LV_STATE_CHECKED);
lv_obj_add_style(obj, &theme->styles.tab_btn, LV_STATE_CHECKED);
@@ -818,8 +818,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
lv_obj_add_style(obj, &theme->styles.disabled, LV_STATE_DISABLED);
#if LV_USE_MENU
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_menu_sidebar_header_cont_class) ||
lv_obj_check_type(lv_obj_get_parent(obj), &lv_menu_main_header_cont_class)) {
if(lv_obj_check_type(parent, &lv_menu_sidebar_header_cont_class) ||
lv_obj_check_type(parent, &lv_menu_main_header_cont_class)) {
lv_obj_add_style(obj, &theme->styles.menu_header_btn, 0);
lv_obj_add_style(obj, &theme->styles.menu_pressed, LV_STATE_PRESSED);
}
@@ -837,7 +837,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
else if(lv_obj_check_type(obj, &lv_buttonmatrix_class)) {
#if LV_USE_CALENDAR
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_calendar_class)) {
if(lv_obj_check_type(parent, &lv_calendar_class)) {
lv_obj_add_style(obj, &theme->styles.calendar_btnm_bg, 0);
lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY);
lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED);
@@ -1152,7 +1152,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
return;
}
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) {
if(lv_obj_check_type(parent, &lv_msgbox_class)) {
lv_obj_add_style(obj, &theme->styles.pad_tiny, 0);
return;
}
+6 -6
View File
@@ -233,8 +233,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
LV_UNUSED(th);
my_theme_t * theme = theme_def;
lv_obj_t * parent = lv_obj_get_parent(obj);
if(lv_obj_get_parent(obj) == NULL) {
if(parent == NULL) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
@@ -242,7 +243,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
if(lv_obj_check_type(obj, &lv_obj_class)) {
#if LV_USE_TABVIEW
lv_obj_t * parent = lv_obj_get_parent(obj);
/*Tabview content area*/
if(lv_obj_check_type(parent, &lv_tabview_class)) {
return;
@@ -258,13 +258,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#if LV_USE_WIN
/*Header*/
if(lv_obj_get_index(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
if(lv_obj_check_type(parent, &lv_win_class) && lv_obj_get_child(parent, 0) == 0) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.no_radius, 0);
return;
}
/*Content*/
else if(lv_obj_get_index(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
else if(lv_obj_check_type(parent, &lv_win_class) && lv_obj_get_child(parent, 1) == obj) {
lv_obj_add_style(obj, &theme->styles.card, 0);
lv_obj_add_style(obj, &theme->styles.no_radius, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
@@ -288,7 +288,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#if LV_USE_BUTTONMATRIX
else if(lv_obj_check_type(obj, &lv_buttonmatrix_class)) {
#if LV_USE_MSGBOX
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) {
if(lv_obj_check_type(parent, &lv_msgbox_class)) {
lv_obj_add_style(obj, &theme->styles.pad_gap, 0);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED);
@@ -299,7 +299,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
}
#endif
#if LV_USE_TABVIEW
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) {
if(lv_obj_check_type(parent, &lv_tabview_class)) {
lv_obj_add_style(obj, &theme->styles.pad_gap, 0);
lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS);
lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED);
+6 -6
View File
@@ -206,8 +206,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
LV_UNUSED(th);
my_theme_t * theme = theme_def;
lv_obj_t * parent = lv_obj_get_parent(obj);
if(lv_obj_get_parent(obj) == NULL) {
if(parent == NULL) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
@@ -215,7 +216,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
if(lv_obj_check_type(obj, &lv_obj_class)) {
#if LV_USE_TABVIEW
lv_obj_t * parent = lv_obj_get_parent(obj);
/*Tabview content area*/
if(lv_obj_check_type(parent, &lv_tabview_class)) {
lv_obj_add_style(obj, &theme->styles.scr, 0);
@@ -231,12 +231,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#if LV_USE_WIN
/*Header*/
if(lv_obj_get_index(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
if(lv_obj_check_type(parent, &lv_win_class) && lv_obj_get_child(parent, 0) == obj) {
lv_obj_add_style(obj, &theme->styles.light, 0);
return;
}
/*Content*/
else if(lv_obj_get_index(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
else if(lv_obj_check_type(parent, &lv_win_class) && lv_obj_get_child(parent, 1) == obj) {
lv_obj_add_style(obj, &theme->styles.light, 0);
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
return;
@@ -254,13 +254,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#if LV_USE_BUTTONMATRIX
else if(lv_obj_check_type(obj, &lv_buttonmatrix_class)) {
#if LV_USE_MSGBOX
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) {
if(lv_obj_check_type(parent, &lv_msgbox_class)) {
lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS);
return;
}
#endif
#if LV_USE_TABVIEW
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) {
if(lv_obj_check_type(parent, &lv_tabview_class)) {
lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS);
return;
}