Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-11-02 07:44:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-11-02 07:45:19 +0300
commit4a85089abe6d5abb9f6bb0d8255eba33dc030fcb (patch)
tree25459e54af9cf6712ca349b924319939ba853909 /source/blender/editors/interface/interface_regions.c
parentcf6e45b5224d16263d7c87411a2ff71ed928410f (diff)
parent765e28948e706d8fce97c23d4d050a607971488b (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/interface/interface_regions.c')
-rw-r--r--source/blender/editors/interface/interface_regions.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index aabb165b483..cd3aa2095b0 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2635,6 +2635,7 @@ struct uiPopupMenu {
uiBlock *block;
uiLayout *layout;
uiBut *but;
+ ARegion *butregion;
int mx, my;
bool popup, slideout;
@@ -2881,17 +2882,33 @@ uiPopupMenu *UI_popup_menu_begin(bContext *C, const char *title, int icon)
return UI_popup_menu_begin_ex(C, title, __func__, icon);
}
+/**
+ * Setting the button makes the popup open from the button instead of the cursor.
+ */
+void UI_popup_menu_but_set(uiPopupMenu *pup, struct ARegion *butregion, uiBut *but)
+{
+ pup->but = but;
+ pup->butregion = butregion;
+}
+
/* set the whole structure to work */
void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
{
wmWindow *window = CTX_wm_window(C);
uiPopupBlockHandle *menu;
+ uiBut *but = NULL;
+ ARegion *butregion = NULL;
pup->popup = true;
pup->mx = window->eventstate->x;
pup->my = window->eventstate->y;
-
- menu = ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_POPUP, pup);
+
+ if (pup->but) {
+ but = pup->but;
+ butregion = pup->butregion;
+ }
+
+ menu = ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup);
menu->popup = true;
UI_popup_handlers_add(C, &window->modalhandlers, menu, 0);