[Bf-blender-cvs] [26c8e09cffd] blender2.8: Fix T59137: Prefs moves header to bottom

Campbell Barton noreply at git.blender.org
Thu Dec 13 23:11:23 CET 2018


Commit: 26c8e09cffd50375c62d3ed11d4045deaf3abc6b
Author: Campbell Barton
Date:   Fri Dec 14 09:07:22 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB26c8e09cffd50375c62d3ed11d4045deaf3abc6b

Fix T59137: Prefs moves header to bottom

Only use a new spaces header alignment when no previous header exists.

===================================================================

M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/area.c

===================================================================

diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index a5660c43416..ce0c9468d1e 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -149,6 +149,7 @@ void    ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool s
 void    ED_area_prevspace(struct bContext *C, ScrArea *sa);
 void    ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2);
 int     ED_area_headersize(void);
+int     ED_area_header_alignment_or_fallback(const ScrArea *area, int fallback);
 int     ED_area_header_alignment(const ScrArea *area);
 int     ED_area_global_size_y(const ScrArea *area);
 int     ED_area_global_min_size_y(const ScrArea *area);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 3eecab46aa5..dd7b6fe5ce1 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1816,11 +1816,17 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
 		/* 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
+		 * 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
+		 *
+		 * Newly created windows wont have any space data, use the alignment
+		 * the space type defaults to in this case instead
+		 * (needed for preferences to have space-type on bottom).
 		 */
-		const bool sync_header_alignment = (sa->flag & AREA_FLAG_TEMP_TYPE) == 0;
-		int header_alignment = ED_area_header_alignment(sa);
+		int header_alignment = ED_area_header_alignment_or_fallback(sa, -1);
+		const bool sync_header_alignment = (
+		        (header_alignment != -1) &&
+		        (sa->flag & AREA_FLAG_TEMP_TYPE) == 0);
 
 		/* in some cases (opening temp space) we don't want to
 		 * call area exit callback, so we temporarily unset it */
@@ -1869,17 +1875,6 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
 			/* put in front of list */
 			BLI_remlink(&sa->spacedata, sl);
 			BLI_addhead(&sa->spacedata, sl);
-
-
-			/* Sync header alignment. */
-			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;
-					}
-				}
-			}
 		}
 		else {
 			/* new space */
@@ -1897,6 +1892,16 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
 			}
 		}
 
+		/* Sync header alignment. */
+		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;
+				}
+			}
+		}
+
 		ED_area_initialize(CTX_wm_manager(C), win, sa);
 
 		/* tell WM to refresh, cursor types etc */
@@ -2498,16 +2503,19 @@ int ED_area_headersize(void)
 	return (int)(HEADERY * UI_DPI_FAC);
 }
 
-
-int ED_area_header_alignment(const ScrArea *area)
+int ED_area_header_alignment_or_fallback(const ScrArea *area, int fallback)
 {
 	for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
 		if (ar->regiontype == RGN_TYPE_HEADER) {
 			return ar->alignment;
 		}
 	}
+	return fallback;
+}
 
-	return RGN_ALIGN_TOP;
+int ED_area_header_alignment(const ScrArea *area)
+{
+	return ED_area_header_alignment_or_fallback(area, RGN_ALIGN_TOP);
 }
 
 /**



More information about the Bf-blender-cvs mailing list