[Bf-blender-cvs] [8cb6ede2bf7] blender2.8: UI: locate popover w/ active item under cursor

Campbell Barton noreply at git.blender.org
Sun May 20 09:58:58 CEST 2018


Commit: 8cb6ede2bf78ae711077e3742fdb9b72e79a3b08
Author: Campbell Barton
Date:   Sun May 20 09:53:01 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB8cb6ede2bf78ae711077e3742fdb9b72e79a3b08

UI: locate popover w/ active item under cursor

Use when popover has no parent, useful for accessing the toolbar.

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

M	source/blender/editors/interface/interface_region_popover.c

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

diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 6be76572e0e..2f654b4f7cd 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -178,10 +178,23 @@ static uiBlock *ui_block_func_POPOVER(bContext *C, uiPopupBlockHandle *handle, v
 	}
 	else {
 		/* Not attached to a button. */
-		int offset[2] = {0, 0};  /* Dummy. */
+		int offset[2] = {0, 0};
 		UI_block_flag_enable(block, UI_BLOCK_LOOP);
 		UI_block_direction_set(block, block->direction);
 		block->minbounds = UI_MENU_WIDTH_MIN;
+
+		uiBut *but = NULL;
+		for (but = block->buttons.first; but; but = but->next) {
+			if (but->flag & (UI_SELECT | UI_SELECT_DRAW)) {
+				break;
+			}
+		}
+
+		if (but) {
+			offset[0] = -(but->rect.xmin + 0.8f * BLI_rctf_size_x(&but->rect));
+			offset[1] = -(but->rect.ymin + 0.5f * BLI_rctf_size_y(&but->rect));
+		}
+
 		UI_block_bounds_set_popup(block, block_margin, offset[0], offset[1]);
 	}



More information about the Bf-blender-cvs mailing list