Fix T61136: Header alignment preference has no effect

Users expect this to apply to existing files,
adjust this to apply on load, defaults to off.
This commit is contained in:
Campbell Barton 2019-02-06 21:15:39 +11:00
parent 18e67813cd
commit afd4bf8694
Notes: blender-bot 2023-02-14 03:51:38 +01:00
Referenced by issue #61244, Proposal: Remove bottom headers
Referenced by issue #61136, Header always on TOP, editors's preferences has no effect.
7 changed files with 46 additions and 9 deletions

View File

@ -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")

View File

@ -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

View File

@ -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;
}
}
}
}

View File

@ -455,7 +455,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
USER_FLAG_DEPRECATED_4);
userdef->uiflag &= ~(
USER_UIFLAG_DEPRECATED_8 |
USER_HEADER_FROM_PREF |
USER_UIFLAG_DEPRECATED_12 |
USER_UIFLAG_DEPRECATED_22);
}

View File

@ -477,6 +477,12 @@ void ED_screens_initialize(Main *bmain, wmWindowManager *wm)
ED_screen_set_active_region(NULL, win, &win->eventstate->x);
}
}
if (U.uiflag & USER_HEADER_FROM_PREF) {
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
BKE_screen_header_alignment_reset(screen);
}
}
}
void ED_screen_ensure_updated(wmWindowManager *wm, wmWindow *win, bScreen *screen)

View File

@ -872,7 +872,8 @@ 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 */
/** Otherwise use header alignment from the file. */
USER_HEADER_FROM_PREF = (1 << 8),
USER_MENUOPENAUTO = (1 << 9),
USER_DEPTH_CURSOR = (1 << 10),
USER_AUTOPERSP = (1 << 11),

View File

@ -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_FROM_PREF) {
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();
@ -3839,16 +3850,17 @@ static void rna_def_userdef_view(BlenderRNA *brna)
"Otherwise menus, etc will always be top to bottom, left to right, "
"no matter opening direction");
static const EnumPropertyItem header_align_default_items[] = {
{0, "TOP", 0, "Top", ""},
{USER_HEADER_BOTTOM, "BOTTOM", 0, "Bottom", ""},
static const EnumPropertyItem header_align_items[] = {
{0, "NONE", 0, "Default", "Keep existing header alignment"},
{USER_HEADER_FROM_PREF, "TOP", 0, "Top", "Top aligned on load"},
{USER_HEADER_FROM_PREF | USER_HEADER_BOTTOM, "BOTTOM", 0, "Bottom", "Bottom align on load (except for property editors)"},
{0, NULL, 0, NULL, NULL},
};
prop = RNA_def_property(srna, "header_align_default", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, header_align_default_items);
prop = RNA_def_property(srna, "header_align", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, header_align_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", ""},