Commit: 59bc71d69b138db12c9017c7a7d492fdb6dcddc3
Author: Campbell Barton
Date: Sun Aug 16 21:14:26 2020 +1000
Branches: blender-v2.90-release
https://developer.blender.org/rB59bc71d69b138db12c9017c7a7d492fdb6dcddc3
Fix popups opening in the wrong direction over headers
Checks for header alignment didn't account for tool-header & header
having different alignment.
There is no reason to use a lookup function on the area
(ED_area_header_alignment) as we already have region.
Check the regions alignment directly, remove access functions.
===================================================================
M source/blender/editors/include/ED_screen.h
M source/blender/editors/interface/interface_region_menu_popup.c
M source/blender/editors/interface/interface_region_popover.c
M source/blender/editors/screen/area.c
M source/blender/makesdna/DNA_screen_types.h
M source/blender/windowmanager/intern/wm_event_system.c
===================================================================
diff --git a/source/blender/editors/include/ED_screen.h
b/source/blender/editors/include/ED_screen.h
index 59567803f35..5a79e2de8d6 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -187,11 +187,7 @@ void ED_area_newspace(struct bContext *C, ScrArea *area,
int type, const bool sk
void ED_area_prevspace(struct bContext *C, ScrArea *area);
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_footersize(void);
-int ED_area_footer_alignment_or_fallback(const ScrArea *area, int fallback);
-int ED_area_footer_alignment(const ScrArea *area);
int ED_area_global_size_y(const ScrArea *area);
int ED_area_global_min_size_y(const ScrArea *area);
int ED_area_global_max_size_y(const ScrArea *area);
diff --git a/source/blender/editors/interface/interface_region_menu_popup.c
b/source/blender/editors/interface/interface_region_menu_popup.c
index 077e8888d53..dbb072fa4a6 100644
--- a/source/blender/editors/interface/interface_region_menu_popup.c
+++ b/source/blender/editors/interface/interface_region_menu_popup.c
@@ -284,17 +284,10 @@ static uiBlock *ui_block_func_POPUP(bContext *C,
uiPopupBlockHandle *handle, voi
else {
/* for a header menu we set the direction automatic */
if (!pup->slideout && flip) {
- ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
- if (area && region) {
- if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
- if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_header_alignment(area)) ==
RGN_ALIGN_BOTTOM) {
- UI_block_direction_set(block, UI_DIR_UP);
- UI_block_order_flip(block);
- }
- }
- if (region->regiontype == RGN_TYPE_FOOTER) {
- if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_footer_alignment(area)) ==
RGN_ALIGN_BOTTOM) {
+ if (region) {
+ if (RGN_TYPE_IS_HEADER_ANY(region->regiontype)) {
+ if (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_BOTTOM)
{
UI_block_direction_set(block, UI_DIR_UP);
UI_block_order_flip(block);
}
diff --git a/source/blender/editors/interface/interface_region_popover.c
b/source/blender/editors/interface/interface_region_popover.c
index 0ad7e570e80..18c31dde66f 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -171,7 +171,6 @@ static uiBlock *ui_block_func_POPOVER(bContext *C,
uiPopupBlockHandle *handle, v
}
if (!slideout) {
- ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
if (region && region->panels.first) {
@@ -180,14 +179,9 @@ static uiBlock *ui_block_func_POPOVER(bContext *C,
uiPopupBlockHandle *handle, v
UI_block_direction_set(block, UI_DIR_UP | UI_DIR_CENTER_X);
}
/* Prefer popover from header to be positioned into the editor. */
- else if (area && region) {
- if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
- if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_header_alignment(area)) ==
RGN_ALIGN_BOTTOM) {
- UI_block_direction_set(block, UI_DIR_UP | UI_DIR_CENTER_X);
- }
- }
- if (region->regiontype == RGN_TYPE_FOOTER) {
- if (RGN_ALIGN_ENUM_FROM_MASK(ED_area_footer_alignment(area)) ==
RGN_ALIGN_BOTTOM) {
+ else if (region) {
+ if (RGN_TYPE_IS_HEADER_ANY(region->regiontype)) {
+ if (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_BOTTOM)
{
UI_block_direction_set(block, UI_DIR_UP | UI_DIR_CENTER_X);
}
}
diff --git a/source/blender/editors/screen/area.c
b/source/blender/editors/screen/area.c
index 296fe24edcd..df33222ce37 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -3159,43 +3159,11 @@ int ED_area_headersize(void)
return U.widget_unit + (int)(UI_DPI_FAC * HEADER_PADDING_Y);
}
-int ED_area_header_alignment_or_fallback(const ScrArea *area, int fallback)
-{
- LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
- if (region->regiontype == RGN_TYPE_HEADER) {
- return region->alignment;
- }
- }
- return fallback;
-}
-
-int ED_area_header_alignment(const ScrArea *area)
-{
- return ED_area_header_alignment_or_fallback(
- area, (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM :
RGN_ALIGN_TOP);
-}
-
int ED_area_footersize(void)
{
return ED_area_headersize();
}
-int ED_area_footer_alignment_or_fallback(const ScrArea *area, int fallback)
-{
- LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
- if (region->regiontype == RGN_TYPE_FOOTER) {
- return region->alignment;
- }
- }
- return fallback;
-}
-
-int ED_area_footer_alignment(const ScrArea *area)
-{
- return ED_area_footer_alignment_or_fallback(
- area, (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP :
RGN_ALIGN_BOTTOM);
-}
-
/**
* \return the final height of a global \a area, accounting for DPI.
*/
diff --git a/source/blender/makesdna/DNA_screen_types.h
b/source/blender/makesdna/DNA_screen_types.h
index 60d6f85569c..7ff96c5a908 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -645,6 +645,11 @@ typedef enum eRegionType {
/* Region supports panel tabs (categories). */
#define RGN_TYPE_HAS_CATEGORY_MASK (1 << RGN_TYPE_UI)
+/* Check for any kind of header region. */
+#define RGN_TYPE_IS_HEADER_ANY(regiontype) \
+ (((1 << (regiontype)) & \
+ ((1 << RGN_TYPE_HEADER) | 1 << (RGN_TYPE_TOOL_HEADER) | (1 <<
RGN_TYPE_FOOTER))) != 0)
+
/** #ARegion.alignment */
enum {
RGN_ALIGN_NONE = 0,
diff --git a/source/blender/windowmanager/intern/wm_event_system.c
b/source/blender/windowmanager/intern/wm_event_system.c
index 8dbb608cd30..c14413e3d01 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1363,8 +1363,7 @@ static int wm_operator_invoke(bContext *C,
ScrArea *area = CTX_wm_area(C);
/* Wrap only in X for header. */
- if (region &&
- ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER,
RGN_TYPE_FOOTER)) {
+ if (region && RGN_TYPE_IS_HEADER_ANY(region->regiontype)) {
wrap = WM_CURSOR_WRAP_X;
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs