Blender V5.0
interface_region_popup.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include <algorithm>
12#include <cstdarg>
13#include <cstdlib>
14#include <cstring>
15
16#include "MEM_guardedalloc.h"
17
18#include "DNA_userdef_types.h"
19
20#include "BLF_api.hh"
21
22#include "BLI_listbase.h"
23#include "BLI_math_vector.h"
24#include "BLI_rect.h"
25#include "BLI_utildefines.h"
26
27#include "BKE_context.hh"
28#include "BKE_screen.hh"
29
30#include "WM_api.hh"
31#include "WM_types.hh"
32
33#include "ED_screen.hh"
34
35#include "interface_intern.hh"
37
39
40/* -------------------------------------------------------------------- */
43
44void ui_popup_translate(ARegion *region, const int mdiff[2])
45{
46 BLI_rcti_translate(&region->winrct, UNPACK2(mdiff));
47
49
51
52 /* update blocks */
53 LISTBASE_FOREACH (uiBlock *, block, &region->runtime->uiblocks) {
54 uiPopupBlockHandle *handle = block->handle;
55 /* Make empty, will be initialized on next use, see #60608. */
56 BLI_rctf_init(&handle->prev_block_rect, 0, 0, 0, 0);
57
58 LISTBASE_FOREACH (uiSafetyRct *, saferct, &block->saferct) {
59 BLI_rctf_translate(&saferct->parent, UNPACK2(mdiff));
60 BLI_rctf_translate(&saferct->safety, UNPACK2(mdiff));
61 }
62 }
63}
64
65/* position block relative to but, result is in window space */
67 ARegion *butregion,
68 uiBut *but,
69 uiBlock *block)
70{
71 uiPopupBlockHandle *handle = block->handle;
72
73 /* Compute button position in window coordinates using the source
74 * button region/block, to position the popup attached to it. */
75 rctf butrct;
76 if (!handle->refresh) {
77 ui_block_to_window_rctf(butregion, but->block, &butrct, &but->rect);
78
79 /* widget_roundbox_set has this correction too, keep in sync */
80 if (but->type != ButType::Pulldown) {
81 if (but->drawflag & UI_BUT_ALIGN_TOP) {
82 butrct.ymax += U.pixelsize;
83 }
84 if (but->drawflag & UI_BUT_ALIGN_LEFT) {
85 butrct.xmin -= U.pixelsize;
86 }
87 }
88
89 handle->prev_butrct = butrct;
90 }
91 else {
92 /* For refreshes, keep same button position so popup doesn't move. */
93 butrct = handle->prev_butrct;
94 }
95
96 /* Compute block size in window space, based on buttons contained in it. */
97 if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) {
98 if (!block->buttons.is_empty()) {
100
101 for (const std::unique_ptr<uiBut> &bt : block->buttons) {
103 bt->rect.xmax += UI_MENU_SUBMENU_PADDING;
104 }
105 BLI_rctf_union(&block->rect, &bt->rect);
106 }
107 }
108 else {
109 /* we're nice and allow empty blocks too */
110 block->rect.xmin = block->rect.ymin = 0;
111 block->rect.xmax = block->rect.ymax = 20;
112 }
113 }
114
115 /* Trim the popup and its contents to the width of the button if the size difference
116 * is small. This avoids cases where the rounded corner clips underneath the button. */
117 const int delta = BLI_rctf_size_x(&block->rect) - BLI_rctf_size_x(&butrct);
118 const float max_radius = (0.5f * U.widget_unit);
119
120 if (delta >= 0 && delta < max_radius) {
121 for (const std::unique_ptr<uiBut> &bt : block->buttons) {
122 /* Only trim the right most buttons in multi-column popovers. */
123 if (bt->rect.xmax == block->rect.xmax) {
124 bt->rect.xmax -= delta;
125 }
126 }
127 block->rect.xmax -= delta;
128 }
129
130 ui_block_to_window_rctf(butregion, but->block, &block->rect, &block->rect);
131
132 /* `block->rect` is already scaled with `butregion->winrct`,
133 * apply this scale to layout panels too. */
134 if (Panel *panel = block->panel) {
135 for (LayoutPanelBody &body : panel->runtime->layout_panels.bodies) {
136 body.start_y /= block->aspect;
137 body.end_y /= block->aspect;
138 }
139 for (LayoutPanelHeader &header : panel->runtime->layout_panels.headers) {
140 header.start_y /= block->aspect;
141 header.end_y /= block->aspect;
142 }
143 }
144
145 /* Compute direction relative to button, based on available space. */
146 const int size_x = BLI_rctf_size_x(&block->rect) + 0.2f * UI_UNIT_X; /* 4 for shadow */
147 const int size_y = BLI_rctf_size_y(&block->rect) + 0.2f * UI_UNIT_Y;
148 const int center_x = (block->direction & UI_DIR_CENTER_X) ? size_x / 2 : 0;
149 const int center_y = (block->direction & UI_DIR_CENTER_Y) ? size_y / 2 : 0;
150
151 const blender::int2 win_size = WM_window_native_pixel_size(window);
152
153 /* Take into account maximum size so we don't have to flip on refresh. */
154 const blender::float2 max_size = {
155 max_ff(size_x, handle->max_size_x),
156 max_ff(size_y, handle->max_size_y),
157 };
158
159 short dir1 = 0, dir2 = 0;
160
161 if (!handle->refresh) {
162 bool left = false, right = false, top = false, down = false;
163
164 /* check if there's space at all */
165 if (butrct.xmin - max_size[0] + center_x > 0.0f) {
166 left = true;
167 }
168 if (butrct.xmax + max_size[0] - center_x < win_size[0]) {
169 right = true;
170 }
171 if (butrct.ymin - max_size[1] + center_y > 0.0f) {
172 down = true;
173 }
174 if (butrct.ymax + max_size[1] - center_y < win_size[1]) {
175 top = true;
176 }
177
178 if (top == 0 && down == 0) {
179 if (butrct.ymin - max_size[1] < win_size[1] - butrct.ymax - max_size[1]) {
180 top = true;
181 }
182 else {
183 down = true;
184 }
185 }
186
187 dir1 = (block->direction & UI_DIR_ALL);
188
189 /* Secondary directions. */
190 if (dir1 & (UI_DIR_UP | UI_DIR_DOWN)) {
191 if (dir1 & UI_DIR_LEFT) {
192 dir2 = UI_DIR_LEFT;
193 }
194 else if (dir1 & UI_DIR_RIGHT) {
195 dir2 = UI_DIR_RIGHT;
196 }
197 dir1 &= (UI_DIR_UP | UI_DIR_DOWN);
198 }
199
200 if ((dir2 == 0) && ELEM(dir1, UI_DIR_LEFT, UI_DIR_RIGHT)) {
201 dir2 = UI_DIR_DOWN;
202 }
203 if ((dir2 == 0) && ELEM(dir1, UI_DIR_UP, UI_DIR_DOWN)) {
204 dir2 = UI_DIR_LEFT;
205 }
206
207 /* no space at all? don't change */
208 if (left || right) {
209 if (dir1 == UI_DIR_LEFT && left == 0) {
210 dir1 = UI_DIR_RIGHT;
211 }
212 if (dir1 == UI_DIR_RIGHT && right == 0) {
213 dir1 = UI_DIR_LEFT;
214 }
215 /* this is aligning, not append! */
216 if (dir2 == UI_DIR_LEFT && right == 0) {
217 dir2 = UI_DIR_RIGHT;
218 }
219 if (dir2 == UI_DIR_RIGHT && left == 0) {
220 dir2 = UI_DIR_LEFT;
221 }
222 }
223 if (down || top) {
224 if (dir1 == UI_DIR_UP && top == 0) {
225 dir1 = UI_DIR_DOWN;
226 }
227 if (dir1 == UI_DIR_DOWN && down == 0) {
228 dir1 = UI_DIR_UP;
229 }
230 BLI_assert(dir2 != UI_DIR_UP);
231 // if (dir2 == UI_DIR_UP && top == 0) { dir2 = UI_DIR_DOWN; }
232 if (dir2 == UI_DIR_DOWN && down == 0) {
233 dir2 = UI_DIR_UP;
234 }
235 }
236
237 handle->prev_dir1 = dir1;
238 handle->prev_dir2 = dir2;
239 }
240 else {
241 /* For refreshes, keep same popup direct so popup doesn't move
242 * to a totally different position while editing in it. */
243 dir1 = handle->prev_dir1;
244 dir2 = handle->prev_dir2;
245 }
246
247 /* Compute offset based on direction. */
248 float offset_x = 0, offset_y = 0;
249
250 /* Ensure buttons don't come between the parent button and the popup, see: #63566. */
251 const float offset_overlap = max_ff(U.pixelsize, 1.0f);
252
253 if (dir1 == UI_DIR_LEFT) {
254 offset_x = (butrct.xmin - block->rect.xmax) + offset_overlap;
255 if (dir2 == UI_DIR_UP) {
256 offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING;
257 }
258 else {
259 offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING;
260 }
261 }
262 else if (dir1 == UI_DIR_RIGHT) {
263 offset_x = (butrct.xmax - block->rect.xmin) - offset_overlap;
264 if (dir2 == UI_DIR_UP) {
265 offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING;
266 }
267 else {
268 offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING;
269 }
270 }
271 else if (dir1 == UI_DIR_UP) {
272 offset_y = (butrct.ymax - block->rect.ymin) - offset_overlap;
273
274 if (but->type == ButType::Color &&
275 block->rect.ymax + offset_y > win_size[1] - UI_POPUP_MENU_TOP)
276 {
277 /* Shift this down, aligning the top edge close to the window top. */
278 offset_y = win_size[1] - block->rect.ymax - UI_POPUP_MENU_TOP;
279 /* All four corners should be rounded since this no longer button-aligned. */
280 block->direction = UI_DIR_CENTER_Y;
281 dir1 = UI_DIR_CENTER_Y;
282 }
283
284 if (dir2 == UI_DIR_RIGHT) {
285 offset_x = butrct.xmax - block->rect.xmax + center_x;
286 }
287 else {
288 offset_x = butrct.xmin - block->rect.xmin - center_x;
289 }
290 }
291 else if (dir1 == UI_DIR_DOWN) {
292 offset_y = (butrct.ymin - block->rect.ymax) + offset_overlap;
293
294 if (but->type == ButType::Color && block->rect.ymin + offset_y < UI_SCREEN_MARGIN) {
295 /* Shift this up, aligning the bottom edge close to the window bottom. */
296 offset_y = -block->rect.ymin + UI_SCREEN_MARGIN;
297 /* All four corners should be rounded since this no longer button-aligned. */
298 block->direction = UI_DIR_CENTER_Y;
299 dir1 = UI_DIR_CENTER_Y;
300 }
301
302 if (dir2 == UI_DIR_RIGHT) {
303 offset_x = butrct.xmax - block->rect.xmax + center_x;
304 }
305 else {
306 offset_x = butrct.xmin - block->rect.xmin - center_x;
307 }
308 }
309
310 /* Center over popovers for eg. */
311 if (block->direction & UI_DIR_CENTER_X) {
312 offset_x += BLI_rctf_size_x(&butrct) / ((dir2 == UI_DIR_LEFT) ? 2 : -2);
313 }
314
315 /* Apply offset, buttons in window coords. */
316 for (const std::unique_ptr<uiBut> &bt : block->buttons) {
317 ui_block_to_window_rctf(butregion, but->block, &bt->rect, &bt->rect);
318
319 BLI_rctf_translate(&bt->rect, offset_x, offset_y);
320
321 /* ui_but_update recalculates drawstring size in pixels */
322 ui_but_update(bt.get());
323 }
324
325 BLI_rctf_translate(&block->rect, offset_x, offset_y);
326
327 /* Safety calculus. */
328 {
329 const float midx = BLI_rctf_cent_x(&butrct);
330 const float midy = BLI_rctf_cent_y(&butrct);
331
332 /* when you are outside parent button, safety there should be smaller */
333
334 const int s1 = (U.flag & USER_MENU_CLOSE_LEAVE) ? 40 * UI_SCALE_FAC : win_size[0];
335 const int s2 = 3 * UI_SCALE_FAC;
336
337 /* parent button to left */
338 if (midx < block->rect.xmin) {
339 block->safety.xmin = block->rect.xmin - s2;
340 }
341 else {
342 block->safety.xmin = block->rect.xmin - s1;
343 }
344 /* parent button to right */
345 if (midx > block->rect.xmax) {
346 block->safety.xmax = block->rect.xmax + s2;
347 }
348 else {
349 block->safety.xmax = block->rect.xmax + s1;
350 }
351
352 /* parent button on bottom */
353 if (midy < block->rect.ymin) {
354 block->safety.ymin = block->rect.ymin - s2;
355 }
356 else {
357 block->safety.ymin = block->rect.ymin - s1;
358 }
359 /* parent button on top */
360 if (midy > block->rect.ymax) {
361 block->safety.ymax = block->rect.ymax + s2;
362 }
363 else {
364 block->safety.ymax = block->rect.ymax + s1;
365 }
366
367 /* Exception for switched pull-downs. */
368 if (dir1 && (dir1 & block->direction) == 0) {
369 if (dir2 == UI_DIR_RIGHT) {
370 block->safety.xmax = block->rect.xmax + s2;
371 }
372 if (dir2 == UI_DIR_LEFT) {
373 block->safety.xmin = block->rect.xmin - s2;
374 }
375 }
376
377 const bool fully_aligned_with_button = BLI_rctf_size_x(&block->rect) <=
378 BLI_rctf_size_x(&butrct) + 1;
379 const bool off_screen_left = (block->rect.xmin < 0);
380 const bool off_screen_right = (block->rect.xmax > win_size[0]);
381
382 if (fully_aligned_with_button) {
383 /* Popup is neither left or right from the button. */
384 dir2 &= ~(UI_DIR_LEFT | UI_DIR_RIGHT);
385 }
386 else if (off_screen_left || off_screen_right) {
387 /* Popup is both left and right from the button. */
388 dir2 |= (UI_DIR_LEFT | UI_DIR_RIGHT);
389 }
390
391 /* Popovers don't need secondary direction. Pull-downs to
392 * the left or right are currently not supported. */
393 const bool no_2nd_dir = (but->type == ButType::Popover || ui_but_menu_draw_as_popover(but) ||
394 dir1 & (UI_DIR_RIGHT | UI_DIR_LEFT));
395 block->direction = no_2nd_dir ? dir1 : (dir1 | dir2);
396 }
397
398 /* Keep a list of these, needed for pull-down menus. */
399 uiSafetyRct *saferct = MEM_callocN<uiSafetyRct>(__func__);
400 saferct->parent = butrct;
401 saferct->safety = block->safety;
402 BLI_freelistN(&block->saferct);
403 BLI_duplicatelist(&block->saferct, &but->block->saferct);
404 BLI_addhead(&block->saferct, saferct);
405}
406
408
409/* -------------------------------------------------------------------- */
412
413static void ui_block_region_refresh(const bContext *C, ARegion *region)
414{
416
417 ScrArea *ctx_area = CTX_wm_area(C);
418 ARegion *ctx_region = CTX_wm_region(C);
419
420 if (region->runtime->do_draw & RGN_REFRESH_UI) {
421 ScrArea *handle_ctx_area;
422 ARegion *handle_ctx_region;
423
424 region->runtime->do_draw &= ~RGN_REFRESH_UI;
425 LISTBASE_FOREACH_MUTABLE (uiBlock *, block, &region->runtime->uiblocks) {
426 uiPopupBlockHandle *handle = block->handle;
427
428 if (handle->can_refresh) {
429 handle_ctx_area = handle->ctx_area;
430 handle_ctx_region = handle->ctx_region;
431
432 if (handle_ctx_area) {
433 CTX_wm_area_set((bContext *)C, handle_ctx_area);
434 }
435 if (handle_ctx_region) {
436 CTX_wm_region_set((bContext *)C, handle_ctx_region);
437 }
438
439 uiBut *but = handle->popup_create_vars.but;
440 ARegion *butregion = handle->popup_create_vars.butregion;
441 ui_popup_block_refresh((bContext *)C, handle, butregion, but);
442 }
443 }
444 }
445
446 CTX_wm_area_set((bContext *)C, ctx_area);
447 CTX_wm_region_set((bContext *)C, ctx_region);
448}
449
450static void ui_block_region_draw(const bContext *C, ARegion *region)
451{
452 LISTBASE_FOREACH (uiBlock *, block, &region->runtime->uiblocks) {
453 UI_block_draw(C, block);
454 }
455}
456
461{
462 ARegion *region = params->region;
463 const wmNotifier *wmn = params->notifier;
464
465 switch (wmn->category) {
466 case NC_WINDOW: {
467 switch (wmn->action) {
468 case NA_EDITED: {
469 /* window resize */
471 break;
472 }
473 }
474 break;
475 }
476 }
477}
478
479static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
480{
481 const float xmin_orig = block->rect.xmin;
482 const int margin = UI_SCREEN_MARGIN;
483
484 if (block->flag & UI_BLOCK_NO_WIN_CLIP) {
485 return;
486 }
487
488 const blender::int2 win_size = WM_window_native_pixel_size(window);
489
490 /* shift to left if outside of view */
491 if (block->rect.xmax > win_size[0] - margin) {
492 const float xofs = win_size[0] - margin - block->rect.xmax;
493 block->rect.xmin += xofs;
494 block->rect.xmax += xofs;
495 }
496 /* shift menus to right if outside of view */
497 if (block->rect.xmin < margin) {
498 const float xofs = (margin - block->rect.xmin);
499 block->rect.xmin += xofs;
500 block->rect.xmax += xofs;
501 }
502
503 block->rect.ymin = std::max<float>(block->rect.ymin, margin);
504 block->rect.ymax = std::min<float>(block->rect.ymax, win_size[1] - UI_POPUP_MENU_TOP);
505
506 /* ensure menu items draw inside left/right boundary */
507 const float xofs = block->rect.xmin - xmin_orig;
508 for (const std::unique_ptr<uiBut> &bt : block->buttons) {
509 bt->rect.xmin += xofs;
510 bt->rect.xmax += xofs;
511 }
512}
513
515{
517
518 for (const std::unique_ptr<uiBut> &bt : block->buttons) {
519 bt->flag &= ~UI_SCROLLED;
520 }
521
522 if (block->buttons.size() < 2) {
523 return;
524 }
525
526 /* mark buttons that are outside boundary */
527 for (const std::unique_ptr<uiBut> &bt : block->buttons) {
528 if (bt->rect.ymin < block->rect.ymin) {
529 bt->flag |= UI_SCROLLED;
530 block->flag |= UI_BLOCK_CLIPBOTTOM;
531 }
532 if (bt->rect.ymax > block->rect.ymax) {
533 bt->flag |= UI_SCROLLED;
534 block->flag |= UI_BLOCK_CLIPTOP;
535 }
536 }
537
538 /* mark buttons overlapping arrows, if we have them */
539 for (const std::unique_ptr<uiBut> &bt : block->buttons) {
540 if (block->flag & UI_BLOCK_CLIPBOTTOM) {
541 if (bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW) {
542 bt->flag |= UI_SCROLLED;
543 }
544 }
545 if (block->flag & UI_BLOCK_CLIPTOP) {
546 if (bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW) {
547 bt->flag |= UI_SCROLLED;
548 }
549 }
550 }
551}
552
554{
555 wmWindow *ctx_win = CTX_wm_window(C);
556 ScrArea *ctx_area = CTX_wm_area(C);
557 ARegion *ctx_region = CTX_wm_region(C);
558
560 wmWindow *win = ctx_win;
561 bScreen *screen = CTX_wm_screen(C);
562
563 /* There may actually be a different window active than the one showing the popup, so lookup real
564 * one. */
565 if (BLI_findindex(&screen->regionbase, handle->region) == -1) {
566 LISTBASE_FOREACH (wmWindow *, win_iter, &wm->windows) {
567 screen = WM_window_get_active_screen(win_iter);
568 if (BLI_findindex(&screen->regionbase, handle->region) != -1) {
569 win = win_iter;
570 break;
571 }
572 }
573 }
574
575 BLI_assert(win && screen);
576
577 CTX_wm_window_set(C, win);
578 ui_region_temp_remove(C, screen, handle->region);
579
580 /* Reset context (area and region were null'ed when changing context window). */
581 CTX_wm_window_set(C, ctx_win);
582 CTX_wm_area_set(C, ctx_area);
583 CTX_wm_region_set(C, ctx_region);
584
585 /* reset to region cursor (only if there's not another menu open) */
586 if (BLI_listbase_is_empty(&screen->regionbase)) {
587 win->tag_cursor_refresh = true;
588 }
589
590 if (handle->scrolltimer) {
591 WM_event_timer_remove(wm, win, handle->scrolltimer);
592 }
593}
594
595void ui_layout_panel_popup_scroll_apply(Panel *panel, const float dy)
596{
597 if (!panel || dy == 0.0f) {
598 return;
599 }
600 for (LayoutPanelBody &body : panel->runtime->layout_panels.bodies) {
601 body.start_y += dy;
602 body.end_y += dy;
603 }
604 for (LayoutPanelHeader &headcer : panel->runtime->layout_panels.headers) {
605 headcer.start_y += dy;
606 headcer.end_y += dy;
607 }
608}
609
611{
612 Panel *&panel = region->runtime->popup_block_panel;
613 if (!panel) {
614 /* Dummy popup panel type. */
615 static PanelType panel_type = []() {
616 PanelType type{};
618 return type;
619 }();
620 panel = BKE_panel_new(&panel_type);
621 }
622 panel->runtime->layout_panels.clear();
623 block->panel = panel;
624 panel->runtime->block = block;
625}
626
628 uiPopupBlockHandle *handle,
629 ARegion *butregion,
630 uiBut *but)
631{
632 const int margin = UI_POPUP_MARGIN;
633 wmWindow *window = CTX_wm_window(C);
634 ARegion *region = handle->region;
635
637 const uiBlockHandleCreateFunc handle_create_func = handle->popup_create_vars.handle_create_func;
638 void *arg = handle->popup_create_vars.arg;
639
640 uiBlock *block_old = static_cast<uiBlock *>(region->runtime->uiblocks.first);
641
642 handle->refresh = (block_old != nullptr);
643
644 BLI_assert(!handle->refresh || handle->can_refresh);
645
646#ifndef NDEBUG
647 wmEvent *event_back = window->eventstate;
648 wmEvent *event_last_back = window->event_last_handled;
649#endif
650
651 /* create ui block */
652 uiBlock *block;
653 if (create_func) {
654 block = create_func(C, region, arg);
655 }
656 else {
657 block = handle_create_func(C, handle, arg);
658 }
659
660 /* Don't create accelerator keys if the parent menu does not have them. */
661 if (but && but->block->flag & UI_BLOCK_NO_ACCELERATOR_KEYS) {
663 }
664
665 /* callbacks _must_ leave this for us, otherwise we can't call UI_block_update_from_old */
666 BLI_assert(!block->endblock);
667
668 /* Ensure we don't use mouse coords here.
669 *
670 * NOTE(@ideasman42): Important because failing to do will cause glitches refreshing the popup.
671 *
672 * - Many popups use #wmEvent::xy to position them.
673 * - Refreshing a pop-up must only ever change it's contents. Consider that refreshing
674 * might be used to show a menu item as grayed out, or change a text label,
675 * we *never* want the popup to move based on the cursor location while refreshing.
676 * - The location of the cursor at the time of creation is stored in:
677 * `handle->popup_create_vars.event_xy` which must be used instead.
678 *
679 * Since it's difficult to control logic which is called indirectly here,
680 * clear the `eventstate` entirely to ensure it's never used when refreshing a popup. */
681#ifndef NDEBUG
682 window->eventstate = nullptr;
683#endif
684
685 if (block->handle) {
686 memcpy(block->handle, handle, sizeof(uiPopupBlockHandle));
687 MEM_delete(handle);
688 handle = block->handle;
689 }
690 else {
691 block->handle = handle;
692 }
693
694 region->regiondata = handle;
695
696 /* set UI_BLOCK_NUMSELECT before UI_block_end() so we get alphanumeric keys assigned */
697 if (but == nullptr) {
698 block->flag |= UI_BLOCK_POPUP;
699 }
700
701 block->flag |= UI_BLOCK_LOOP;
703
704 /* defer this until blocks are translated (below) */
705 block->oldblock = nullptr;
706
707 if (!block->endblock) {
710 window,
712 region,
714 block,
717 }
718
719 /* if this is being created from a button */
720 if (but) {
721 block->aspect = but->block->aspect;
722 ui_popup_block_position(window, butregion, but, block);
723 handle->direction = block->direction;
724 }
725 else {
726 /* Keep a list of these, needed for pull-down menus. */
727 uiSafetyRct *saferct = MEM_callocN<uiSafetyRct>(__func__);
728 saferct->safety = block->safety;
729 BLI_addhead(&block->saferct, saferct);
730 }
731
732 if (block->flag & UI_BLOCK_PIE_MENU) {
733 const int win_width = UI_SCREEN_MARGIN;
734
735 const blender::int2 win_size = WM_window_native_pixel_size(window);
736
738
739 /* only try translation if area is large enough */
740 int x_offset = 0;
741 if (BLI_rctf_size_x(&block->rect) < win_size[0] - (2.0f * win_width)) {
742 if (block->rect.xmin < win_width) {
743 x_offset += win_width - block->rect.xmin;
744 }
745 if (block->rect.xmax > win_size[0] - win_width) {
746 x_offset += win_size[0] - win_width - block->rect.xmax;
747 }
748 }
749
750 int y_offset = 0;
751 if (BLI_rctf_size_y(&block->rect) < win_size[1] - (2.0f * win_width)) {
752 if (block->rect.ymin < win_width) {
753 y_offset += win_width - block->rect.ymin;
754 }
755 if (block->rect.ymax > win_size[1] - win_width) {
756 y_offset += win_size[1] - win_width - block->rect.ymax;
757 }
758 }
759 /* if we are offsetting set up initial data for timeout functionality */
760
761 if ((x_offset != 0) || (y_offset != 0)) {
762 block->pie_data.pie_center_spawned[0] += x_offset;
763 block->pie_data.pie_center_spawned[1] += y_offset;
764
765 UI_block_translate(block, x_offset, y_offset);
766
767 if (U.pie_initial_timeout > 0) {
769 }
770 }
771
772 region->winrct.xmin = 0;
773 region->winrct.xmax = win_size[0];
774 region->winrct.ymin = 0;
775 region->winrct.ymax = win_size[1];
776
778
779 /* lastly set the buttons at the center of the pie menu, ready for animation */
780 if (U.pie_animation_timeout > 0) {
781 for (const std::unique_ptr<uiBut> &but_iter : block->buttons) {
782 if (but_iter->pie_dir != UI_RADIAL_NONE) {
783 BLI_rctf_recenter(&but_iter->rect, UNPACK2(block->pie_data.pie_center_spawned));
784 }
785 }
786 }
787 }
788 else {
789 /* Add an offset to draw the popover arrow. */
790 if ((block->flag & UI_BLOCK_POPOVER) && ELEM(block->direction, UI_DIR_UP, UI_DIR_DOWN)) {
791 /* Keep sync with 'ui_draw_popover_back_impl'. */
792 const float unit_size = U.widget_unit / block->aspect;
793 const float unit_half = unit_size * (block->direction == UI_DIR_DOWN ? 0.5 : -0.5);
794
795 UI_block_translate(block, 0, -unit_half);
796 }
797
798 /* clip block with window boundary */
799 ui_popup_block_clip(window, block);
800
801 /* Avoid menu moving down and losing cursor focus by keeping it at
802 * the same height. */
803 if (handle->refresh && handle->prev_block_rect.ymax > block->rect.ymax) {
805 const float offset = handle->prev_block_rect.ymax - block->rect.ymax;
806 UI_block_translate(block, 0, offset);
807 block->rect.ymin = handle->prev_block_rect.ymin;
808 }
809 }
810
811 handle->prev_block_rect = block->rect;
812
813 /* the block and buttons were positioned in window space as in 2.4x, now
814 * these menu blocks are regions so we bring it back to region space.
815 * additionally we add some padding for the menu shadow or rounded menus */
816 region->winrct.xmin = block->rect.xmin - margin;
817 region->winrct.xmax = block->rect.xmax + margin;
818 region->winrct.ymin = block->rect.ymin - margin;
819 region->winrct.ymax = block->rect.ymax + UI_POPUP_MENU_TOP;
820
821 UI_block_translate(block, -region->winrct.xmin, -region->winrct.ymin);
822 /* Popups can change size, fix scroll offset if a panel was closed. */
823 float ymin = FLT_MAX;
824 float ymax = -FLT_MAX;
825 for (const std::unique_ptr<uiBut> &bt : block->buttons) {
826 ymin = min_ff(ymin, bt->rect.ymin);
827 ymax = max_ff(ymax, bt->rect.ymax);
828 }
829 const int scroll_pad = ui_block_is_menu(block) ? UI_MENU_SCROLL_PAD : UI_UNIT_Y * 0.5f;
830 const float scroll_min = std::min(block->rect.ymax - ymax - scroll_pad, 0.0f);
831 const float scroll_max = std::max(block->rect.ymin - ymin + scroll_pad, 0.0f);
832 handle->scrolloffset = std::clamp(handle->scrolloffset, scroll_min, scroll_max);
833 /* apply scroll offset */
834 if (handle->scrolloffset != 0.0f) {
835 for (const std::unique_ptr<uiBut> &bt : block->buttons) {
836 bt->rect.ymin += handle->scrolloffset;
837 bt->rect.ymax += handle->scrolloffset;
838 }
839 }
840 /* Layout panels are relative to `block->rect.ymax`. Rather than a
841 * scroll, this is a offset applied due to the overflow at the top. */
842 ui_layout_panel_popup_scroll_apply(block->panel, -scroll_min);
843 }
844 /* Apply popup scroll offset to layout panels. */
846
847 if (block_old) {
848 block->oldblock = block_old;
851 }
852
853 /* checks which buttons are visible, sets flags to prevent draw (do after region init) */
855
856 /* Adds sub-window. */
858
859 /* Get `winmat` now that we actually have the sub-window. */
860 wmGetProjectionMatrix(block->winmat, &region->winrct);
861
862 /* notify change and redraw */
863 ED_region_tag_redraw(region);
864
865 ED_region_update_rect(region);
866
867#ifndef NDEBUG
868 window->eventstate = event_back;
869 window->event_last_handled = event_last_back;
870#endif
871
872 return block;
873}
874
876 ARegion *butregion,
877 uiBut *but,
879 uiBlockHandleCreateFunc handle_create_func,
880 void *arg,
881 uiFreeArgFunc arg_free,
882 const bool can_refresh)
883{
884 wmWindow *window = CTX_wm_window(C);
885 uiBut *activebut = UI_context_active_but_get(C);
886
887 /* disable tooltips from buttons below */
888 if (activebut) {
889 UI_but_tooltip_timer_remove(C, activebut);
890 }
891 /* standard cursor by default */
893
894 /* create handle */
895 uiPopupBlockHandle *handle = MEM_new<uiPopupBlockHandle>(__func__);
896
897 /* store context for operator */
898 handle->ctx_area = CTX_wm_area(C);
899 handle->ctx_region = CTX_wm_region(C);
900 handle->can_refresh = can_refresh;
901
902 /* store vars to refresh popup (RGN_REFRESH_UI) */
904 handle->popup_create_vars.handle_create_func = handle_create_func;
905 handle->popup_create_vars.arg = arg;
906 handle->popup_create_vars.arg_free = arg_free;
907 handle->popup_create_vars.but = but;
908 handle->popup_create_vars.butregion = but ? butregion : nullptr;
910
911 /* create area region */
913 handle->region = region;
914
915 static ARegionType type;
916 memset(&type, 0, sizeof(ARegionType));
920 region->runtime->type = &type;
921
922 UI_region_handlers_add(&region->runtime->handlers);
923
924 /* Note that this will be set in the code-path that typically calls refreshing
925 * (that loops over #Screen::regionbase and refreshes regions tagged with #RGN_REFRESH_UI).
926 * Whereas this only runs on initial creation.
927 * Set the region here so drawing logic can rely on it being set.
928 * Note that restoring the previous value may not be needed, it just avoids potential
929 * problems caused by popups manipulating the context which created them.
930 *
931 * The check for `can_refresh` exists because the context when refreshing sets the "region_popup"
932 * so failing to do so here would cause callbacks draw function to have a different context
933 * the first time it's called. Setting this in every context causes button context menus to
934 * fail because setting the "region_popup" causes poll functions to reference the popup region
935 * instead of the region where the button was created, see #121728.
936 *
937 * NOTE(@ideasman42): the logic for which popups run with their region set to
938 * #bContext::wm::region_popup could be adjusted, making this context member depend on
939 * the ability to refresh seems somewhat arbitrary although it does make *some* sense
940 * because accessing the region later (to tag for refreshing for example)
941 * only makes sense if that region supports refreshing. */
942 ARegion *region_popup_prev = nullptr;
943 if (can_refresh) {
944 region_popup_prev = CTX_wm_region_popup(C);
945 CTX_wm_region_popup_set(C, region);
946 }
947
948 uiBlock *block = ui_popup_block_refresh(C, handle, butregion, but);
949 handle = block->handle;
950
951 /* Wait with tooltips until the mouse is moved, button handling will re-enable them on the first
952 * actual mouse move. */
953 block->tooltipdisabled = true;
954
955 if (can_refresh) {
956 CTX_wm_region_popup_set(C, region_popup_prev);
957 }
958
959 /* keep centered on window resizing */
962 }
963
964 return handle;
965}
966
968{
969 bool is_submenu = false;
970
971 /* If this popup is created from a popover which does NOT have keep-open flag set,
972 * then close the popover too. We could extend this to other popup types too. */
973 ARegion *region = handle->popup_create_vars.butregion;
974 if (region != nullptr) {
975 LISTBASE_FOREACH (uiBlock *, block, &region->runtime->uiblocks) {
976 if (block->handle && (block->flag & UI_BLOCK_POPOVER) &&
977 (block->flag & UI_BLOCK_KEEP_OPEN) == 0)
978 {
979 uiPopupBlockHandle *menu = block->handle;
980 menu->menuretval = UI_RETURN_OK;
981 }
982
983 if (ui_block_is_menu(block)) {
984 is_submenu = true;
985 }
986 }
987 }
988
989 /* Clear the status bar text that is set when opening a menu. */
990 if (!is_submenu) {
991 ED_workspace_status_text(C, nullptr);
992 }
993
994 if (handle->popup_create_vars.arg_free) {
996 }
997
998 if (handle->region->runtime->popup_block_panel) {
999 BKE_panel_free(handle->region->runtime->popup_block_panel);
1000 }
1001
1002 ui_popup_block_remove(C, handle);
1003
1004 MEM_delete(handle);
1005}
1006
1015
1016static void ui_alert_ok_cb(bContext *C, void *arg1, void *arg2)
1017{
1018 uiAlertData *data = static_cast<uiAlertData *>(arg1);
1019 MEM_delete(data);
1020 uiBlock *block = static_cast<uiBlock *>(arg2);
1022 wmWindow *win = CTX_wm_window(C);
1023 UI_popup_block_close(C, win, block);
1024}
1025
1026static void ui_alert_ok(bContext * /*C*/, void *arg, int /*retval*/)
1027{
1028 uiAlertData *data = static_cast<uiAlertData *>(arg);
1029 MEM_delete(data);
1030}
1031
1032static void ui_alert_cancel(bContext * /*C*/, void *user_data)
1033{
1034 uiAlertData *data = static_cast<uiAlertData *>(user_data);
1035 MEM_delete(data);
1036}
1037
1038static uiBlock *ui_alert_create(bContext *C, ARegion *region, void *user_data)
1039{
1040 uiAlertData *data = static_cast<uiAlertData *>(user_data);
1041
1042 const uiStyle *style = UI_style_get_dpi();
1043 const short icon_size = (data->compact ? 32 : 40) * UI_SCALE_FAC;
1044 const int max_width = int((data->compact ? 250.0f : 350.0f) * UI_SCALE_FAC);
1045 const int min_width = int(120.0f * UI_SCALE_FAC);
1046
1047 uiBlock *block = UI_block_begin(C, region, __func__, blender::ui::EmbossType::Emboss);
1051 UI_popup_dummy_panel_set(region, block);
1052
1054 if (data->mouse_move_quit) {
1056 }
1057
1058 const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
1059
1060 UI_fontstyle_set(&style->widget);
1061 /* Width based on the text lengths. */
1062 int text_width = BLF_width(style->widget.uifont_id, data->title.c_str(), data->title.size());
1063
1065 fstyle->uifont_id, data->message, max_width, BLFWrapMode::Typographical);
1066
1067 for (auto &st_ref : messages) {
1068 const std::string &st = st_ref;
1069 text_width = std::max(text_width,
1070 int(BLF_width(style->widget.uifont_id, st.c_str(), st.size())));
1071 }
1072
1073 int dialog_width = std::max(text_width + int(style->columnspace * 2.5), min_width);
1074
1075 uiLayout *layout;
1076 layout = uiItemsAlertBox(block, style, dialog_width + icon_size, data->icon, icon_size);
1077
1078 uiLayout *content = &layout->column(false);
1079 content->scale_y_set(0.75f);
1080
1081 /* Title. */
1082 uiItemL_ex(content, data->title, ICON_NONE, true, false);
1083
1084 content->separator(1.0f);
1085
1086 /* Message lines. */
1087 for (auto &st : messages) {
1088 content->label(st, ICON_NONE);
1089 }
1090
1091 if (data->okay_button) {
1092
1093 layout->separator(2.0f);
1094
1095 /* Clear so the OK button is left alone. */
1096 UI_block_func_set(block, nullptr, nullptr, nullptr);
1097
1098 const float pad = std::max((1.0f - ((200.0f * UI_SCALE_FAC) / float(text_width))) / 2.0f,
1099 0.01f);
1100 uiLayout *split = &layout->split(pad, true);
1101 split->column(true);
1102 uiLayout *buttons = &split->split(1.0f - (pad * 2.0f), true);
1103 buttons->scale_y_set(1.2f);
1104
1105 uiBlock *buttons_block = layout->block();
1106 uiBut *okay_but = uiDefBut(
1107 buttons_block, ButType::But, 0, "OK", 0, 0, 0, UI_UNIT_Y, nullptr, 0, 0, "");
1108 UI_but_func_set(okay_but, ui_alert_ok_cb, user_data, block);
1110 }
1111
1112 const int padding = (data->compact ? 10 : 14) * UI_SCALE_FAC;
1113
1114 if (data->mouse_move_quit) {
1115 const float button_center_x = -0.5f;
1116 const float button_center_y = data->okay_button ? 4.0f : 2.0f;
1117 const int bounds_offset[2] = {int(button_center_x * layout->width()),
1118 int(button_center_y * UI_UNIT_X)};
1119 UI_block_bounds_set_popup(block, padding, bounds_offset);
1120 }
1121 else {
1123 }
1124
1125 return block;
1126}
1127
1129 const StringRef title,
1130 const StringRef message,
1131 const eAlertIcon icon,
1132 const bool compact)
1133{
1134 uiAlertData *data = MEM_new<uiAlertData>(__func__);
1135 data->title = title;
1136 data->message = message;
1137 data->icon = icon;
1138 data->compact = compact;
1139 data->okay_button = true;
1140 data->mouse_move_quit = compact;
1141
1143}
1144
bScreen * CTX_wm_screen(const bContext *C)
ARegion * CTX_wm_region_popup(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_window_set(bContext *C, wmWindow *win)
Main * CTX_data_main(const bContext *C)
void CTX_wm_area_set(bContext *C, ScrArea *area)
void CTX_wm_region_set(bContext *C, ARegion *region)
ARegion * CTX_wm_region(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
void CTX_wm_region_popup_set(bContext *C, ARegion *region_popup)
@ PANEL_TYPE_NO_HEADER
void BKE_panel_free(Panel *panel)
Definition screen.cc:563
Panel * BKE_panel_new(PanelType *panel_type)
Definition screen.cc:546
blender::Vector< blender::StringRef > BLF_string_wrap(int fontid, blender::StringRef str, const int max_pixel_width, BLFWrapMode mode=BLFWrapMode::Minimal)
Definition blf.cc:1061
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
Definition blf.cc:802
#define BLI_assert(a)
Definition BLI_assert.h:46
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:497
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:91
void void void void void void BLI_duplicatelist(ListBase *dst, const ListBase *src) ATTR_NONNULL(1
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
void BLI_rctf_translate(struct rctf *rect, float x, float y)
Definition rct.cc:573
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition BLI_rect.h:189
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition BLI_rect.h:185
void BLI_rcti_translate(struct rcti *rect, int x, int y)
Definition rct.cc:566
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition rct.cc:404
void BLI_rctf_recenter(struct rctf *rect, float x, float y)
Definition rct.cc:602
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.h:202
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.h:206
void BLI_rctf_init_minmax(struct rctf *rect)
Definition rct.cc:480
#define UNPACK2(a)
#define ELEM(...)
@ RGN_REFRESH_UI
@ RGN_TYPE_TEMPORARY
#define UI_SCALE_FAC
@ USER_MENU_CLOSE_LEAVE
void ED_region_tag_refresh_ui(ARegion *region)
Definition area.cc:647
void ED_region_update_rect(ARegion *region)
Definition area.cc:2296
void ED_region_floating_init(ARegion *region)
Definition area.cc:2301
void ED_workspace_status_text(bContext *C, const char *str)
Definition area.cc:1024
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:618
static void split(const char *text, const char *seps, char ***str, int *count)
Read Guarded memory(de)allocation.
#define C
Definition RandGen.cpp:29
void UI_but_func_set(uiBut *but, std::function< void(bContext &)> func)
void UI_block_update_from_old(const bContext *C, uiBlock *block)
#define UI_UNIT_Y
void UI_block_emboss_set(uiBlock *block, blender::ui::EmbossType emboss)
void UI_popup_menu_retval_set(const uiBlock *block, int retval, bool enable)
@ UI_BLOCK_CLIPBOTTOM
@ UI_BLOCK_NUMSELECT
@ UI_BLOCK_LOOP
@ UI_BLOCK_MOVEMOUSE_QUIT
@ UI_BLOCK_NO_ACCELERATOR_KEYS
@ UI_BLOCK_PIE_MENU
@ UI_BLOCK_KEEP_OPEN
@ UI_BLOCK_POPUP
@ UI_BLOCK_CLIPTOP
@ UI_BLOCK_POPOVER
@ UI_BLOCK_NO_WIN_CLIP
void UI_block_theme_style_set(uiBlock *block, char theme_style)
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, blender::ui::EmbossType emboss)
@ UI_BUT_ACTIVE_DEFAULT
void UI_block_bounds_set_popup(uiBlock *block, int addval, const int bounds_offset[2])
Definition interface.cc:653
const uiStyle * UI_style_get_dpi()
void UI_popup_block_ex(bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg, wmOperator *op)
void UI_block_translate(uiBlock *block, float x, float y)
Definition interface.cc:402
void UI_block_flag_disable(uiBlock *block, int flag)
void UI_but_tooltip_timer_remove(bContext *C, uiBut *but)
void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block)
uiBut * UI_context_active_but_get(const bContext *C)
void UI_fontstyle_set(const uiFontStyle *fs)
@ UI_BLOCK_BOUNDS_POPUP_CENTER
uiBlock *(*)(bContext *C, ARegion *region, void *arg1) uiBlockCreateFunc
void UI_block_func_set(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2)
void UI_block_draw(const bContext *C, uiBlock *block)
@ UI_RETURN_OK
void UI_blocklist_free_inactive(const bContext *C, ARegion *region)
void UI_block_bounds_set_centered(uiBlock *block, int addval)
Definition interface.cc:679
#define UI_SCREEN_MARGIN
@ UI_BLOCK_THEME_STYLE_POPUP
#define UI_FSTYLE_WIDGET
#define UI_UNIT_X
void UI_block_flag_enable(uiBlock *block, int flag)
@ UI_BUT_ALIGN_TOP
@ UI_BUT_ALIGN_LEFT
void UI_block_end_ex(const bContext *C, Main *bmain, wmWindow *window, Scene *scene, ARegion *region, Depsgraph *depsgraph, uiBlock *block, const int xy[2]=nullptr, int r_xy[2]=nullptr)
void UI_region_handlers_add(ListBase *handlers)
uiBut * uiDefBut(uiBlock *block, uiButTypeWithPointerType but_and_ptr_type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_but_flag_enable(uiBut *but, int flag)
@ UI_DIR_CENTER_X
@ UI_DIR_CENTER_Y
@ UI_DIR_ALL
@ UI_DIR_DOWN
@ UI_DIR_RIGHT
@ UI_DIR_LEFT
@ UI_DIR_UP
uiLayout * uiItemsAlertBox(uiBlock *block, const uiStyle *style, const int dialog_width, const eAlertIcon icon, const int icon_size)
uiBut * uiItemL_ex(uiLayout *layout, blender::StringRef name, int icon, bool highlight, bool redalert)
void(*)(void *arg) uiFreeArgFunc
#define NC_WINDOW
Definition WM_types.hh:375
#define NA_EDITED
Definition WM_types.hh:584
int pad[32 - sizeof(int)]
#define U
BMesh const char void * data
int64_t size() const
bool is_empty() const
uint top
uint padding(uint offset, uint alignment)
void ui_but_update(uiBut *but)
bool ui_but_menu_draw_as_popover(const uiBut *but)
void ui_block_to_window_rctf(const ARegion *region, const uiBlock *block, rctf *rct_dst, const rctf *rct_src)
Definition interface.cc:170
float ui_block_calc_pie_segment(uiBlock *block, const float event_xy[2])
#define UI_POPUP_MENU_TOP
@ UI_PIE_INITIAL_DIRECTION
uiBlock *(*)(bContext *C, uiPopupBlockHandle *handle, void *arg1) uiBlockHandleCreateFunc
#define UI_MENU_SUBMENU_PADDING
#define UI_POPUP_MARGIN
bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT
#define UI_MENU_SCROLL_PAD
#define UI_MENU_PADDING
@ UI_RADIAL_NONE
#define UI_MENU_SCROLL_ARROW
@ UI_BLOCK_CONTAINS_SUBMENU_BUT
@ UI_SCROLLED
static uiBlock * ui_alert_create(bContext *C, ARegion *region, void *user_data)
static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut *but, uiBlock *block)
static void ui_block_region_refresh(const bContext *C, ARegion *region)
static void ui_block_region_popup_window_listener(const wmRegionListenerParams *params)
uiPopupBlockHandle * ui_popup_block_create(bContext *C, ARegion *butregion, uiBut *but, uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg, uiFreeArgFunc arg_free, const bool can_refresh)
void UI_popup_dummy_panel_set(ARegion *region, uiBlock *block)
static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
void ui_popup_block_scrolltest(uiBlock *block)
void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle)
void ui_popup_translate(ARegion *region, const int mdiff[2])
void UI_alert(bContext *C, const StringRef title, const StringRef message, const eAlertIcon icon, const bool compact)
uiBlock * ui_popup_block_refresh(bContext *C, uiPopupBlockHandle *handle, ARegion *butregion, uiBut *but)
static void ui_alert_cancel(bContext *, void *user_data)
static void ui_alert_ok(bContext *, void *arg, int)
static void ui_block_region_draw(const bContext *C, ARegion *region)
static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle)
static void ui_alert_ok_cb(bContext *C, void *arg1, void *arg2)
void ui_layout_panel_popup_scroll_apply(Panel *panel, const float dy)
ARegion * ui_region_temp_add(bScreen *screen)
void ui_region_temp_remove(bContext *C, bScreen *screen, ARegion *region)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
static int left
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
static PyObject * create_func(PyObject *, PyObject *args)
Definition python.cpp:157
#define FLT_MAX
Definition stdcycles.h:14
void(* listener)(const wmRegionListenerParams *params)
void(* draw)(const bContext *C, ARegion *region)
void(* layout)(const bContext *C, ARegion *region)
void * regiondata
ARegionRuntimeHandle * runtime
blender::Vector< LayoutPanelBody > bodies
blender::Vector< LayoutPanelHeader > headers
uiBlock * block
LayoutPanels layout_panels
struct Panel_Runtime * runtime
float pie_center_spawned[2]
float pie_center_init[2]
ListBase regionbase
float xmax
float xmin
float ymax
float ymin
int ymin
int ymax
int xmin
int xmax
float winmat[4][4]
blender::Vector< std::unique_ptr< uiBut > > buttons
PieMenuData pie_data
ListBase saferct
uiBlock * oldblock
uiPopupBlockHandle * handle
eBlockBoundsCalc bounds_type
short content_hints
ButType type
uiBlock * block
void scale_y_set(float scale)
uiBlock * block() const
void label(blender::StringRef name, int icon)
uiLayout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
int width() const
uiLayout & split(float percentage, bool align)
uiBlockHandleCreateFunc handle_create_func
uiBlockCreateFunc create_func
uiPopupBlockCreate popup_create_vars
uiFontStyle widget
short columnspace
int xy[2]
Definition WM_types.hh:761
unsigned int action
Definition WM_types.hh:358
unsigned int category
Definition WM_types.hh:358
struct wmEvent * eventstate
struct wmEvent * event_last_handled
void WM_cursor_set(wmWindow *win, int curs)
@ WM_CURSOR_DEFAULT
Definition wm_cursors.hh:15
void wmGetProjectionMatrix(float mat[4][4], const rcti *winrct)
blender::int2 WM_window_native_pixel_size(const wmWindow *win)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)
bScreen * WM_window_get_active_screen(const wmWindow *win)