Blender  V3.3
interface_region_menu_popup.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2008 Blender Foundation. All rights reserved. */
3 
10 #include <cstdarg>
11 #include <cstdlib>
12 #include <cstring>
13 
14 #include "MEM_guardedalloc.h"
15 
16 #include "DNA_userdef_types.h"
17 
18 #include "BLI_listbase.h"
19 #include "BLI_math.h"
20 
21 #include "BLI_ghash.h"
22 #include "BLI_rect.h"
23 #include "BLI_string.h"
24 #include "BLI_utildefines.h"
25 
26 #include "BKE_context.h"
27 #include "BKE_report.h"
28 #include "BKE_screen.h"
29 
30 #include "WM_api.h"
31 #include "WM_types.h"
32 
33 #include "RNA_access.h"
34 
35 #include "UI_interface.h"
36 
37 #include "BLT_translation.h"
38 
39 #include "ED_screen.h"
40 
41 #include "interface_intern.h"
43 
44 /* -------------------------------------------------------------------- */
48 bool ui_but_menu_step_poll(const uiBut *but)
49 {
50  BLI_assert(but->type == UI_BTYPE_MENU);
51 
52  /* currently only RNA buttons */
53  return ((but->menu_step_func != nullptr) ||
54  (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM));
55 }
56 
57 int ui_but_menu_step(uiBut *but, int direction)
58 {
59  if (ui_but_menu_step_poll(but)) {
60  if (but->menu_step_func) {
61  return but->menu_step_func(
62  static_cast<bContext *>(but->block->evil_C), direction, but->poin);
63  }
64 
65  const int curval = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
66  return RNA_property_enum_step(static_cast<bContext *>(but->block->evil_C),
67  &but->rnapoin,
68  but->rnaprop,
69  curval,
70  direction);
71  }
72 
73  printf("%s: cannot cycle button '%s'\n", __func__, but->str);
74  return 0;
75 }
76 
79 /* -------------------------------------------------------------------- */
88 static uint ui_popup_string_hash(const char *str, const bool use_sep)
89 {
90  /* sometimes button contains hotkey, sometimes not, strip for proper compare */
91  int hash;
92  const char *delimit = use_sep ? strrchr(str, UI_SEP_CHAR) : nullptr;
93 
94  if (delimit) {
95  hash = BLI_ghashutil_strhash_n(str, delimit - str);
96  }
97  else {
99  }
100 
101  return hash;
102 }
103 
105 {
106  return BLI_ghashutil_strhash(str);
107 }
108 
109 /* but == nullptr read, otherwise set */
111 {
112  static uint mem[256];
113  static bool first = true;
114 
115  const uint hash = block->puphash;
116  const uint hash_mod = hash & 255;
117 
118  if (first) {
119  /* init */
120  memset(mem, -1, sizeof(mem));
121  first = false;
122  }
123 
124  if (but) {
125  /* set */
126  mem[hash_mod] = ui_popup_string_hash(but->str, but->flag & UI_BUT_HAS_SEP_CHAR);
127  return nullptr;
128  }
129 
130  /* get */
131  LISTBASE_FOREACH (uiBut *, but_iter, &block->buttons) {
132  /* Prevent labels (typically headings), from being returned in the case the text
133  * happens to matches one of the menu items.
134  * Skip separators too as checking them is redundant. */
135  if (ELEM(but_iter->type, UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) {
136  continue;
137  }
138  if (mem[hash_mod] ==
139  ui_popup_string_hash(but_iter->str, but_iter->flag & UI_BUT_HAS_SEP_CHAR)) {
140  return but_iter;
141  }
142  }
143 
144  return nullptr;
145 }
146 
148 {
149  return ui_popup_menu_memory__internal(block, nullptr);
150 }
151 
153 {
154  ui_popup_menu_memory__internal(block, but);
155 }
156 
159 /* -------------------------------------------------------------------- */
163 struct uiPopupMenu {
168 
169  int mx, my;
171 
173  void *menu_arg;
174 };
175 
176 static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, void *arg_pup)
177 {
178  uiBlock *block;
179  uiPopupMenu *pup = static_cast<uiPopupMenu *>(arg_pup);
180  int minwidth, width, height;
181  char direction;
182  bool flip;
183 
184  if (pup->menu_func) {
185  pup->block->handle = handle;
186  pup->menu_func(C, pup->layout, pup->menu_arg);
187  pup->block->handle = nullptr;
188  }
189 
190  /* Find block minimum width. */
191  if (uiLayoutGetUnitsX(pup->layout) != 0.0f) {
192  /* Use the minimum width from the layout if it's set. */
193  minwidth = uiLayoutGetUnitsX(pup->layout) * UI_UNIT_X;
194  }
195  else if (pup->but) {
196  /* Minimum width to enforce. */
197  if (pup->but->drawstr[0]) {
198  minwidth = BLI_rctf_size_x(&pup->but->rect);
199  }
200  else {
201  /* For buttons with no text, use the minimum (typically icon only). */
202  minwidth = UI_MENU_WIDTH_MIN;
203  }
204  }
205  else {
206  minwidth = UI_MENU_WIDTH_MIN;
207  }
208 
209  /* Find block direction. */
210  if (pup->but) {
211  if (pup->block->direction != 0) {
212  /* allow overriding the direction from menu_func */
213  direction = pup->block->direction;
214  }
215  else {
216  direction = UI_DIR_DOWN;
217  }
218  }
219  else {
220  direction = UI_DIR_DOWN;
221  }
222 
223  flip = (direction == UI_DIR_DOWN);
224 
225  block = pup->block;
226 
227  /* in some cases we create the block before the region,
228  * so we set it delayed here if necessary */
229  if (BLI_findindex(&handle->region->uiblocks, block) == -1) {
230  UI_block_region_set(block, handle->region);
231  }
232 
233  block->direction = direction;
234 
236 
238 
239  if (pup->popup) {
240  int offset[2];
241 
242  uiBut *but_activate = nullptr;
245  UI_block_direction_set(block, direction);
246 
247  /* offset the mouse position, possibly based on earlier selection */
248  uiBut *bt;
249  if ((block->flag & UI_BLOCK_POPUP_MEMORY) && (bt = ui_popup_menu_memory_get(block))) {
250  /* position mouse on last clicked item, at 0.8*width of the
251  * button, so it doesn't overlap the text too much, also note
252  * the offset is negative because we are inverse moving the
253  * block to be under the mouse */
254  offset[0] = -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect));
255  offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y);
256 
257  if (ui_but_is_editable(bt)) {
258  but_activate = bt;
259  }
260  }
261  else {
262  /* position mouse at 0.8*width of the button and below the tile
263  * on the first item */
264  offset[0] = 0;
265  LISTBASE_FOREACH (uiBut *, but_iter, &block->buttons) {
266  offset[0] = min_ii(offset[0],
267  -(but_iter->rect.xmin + 0.8f * BLI_rctf_size_x(&but_iter->rect)));
268  }
269 
270  offset[1] = 2.1 * UI_UNIT_Y;
271 
272  LISTBASE_FOREACH (uiBut *, but_iter, &block->buttons) {
273  if (ui_but_is_editable(but_iter)) {
274  but_activate = but_iter;
275  break;
276  }
277  }
278  }
279 
280  /* in rare cases this is needed since moving the popup
281  * to be within the window bounds may move it away from the mouse,
282  * This ensures we set an item to be active. */
283  if (but_activate) {
284  ui_but_activate_over(C, handle->region, but_activate);
285  }
286 
287  block->minbounds = minwidth;
288  UI_block_bounds_set_menu(block, 1, offset);
289  }
290  else {
291  /* for a header menu we set the direction automatic */
292  if (!pup->slideout && flip) {
293  ARegion *region = CTX_wm_region(C);
294  if (region) {
295  if (RGN_TYPE_IS_HEADER_ANY(region->regiontype)) {
298  UI_block_order_flip(block);
299  }
300  }
301  }
302  }
303 
304  block->minbounds = minwidth;
305  UI_block_bounds_set_text(block, 3.0f * UI_UNIT_X);
306  }
307 
308  /* if menu slides out of other menu, override direction */
309  if (pup->slideout) {
311  }
312 
313  return pup->block;
314 }
315 
317  bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg)
318 {
319  wmWindow *window = CTX_wm_window(C);
320  const uiStyle *style = UI_style_get_dpi();
321  uiPopupBlockHandle *handle;
322 
323  uiPopupMenu *pup = MEM_cnew<uiPopupMenu>(__func__);
324  pup->block = UI_block_begin(C, nullptr, __func__, UI_EMBOSS_PULLDOWN);
325  pup->block->flag |= UI_BLOCK_NUMSELECT; /* default menus to numselect */
326  pup->layout = UI_block_layout(
327  pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, UI_MENU_PADDING, style);
328  pup->slideout = but ? ui_block_is_menu(but->block) : false;
329  pup->but = but;
331 
332  if (!but) {
333  /* no button to start from, means we are a popup */
334  pup->mx = window->eventstate->xy[0];
335  pup->my = window->eventstate->xy[1];
336  pup->popup = true;
337  pup->block->flag |= UI_BLOCK_NO_FLIP;
338  }
339  /* some enums reversing is strange, currently we have no good way to
340  * reverse some enum's but not others, so reverse all so the first menu
341  * items are always close to the mouse cursor */
342  else {
343 #if 0
344  /* if this is an rna button then we can assume its an enum
345  * flipping enums is generally not good since the order can be
346  * important T28786. */
347  if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) {
348  pup->block->flag |= UI_BLOCK_NO_FLIP;
349  }
350 #endif
351  if (but->context) {
352  uiLayoutContextCopy(pup->layout, but->context);
353  }
354  }
355 
356  /* menu is created from a callback */
357  pup->menu_func = menu_func;
358  pup->menu_arg = arg;
359 
360  handle = ui_popup_block_create(C, butregion, but, nullptr, ui_block_func_POPUP, pup, nullptr);
361 
362  if (!but) {
363  handle->popup = true;
364 
365  UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
366  WM_event_add_mousemove(window);
367  }
368 
369  MEM_freeN(pup);
370 
371  return handle;
372 }
373 
376 /* -------------------------------------------------------------------- */
381  const char *title,
382  const char *block_name,
383  int icon)
384 {
385  const uiStyle *style = UI_style_get_dpi();
386  uiPopupMenu *pup = MEM_cnew<uiPopupMenu>(__func__);
387  uiBut *but;
388 
389  pup->block = UI_block_begin(C, nullptr, block_name, UI_EMBOSS_PULLDOWN);
391  pup->block->puphash = ui_popup_menu_hash(title);
392  pup->layout = UI_block_layout(
393  pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, UI_MENU_PADDING, style);
394 
395  /* NOTE: this intentionally differs from the menu & sub-menu default because many operators
396  * use popups like this to select one of their options -
397  * where having invoke doesn't make sense */
399 
400  /* create in advance so we can let buttons point to retval already */
401  pup->block->handle = MEM_cnew<uiPopupBlockHandle>(__func__);
402 
403  /* create title button */
404  if (title[0]) {
405  char titlestr[256];
406 
407  if (icon) {
408  BLI_snprintf(titlestr, sizeof(titlestr), " %s", title);
409  uiDefIconTextBut(pup->block,
411  0,
412  icon,
413  titlestr,
414  0,
415  0,
416  200,
417  UI_UNIT_Y,
418  nullptr,
419  0.0,
420  0.0,
421  0,
422  0,
423  "");
424  }
425  else {
426  but = uiDefBut(
427  pup->block, UI_BTYPE_LABEL, 0, title, 0, 0, 200, UI_UNIT_Y, nullptr, 0.0, 0.0, 0, 0, "");
428  but->drawflag = UI_BUT_TEXT_LEFT;
429  }
430 
431  uiItemS(pup->layout);
432  }
433 
434  return pup;
435 }
436 
437 uiPopupMenu *UI_popup_menu_begin(bContext *C, const char *title, int icon)
438 {
439  return UI_popup_menu_begin_ex(C, title, __func__, icon);
440 }
441 
442 void UI_popup_menu_but_set(uiPopupMenu *pup, struct ARegion *butregion, uiBut *but)
443 {
444  pup->but = but;
445  pup->butregion = butregion;
446 }
447 
449 {
450  wmWindow *window = CTX_wm_window(C);
451  uiPopupBlockHandle *menu;
452  uiBut *but = nullptr;
453  ARegion *butregion = nullptr;
454 
455  pup->popup = true;
456  pup->mx = window->eventstate->xy[0];
457  pup->my = window->eventstate->xy[1];
458 
459  if (pup->but) {
460  but = pup->but;
461  butregion = pup->butregion;
462  }
463 
464  menu = ui_popup_block_create(C, butregion, but, nullptr, ui_block_func_POPUP, pup, nullptr);
465  menu->popup = true;
466 
467  UI_popup_handlers_add(C, &window->modalhandlers, menu, 0);
468  WM_event_add_mousemove(window);
469 
470  MEM_freeN(pup);
471 }
472 
474 {
475  if (!UI_block_is_empty_ex(pup->block, true)) {
476  UI_popup_menu_end(C, pup);
477  return true;
478  }
479  UI_block_layout_resolve(pup->block, nullptr, nullptr);
480  MEM_freeN(pup->block->handle);
481  UI_block_free(C, pup->block);
482  MEM_freeN(pup);
483  return false;
484 }
485 
487 {
488  return pup->layout;
489 }
490 
493 /* -------------------------------------------------------------------- */
498 {
499  uiPopupMenu *pup = nullptr;
500  uiLayout *layout;
501 
502  if (!CTX_wm_window(C)) {
503  return;
504  }
505 
506  LISTBASE_FOREACH (Report *, report, &reports->list) {
507  int icon;
508  const char *msg, *msg_next;
509 
510  if (report->type < reports->printlevel) {
511  continue;
512  }
513 
514  if (pup == nullptr) {
515  char title[UI_MAX_DRAW_STR];
516  BLI_snprintf(title, sizeof(title), "%s: %s", IFACE_("Report"), report->typestr);
517  /* popup_menu stuff does just what we need (but pass meaningful block name) */
518  pup = UI_popup_menu_begin_ex(C, title, __func__, ICON_NONE);
519  layout = UI_popup_menu_layout(pup);
520  }
521  else {
522  uiItemS(layout);
523  }
524 
525  /* split each newline into a label */
526  msg = report->message;
527  icon = UI_icon_from_report_type(report->type);
528  do {
529  char buf[UI_MAX_DRAW_STR];
530  msg_next = strchr(msg, '\n');
531  if (msg_next) {
532  msg_next++;
533  BLI_strncpy(buf, msg, MIN2(sizeof(buf), msg_next - msg));
534  msg = buf;
535  }
536  uiItemL(layout, msg, icon);
537  icon = ICON_NONE;
538  } while ((msg = msg_next) && *msg);
539  }
540 
541  if (pup) {
542  UI_popup_menu_end(C, pup);
543  }
544 }
545 
546 int UI_popup_menu_invoke(bContext *C, const char *idname, ReportList *reports)
547 {
548  uiPopupMenu *pup;
549  uiLayout *layout;
550  MenuType *mt = WM_menutype_find(idname, true);
551 
552  if (mt == nullptr) {
553  BKE_reportf(reports, RPT_ERROR, "Menu \"%s\" not found", idname);
554  return OPERATOR_CANCELLED;
555  }
556 
557  if (WM_menutype_poll(C, mt) == false) {
558  /* cancel but allow event to pass through, just like operators do */
560  }
561 
562  pup = UI_popup_menu_begin(C, IFACE_(mt->label), ICON_NONE);
563  layout = UI_popup_menu_layout(pup);
564 
565  UI_menutype_draw(C, mt, layout);
566 
567  UI_popup_menu_end(C, pup);
568 
569  return OPERATOR_INTERFACE;
570 }
571 
574 /* -------------------------------------------------------------------- */
579  bContext *C, uiBlockCreateFunc func, void *arg, uiFreeArgFunc arg_free, bool can_refresh)
580 {
581  wmWindow *window = CTX_wm_window(C);
582  uiPopupBlockHandle *handle;
583 
584  handle = ui_popup_block_create(C, nullptr, nullptr, func, nullptr, arg, arg_free);
585  handle->popup = true;
586 
587  /* It can be useful to disable refresh (even though it will work)
588  * as this exists text fields which can be disruptive if refresh isn't needed. */
589  handle->can_refresh = can_refresh;
590 
591  UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
593  C, handle->region, static_cast<uiBlock *>(handle->region->uiblocks.first));
594  WM_event_add_mousemove(window);
595 }
596 
598 {
599  UI_popup_block_invoke_ex(C, func, arg, arg_free, true);
600 }
601 
603  uiBlockCreateFunc func,
604  uiBlockHandleFunc popup_func,
605  uiBlockCancelFunc cancel_func,
606  void *arg,
607  wmOperator *op)
608 {
609  wmWindow *window = CTX_wm_window(C);
610  uiPopupBlockHandle *handle;
611 
612  handle = ui_popup_block_create(C, nullptr, nullptr, func, nullptr, arg, nullptr);
613  handle->popup = true;
614  handle->retvalue = 1;
615  handle->can_refresh = true;
616 
617  handle->popup_op = op;
618  handle->popup_arg = arg;
619  handle->popup_func = popup_func;
620  handle->cancel_func = cancel_func;
621  // handle->opcontext = opcontext;
622 
623  UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
625  C, handle->region, static_cast<uiBlock *>(handle->region->uiblocks.first));
626  WM_event_add_mousemove(window);
627 }
628 
629 #if 0 /* UNUSED */
630 void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, wmOperatorCallContext opcontext)
631 {
632  wmWindow *window = CTX_wm_window(C);
633  uiPopupBlockHandle *handle;
634 
635  handle = ui_popup_block_create(C, nullptr, nullptr, func, nullptr, op, nullptr);
636  handle->popup = 1;
637  handle->retvalue = 1;
638  handle->can_refresh = true;
639 
640  handle->popup_arg = op;
641  handle->popup_func = operator_cb;
642  handle->cancel_func = confirm_cancel_operator;
643  handle->opcontext = opcontext;
644 
645  UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
647 }
648 #endif
649 
651 {
652  /* if loading new .blend while popup is open, window will be nullptr */
653  if (block->handle) {
654  if (win) {
655  const bScreen *screen = WM_window_get_active_screen(win);
656 
658  ui_popup_block_free(C, block->handle);
659 
660  /* In the case we have nested popups,
661  * closing one may need to redraw another, see: T48874 */
662  LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
663  ED_region_tag_refresh_ui(region);
664  }
665  }
666  }
667 }
668 
669 bool UI_popup_block_name_exists(const bScreen *screen, const char *name)
670 {
671  LISTBASE_FOREACH (const ARegion *, region, &screen->regionbase) {
672  LISTBASE_FOREACH (const uiBlock *, block, &region->uiblocks) {
673  if (STREQ(block->name, name)) {
674  return true;
675  }
676  }
677  }
678  return false;
679 }
680 
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_assert(a)
Definition: BLI_assert.h:46
unsigned int BLI_ghashutil_strhash_n(const char *key, size_t n)
#define BLI_ghashutil_strhash(key)
Definition: BLI_ghash.h:573
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int min_ii(int a, int b)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition: BLI_rect.h:194
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
unsigned int uint
Definition: BLI_sys_types.h:67
#define ELEM(...)
#define MIN2(a, b)
#define STREQ(a, b)
#define IFACE_(msgid)
#define RGN_ALIGN_ENUM_FROM_MASK(align)
@ RGN_ALIGN_BOTTOM
#define RGN_TYPE_IS_HEADER_ANY(regiontype)
@ OPERATOR_CANCELLED
@ OPERATOR_INTERFACE
@ OPERATOR_PASS_THROUGH
void ED_region_tag_refresh_ui(struct ARegion *region)
Definition: area.c:683
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
Read Guarded memory(de)allocation.
@ PROP_ENUM
Definition: RNA_types.h:63
#define C
Definition: RandGen.cpp:25
@ UI_BUT_TEXT_LEFT
Definition: UI_interface.h:259
@ UI_LAYOUT_VERTICAL
uiBut * uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.cc:5623
#define UI_UNIT_Y
@ UI_BUT_HAS_SEP_CHAR
Definition: UI_interface.h:222
@ UI_EMBOSS_PULLDOWN
Definition: UI_interface.h:110
const struct uiStyle * UI_style_get_dpi(void)
void UI_block_theme_style_set(uiBlock *block, char theme_style)
Definition: interface.cc:3634
int UI_icon_from_report_type(int type)
void UI_menutype_draw(struct bContext *C, struct MenuType *mt, struct uiLayout *layout)
#define UI_SEP_CHAR
Definition: UI_interface.h:83
uiBut * uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip)
Definition: interface.cc:4806
void(* uiBlockHandleFunc)(struct bContext *C, void *arg, int event)
Definition: UI_interface.h:540
void uiItemL(uiLayout *layout, const char *name, int icon)
@ UI_BLOCK_THEME_STYLE_POPUP
Definition: UI_interface.h:770
@ UI_LAYOUT_MENU
float uiLayoutGetUnitsX(uiLayout *layout)
void uiLayoutContextCopy(uiLayout *layout, struct bContextStore *context)
@ UI_DIR_DOWN
Definition: UI_interface.h:124
@ UI_DIR_RIGHT
Definition: UI_interface.h:126
@ UI_DIR_UP
Definition: UI_interface.h:123
void uiItemS(uiLayout *layout)
void(* uiFreeArgFunc)(void *arg)
Definition: UI_interface.h:603
#define UI_MAX_DRAW_STR
Definition: UI_interface.h:91
void UI_popup_handlers_add(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup, char flag)
void UI_block_bounds_set_menu(uiBlock *block, int addval, const int bounds_offset[2])
Definition: interface.cc:612
bool UI_block_is_empty_ex(const uiBlock *block, bool skip_title)
uiLayout * UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, const struct uiStyle *style)
void UI_block_bounds_set_text(uiBlock *block, int addval)
Definition: interface.cc:592
void UI_block_free(const struct bContext *C, uiBlock *block)
bool UI_block_active_only_flagged_buttons(const struct bContext *C, struct ARegion *region, struct uiBlock *block)
uiBlock * UI_block_begin(const struct bContext *C, struct ARegion *region, const char *name, eUIEmbossType emboss)
void UI_block_order_flip(uiBlock *block)
Definition: interface.cc:5815
void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
void(* uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1)
Definition: UI_interface.h:592
void UI_block_direction_set(uiBlock *block, char direction)
Definition: interface.cc:5810
#define UI_UNIT_X
void UI_block_flag_enable(uiBlock *block, int flag)
Definition: interface.cc:5848
@ UI_BTYPE_LABEL
Definition: UI_interface.h:354
@ UI_BTYPE_SEPR_LINE
Definition: UI_interface.h:386
@ UI_BTYPE_SEPR
Definition: UI_interface.h:385
@ UI_BTYPE_MENU
Definition: UI_interface.h:334
void UI_popup_handlers_remove(struct ListBase *handlers, uiPopupBlockHandle *popup)
void uiLayoutSetOperatorContext(uiLayout *layout, wmOperatorCallContext opcontext)
void(* uiBlockCancelFunc)(struct bContext *C, void *arg1)
Definition: UI_interface.h:715
void UI_block_region_set(uiBlock *block, struct ARegion *region)
Definition: interface.cc:3551
uiBlock *(* uiBlockCreateFunc)(struct bContext *C, struct ARegion *region, void *arg1)
Definition: UI_interface.h:714
@ UI_BLOCK_NUMSELECT
Definition: UI_interface.h:138
@ UI_BLOCK_LOOP
Definition: UI_interface.h:135
@ UI_BLOCK_POPUP_MEMORY
Definition: UI_interface.h:148
@ UI_BLOCK_MOVEMOUSE_QUIT
Definition: UI_interface.h:143
@ UI_BLOCK_IS_FLIP
Definition: UI_interface.h:136
@ UI_BLOCK_NO_FLIP
Definition: UI_interface.h:137
wmOperatorCallContext
Definition: WM_types.h:199
@ WM_OP_INVOKE_REGION_WIN
Definition: WM_types.h:202
@ WM_OP_EXEC_REGION_WIN
Definition: WM_types.h:209
#define str(s)
void ui_but_activate_over(bContext *C, ARegion *region, uiBut *but)
uiPopupBlockHandle * ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but, uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg, uiFreeArgFunc arg_free)
void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle)
bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT
#define UI_MENU_PADDING
bool ui_but_is_editable(const uiBut *but) ATTR_WARN_UNUSED_RESULT
#define UI_MENU_WIDTH_MIN
static uiBut * ui_popup_menu_memory__internal(uiBlock *block, uiBut *but)
void UI_popup_menu_but_set(uiPopupMenu *pup, struct ARegion *butregion, uiBut *but)
bool ui_but_menu_step_poll(const uiBut *but)
uiPopupMenu * UI_popup_menu_begin_ex(bContext *C, const char *title, const char *block_name, int icon)
void UI_popup_block_invoke(bContext *C, uiBlockCreateFunc func, void *arg, uiFreeArgFunc arg_free)
void UI_popup_block_ex(bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg, wmOperator *op)
void UI_popup_menu_end(bContext *C, uiPopupMenu *pup)
void UI_popup_block_invoke_ex(bContext *C, uiBlockCreateFunc func, void *arg, uiFreeArgFunc arg_free, bool can_refresh)
bool UI_popup_block_name_exists(const bScreen *screen, const char *name)
void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block)
static uint ui_popup_string_hash(const char *str, const bool use_sep)
uiLayout * UI_popup_menu_layout(uiPopupMenu *pup)
uint ui_popup_menu_hash(const char *str)
int ui_but_menu_step(uiBut *but, int direction)
uiBut * ui_popup_menu_memory_get(uiBlock *block)
void UI_popup_menu_reports(bContext *C, ReportList *reports)
int UI_popup_menu_invoke(bContext *C, const char *idname, ReportList *reports)
static uiBlock * ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, void *arg_pup)
bool UI_popup_menu_end_or_cancel(bContext *C, uiPopupMenu *pup)
uiPopupBlockHandle * ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg)
void ui_popup_menu_memory_set(uiBlock *block, uiBut *but)
uiPopupMenu * UI_popup_menu_begin(bContext *C, const char *title, int icon)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
#define hash
Definition: noise.c:153
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1010
int RNA_property_enum_step(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, int from_value, int step)
Definition: rna_access.c:3460
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3402
short alignment
short regiontype
ListBase uiblocks
void * first
Definition: DNA_listBase.h:31
char label[BKE_ST_MAXNAME]
Definition: BKE_screen.h:362
ListBase regionbase
float xmin
Definition: DNA_vec_types.h:69
float ymin
Definition: DNA_vec_types.h:70
uiPopupBlockHandle * handle
ListBase buttons
void * evil_C
struct bContextStore * context
eButType type
uiBlock * block
char * poin
char drawstr[UI_MAX_DRAW_STR]
uiMenuStepFunc menu_step_func
struct PropertyRNA * rnaprop
char * str
struct PointerRNA rnapoin
struct ARegion * region
struct wmOperator * popup_op
void(* cancel_func)(struct bContext *C, void *arg)
void(* popup_func)(struct bContext *C, void *arg, int event)
uiMenuCreateFunc menu_func
int xy[2]
Definition: WM_types.h:682
struct wmEvent * eventstate
void WM_event_add_mousemove(wmWindow *win)
MenuType * WM_menutype_find(const char *idname, bool quiet)
Definition: wm_menu_type.c:30
bool WM_menutype_poll(bContext *C, MenuType *mt)
Definition: wm_menu_type.c:87
bScreen * WM_window_get_active_screen(const wmWindow *win)
Definition: wm_window.c:2300