Blender V5.3
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.hh"
23#include "BLI_math_vector_c.hh"
24#include "BLI_rect.hh"
25#include "BLI_utildefines.hh"
26#include "BLI_vector_set.hh"
27
28#include "BKE_context.hh"
29#include "BKE_screen.hh"
30
31#include "WM_api.hh"
32#include "WM_types.hh"
33
34#include "ED_screen.hh"
35
36#include "interface_intern.hh"
38
39namespace blender::ui {
40
41/* -------------------------------------------------------------------- */
44
45void popup_translate(ARegion *region, const int mdiff[2])
46{
47 BLI_rcti_translate(&region->winrct, UNPACK2(mdiff));
48
50
52
53 /* update blocks */
54 for (Block &block : region->runtime->uiblocks) {
55 PopupBlockHandle *handle = block.handle;
56 /* Make empty, will be initialized on next use, see #60608. */
57 BLI_rctf_init(&handle->prev_block_rect, 0, 0, 0, 0);
58
59 for (SafetyRect &saferct : block.saferct) {
60 BLI_rctf_translate(&saferct.parent, UNPACK2(mdiff));
61 BLI_rctf_translate(&saferct.safety, UNPACK2(mdiff));
62 }
63 }
64}
65
66/* position block relative to but, result is in window space */
67static void popup_block_position(wmWindow *window, ARegion *butregion, Button *but, Block *block)
68{
69 PopupBlockHandle *handle = block->handle;
70
71 /* Compute button position in window coordinates using the source
72 * button region/block, to position the popup attached to it. */
73 rctf butrct;
74 if (!handle->refresh) {
75 block_to_window_rctf(butregion, but->block, &butrct, &but->rect);
76
77 /* widget_roundbox_set has this correction too, keep in sync */
78 if (but->type != ButtonType::Pulldown) {
79 if (but->drawflag & BUT_ALIGN_TOP) {
80 butrct.ymax += U.pixelsize;
81 }
82 if (but->drawflag & BUT_ALIGN_LEFT) {
83 butrct.xmin -= U.pixelsize;
84 }
85 }
86
87 handle->prev_butrct = butrct;
88 }
89 else {
90 /* For refreshes, keep same button position so popup doesn't move. */
91 butrct = handle->prev_butrct;
92 }
93
94 /* Compute block size in window space, based on buttons contained in it. */
95 if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) {
96 if (!block->buttons_ptrs.is_empty()) {
98
99 for (Button &bt : block->buttons()) {
101 bt.rect.xmax += UI_MENU_SUBMENU_PADDING;
102 }
103 BLI_rctf_union(&block->rect, &bt.rect);
104 }
105 }
106 else {
107 /* we're nice and allow empty blocks too */
108 block->rect.xmin = block->rect.ymin = 0;
109 block->rect.xmax = block->rect.ymax = 20;
110 }
111 }
112
113 /* Trim the popup and its contents to the width of the button if the size difference
114 * is small. This avoids cases where the rounded corner clips underneath the button. */
115 const int delta = BLI_rctf_size_x(&block->rect) - BLI_rctf_size_x(&butrct);
116 const float max_radius = (0.5f * U.widget_unit);
117
118 if (delta >= 0 && delta < max_radius) {
119 for (Button &bt : block->buttons()) {
120 /* Only trim the right most buttons in multi-column popovers. */
121 if (bt.rect.xmax == block->rect.xmax) {
122 bt.rect.xmax -= delta;
123 }
124 }
125 block->rect.xmax -= delta;
126 }
127
128 block_to_window_rctf(butregion, but->block, &block->rect, &block->rect);
129
130 /* `block->rect` is already scaled with `butregion->winrct`,
131 * apply this scale to layout panels too. */
132 if (Panel *panel = block->panel) {
133 for (LayoutPanelBody &body : panel->runtime->layout_panels.bodies) {
134 body.start_y /= block->aspect;
135 body.end_y /= block->aspect;
136 }
137 for (LayoutPanelHeader &header : panel->runtime->layout_panels.headers) {
138 header.start_y /= block->aspect;
139 header.end_y /= block->aspect;
140 }
141 }
142
143 /* Compute direction relative to button, based on available space. */
144 const int size_x = BLI_rctf_size_x(&block->rect) + 0.2f * UI_UNIT_X; /* 4 for shadow */
145 const int size_y = BLI_rctf_size_y(&block->rect) + 0.2f * UI_UNIT_Y;
146 const int center_x = (block->direction & UI_DIR_CENTER_X) ? size_x / 2 : 0;
147 const int center_y = (block->direction & UI_DIR_CENTER_Y) ? size_y / 2 : 0;
148
149 const int2 win_size = WM_window_native_pixel_size(window);
150
151 /* Take into account maximum size so we don't have to flip on refresh. */
152 const float2 max_size = {
153 max_ff(size_x, handle->max_size_x),
154 max_ff(size_y, handle->max_size_y),
155 };
156
157 short dir1 = 0, dir2 = 0;
158
159 if (!handle->refresh) {
160 bool left = false, right = false, top = false, down = false;
161
162 /* check if there's space at all */
163 if (butrct.xmin - max_size[0] + center_x > 0.0f) {
164 left = true;
165 }
166 if (butrct.xmax + max_size[0] - center_x < win_size[0]) {
167 right = true;
168 }
169 if (butrct.ymin - max_size[1] + center_y > 0.0f) {
170 down = true;
171 }
172 if (butrct.ymax + max_size[1] - center_y < win_size[1]) {
173 top = true;
174 }
175
176 if (top == 0 && down == 0) {
177 if (butrct.ymin - max_size[1] < win_size[1] - butrct.ymax - max_size[1]) {
178 top = true;
179 }
180 else {
181 down = true;
182 }
183 }
184
185 dir1 = (block->direction & UI_DIR_ALL);
186
187 /* Secondary directions. */
188 if (dir1 & (UI_DIR_UP | UI_DIR_DOWN)) {
189 if (dir1 & UI_DIR_LEFT) {
190 dir2 = UI_DIR_LEFT;
191 }
192 else if (dir1 & UI_DIR_RIGHT) {
193 dir2 = UI_DIR_RIGHT;
194 }
195 dir1 &= (UI_DIR_UP | UI_DIR_DOWN);
196 }
197
198 if ((dir2 == 0) && ELEM(dir1, UI_DIR_LEFT, UI_DIR_RIGHT)) {
199 dir2 = UI_DIR_DOWN;
200 }
201 if ((dir2 == 0) && ELEM(dir1, UI_DIR_UP, UI_DIR_DOWN)) {
202 dir2 = UI_DIR_LEFT;
203 }
204
205 /* no space at all? don't change */
206 if (left || right) {
207 if (dir1 == UI_DIR_LEFT && left == 0) {
208 dir1 = UI_DIR_RIGHT;
209 }
210 if (dir1 == UI_DIR_RIGHT && right == 0) {
211 dir1 = UI_DIR_LEFT;
212 }
213 /* this is aligning, not append! */
214 if (dir2 == UI_DIR_LEFT && right == 0) {
215 dir2 = UI_DIR_RIGHT;
216 }
217 if (dir2 == UI_DIR_RIGHT && left == 0) {
218 dir2 = UI_DIR_LEFT;
219 }
220 }
221 if (down || top) {
222 if (dir1 == UI_DIR_UP && top == 0) {
223 dir1 = UI_DIR_DOWN;
224 }
225 if (dir1 == UI_DIR_DOWN && down == 0) {
226 dir1 = UI_DIR_UP;
227 }
228 BLI_assert(dir2 != UI_DIR_UP);
229 // if (dir2 == UI_DIR_UP && top == 0) { dir2 = UI_DIR_DOWN; }
230 if (dir2 == UI_DIR_DOWN && down == 0) {
231 dir2 = UI_DIR_UP;
232 }
233 }
234
235 handle->prev_dir1 = dir1;
236 handle->prev_dir2 = dir2;
237 }
238 else {
239 /* For refreshes, keep same popup direct so popup doesn't move
240 * to a totally different position while editing in it. */
241 dir1 = handle->prev_dir1;
242 dir2 = handle->prev_dir2;
243 }
244
245 /* Compute offset based on direction. */
246 float offset_x = 0, offset_y = 0;
247
248 /* Ensure buttons don't come between the parent button and the popup, see: #63566. */
249 const float offset_overlap = max_ff(U.pixelsize, 1.0f);
250
251 if (dir1 == UI_DIR_LEFT) {
252 offset_x = (butrct.xmin - block->rect.xmax) + offset_overlap;
253 if (dir2 == UI_DIR_UP) {
254 offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING;
255 }
256 else {
257 offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING;
258 }
259 }
260 else if (dir1 == UI_DIR_RIGHT) {
261 offset_x = (butrct.xmax - block->rect.xmin) - offset_overlap;
262 if (dir2 == UI_DIR_UP) {
263 offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING;
264 }
265 else {
266 offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING;
267 }
268 }
269 else if (dir1 == UI_DIR_UP) {
270 offset_y = (butrct.ymax - block->rect.ymin) - offset_overlap;
271
272 if (but->type == ButtonType::Color &&
273 block->rect.ymax + offset_y > win_size[1] - UI_POPUP_MENU_TOP)
274 {
275 /* Shift this down, aligning the top edge close to the window top. */
276 offset_y = win_size[1] - block->rect.ymax - UI_POPUP_MENU_TOP;
277 /* All four corners should be rounded since this no longer button-aligned. */
278 block->direction = UI_DIR_CENTER_Y;
279 dir1 = UI_DIR_CENTER_Y;
280 }
281
282 if (dir2 == UI_DIR_RIGHT) {
283 offset_x = butrct.xmax - block->rect.xmax + center_x;
284 }
285 else {
286 offset_x = butrct.xmin - block->rect.xmin - center_x;
287 }
288 }
289 else if (dir1 == UI_DIR_DOWN) {
290 offset_y = (butrct.ymin - block->rect.ymax) + offset_overlap;
291
292 if (but->type == ButtonType::Color && block->rect.ymin + offset_y < UI_SCREEN_MARGIN) {
293 /* Shift this up, aligning the bottom edge close to the window bottom. */
294 offset_y = -block->rect.ymin + UI_SCREEN_MARGIN;
295 /* All four corners should be rounded since this no longer button-aligned. */
296 block->direction = UI_DIR_CENTER_Y;
297 dir1 = UI_DIR_CENTER_Y;
298 }
299
300 if (dir2 == UI_DIR_RIGHT) {
301 offset_x = butrct.xmax - block->rect.xmax + center_x;
302 }
303 else {
304 offset_x = butrct.xmin - block->rect.xmin - center_x;
305 }
306 }
307
308 /* Center over popovers for eg. */
309 if (block->direction & UI_DIR_CENTER_X) {
310 offset_x += BLI_rctf_size_x(&butrct) / ((dir2 == UI_DIR_LEFT) ? 2 : -2);
311 }
312
313 /* Apply offset, buttons in window coords. */
314 for (Button &bt : block->buttons()) {
315 block_to_window_rctf(butregion, but->block, &bt.rect, &bt.rect);
316
317 BLI_rctf_translate(&bt.rect, offset_x, offset_y);
318
319 /* ui_but_update recalculates drawstring size in pixels */
320 button_update(&bt);
321 }
322
323 BLI_rctf_translate(&block->rect, offset_x, offset_y);
324
325 /* Safety calculus. */
326 {
327 const float midx = BLI_rctf_cent_x(&butrct);
328 const float midy = BLI_rctf_cent_y(&butrct);
329
330 /* when you are outside parent button, safety there should be smaller */
331
332 const int s1 = (U.flag & USER_MENU_CLOSE_LEAVE) ? 40 * UI_SCALE_FAC : win_size[0];
333 const int s2 = 3 * UI_SCALE_FAC;
334
335 /* parent button to left */
336 if (midx < block->rect.xmin) {
337 block->safety.xmin = block->rect.xmin - s2;
338 }
339 else {
340 block->safety.xmin = block->rect.xmin - s1;
341 }
342 /* parent button to right */
343 if (midx > block->rect.xmax) {
344 block->safety.xmax = block->rect.xmax + s2;
345 }
346 else {
347 block->safety.xmax = block->rect.xmax + s1;
348 }
349
350 /* parent button on bottom */
351 if (midy < block->rect.ymin) {
352 block->safety.ymin = block->rect.ymin - s2;
353 }
354 else {
355 block->safety.ymin = block->rect.ymin - s1;
356 }
357 /* parent button on top */
358 if (midy > block->rect.ymax) {
359 block->safety.ymax = block->rect.ymax + s2;
360 }
361 else {
362 block->safety.ymax = block->rect.ymax + s1;
363 }
364
365 /* Exception for switched pull-downs. */
366 if (dir1 && (dir1 & block->direction) == 0) {
367 if (dir2 == UI_DIR_RIGHT) {
368 block->safety.xmax = block->rect.xmax + s2;
369 }
370 if (dir2 == UI_DIR_LEFT) {
371 block->safety.xmin = block->rect.xmin - s2;
372 }
373 }
374
375 const bool fully_aligned_with_button = BLI_rctf_size_x(&block->rect) <=
376 BLI_rctf_size_x(&butrct) + 1;
377 const bool off_screen_left = (block->rect.xmin < 0);
378 const bool off_screen_right = (block->rect.xmax > win_size[0]);
379
380 if (fully_aligned_with_button) {
381 /* Popup is neither left or right from the button. */
382 dir2 &= ~(UI_DIR_LEFT | UI_DIR_RIGHT);
383 }
384 else if (off_screen_left || off_screen_right) {
385 /* Popup is both left and right from the button. */
386 dir2 |= (UI_DIR_LEFT | UI_DIR_RIGHT);
387 }
388
389 /* Popovers don't need secondary direction. Pull-downs to
390 * the left or right are currently not supported. */
391 const bool no_2nd_dir = (but->type == ButtonType::Popover ||
393 dir1 & (UI_DIR_RIGHT | UI_DIR_LEFT));
394 block->direction = no_2nd_dir ? dir1 : (dir1 | dir2);
395 }
396
397 /* Keep a list of these, needed for pull-down menus. */
398 SafetyRect *saferct = MEM_new<SafetyRect>(__func__);
399 saferct->parent = butrct;
400 saferct->safety = block->safety;
401 block->saferct.free_no_destruct();
402 BLI_duplicatelist(&block->saferct, &but->block->saferct);
403 BLI_addhead(&block->saferct, saferct);
404}
405
407
408/* -------------------------------------------------------------------- */
411
412static void block_region_refresh(const bContext *C, ARegion *region)
413{
415
416 ScrArea *ctx_area = CTX_wm_area(C);
417 ARegion *ctx_region = CTX_wm_region(C);
418
419 if (region->runtime->do_draw & RGN_REFRESH_UI) {
420 ScrArea *handle_ctx_area;
421 ARegion *handle_ctx_region;
422
423 region->runtime->do_draw &= ~RGN_REFRESH_UI;
424 for (Block &block : region->runtime->uiblocks.items_mutable()) {
425 PopupBlockHandle *handle = block.handle;
426
427 if (handle->can_refresh) {
428 handle_ctx_area = handle->ctx_area;
429 handle_ctx_region = handle->ctx_region;
430
431 if (handle_ctx_area) {
432 CTX_wm_area_set(const_cast<bContext *>(C), handle_ctx_area);
433 }
434 if (handle_ctx_region) {
435 CTX_wm_region_set(const_cast<bContext *>(C), handle_ctx_region);
436 }
437
438 Button *but = handle->popup_create_vars.but;
439 ARegion *butregion = handle->popup_create_vars.butregion;
440 popup_block_refresh(const_cast<bContext *>(C), handle, butregion, but);
441 }
442 }
443 }
444
445 CTX_wm_area_set(const_cast<bContext *>(C), ctx_area);
446 CTX_wm_region_set(const_cast<bContext *>(C), ctx_region);
447}
448
449static void block_region_draw(const bContext *C, ARegion *region)
450{
451 for (Block &block : region->runtime->uiblocks) {
452 block_draw(C, &block);
453 }
454}
455
460{
461 ARegion *region = params->region;
462 const wmNotifier *wmn = params->notifier;
463
464 switch (wmn->category) {
465 case NC_WINDOW: {
466 switch (wmn->action) {
467 case NA_EDITED: {
468 /* window resize */
470 break;
471 }
472 }
473 break;
474 }
475 }
476}
477
478static void popup_block_clip(wmWindow *window, Block *block)
479{
480 const float xmin_orig = block->rect.xmin;
481 const int margin = UI_SCREEN_MARGIN;
482
483 if (block->flag & BLOCK_NO_WIN_CLIP) {
484 return;
485 }
486
487 const int2 win_size = WM_window_native_pixel_size(window);
488
489 /* shift to left if outside of view */
490 if (block->rect.xmax > win_size[0] - margin) {
491 const float xofs = win_size[0] - margin - block->rect.xmax;
492 block->rect.xmin += xofs;
493 block->rect.xmax += xofs;
494 }
495 /* shift menus to right if outside of view */
496 if (block->rect.xmin < margin) {
497 const float xofs = (margin - block->rect.xmin);
498 block->rect.xmin += xofs;
499 block->rect.xmax += xofs;
500 }
501
502 block->rect.ymin = std::max<float>(block->rect.ymin, margin);
503 block->rect.ymax = std::min<float>(block->rect.ymax, win_size[1] - UI_POPUP_MENU_TOP);
504
505 /* ensure menu items draw inside left/right boundary */
506 const float xofs = block->rect.xmin - xmin_orig;
507 for (Button &bt : block->buttons()) {
508 bt.rect.xmin += xofs;
509 bt.rect.xmax += xofs;
510 }
511}
512
514{
515 block->flag &= ~(BLOCK_CLIPBOTTOM | BLOCK_CLIPTOP);
516
517 for (Button &bt : block->buttons()) {
518 bt.flag &= ~UI_SCROLLED;
519 }
520
521 if (block->buttons_ptrs.size() < 2) {
522 return;
523 }
524 if (block->handle->scrolloffset != block->handle->scrollmin) {
525 block->flag |= BLOCK_CLIPTOP;
526 }
527 if (block->handle->scrolloffset != block->handle->scrollmax) {
528 block->flag |= BLOCK_CLIPBOTTOM;
529 }
530
531 for (Button &bt : block->buttons()) {
532 /* Tag buttons that are outside boundary */
533 if (bt.rect.ymax < block->rect.ymin) {
534 bt.flag |= UI_SCROLLED;
535 }
536 if (bt.rect.ymin > block->rect.ymax) {
537 bt.flag |= UI_SCROLLED;
538 }
539 /* Tag buttons overlapping arrows, if we have them */
540 if (block->flag & BLOCK_CLIPBOTTOM) {
541 if (bt.rect.ymax < block->rect.ymin + UI_MENU_SCROLL_MOUSE / block->aspect) {
542 bt.flag |= UI_SCROLLED;
543 }
544 }
545 if (block->flag & BLOCK_CLIPTOP) {
546 if (bt.rect.ymin > block->rect.ymax - UI_MENU_SCROLL_MOUSE / block->aspect) {
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 for (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 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 (screen->regionbase.is_empty()) {
587 win->tag_cursor_refresh = true;
588 }
589
590 if (handle->scrolltimer) {
591 WM_event_timer_remove(wm, win, handle->scrolltimer);
592 }
593 if (handle->keep_open_timer) {
595 }
596 if (handle->mmb_panning) {
598 WM_cursor_grab_disable(win, nullptr);
599 }
600}
601
602void layout_panel_popup_scroll_apply(Panel *panel, const float dy)
603{
604 if (!panel || dy == 0.0f) {
605 return;
606 }
607 for (LayoutPanelBody &body : panel->runtime->layout_panels.bodies) {
608 body.start_y += dy;
609 body.end_y += dy;
610 }
611 for (LayoutPanelHeader &header : panel->runtime->layout_panels.headers) {
612 header.start_y += dy;
613 header.end_y += dy;
614 }
615}
616
626 std::string idname;
627 ListBaseT<LayoutPanelState> states = {};
628
630
632 {
633 for (LayoutPanelState &state : states.items_mutable()) {
635 MEM_delete(state.idname);
636 MEM_delete(&state);
637 }
638 }
639};
640
642 StringRef operator()(const std::unique_ptr<PopupLayoutPanelStates> &value) const
643 {
644 return StringRef(value->idname);
645 }
646};
647
648ListBaseT<LayoutPanelState> &popup_persistent_layout_panel_states(StringRef idname)
649{
652 popup_states;
653 if (!popup_states.contains_as(idname)) {
654 popup_states.add_new(std::make_unique<PopupLayoutPanelStates>(idname));
655 }
656 return popup_states.lookup_key_as(idname)->states;
657}
658
659void popup_dummy_panel_set(ARegion *region, Block *block, StringRef idname)
660{
661 Panel *&panel = region->runtime->popup_block_panel;
662 if (!panel) {
663 /* Dummy popup panel type. */
664 static PanelType panel_type = []() {
665 PanelType type{};
667 return type;
668 }();
669 panel = BKE_panel_new(&panel_type);
670 }
671 panel->runtime->layout_panels.clear();
673 block->panel = panel;
674 panel->runtime->block = block;
675}
676
678{
679 const int margin = UI_POPUP_MARGIN;
680 wmWindow *window = CTX_wm_window(C);
681 ARegion *region = handle->region;
682
683 const BlockCreateFunc create_func = handle->popup_create_vars.create_func;
684 const BlockHandleCreateFunc handle_create_func = handle->popup_create_vars.handle_create_func;
685 void *arg = handle->popup_create_vars.arg;
686
687 Block *block_old = region->runtime->uiblocks.first();
688
689 handle->refresh = (block_old != nullptr);
690
691 BLI_assert(!handle->refresh || handle->can_refresh);
692
693#ifndef NDEBUG
694 wmEvent *event_back = window->runtime->eventstate;
695 wmEvent *event_last_back = window->runtime->event_last_handled;
696#endif
697
698 /* create ui block */
699 Block *block;
700 if (create_func) {
701 block = create_func(C, region, arg);
702 }
703 else {
704 block = handle_create_func(C, handle, arg);
705 }
706
707 /* Don't create accelerator keys if the parent menu does not have them. */
708 if (but && but->block->flag & BLOCK_NO_ACCELERATOR_KEYS) {
710 }
711
712 /* callbacks _must_ leave this for us, otherwise we can't call block_update_from_old */
713 BLI_assert(!block->endblock);
714
715 /* Ensure we don't use mouse coords here.
716 *
717 * NOTE(@ideasman42): Important because failing to do will cause glitches refreshing the popup.
718 *
719 * - Many popups use #wmEvent::xy to position them.
720 * - Refreshing a pop-up must only ever change it's contents. Consider that refreshing
721 * might be used to show a menu item as grayed out, or change a text label,
722 * we *never* want the popup to move based on the cursor location while refreshing.
723 * - The location of the cursor at the time of creation is stored in:
724 * `handle->popup_create_vars.event_xy` which must be used instead.
725 *
726 * Since it's difficult to control logic which is called indirectly here,
727 * clear the `eventstate` entirely to ensure it's never used when refreshing a popup. */
728#ifndef NDEBUG
729 window->runtime->eventstate = nullptr;
730#endif
731
732 if (block->handle) {
733 memcpy(block->handle, handle, sizeof(PopupBlockHandle));
734 MEM_delete(handle);
735 handle = block->handle;
736 }
737 else {
738 block->handle = handle;
739 }
740
741 region->regiondata = handle;
742
743 /* set BLOCK_NUMSELECT before block_end() so we get alphanumeric keys assigned */
744 if (but == nullptr) {
745 block->flag |= BLOCK_POPUP;
746 }
747
748 block->flag |= BLOCK_LOOP;
750
751 /* defer this until blocks are translated (below) */
752 block->oldblock = nullptr;
753
754 if (!block->endblock) {
757 window,
759 region,
761 block,
764 }
765
766 /* if this is being created from a button */
767 if (but) {
768 block->aspect = but->block->aspect;
769 popup_block_position(window, butregion, but, block);
770 handle->direction = block->direction;
771 }
772 else {
773 /* Keep a list of these, needed for pull-down menus. */
774 SafetyRect *saferct = MEM_new<SafetyRect>(__func__);
775 saferct->safety = block->safety;
776 BLI_addhead(&block->saferct, saferct);
777 }
778
779 if (block->flag & BLOCK_PIE_MENU) {
780 const int win_width = UI_SCREEN_MARGIN;
781
782 const int2 win_size = WM_window_native_pixel_size(window);
783
784 copy_v2_v2(block->pie_data->pie_center_init, block->pie_data->pie_center_spawned);
785
786 /* only try translation if area is large enough */
787 int x_offset = 0;
788 if (BLI_rctf_size_x(&block->rect) < win_size[0] - (2.0f * win_width)) {
789 if (block->rect.xmin < win_width) {
790 x_offset += win_width - block->rect.xmin;
791 }
792 if (block->rect.xmax > win_size[0] - win_width) {
793 x_offset += win_size[0] - win_width - block->rect.xmax;
794 }
795 }
796
797 int y_offset = 0;
798 if (BLI_rctf_size_y(&block->rect) < win_size[1] - (2.0f * win_width)) {
799 if (block->rect.ymin < win_width) {
800 y_offset += win_width - block->rect.ymin;
801 }
802 if (block->rect.ymax > win_size[1] - win_width) {
803 y_offset += win_size[1] - win_width - block->rect.ymax;
804 }
805 }
806 /* if we are offsetting set up initial data for timeout functionality */
807
808 if ((x_offset != 0) || (y_offset != 0)) {
809 block->pie_data->pie_center_spawned[0] += x_offset;
810 block->pie_data->pie_center_spawned[1] += y_offset;
811
812 block_translate(block, x_offset, y_offset);
813
814 if (U.pie_initial_timeout > 0) {
815 block->pie_data->flags |= PIE_INITIAL_DIRECTION;
816 }
817 }
818
819 region->winrct.xmin = 0;
820 region->winrct.xmax = win_size[0];
821 region->winrct.ymin = 0;
822 region->winrct.ymax = win_size[1];
823
824 block_calc_pie_segment(block, block->pie_data->pie_center_init);
825
826 /* lastly set the buttons at the center of the pie menu, ready for animation */
827 if (U.pie_animation_timeout > 0) {
828 for (Button &but_iter : block->buttons()) {
829 if (but_iter.pie_dir != UI_RADIAL_NONE) {
830 BLI_rctf_recenter(&but_iter.rect, UNPACK2(block->pie_data->pie_center_spawned));
831 }
832 }
833 }
834 }
835 else {
836 /* Add an offset to draw the popover arrow. */
837 if ((block->flag & BLOCK_POPOVER) && ELEM(block->direction, UI_DIR_UP, UI_DIR_DOWN)) {
838 /* Keep sync with 'ui_draw_popover_back_impl'. */
839 const float unit_size = U.widget_unit / block->aspect;
840 const float unit_half = unit_size * (block->direction == UI_DIR_DOWN ? 0.5 : -0.5);
841
842 block_translate(block, 0, -unit_half);
843 }
844
845 /* clip block with window boundary */
846 popup_block_clip(window, block);
847
848 /* Avoid menu moving down and losing cursor focus by keeping it at the same height when the
849 * popup is displaced down by at least one window unit. */
850 if (handle->refresh && (handle->prev_block_rect.ymax - block->rect.ymax) > 1.0f) {
852 const float offset = handle->prev_block_rect.ymax - block->rect.ymax;
853 block_translate(block, 0, offset);
854 block->rect.ymin = handle->prev_block_rect.ymin;
855 }
856 }
857
858 handle->prev_block_rect = block->rect;
859
860 /* the block and buttons were positioned in window space as in 2.4x, now
861 * these menu blocks are regions so we bring it back to region space.
862 * additionally we add some padding for the menu shadow or rounded menus */
863 region->winrct.xmin = block->rect.xmin - margin;
864 region->winrct.xmax = block->rect.xmax + margin;
865 region->winrct.ymin = block->rect.ymin - margin;
866 region->winrct.ymax = block->rect.ymax + UI_POPUP_MENU_TOP;
867
868 block_translate(block, -region->winrct.xmin, -region->winrct.ymin);
869 /* Popups can change size, fix scroll offset if a panel was closed. */
870 float ymin = FLT_MAX;
871 float ymax = -FLT_MAX;
872 for (const Button &bt : block->buttons()) {
873 ymin = min_ff(ymin, bt.rect.ymin);
874 ymax = max_ff(ymax, bt.rect.ymax);
875 }
876 const float bounds = block->bounds / block->aspect;
877
878 handle->scrollmin = std::round(std::min(block->rect.ymax - (ymax + bounds), 0.0f));
879 handle->scrollmax = std::round(std::max(block->rect.ymin - (ymin - bounds), 0.0f));
880 handle->scrolloffset = std::clamp(handle->scrolloffset, handle->scrollmin, handle->scrollmax);
881
882 /* apply scroll offset */
883 if (handle->scrolloffset != 0.0f) {
884 for (Button &bt : block->buttons()) {
885 bt.rect.ymin += handle->scrolloffset;
886 bt.rect.ymax += handle->scrolloffset;
887 }
888 }
889 /* Layout panels are relative to `block->rect.ymax`. Rather than a
890 * scroll, this is a offset applied due to the overflow at the top. */
892 }
893 /* Apply popup scroll offset to layout panels. */
895
896 if (block_old) {
897 block->oldblock = block_old;
898 block_update_from_old(C, block);
899 blocklist_free_inactive(C, region);
900 }
901
902 /* checks which buttons are visible, sets flags to prevent draw (do after region init) */
904
905 /* Adds sub-window. */
907
908 /* Get `winmat` now that we actually have the sub-window. */
909 wmGetProjectionMatrix(block->winmat, &region->winrct);
910
911 /* notify change and redraw */
912 ED_region_tag_redraw(region);
913
914 ED_region_update_rect(region);
915
916#ifndef NDEBUG
917 window->runtime->eventstate = event_back;
918 window->runtime->event_last_handled = event_last_back;
919#endif
920
921 return block;
922}
923
925 ARegion *butregion,
926 Button *but,
927 BlockCreateFunc create_func,
928 BlockHandleCreateFunc handle_create_func,
929 void *arg,
930 FreeArgFunc arg_free,
931 const bool can_refresh)
932{
933 wmWindow *window = CTX_wm_window(C);
934
935 /* Needed for the splash popup which may be called before the DPI is set, see #161001. */
936 if (window->runtime && window->runtime->ghostwin) {
938 }
939
940 Button *activebut = context_active_but_get(C);
941
942 /* disable tooltips from buttons below */
943 if (activebut) {
944 button_tooltip_timer_remove(C, activebut);
945 }
946 /* standard cursor by default */
948
949 /* create handle */
950 PopupBlockHandle *handle = MEM_new<PopupBlockHandle>(__func__);
951
952 /* store context for operator */
953 handle->ctx_area = CTX_wm_area(C);
954 handle->ctx_region = CTX_wm_region(C);
956 handle->can_refresh = can_refresh;
957
958 /* store vars to refresh popup (RGN_REFRESH_UI) */
959 handle->popup_create_vars.create_func = create_func;
960 handle->popup_create_vars.handle_create_func = handle_create_func;
961 handle->popup_create_vars.arg = arg;
962 handle->popup_create_vars.arg_free = arg_free;
963 handle->popup_create_vars.but = but;
964 handle->popup_create_vars.butregion = but ? butregion : nullptr;
966
967 /* create area region */
969 handle->region = region;
970
971 static ARegionType type;
972 memset(&type, 0, sizeof(ARegionType));
973 type.draw = block_region_draw;
976 region->runtime->type = &type;
977
979
980 /* Note that this will be set in the code-path that typically calls refreshing
981 * (that loops over #Screen::regionbase and refreshes regions tagged with #RGN_REFRESH_UI).
982 * Whereas this only runs on initial creation.
983 * Set the region here so drawing logic can rely on it being set.
984 * Note that restoring the previous value may not be needed, it just avoids potential
985 * problems caused by popups manipulating the context which created them.
986 *
987 * The check for `can_refresh` exists because the context when refreshing sets the "region_popup"
988 * so failing to do so here would cause callbacks draw function to have a different context
989 * the first time it's called. Setting this in every context causes button context menus to
990 * fail because setting the "region_popup" causes poll functions to reference the popup region
991 * instead of the region where the button was created, see #121728.
992 *
993 * NOTE(@ideasman42): the logic for which popups run with their region set to
994 * #bContext::wm::region_popup could be adjusted, making this context member depend on
995 * the ability to refresh seems somewhat arbitrary although it does make *some* sense
996 * because accessing the region later (to tag for refreshing for example)
997 * only makes sense if that region supports refreshing. */
998 ARegion *region_popup_prev = nullptr;
999 if (can_refresh) {
1000 region_popup_prev = CTX_wm_region_popup(C);
1001 CTX_wm_region_popup_set(C, region);
1002 }
1003
1004 Block *block = popup_block_refresh(C, handle, butregion, but);
1005 handle = block->handle;
1006
1007 /* Wait with tooltips until the mouse is moved, button handling will re-enable them on the first
1008 * actual mouse move. */
1009 block->tooltipdisabled = true;
1010
1011 if (can_refresh) {
1012 CTX_wm_region_popup_set(C, region_popup_prev);
1013 }
1014
1015 /* keep centered on window resizing */
1016 if (block->bounds_type == BLOCK_BOUNDS_POPUP_CENTER) {
1018 }
1019
1020 return handle;
1021}
1022
1024{
1025 bool is_submenu = false;
1026
1027 /* If this popup is created from a popover which does NOT have keep-open flag set,
1028 * then close the popover too. We could extend this to other popup types too. */
1029 ARegion *region = handle->popup_create_vars.butregion;
1030 if (region != nullptr) {
1031 for (Block &block : region->runtime->uiblocks) {
1032 if (block.handle && (block.flag & BLOCK_POPOVER) && (block.flag & BLOCK_KEEP_OPEN) == 0) {
1033 PopupBlockHandle *menu = block.handle;
1034 menu->menuretval = RETURN_OK;
1035 }
1036
1037 if (block_is_menu(&block)) {
1038 is_submenu = true;
1039 }
1040 }
1041 }
1042
1043 /* Clear the status bar text that is set when opening a menu. */
1044 if (!is_submenu) {
1045 ED_workspace_status_text(C, nullptr);
1046 }
1047
1048 if (handle->popup_create_vars.arg_free) {
1050 }
1051
1052 if (handle->region->runtime->popup_block_panel) {
1054 }
1055
1056 popup_block_remove(C, handle);
1057
1058 MEM_delete(handle);
1059
1060#ifdef WITH_INPUT_IME
1061 WM_window_IME_region_refresh(CTX_wm_window(C), CTX_wm_area(C), CTX_wm_region(C));
1062#endif
1063}
1064
1067 std::string title;
1068 std::string message;
1072};
1073
1074static void alert_ok_cb(bContext *C, void *arg1, void *arg2)
1075{
1076 AlertData *data = static_cast<AlertData *>(arg1);
1077 MEM_delete(data);
1078 Block *block = static_cast<Block *>(arg2);
1079 popup_menu_retval_set(block, RETURN_OK, true);
1080 wmWindow *win = CTX_wm_window(C);
1081 popup_block_close(C, win, block);
1082}
1083
1084static void alert_ok(bContext * /*C*/, void *arg, int /*retval*/)
1085{
1086 AlertData *data = static_cast<AlertData *>(arg);
1087 MEM_delete(data);
1088}
1089
1090static void alert_cancel(bContext * /*C*/, void *user_data)
1091{
1092 AlertData *data = static_cast<AlertData *>(user_data);
1093 MEM_delete(data);
1094}
1095
1096static Block *alert_create(bContext *C, ARegion *region, void *user_data)
1097{
1098 AlertData *data = static_cast<AlertData *>(user_data);
1099
1100 const uiStyle *style = style_get_dpi();
1101 const short icon_size = (data->compact ? 32 : 40) * UI_SCALE_FAC;
1102 const int max_width = int((data->compact ? 250.0f : 350.0f) * UI_SCALE_FAC);
1103 const int min_width = int(120.0f * UI_SCALE_FAC);
1104
1105 Block *block = block_begin(C, region, __func__, EmbossType::Emboss);
1109 popup_dummy_panel_set(region, block, data->title);
1110
1112 if (data->mouse_move_quit) {
1114 }
1115
1116 const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
1117
1118 fontstyle_set(&style->widget);
1119 /* Width based on the text lengths. */
1120 int text_width = BLF_width(style->widget.uifont_id, data->title.c_str(), data->title.size());
1121
1123 fstyle->uifont_id, data->message, max_width, BLFWrapMode::Typographical);
1124
1125 for (auto &st_ref : messages) {
1126 const std::string &st = st_ref;
1127 text_width = std::max(text_width,
1128 int(BLF_width(style->widget.uifont_id, st.c_str(), st.size())));
1129 }
1130
1131 int dialog_width = std::max(text_width + int(style->columnspace * 2.5), min_width);
1132
1133 Layout &layout = *uiItemsAlertBox(block, style, dialog_width + icon_size, data->icon, icon_size);
1134
1135 Layout &content = layout.column(false);
1136 content.scale_y_set(0.75f);
1137
1138 /* Title. */
1139 uiItemL_ex(&content, data->title, ICON_NONE, true, false);
1140
1141 content.separator(1.0f);
1142
1143 /* Message lines. */
1144 for (auto &st : messages) {
1145 content.label(st, ICON_NONE);
1146 }
1147
1148 if (data->okay_button) {
1149
1150 layout.separator(2.0f);
1151
1152 /* Clear so the OK button is left alone. */
1153 block_func_set(block, nullptr, nullptr, nullptr);
1154
1155 const float pad = std::max((1.0f - ((200.0f * UI_SCALE_FAC) / float(text_width))) / 2.0f,
1156 0.01f);
1157 Layout &split = layout.split(pad, true);
1158 split.column(true);
1159 Layout &buttons = split.split(1.0f - (pad * 2.0f), true);
1160 buttons.scale_y_set(1.2f);
1161
1162 Block *buttons_block = layout.block();
1163 Button *okay_but = uiDefBut(
1164 buttons_block, ButtonType::But, "OK", 0, 0, 0, UI_UNIT_Y, nullptr, 0, 0, "");
1165 button_func_set(okay_but, alert_ok_cb, user_data, block);
1167 }
1168
1169 const int padding = (data->compact ? 10 : 14) * UI_SCALE_FAC;
1170
1171 if (data->mouse_move_quit) {
1172 const float button_center_x = -0.5f;
1173 const float button_center_y = data->okay_button ? 4.0f : 2.0f;
1174 const int bounds_offset[2] = {int(button_center_x * layout.width()),
1175 int(button_center_y * UI_UNIT_X)};
1176 block_bounds_set_popup(block, padding, bounds_offset);
1177 }
1178 else {
1180 }
1181
1182 return block;
1183}
1184
1186 const StringRef title,
1187 const StringRef message,
1188 const AlertIcon icon,
1189 const bool compact)
1190{
1191 AlertData *data = MEM_new<AlertData>(__func__);
1192 data->title = title;
1193 data->message = message;
1194 data->icon = icon;
1195 data->compact = compact;
1196 data->okay_button = true;
1197 data->mouse_move_quit = compact;
1198
1200}
1201
1203
1204} // namespace blender::ui
#define UI_SCALE_FAC
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_UNIT_Y
#define UI_SCREEN_MARGIN
#define UI_FSTYLE_WIDGET
#define UI_UNIT_X
#define NC_WINDOW
Definition WM_types.hh:388
#define NA_EDITED
Definition WM_types.hh:634
int pad[32 - sizeof(int)]
#define UNPACK2(a)
#define ELEM(...)
constexpr StringRef()
const Key & lookup_key_as(const ForwardKey &key) const
bool contains_as(const ForwardKey &key) const
void add_new(const Key &key)
#define FLT_MAX
#define UI_POPUP_MENU_TOP
#define UI_MENU_SUBMENU_PADDING
#define UI_POPUP_MARGIN
#define UI_MENU_PADDING
#define UI_MENU_SCROLL_MOUSE
const int state
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition abc_util.cc:68
Block * popup_block_refresh(bContext *C, PopupBlockHandle *handle, ARegion *butregion, Button *but)
void layout_panel_popup_scroll_apply(Panel *panel, const float dy)
void popup_block_close(bContext *C, wmWindow *win, Block *block)
bool button_menu_draw_as_popover(const Button *but)
static void block_region_draw(const bContext *C, ARegion *region)
void button_func_set(Button *but, std::function< void(bContext &)> func)
static Block * alert_create(bContext *C, ARegion *region, void *user_data)
void block_translate(Block *block, float x, float y)
Definition interface.cc:408
void popup_block_ex(bContext *C, BlockCreateFunc func, BlockHandleFunc popup_func, BlockCancelFunc cancel_func, void *arg, wmOperator *op)
static void alert_cancel(bContext *, void *user_data)
void popup_block_free(bContext *C, PopupBlockHandle *handle)
void block_update_from_old(const bContext *C, Block *block)
void popup_block_scrolltest(Block *block)
void(*)(void *arg) FreeArgFunc
void region_temp_remove(bContext *C, bScreen *screen, ARegion *region)
void fontstyle_set(const uiFontStyle *fs)
void block_end_ex(const bContext *C, Main *bmain, wmWindow *window, Scene *scene, ARegion *region, Depsgraph *depsgraph, Block *block, const int xy[2]=nullptr, int r_xy[2]=nullptr, bool postpone_callbacks=false)
void block_flag_enable(Block *block, int flag)
Layout * uiItemsAlertBox(Block *block, const uiStyle *style, const int dialog_width, const AlertIcon icon, const int icon_size)
bool block_is_menu(const Block *block) ATTR_WARN_UNUSED_RESULT
const uiStyle * style_get_dpi()
ARegion * region_temp_add(bScreen *screen)
void alert(bContext *C, StringRef title, StringRef message, AlertIcon icon, bool compact)
void button_flag_enable(Button *but, int64_t flag)
Block * block_begin(const bContext *C, ARegion *region, std::string name, EmbossType emboss)
Button * uiDefBut(Block *block, ButtonTypeWithPointerType but_and_ptr_type, StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< StringRef > tip)
void block_to_window_rctf(const ARegion *region, const Block *block, rctf *rct_dst, const rctf *rct_src)
Definition interface.cc:172
Block *(*)(bContext *C, ARegion *region, void *arg1) BlockCreateFunc
static void block_region_refresh(const bContext *C, ARegion *region)
void block_theme_style_set(Block *block, char theme_style)
ListBaseT< LayoutPanelState > & popup_persistent_layout_panel_states(StringRef idname)
void blocklist_free_inactive(const bContext *C, ARegion *region)
Block *(*)(bContext *C, PopupBlockHandle *handle, void *arg1) BlockHandleCreateFunc
static void popup_block_position(wmWindow *window, ARegion *butregion, Button *but, Block *block)
void popup_menu_retval_set(const Block *block, int retval, bool enable)
PopupBlockHandle * popup_block_create(bContext *C, ARegion *butregion, Button *but, BlockCreateFunc create_func, BlockHandleCreateFunc handle_create_func, void *arg, FreeArgFunc arg_free, bool can_refresh)
void button_tooltip_timer_remove(bContext *C, Button *but)
void block_emboss_set(Block *block, EmbossType emboss)
void block_func_set(Block *block, ButtonHandleFunc func, void *arg1, void *arg2)
void block_flag_disable(Block *block, int flag)
Button * uiItemL_ex(Layout *layout, StringRef name, int icon, bool highlight, bool redalert)
void block_draw(const bContext *C, Block *block)
float block_calc_pie_segment(Block *block, const float event_xy[2])
static void block_region_popup_window_listener(const wmRegionListenerParams *params)
void block_bounds_set_popup(Block *block, int addval, const int bounds_offset[2])
Definition interface.cc:667
static void alert_ok_cb(bContext *C, void *arg1, void *arg2)
static void alert_ok(bContext *, void *arg, int)
Button * context_active_but_get(const bContext *C)
void popup_dummy_panel_set(ARegion *region, Block *block, StringRef idname)
void popup_translate(ARegion *region, const int mdiff[2])
void region_handlers_add(ListBaseT< wmEventHandler > *handlers)
void block_bounds_set_centered(Block *block, int addval)
Definition interface.cc:693
void button_update(Button *but)
static void popup_block_clip(wmWindow *window, Block *block)
static void popup_block_remove(bContext *C, PopupBlockHandle *handle)
MINLINE float min_ff(float a, float b)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
ScrArea * CTX_wm_area(const bContext *C)
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
uint padding(uint offset, uint alignment)
void ED_region_update_rect(ARegion *region)
Definition area.cc:2539
Panel * BKE_panel_new(PanelType *panel_type)
Definition screen.cc:685
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:835
void BLI_rctf_recenter(struct rctf *rect, float x, float y)
Definition rct.cc:616
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
void void void void void void BLI_duplicatelist(ListBase *dst, const ListBase *src) ATTR_NONNULL(1
Definition listbase.cc:834
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
MINLINE void copy_v2_v2(float r[2], const float a[2])
void CTX_wm_window_set(bContext *C, wmWindow *win)
wmWindow * CTX_wm_window(const bContext *C)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void ED_region_tag_refresh_ui(ARegion *region)
Definition area.cc:738
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
BMesh const char void * data
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.hh:215
wmWindowManager * CTX_wm_manager(const bContext *C)
VectorSet< T, InlineBufferCapacity, DefaultProbingStrategy, CustomIDHash< T, GetIDFn >, CustomIDEqual< T, GetIDFn > > CustomIDVectorSet
void BLI_rcti_translate(struct rcti *rect, int x, int y)
Definition rct.cc:580
void BLI_rctf_init_minmax(struct rctf *rect)
Definition rct.cc:494
Vector< StringRef > BLF_string_wrap(int fontid, StringRef str, const int max_pixel_width, BLFWrapMode mode=BLFWrapMode::Minimal)
Definition blf.cc:1103
void ED_region_floating_init(ARegion *region)
Definition area.cc:2544
void WM_cursor_grab_disable(wmWindow *win, const int mouse_ungrab_xy[2])
void CTX_wm_region_popup_set(bContext *C, ARegion *region_popup)
void BKE_panel_free(Panel *panel)
Definition screen.cc:702
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
@ WM_CURSOR_DEFAULT
Definition wm_cursors.hh:17
Main * CTX_data_main(const bContext *C)
@ PANEL_TYPE_NO_HEADER
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
int2 WM_window_native_pixel_size(const wmWindow *win)
MINLINE float max_ff(float a, float b)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition BLI_rect.hh:198
ARegion * CTX_wm_region_popup(const bContext *C)
void BLI_rctf_translate(struct rctf *rect, float x, float y)
Definition rct.cc:587
void wmGetProjectionMatrix(float mat[4][4], const rcti *winrct)
Scene * CTX_data_scene(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
void WM_cursor_set(wmWindow *win, int curs)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)
bScreen * WM_window_get_active_screen(const wmWindow *win)
void WM_window_dpi_set_userdef(const wmWindow *win)
Definition wm_window.cc:737
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
Definition area.cc:1153
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition BLI_rect.hh:194
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition rct.cc:418
void CTX_wm_area_set(bContext *C, ScrArea *area)
void(*) draw(const bContext *C, ARegion *region)
void(*) listener(const wmRegionListenerParams *params)
void(*) layout(const bContext *C, ARegion *region)
bke::ARegionRuntime * runtime
eRegion_Type regiontype
Vector< LayoutPanelBody > bodies
Vector< LayoutPanelHeader > headers
LayoutPanels layout_panels
ListBaseT< LayoutPanelState > * layout_panel_states_storage
struct Panel_Runtime * runtime
ListBaseT< ARegion > regionbase
ListBaseT< wmEventHandler > handlers
ListBaseT< ui::Block > uiblocks
struct ARegionType * type
ListBaseT< SafetyRect > saferct
Vector< std::unique_ptr< Button > > buttons_ptrs
BlockBoundsCalc bounds_type
std::ranges::transform_view< std::ranges::ref_view< const Vector< std::unique_ptr< Button > > >, Button &(*)(const std::unique_ptr< Button > &)> buttons() const
std::unique_ptr< PieMenuData > pie_data
PopupBlockHandle * handle
void label(StringRef name, int icon)
Layout & split(float percentage, bool align)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
void scale_y_set(float scale)
BlockHandleCreateFunc handle_create_func
StringRef operator()(const std::unique_ptr< PopupLayoutPanelStates > &value) const
unsigned int action
Definition WM_types.hh:371
unsigned int category
Definition WM_types.hh:371
bke::WindowRuntime * runtime
uiFontStyle widget
short columnspace