[Bf-blender-cvs] [fc32bd729c5] blender2.8: UI: don't flip contents of popovers, avoid closing when size changes.

Brecht Van Lommel noreply at git.blender.org
Sun Apr 29 09:24:29 CEST 2018


Commit: fc32bd729c5b75088db5c7c6ad288a64e7dcf8a6
Author: Brecht Van Lommel
Date:   Sun Apr 29 08:45:57 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBfc32bd729c5b75088db5c7c6ad288a64e7dcf8a6

UI: don't flip contents of popovers, avoid closing when size changes.

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

M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_region_popover.c
M	source/blender/editors/interface/interface_region_popup.c

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

diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index c9ed3c36b22..a10321eb91e 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -572,6 +572,9 @@ struct uiPopupBlockHandle {
 	/* menu direction */
 	int direction;
 
+	/* previous rect for refresh */
+	rctf prev_block_rect;
+
 /* #ifdef USE_DRAG_POPUP */
 	bool is_grab;
 	int     grab_xy_prev[2];
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 845511b3279..f3a953cfc10 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -95,12 +95,8 @@ static void ui_popover_create_block(bContext *C, uiPopover *pup, int opcontext)
 			uiLayoutContextCopy(pup->layout, pup->but->context);
 		}
 	}
-	else {
-		/* Some enums reversing is strange, currently we have no good way to
-		 * reverse some enum's but not others, so reverse all so the first menu
-		 * items are always close to the mouse cursor. */
-		pup->block->flag |= UI_BLOCK_NO_FLIP;
-	}
+
+	pup->block->flag |= UI_BLOCK_NO_FLIP;
 }
 
 static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, void *arg_pup)
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c
index 94e6aa44811..f397c62920b 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.c
@@ -591,6 +591,17 @@ uiBlock *ui_popup_block_refresh(
 	else {
 		/* clip block with window boundary */
 		ui_popup_block_clip(window, block);
+
+		/* Avoid menu moving down and losing cursor focus by keeping it at
+		 * the same height. */
+		if (block_old && handle->prev_block_rect.ymax > block->rect.ymax) {
+			float offset = handle->prev_block_rect.ymax - block->rect.ymax;
+			ui_block_translate(block, 0, offset);
+			block->rect.ymin = handle->prev_block_rect.ymin;
+		}
+
+		handle->prev_block_rect = block->rect;
+
 		/* the block and buttons were positioned in window space as in 2.4x, now
 		 * these menu blocks are regions so we bring it back to region space.
 		 * additionally we add some padding for the menu shadow or rounded menus */



More information about the Bf-blender-cvs mailing list