diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-12-14 01:07:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-12-14 01:09:41 +0300 |
commit | 26c8e09cffd50375c62d3ed11d4045deaf3abc6b (patch) | |
tree | ba33f105ec918a395f9f91d0f3ea3cc77877c70d /source/blender/editors/screen/area.c | |
parent | cb6d018ec9496912943726a0c45829cf8b7c6696 (diff) |
Fix T59137: Prefs moves header to bottom
Only use a new spaces header alignment when no previous header exists.
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 42 |
1 files changed, 25 insertions, 17 deletions
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); } /** |