2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2008 Blender Foundation.
19 * All rights reserved.
21 * Contributor(s): Blender Foundation
23 * ***** END GPL LICENSE BLOCK *****
26 /** \file blender/editors/interface/interface_region_popup.c
27 * \ingroup edinterface
29 * PopUp Region (Generic)
37 #include "MEM_guardedalloc.h"
39 #include "DNA_userdef_types.h"
42 #include "BLI_listbase.h"
44 #include "BLI_utildefines.h"
46 #include "BKE_context.h"
47 #include "BKE_screen.h"
52 #include "UI_interface.h"
54 #include "ED_screen.h"
56 #include "interface_intern.h"
57 #include "interface_regions_intern.h"
59 /* -------------------------------------------------------------------- */
60 /** \name Utility Functions
64 * Translate any popup regions (so we can drag them).
66 void ui_popup_translate(ARegion *ar, const int mdiff[2])
70 BLI_rcti_translate(&ar->winrct, UNPACK2(mdiff));
72 ED_region_update_rect(ar);
74 ED_region_tag_redraw(ar);
77 for (block = ar->uiblocks.first; block; block = block->next) {
79 for (saferct = block->saferct.first; saferct; saferct = saferct->next) {
80 BLI_rctf_translate(&saferct->parent, UNPACK2(mdiff));
81 BLI_rctf_translate(&saferct->safety, UNPACK2(mdiff));
86 /* position block relative to but, result is in window space */
87 static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut *but, uiBlock *block)
89 uiPopupBlockHandle *handle = block->handle;
91 /* Compute button position in window coordinates using the source
92 * button region/block, to position the popup attached to it. */
95 if (!handle->refresh) {
96 ui_block_to_window_rctf(butregion, but->block, &butrct, &but->rect);
98 /* widget_roundbox_set has this correction too, keep in sync */
99 if (but->type != UI_BTYPE_PULLDOWN) {
100 if (but->drawflag & UI_BUT_ALIGN_TOP)
101 butrct.ymax += U.pixelsize;
102 if (but->drawflag & UI_BUT_ALIGN_LEFT)
103 butrct.xmin -= U.pixelsize;
106 handle->prev_butrct = butrct;
109 /* For refreshes, keep same button position so popup doesn't move. */
110 butrct = handle->prev_butrct;
113 /* Compute block size in window space, based on buttons contained in it. */
114 if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) {
115 if (block->buttons.first) {
116 BLI_rctf_init_minmax(&block->rect);
118 for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
119 if (block->content_hints & UI_BLOCK_CONTAINS_SUBMENU_BUT) {
120 bt->rect.xmax += UI_MENU_SUBMENU_PADDING;
122 BLI_rctf_union(&block->rect, &bt->rect);
126 /* we're nice and allow empty blocks too */
127 block->rect.xmin = block->rect.ymin = 0;
128 block->rect.xmax = block->rect.ymax = 20;
132 ui_block_to_window_rctf(butregion, but->block, &block->rect, &block->rect);
134 /* Compute direction relative to button, based on available space. */
135 const int size_x = BLI_rctf_size_x(&block->rect) + 0.2f * UI_UNIT_X; /* 4 for shadow */
136 const int size_y = BLI_rctf_size_y(&block->rect) + 0.2f * UI_UNIT_Y;
137 const int center_x = (block->direction & UI_DIR_CENTER_X) ? size_x / 2 : 0;
138 const int center_y = (block->direction & UI_DIR_CENTER_Y) ? size_y / 2 : 0;
140 short dir1 = 0, dir2 = 0;
142 if (!handle->refresh) {
143 bool left = 0, right = 0, top = 0, down = 0;
145 const int win_x = WM_window_pixels_x(window);
146 const int win_y = WM_window_pixels_y(window);
148 /* Take into account maximum size so we don't have to flip on refresh. */
149 const float max_size_x = max_ff(size_x, handle->max_size_x);
150 const float max_size_y = max_ff(size_y, handle->max_size_y);
152 /* check if there's space at all */
153 if (butrct.xmin - max_size_x + center_x > 0.0f) left = 1;
154 if (butrct.xmax + max_size_x - center_x < win_x) right = 1;
155 if (butrct.ymin - max_size_y + center_y > 0.0f) down = 1;
156 if (butrct.ymax + max_size_y - center_y < win_y) top = 1;
158 if (top == 0 && down == 0) {
159 if (butrct.ymin - max_size_y < win_y - butrct.ymax - max_size_y)
165 dir1 = (block->direction & UI_DIR_ALL);
167 /* Secondary directions. */
168 if (dir1 & (UI_DIR_UP | UI_DIR_DOWN)) {
169 if (dir1 & UI_DIR_LEFT) dir2 = UI_DIR_LEFT;
170 else if (dir1 & UI_DIR_RIGHT) dir2 = UI_DIR_RIGHT;
171 dir1 &= (UI_DIR_UP | UI_DIR_DOWN);
174 if ((dir2 == 0) && (dir1 == UI_DIR_LEFT || dir1 == UI_DIR_RIGHT)) dir2 = UI_DIR_DOWN;
175 if ((dir2 == 0) && (dir1 == UI_DIR_UP || dir1 == UI_DIR_DOWN)) dir2 = UI_DIR_LEFT;
177 /* no space at all? don't change */
179 if (dir1 == UI_DIR_LEFT && left == 0) dir1 = UI_DIR_RIGHT;
180 if (dir1 == UI_DIR_RIGHT && right == 0) dir1 = UI_DIR_LEFT;
181 /* this is aligning, not append! */
182 if (dir2 == UI_DIR_LEFT && right == 0) dir2 = UI_DIR_RIGHT;
183 if (dir2 == UI_DIR_RIGHT && left == 0) dir2 = UI_DIR_LEFT;
186 if (dir1 == UI_DIR_UP && top == 0) dir1 = UI_DIR_DOWN;
187 if (dir1 == UI_DIR_DOWN && down == 0) dir1 = UI_DIR_UP;
188 BLI_assert(dir2 != UI_DIR_UP);
189 // if (dir2 == UI_DIR_UP && top == 0) dir2 = UI_DIR_DOWN;
190 if (dir2 == UI_DIR_DOWN && down == 0) dir2 = UI_DIR_UP;
193 handle->prev_dir1 = dir1;
194 handle->prev_dir2 = dir2;
197 /* For refreshes, keep same popup direct so popup doesn't move
198 * to a totally different position while editing in it. */
199 dir1 = handle->prev_dir1;
200 dir2 = handle->prev_dir2;
203 /* Compute offset based on direction. */
204 int offset_x = 0, offset_y = 0;
206 if (dir1 == UI_DIR_LEFT) {
207 offset_x = butrct.xmin - block->rect.xmax;
208 if (dir2 == UI_DIR_UP) offset_y = butrct.ymin - block->rect.ymin - center_y - MENU_PADDING;
209 else offset_y = butrct.ymax - block->rect.ymax + center_y + MENU_PADDING;
211 else if (dir1 == UI_DIR_RIGHT) {
212 offset_x = butrct.xmax - block->rect.xmin;
213 if (dir2 == UI_DIR_UP) offset_y = butrct.ymin - block->rect.ymin - center_y - MENU_PADDING;
214 else offset_y = butrct.ymax - block->rect.ymax + center_y + MENU_PADDING;
216 else if (dir1 == UI_DIR_UP) {
217 offset_y = butrct.ymax - block->rect.ymin;
218 if (dir2 == UI_DIR_RIGHT) offset_x = butrct.xmax - block->rect.xmax + center_x;
219 else offset_x = butrct.xmin - block->rect.xmin - center_x;
220 /* changed direction? */
221 if ((dir1 & block->direction) == 0) {
223 UI_block_order_flip(block);
226 else if (dir1 == UI_DIR_DOWN) {
227 offset_y = butrct.ymin - block->rect.ymax;
228 if (dir2 == UI_DIR_RIGHT) offset_x = butrct.xmax - block->rect.xmax + center_x;
229 else offset_x = butrct.xmin - block->rect.xmin - center_x;
230 /* changed direction? */
231 if ((dir1 & block->direction) == 0) {
233 UI_block_order_flip(block);
237 /* Center over popovers for eg. */
238 if (block->direction & UI_DIR_CENTER_X) {
239 offset_x += BLI_rctf_size_x(&butrct) / ((dir2 == UI_DIR_LEFT) ? 2 : - 2);
242 /* Apply offset, buttons in window coords. */
243 for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
244 ui_block_to_window_rctf(butregion, but->block, &bt->rect, &bt->rect);
246 BLI_rctf_translate(&bt->rect, offset_x, offset_y);
248 /* ui_but_update recalculates drawstring size in pixels */
252 BLI_rctf_translate(&block->rect, offset_x, offset_y);
254 /* Safety calculus. */
256 const float midx = BLI_rctf_cent_x(&butrct);
257 const float midy = BLI_rctf_cent_y(&butrct);
259 /* when you are outside parent button, safety there should be smaller */
261 /* parent button to left */
262 if (midx < block->rect.xmin) block->safety.xmin = block->rect.xmin - 3;
263 else block->safety.xmin = block->rect.xmin - 40;
264 /* parent button to right */
265 if (midx > block->rect.xmax) block->safety.xmax = block->rect.xmax + 3;
266 else block->safety.xmax = block->rect.xmax + 40;
268 /* parent button on bottom */
269 if (midy < block->rect.ymin) block->safety.ymin = block->rect.ymin - 3;
270 else block->safety.ymin = block->rect.ymin - 40;
271 /* parent button on top */
272 if (midy > block->rect.ymax) block->safety.ymax = block->rect.ymax + 3;
273 else block->safety.ymax = block->rect.ymax + 40;
275 /* exception for switched pulldowns... */
276 if (dir1 && (dir1 & block->direction) == 0) {
277 if (dir2 == UI_DIR_RIGHT) block->safety.xmax = block->rect.xmax + 3;
278 if (dir2 == UI_DIR_LEFT) block->safety.xmin = block->rect.xmin - 3;
280 block->direction = dir1;
283 /* keep a list of these, needed for pulldown menus */
284 uiSafetyRct *saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
285 saferct->parent = butrct;
286 saferct->safety = block->safety;
287 BLI_freelistN(&block->saferct);
288 BLI_duplicatelist(&block->saferct, &but->block->saferct);
289 BLI_addhead(&block->saferct, saferct);
294 /* -------------------------------------------------------------------- */
295 /** \name Menu Block Creation
298 static void ui_block_region_refresh(const bContext *C, ARegion *ar)
300 ScrArea *ctx_area = CTX_wm_area(C);
301 ARegion *ctx_region = CTX_wm_region(C);
304 if (ar->do_draw & RGN_DRAW_REFRESH_UI) {
305 ScrArea *handle_ctx_area;
306 ARegion *handle_ctx_region;
309 ar->do_draw &= ~RGN_DRAW_REFRESH_UI;
310 for (block = ar->uiblocks.first; block; block = block_next) {
311 block_next = block->next;
312 uiPopupBlockHandle *handle = block->handle;
314 if (handle->can_refresh) {
315 handle_ctx_area = handle->ctx_area;
316 handle_ctx_region = handle->ctx_region;
318 if (handle_ctx_area) {
319 CTX_wm_area_set((bContext *)C, handle_ctx_area);
321 if (handle_ctx_region) {
322 CTX_wm_region_set((bContext *)C, handle_ctx_region);
325 uiBut *but = handle->popup_create_vars.but;
326 ARegion *butregion = handle->popup_create_vars.butregion;
327 ui_popup_block_refresh((bContext *)C, handle, butregion, but);
332 CTX_wm_area_set((bContext *)C, ctx_area);
333 CTX_wm_region_set((bContext *)C, ctx_region);
336 static void ui_block_region_draw(const bContext *C, ARegion *ar)
340 for (block = ar->uiblocks.first; block; block = block->next)
341 UI_block_draw(C, block);
345 * Use to refresh centered popups on screen resizing (for splash).
347 static void ui_block_region_popup_window_listener(
348 wmWindow *UNUSED(win), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn, const Scene *UNUSED(scene))
350 switch (wmn->category) {
353 switch (wmn->action) {
357 ED_region_tag_refresh_ui(ar);
366 static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
370 int width = UI_SCREEN_MARGIN;
373 if (block->flag & UI_BLOCK_NO_WIN_CLIP) {
377 winx = WM_window_pixels_x(window);
378 winy = WM_window_pixels_y(window);
380 /* shift menus to right if outside of view */
381 if (block->rect.xmin < width) {
382 xofs = (width - block->rect.xmin);
383 block->rect.xmin += xofs;
384 block->rect.xmax += xofs;
386 /* or shift to left if outside of view */
387 if (block->rect.xmax > winx - width) {
388 xofs = winx - width - block->rect.xmax;
389 block->rect.xmin += xofs;
390 block->rect.xmax += xofs;
393 if (block->rect.ymin < width)
394 block->rect.ymin = width;
395 if (block->rect.ymax > winy - UI_POPUP_MENU_TOP)
396 block->rect.ymax = winy - UI_POPUP_MENU_TOP;
398 /* ensure menu items draw inside left/right boundary */
399 for (bt = block->buttons.first; bt; bt = bt->next) {
400 bt->rect.xmin += xofs;
401 bt->rect.xmax += xofs;
406 void ui_popup_block_scrolltest(uiBlock *block)
410 block->flag &= ~(UI_BLOCK_CLIPBOTTOM | UI_BLOCK_CLIPTOP);
412 for (bt = block->buttons.first; bt; bt = bt->next)
413 bt->flag &= ~UI_SCROLLED;
415 if (block->buttons.first == block->buttons.last)
418 /* mark buttons that are outside boundary */
419 for (bt = block->buttons.first; bt; bt = bt->next) {
420 if (bt->rect.ymin < block->rect.ymin) {
421 bt->flag |= UI_SCROLLED;
422 block->flag |= UI_BLOCK_CLIPBOTTOM;
424 if (bt->rect.ymax > block->rect.ymax) {
425 bt->flag |= UI_SCROLLED;
426 block->flag |= UI_BLOCK_CLIPTOP;
430 /* mark buttons overlapping arrows, if we have them */
431 for (bt = block->buttons.first; bt; bt = bt->next) {
432 if (block->flag & UI_BLOCK_CLIPBOTTOM) {
433 if (bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW)
434 bt->flag |= UI_SCROLLED;
436 if (block->flag & UI_BLOCK_CLIPTOP) {
437 if (bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW)
438 bt->flag |= UI_SCROLLED;
443 static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle)
445 wmWindow *win = CTX_wm_window(C);
446 bScreen *sc = CTX_wm_screen(C);
448 ui_region_temp_remove(C, sc, handle->region);
450 /* reset to region cursor (only if there's not another menu open) */
451 if (BLI_listbase_is_empty(&sc->regionbase)) {
452 ED_region_cursor_set(win, CTX_wm_area(C), CTX_wm_region(C));
453 /* in case cursor needs to be changed again */
454 WM_event_add_mousemove(C);
457 if (handle->scrolltimer)
458 WM_event_remove_timer(CTX_wm_manager(C), win, handle->scrolltimer);
462 * Called for creating new popups and refreshing existing ones.
464 uiBlock *ui_popup_block_refresh(
465 bContext *C, uiPopupBlockHandle *handle,
466 ARegion *butregion, uiBut *but)
468 const int margin = UI_POPUP_MARGIN;
469 wmWindow *window = CTX_wm_window(C);
470 ARegion *ar = handle->region;
472 uiBlockCreateFunc create_func = handle->popup_create_vars.create_func;
473 uiBlockHandleCreateFunc handle_create_func = handle->popup_create_vars.handle_create_func;
474 void *arg = handle->popup_create_vars.arg;
476 uiBlock *block_old = ar->uiblocks.first;
479 handle->refresh = (block_old != NULL);
481 BLI_assert(!handle->refresh || handle->can_refresh);
484 wmEvent *event_back = window->eventstate;
487 /* create ui block */
489 block = create_func(C, ar, arg);
491 block = handle_create_func(C, handle, arg);
493 /* callbacks _must_ leave this for us, otherwise we can't call UI_block_update_from_old */
494 BLI_assert(!block->endblock);
496 /* ensure we don't use mouse coords here! */
498 window->eventstate = NULL;
502 memcpy(block->handle, handle, sizeof(uiPopupBlockHandle));
504 handle = block->handle;
507 block->handle = handle;
509 ar->regiondata = handle;
511 /* set UI_BLOCK_NUMSELECT before UI_block_end() so we get alphanumeric keys assigned */
513 block->flag |= UI_BLOCK_POPUP;
516 block->flag |= UI_BLOCK_LOOP;
517 UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
519 /* defer this until blocks are translated (below) */
520 block->oldblock = NULL;
522 if (!block->endblock) {
523 UI_block_end_ex(C, block, handle->popup_create_vars.event_xy, handle->popup_create_vars.event_xy);
526 /* if this is being created from a button */
528 block->aspect = but->block->aspect;
529 ui_popup_block_position(window, butregion, but, block);
530 handle->direction = block->direction;
533 uiSafetyRct *saferct;
534 /* keep a list of these, needed for pulldown menus */
535 saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
536 saferct->safety = block->safety;
537 BLI_addhead(&block->saferct, saferct);
540 if (block->flag & UI_BLOCK_RADIAL) {
541 int win_width = UI_SCREEN_MARGIN;
544 int x_offset = 0, y_offset = 0;
546 winx = WM_window_pixels_x(window);
547 winy = WM_window_pixels_y(window);
549 copy_v2_v2(block->pie_data.pie_center_init, block->pie_data.pie_center_spawned);
551 /* only try translation if area is large enough */
552 if (BLI_rctf_size_x(&block->rect) < winx - (2.0f * win_width)) {
553 if (block->rect.xmin < win_width ) x_offset += win_width - block->rect.xmin;
554 if (block->rect.xmax > winx - win_width) x_offset += winx - win_width - block->rect.xmax;
557 if (BLI_rctf_size_y(&block->rect) < winy - (2.0f * win_width)) {
558 if (block->rect.ymin < win_width ) y_offset += win_width - block->rect.ymin;
559 if (block->rect.ymax > winy - win_width) y_offset += winy - win_width - block->rect.ymax;
561 /* if we are offsetting set up initial data for timeout functionality */
563 if ((x_offset != 0) || (y_offset != 0)) {
564 block->pie_data.pie_center_spawned[0] += x_offset;
565 block->pie_data.pie_center_spawned[1] += y_offset;
567 UI_block_translate(block, x_offset, y_offset);
569 if (U.pie_initial_timeout > 0)
570 block->pie_data.flags |= UI_PIE_INITIAL_DIRECTION;
574 ar->winrct.xmax = winx;
576 ar->winrct.ymax = winy;
578 ui_block_calc_pie_segment(block, block->pie_data.pie_center_init);
580 /* lastly set the buttons at the center of the pie menu, ready for animation */
581 if (U.pie_animation_timeout > 0) {
582 for (uiBut *but_iter = block->buttons.first; but_iter; but_iter = but_iter->next) {
583 if (but_iter->pie_dir != UI_RADIAL_NONE) {
584 BLI_rctf_recenter(&but_iter->rect, UNPACK2(block->pie_data.pie_center_spawned));
590 /* clip block with window boundary */
591 ui_popup_block_clip(window, block);
593 /* Avoid menu moving down and losing cursor focus by keeping it at
594 * the same height. */
595 if (handle->refresh && handle->prev_block_rect.ymax > block->rect.ymax) {
596 float offset = handle->prev_block_rect.ymax - block->rect.ymax;
597 UI_block_translate(block, 0, offset);
598 block->rect.ymin = handle->prev_block_rect.ymin;
601 handle->prev_block_rect = block->rect;
603 /* the block and buttons were positioned in window space as in 2.4x, now
604 * these menu blocks are regions so we bring it back to region space.
605 * additionally we add some padding for the menu shadow or rounded menus */
606 ar->winrct.xmin = block->rect.xmin - margin;
607 ar->winrct.xmax = block->rect.xmax + margin;
608 ar->winrct.ymin = block->rect.ymin - margin;
609 ar->winrct.ymax = block->rect.ymax + UI_POPUP_MENU_TOP;
611 UI_block_translate(block, -ar->winrct.xmin, -ar->winrct.ymin);
613 /* apply scroll offset */
614 if (handle->scrolloffset != 0.0f) {
615 for (uiBut *bt = block->buttons.first; bt; bt = bt->next) {
616 bt->rect.ymin += handle->scrolloffset;
617 bt->rect.ymax += handle->scrolloffset;
623 block->oldblock = block_old;
624 UI_block_update_from_old(C, block);
625 UI_blocklist_free_inactive(C, &ar->uiblocks);
628 /* checks which buttons are visible, sets flags to prevent draw (do after region init) */
629 ui_popup_block_scrolltest(block);
634 /* get winmat now that we actually have the subwindow */
635 wmGetProjectionMatrix(block->winmat, &ar->winrct);
637 /* notify change and redraw */
638 ED_region_tag_redraw(ar);
640 ED_region_update_rect(ar);
643 window->eventstate = event_back;
649 uiPopupBlockHandle *ui_popup_block_create(
650 bContext *C, ARegion *butregion, uiBut *but,
651 uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func,
654 wmWindow *window = CTX_wm_window(C);
655 uiBut *activebut = UI_context_active_but_get(C);
656 static ARegionType type;
659 uiPopupBlockHandle *handle;
661 /* disable tooltips from buttons below */
663 UI_but_tooltip_timer_remove(C, activebut);
665 /* standard cursor by default */
666 WM_cursor_set(window, CURSOR_STD);
669 handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
671 /* store context for operator */
672 handle->ctx_area = CTX_wm_area(C);
673 handle->ctx_region = CTX_wm_region(C);
675 /* store vars to refresh popup (RGN_DRAW_REFRESH_UI) */
676 handle->popup_create_vars.create_func = create_func;
677 handle->popup_create_vars.handle_create_func = handle_create_func;
678 handle->popup_create_vars.arg = arg;
679 handle->popup_create_vars.but = but;
680 handle->popup_create_vars.butregion = but ? butregion : NULL;
681 copy_v2_v2_int(handle->popup_create_vars.event_xy, &window->eventstate->x);
683 /* don't allow by default, only if popup type explicitly supports it */
684 handle->can_refresh = false;
686 /* create area region */
687 ar = ui_region_temp_add(CTX_wm_screen(C));
690 memset(&type, 0, sizeof(ARegionType));
691 type.draw = ui_block_region_draw;
692 type.layout = ui_block_region_refresh;
693 type.regionid = RGN_TYPE_TEMPORARY;
696 UI_region_handlers_add(&ar->handlers);
698 block = ui_popup_block_refresh(C, handle, butregion, but);
699 handle = block->handle;
701 /* keep centered on window resizing */
702 if (block->bounds_type == UI_BLOCK_BOUNDS_POPUP_CENTER) {
703 type.listener = ui_block_region_popup_window_listener;
709 void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle)
711 /* If this popup is created from a popover which does NOT have keep-open flag set,
712 * then close the popover too. We could extend this to other popup types too. */
713 ARegion *ar = handle->popup_create_vars.butregion;
715 for (uiBlock *block = ar->uiblocks.first; block; block = block->next) {
717 (block->flag & UI_BLOCK_POPOVER) &&
718 (block->flag & UI_BLOCK_KEEP_OPEN) == 0)
720 uiPopupBlockHandle *menu = block->handle;
721 menu->menuretval = UI_RETURN_OK;
726 if (handle->popup_create_vars.free_func) {
727 handle->popup_create_vars.free_func(handle, handle->popup_create_vars.arg);
730 ui_popup_block_remove(C, handle);