diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 8db0689ad9c..814e527cbc5 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -210,7 +210,7 @@ class USERPREF_PT_interface_editors(PreferencePanel): flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False) - flow.row().prop(view, "header_align_default", expand=True) + flow.row().prop(view, "header_align") flow.prop(system, "use_region_overlap") flow.prop(view, "show_layout_ui", text="Corner Splitting") flow.prop(view, "color_picker_type") diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 60cfc15a928..d064929848d 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -357,4 +357,6 @@ void BKE_screen_remove_double_scredges(struct bScreen *sc); void BKE_screen_remove_unused_scredges(struct bScreen *sc); void BKE_screen_remove_unused_scrverts(struct bScreen *sc); +void BKE_screen_header_alignment_reset(struct bScreen *screen); + #endif diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 2f1393e43d2..af3384d2023 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -846,3 +846,19 @@ bool BKE_screen_is_used(const bScreen *screen) { return (screen->winid != 0); } + +void BKE_screen_header_alignment_reset(bScreen *screen) +{ + int alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_HEADER) { + if (ELEM(sa->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_BUTS)) { + ar->alignment = RGN_ALIGN_TOP; + continue; + } + ar->alignment = alignment; + } + } + } +} diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 6fa86a06e06..2950af41e1f 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -459,7 +459,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) USER_FLAG_DEPRECATED_4); userdef->uiflag &= ~( - USER_UIFLAG_DEPRECATED_8 | + USER_HEADER_OVERRIDE | USER_UIFLAG_DEPRECATED_12 | USER_UIFLAG_DEPRECATED_22); } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 3acdf99a79f..0485a81d6c2 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -866,7 +866,7 @@ typedef enum eUserpref_UI_Flag { USER_PLAINMENUS = (1 << 5), USER_LOCK_CURSOR_ADJUST = (1 << 6), USER_HEADER_BOTTOM = (1 << 7), - USER_UIFLAG_DEPRECATED_8 = (1 << 8), /* cleared */ + USER_HEADER_OVERRIDE = (1 << 8), USER_MENUOPENAUTO = (1 << 9), USER_DEPTH_CURSOR = (1 << 10), USER_AUTOPERSP = (1 << 11), diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 578779e18f5..96441c208c8 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -101,6 +101,7 @@ static const EnumPropertyItem rna_enum_studio_light_type_items[] = { #include "BKE_mesh_runtime.h" #include "BKE_pbvh.h" #include "BKE_paint.h" +#include "BKE_screen.h" #include "DEG_depsgraph.h" @@ -152,6 +153,16 @@ static void rna_userdef_update_ui(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); /* refresh region sizes */ } +static void rna_userdef_update_ui_header_default(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + if (U.uiflag & USER_HEADER_OVERRIDE) { + for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { + BKE_screen_header_alignment_reset(screen); + } + } + rna_userdef_update_ui(bmain, scene, ptr); +} + static void rna_userdef_language_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { BLF_cache_clear(); @@ -3853,15 +3864,16 @@ static void rna_def_userdef_view(BlenderRNA *brna) "no matter opening direction"); static const EnumPropertyItem header_align_default_items[] = { - {0, "TOP", 0, "Top", ""}, - {USER_HEADER_BOTTOM, "BOTTOM", 0, "Bottom", ""}, + {0, "NONE", 0, "From File", ""}, + {USER_HEADER_OVERRIDE, "TOP", 0, "Top", ""}, + {USER_HEADER_OVERRIDE | USER_HEADER_BOTTOM, "BOTTOM", 0, "Bottom", ""}, {0, NULL, 0, NULL, NULL}, }; - prop = RNA_def_property(srna, "header_align_default", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "header_align", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, header_align_default_items); RNA_def_property_enum_bitflag_sdna(prop, NULL, "uiflag"); RNA_def_property_ui_text(prop, "Header Position", "Default header position for new space-types"); - RNA_def_property_update(prop, 0, "rna_userdef_update"); + RNA_def_property_update(prop, 0, "rna_userdef_update_ui_header_default"); static const EnumPropertyItem text_hinting_items[] = { {0, "AUTO", 0, "Auto", ""}, diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 2de21d756c6..ddc0986f7b8 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -488,6 +488,13 @@ static void wm_file_read_post( DEG_on_visible_update(bmain, true); wm_event_do_depsgraph(C); + if (U.uiflag & USER_HEADER_OVERRIDE) { + for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { + BKE_screen_header_alignment_reset(screen); + } + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + } + ED_editors_init(C); #ifdef WITH_PYTHON