@@ -727,8 +727,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
727
727
LV_UNUSED (th );
728
728
729
729
my_theme_t * theme = theme_def ;
730
+ lv_obj_t * parent = lv_obj_get_parent (obj );
730
731
731
- if (lv_obj_get_parent ( obj ) == NULL ) {
732
+ if (parent == NULL ) {
732
733
lv_obj_add_style (obj , & theme -> styles .scr , 0 );
733
734
lv_obj_add_style (obj , & theme -> styles .scrollbar , LV_PART_SCROLLBAR );
734
735
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)
737
738
738
739
if (lv_obj_check_type (obj , & lv_obj_class )) {
739
740
#if LV_USE_TABVIEW
740
- lv_obj_t * parent = lv_obj_get_parent (obj );
741
741
/*Tabview content area*/
742
- if (parent && lv_obj_check_type (parent , & lv_tabview_class ) && lv_obj_get_index ( obj ) == 1 ) {
742
+ if (lv_obj_check_type (parent , & lv_tabview_class ) && lv_obj_get_child ( parent , 1 ) == obj ) {
743
743
return ;
744
744
}
745
745
/*Tabview button container*/
746
- else if (lv_obj_check_type (parent , & lv_tabview_class ) && lv_obj_get_index ( obj ) == 0 ) {
746
+ else if (lv_obj_check_type (parent , & lv_tabview_class ) && lv_obj_get_child ( parent , 0 ) == obj ) {
747
747
lv_obj_add_style (obj , & theme -> styles .bg_color_white , 0 );
748
748
lv_obj_add_style (obj , & theme -> styles .outline_primary , LV_STATE_FOCUS_KEY );
749
749
lv_obj_add_style (obj , & theme -> styles .tab_bg_focus , LV_STATE_FOCUS_KEY );
750
750
return ;
751
751
}
752
752
/*Tabview pages*/
753
- else if (parent && lv_obj_check_type (lv_obj_get_parent (parent ), & lv_tabview_class )) {
753
+ else if (lv_obj_check_type (lv_obj_get_parent (parent ), & lv_tabview_class )) {
754
754
lv_obj_add_style (obj , & theme -> styles .pad_normal , 0 );
755
755
lv_obj_add_style (obj , & theme -> styles .rotary_scroll , 0 );
756
756
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)
761
761
762
762
#if LV_USE_WIN
763
763
/*Header*/
764
- if (lv_obj_get_index ( obj ) == 0 && lv_obj_check_type ( lv_obj_get_parent ( obj ), & lv_win_class ) ) {
764
+ if (lv_obj_check_type ( parent , & lv_win_class ) && lv_obj_get_child ( parent , 0 ) == obj ) {
765
765
lv_obj_add_style (obj , & theme -> styles .bg_color_grey , 0 );
766
766
lv_obj_add_style (obj , & theme -> styles .pad_tiny , 0 );
767
767
return ;
768
768
}
769
769
/*Content*/
770
- else if (lv_obj_get_index ( obj ) == 1 && lv_obj_check_type ( lv_obj_get_parent ( obj ), & lv_win_class ) ) {
770
+ else if (lv_obj_check_type ( parent , & lv_win_class ) && lv_obj_get_child ( parent , 1 ) == obj ) {
771
771
lv_obj_add_style (obj , & theme -> styles .scr , 0 );
772
772
lv_obj_add_style (obj , & theme -> styles .pad_normal , 0 );
773
773
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)
777
777
#endif
778
778
779
779
#if LV_USE_CALENDAR
780
- if (lv_obj_check_type (lv_obj_get_parent ( obj ) , & lv_calendar_class )) {
780
+ if (lv_obj_check_type (parent , & lv_calendar_class )) {
781
781
/*No style*/
782
782
return ;
783
783
}
@@ -791,9 +791,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
791
791
else if (lv_obj_check_type (obj , & lv_button_class )) {
792
792
793
793
#if LV_USE_TABVIEW
794
- lv_obj_t * parent = lv_obj_get_parent (obj );
795
- if (parent && lv_obj_get_index ( parent ) == 0 ) { /*Tabview header*/
796
- if (lv_obj_check_type (lv_obj_get_parent ( parent ) , & lv_tabview_class )) {
794
+ lv_obj_t * tv = lv_obj_get_parent (parent ); /*parent is the tabview header*/
795
+ if (tv && lv_obj_get_child ( tv , 0 ) == parent ) { /*The button is on the tab view header*/
796
+ if (lv_obj_check_type (tv , & lv_tabview_class )) {
797
797
lv_obj_add_style (obj , & theme -> styles .pressed , LV_STATE_PRESSED );
798
798
lv_obj_add_style (obj , & theme -> styles .bg_color_primary_muted , LV_STATE_CHECKED );
799
799
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)
818
818
lv_obj_add_style (obj , & theme -> styles .disabled , LV_STATE_DISABLED );
819
819
820
820
#if LV_USE_MENU
821
- if (lv_obj_check_type (lv_obj_get_parent ( obj ) , & lv_menu_sidebar_header_cont_class ) ||
822
- lv_obj_check_type (lv_obj_get_parent ( obj ) , & lv_menu_main_header_cont_class )) {
821
+ if (lv_obj_check_type (parent , & lv_menu_sidebar_header_cont_class ) ||
822
+ lv_obj_check_type (parent , & lv_menu_main_header_cont_class )) {
823
823
lv_obj_add_style (obj , & theme -> styles .menu_header_btn , 0 );
824
824
lv_obj_add_style (obj , & theme -> styles .menu_pressed , LV_STATE_PRESSED );
825
825
}
@@ -837,7 +837,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
837
837
else if (lv_obj_check_type (obj , & lv_buttonmatrix_class )) {
838
838
839
839
#if LV_USE_CALENDAR
840
- if (lv_obj_check_type (lv_obj_get_parent ( obj ) , & lv_calendar_class )) {
840
+ if (lv_obj_check_type (parent , & lv_calendar_class )) {
841
841
lv_obj_add_style (obj , & theme -> styles .calendar_btnm_bg , 0 );
842
842
lv_obj_add_style (obj , & theme -> styles .outline_primary , LV_STATE_FOCUS_KEY );
843
843
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)
1152
1152
return ;
1153
1153
}
1154
1154
1155
- if (lv_obj_check_type (lv_obj_get_parent ( obj ) , & lv_msgbox_class )) {
1155
+ if (lv_obj_check_type (parent , & lv_msgbox_class )) {
1156
1156
lv_obj_add_style (obj , & theme -> styles .pad_tiny , 0 );
1157
1157
return ;
1158
1158
}
0 commit comments