Fix T57724: Opening file browser flips user-prefs header
authorCampbell Barton <ideasman42@gmail.com>
Thu, 13 Dec 2018 21:43:14 +0000 (08:43 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 13 Dec 2018 21:43:14 +0000 (08:43 +1100)
source/blender/editors/screen/area.c

index 85f46d86abc8f35298c4782177f4abb3a8b4a92e..3eecab46aa541eede983d898583b83723fe24c56 100644 (file)
@@ -1813,6 +1813,13 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
                SpaceLink *sl;
                /* store sa->type->exit callback */
                void *sa_exit = sa->type ? sa->type->exit : NULL;
+               /* When the user switches between space-types from the type-selector,
+                * changing the header-type is jarring (especially when using Ctrl-MouseWheel).
+                *
+                * However, add-on install for example -forces the header to the top which shouldn't
+                * be applied back to the previous space type when closing - see: T57724
+                */
+               const bool sync_header_alignment = (sa->flag & AREA_FLAG_TEMP_TYPE) == 0;
                int header_alignment = ED_area_header_alignment(sa);
 
                /* in some cases (opening temp space) we don't want to
@@ -1865,10 +1872,12 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
 
 
                        /* Sync header alignment. */
-                       for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
-                               if (ar->regiontype == RGN_TYPE_HEADER) {
-                                       ar->alignment = header_alignment;
-                                       break;
+                       if (sync_header_alignment) {
+                               for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
+                                       if (ar->regiontype == RGN_TYPE_HEADER) {
+                                               ar->alignment = header_alignment;
+                                               break;
+                                       }
                                }
                        }
                }