Blender  V3.3
rna_ui.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <stdlib.h>
8 
9 #include "DNA_screen_types.h"
10 #include "DNA_space_types.h"
11 
12 #include "BLT_translation.h"
13 
14 #include "BKE_idprop.h"
15 #include "BKE_screen.h"
16 
17 #include "BLI_listbase.h"
18 
19 #include "RNA_define.h"
20 
21 #include "RNA_enum_types.h"
22 #include "rna_internal.h"
23 
24 #include "UI_interface.h"
25 
26 #include "WM_toolsystem.h"
27 #include "WM_types.h"
28 
29 /* see WM_types.h */
31  {WM_OP_INVOKE_DEFAULT, "INVOKE_DEFAULT", 0, "Invoke Default", ""},
32  {WM_OP_INVOKE_REGION_WIN, "INVOKE_REGION_WIN", 0, "Invoke Region Window", ""},
33  {WM_OP_INVOKE_REGION_CHANNELS, "INVOKE_REGION_CHANNELS", 0, "Invoke Region Channels", ""},
34  {WM_OP_INVOKE_REGION_PREVIEW, "INVOKE_REGION_PREVIEW", 0, "Invoke Region Preview", ""},
35  {WM_OP_INVOKE_AREA, "INVOKE_AREA", 0, "Invoke Area", ""},
36  {WM_OP_INVOKE_SCREEN, "INVOKE_SCREEN", 0, "Invoke Screen", ""},
37  {WM_OP_EXEC_DEFAULT, "EXEC_DEFAULT", 0, "Exec Default", ""},
38  {WM_OP_EXEC_REGION_WIN, "EXEC_REGION_WIN", 0, "Exec Region Window", ""},
39  {WM_OP_EXEC_REGION_CHANNELS, "EXEC_REGION_CHANNELS", 0, "Exec Region Channels", ""},
40  {WM_OP_EXEC_REGION_PREVIEW, "EXEC_REGION_PREVIEW", 0, "Exec Region Preview", ""},
41  {WM_OP_EXEC_AREA, "EXEC_AREA", 0, "Exec Area", ""},
42  {WM_OP_EXEC_SCREEN, "EXEC_SCREEN", 0, "Exec Screen", ""},
43  {0, NULL, 0, NULL, NULL},
44 };
45 
47  {UILST_LAYOUT_DEFAULT, "DEFAULT", 0, "Default Layout", "Use the default, multi-rows layout"},
48  {UILST_LAYOUT_COMPACT, "COMPACT", 0, "Compact Layout", "Use the compact, single-row layout"},
49  {UILST_LAYOUT_GRID, "GRID", 0, "Grid Layout", "Use the grid-based layout"},
50  {0, NULL, 0, NULL, NULL},
51 };
52 
53 #ifdef RNA_RUNTIME
54 
55 # include "MEM_guardedalloc.h"
56 
57 # include "RNA_access.h"
58 
59 # include "BLI_dynstr.h"
60 
61 # include "BKE_context.h"
62 # include "BKE_report.h"
63 # include "BKE_screen.h"
64 
65 # include "WM_api.h"
66 
67 static ARegionType *region_type_find(ReportList *reports, int space_type, int region_type)
68 {
69  SpaceType *st;
70  ARegionType *art;
71 
72  st = BKE_spacetype_from_id(space_type);
73 
74  for (art = (st) ? st->regiontypes.first : NULL; art; art = art->next) {
75  if (art->regionid == region_type) {
76  break;
77  }
78  }
79 
80  /* region type not found? abort */
81  if (art == NULL) {
82  BKE_report(reports, RPT_ERROR, "Region not found in space type");
83  return NULL;
84  }
85 
86  return art;
87 }
88 
89 /* Panel */
90 
91 static bool panel_poll(const bContext *C, PanelType *pt)
92 {
93  extern FunctionRNA rna_Panel_poll_func;
94 
96  ParameterList list;
97  FunctionRNA *func;
98  void *ret;
99  bool visible;
100 
101  RNA_pointer_create(NULL, pt->rna_ext.srna, NULL, &ptr); /* dummy */
102  func = &rna_Panel_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
103 
104  RNA_parameter_list_create(&list, &ptr, func);
105  RNA_parameter_set_lookup(&list, "context", &C);
106  pt->rna_ext.call((bContext *)C, &ptr, func, &list);
107 
108  RNA_parameter_get_lookup(&list, "visible", &ret);
109  visible = *(bool *)ret;
110 
112 
113  return visible;
114 }
115 
116 static void panel_draw(const bContext *C, Panel *panel)
117 {
118  extern FunctionRNA rna_Panel_draw_func;
119 
120  PointerRNA ptr;
121  ParameterList list;
122  FunctionRNA *func;
123 
124  RNA_pointer_create(&CTX_wm_screen(C)->id, panel->type->rna_ext.srna, panel, &ptr);
125  func = &rna_Panel_draw_func; /* RNA_struct_find_function(&ptr, "draw"); */
126 
127  RNA_parameter_list_create(&list, &ptr, func);
128  RNA_parameter_set_lookup(&list, "context", &C);
129  panel->type->rna_ext.call((bContext *)C, &ptr, func, &list);
130 
132 }
133 
134 static void panel_draw_header(const bContext *C, Panel *panel)
135 {
136  extern FunctionRNA rna_Panel_draw_header_func;
137 
138  PointerRNA ptr;
139  ParameterList list;
140  FunctionRNA *func;
141 
142  RNA_pointer_create(&CTX_wm_screen(C)->id, panel->type->rna_ext.srna, panel, &ptr);
143  func = &rna_Panel_draw_header_func; /* RNA_struct_find_function(&ptr, "draw_header"); */
144 
145  RNA_parameter_list_create(&list, &ptr, func);
146  RNA_parameter_set_lookup(&list, "context", &C);
147  panel->type->rna_ext.call((bContext *)C, &ptr, func, &list);
148 
150 }
151 
152 static void panel_draw_header_preset(const bContext *C, Panel *panel)
153 {
154  extern FunctionRNA rna_Panel_draw_header_preset_func;
155 
156  PointerRNA ptr;
157  ParameterList list;
158  FunctionRNA *func;
159 
160  RNA_pointer_create(&CTX_wm_screen(C)->id, panel->type->rna_ext.srna, panel, &ptr);
161  func = &rna_Panel_draw_header_preset_func;
162 
163  RNA_parameter_list_create(&list, &ptr, func);
164  RNA_parameter_set_lookup(&list, "context", &C);
165  panel->type->rna_ext.call((bContext *)C, &ptr, func, &list);
166 
168 }
169 
170 static void panel_type_clear_recursive(Panel *panel, const PanelType *type)
171 {
172  if (panel->type == type) {
173  panel->type = NULL;
174  }
175 
176  LISTBASE_FOREACH (Panel *, child_panel, &panel->children) {
177  panel_type_clear_recursive(child_panel, type);
178  }
179 }
180 
181 static void rna_Panel_unregister(Main *bmain, StructRNA *type)
182 {
183  ARegionType *art;
185 
186  if (!pt) {
187  return;
188  }
189  if (!(art = region_type_find(NULL, pt->space_type, pt->region_type))) {
190  return;
191  }
192 
195 
196  if (pt->parent) {
197  LinkData *link = BLI_findptr(&pt->parent->children, pt, offsetof(LinkData, data));
198  BLI_freelinkN(&pt->parent->children, link);
199  }
200 
202 
203  LISTBASE_FOREACH (LinkData *, link, &pt->children) {
204  PanelType *child_pt = link->data;
205  child_pt->parent = NULL;
206  }
207 
208  const char space_type = pt->space_type;
209  BLI_freelistN(&pt->children);
210  BLI_freelinkN(&art->paneltypes, pt);
211 
212  for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
213  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
214  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
215  if (sl->spacetype == space_type) {
216  ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
217  &sl->regionbase;
218  LISTBASE_FOREACH (ARegion *, region, regionbase) {
219  if (region->type == art) {
220  LISTBASE_FOREACH (Panel *, panel, &region->panels) {
221  panel_type_clear_recursive(panel, pt);
222  }
223  }
224  /* The unregistered panel might have had a template that added instanced panels,
225  * so remove them just in case. They can be re-added on redraw anyway. */
227  }
228  }
229  }
230  }
231  }
232 
233  /* update while blender is running */
235 }
236 
237 static StructRNA *rna_Panel_register(Main *bmain,
238  ReportList *reports,
239  void *data,
240  const char *identifier,
241  StructValidateFunc validate,
242  StructCallbackFunc call,
244 {
245  ARegionType *art;
246  PanelType *pt, *parent = NULL, dummypt = {NULL};
247  Panel dummypanel = {NULL};
248  PointerRNA dummyptr;
249  int have_function[4];
250  size_t over_alloc = 0; /* Warning, if this becomes a mess, we better do another allocation. */
251  char _panel_descr[RNA_DYN_DESCR_MAX];
252  size_t description_size = 0;
253 
254  /* setup dummy panel & panel type to store static properties in */
255  dummypanel.type = &dummypt;
256  _panel_descr[0] = '\0';
257  dummypanel.type->description = _panel_descr;
258  RNA_pointer_create(NULL, &RNA_Panel, &dummypanel, &dummyptr);
259 
260  /* We have to set default context! Else we get a void string... */
261  strcpy(dummypt.translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
262 
263  /* validate the python class */
264  if (validate(&dummyptr, data, have_function) != 0) {
265  return NULL;
266  }
267 
268  if (strlen(identifier) >= sizeof(dummypt.idname)) {
269  BKE_reportf(reports,
270  RPT_ERROR,
271  "Registering panel class: '%s' is too long, maximum length is %d",
272  identifier,
273  (int)sizeof(dummypt.idname));
274  return NULL;
275  }
276 
277  if ((1 << dummypt.region_type) & RGN_TYPE_HAS_CATEGORY_MASK) {
278  if (dummypt.category[0] == '\0') {
279  /* Use a fallback, otherwise an empty value will draw the panel in every category. */
280  strcpy(dummypt.category, PNL_CATEGORY_FALLBACK);
281 # ifndef NDEBUG
282  printf("Registering panel class: '%s' misses category, please update the script\n",
283  dummypt.idname);
284 # endif
285  }
286  }
287  else {
288  if (dummypt.category[0] != '\0') {
289  if ((1 << dummypt.space_type) & WM_TOOLSYSTEM_SPACE_MASK) {
290  BKE_reportf(reports,
291  RPT_ERROR,
292  "Registering panel class: '%s' has category '%s' ",
293  dummypt.idname,
294  dummypt.category);
295  return NULL;
296  }
297  }
298  }
299 
300  if (!(art = region_type_find(reports, dummypt.space_type, dummypt.region_type))) {
301  return NULL;
302  }
303 
304  /* check if we have registered this panel type before, and remove it */
305  for (pt = art->paneltypes.first; pt; pt = pt->next) {
306  if (STREQ(pt->idname, dummypt.idname)) {
307  PanelType *pt_next = pt->next;
308  if (pt->rna_ext.srna) {
309  rna_Panel_unregister(bmain, pt->rna_ext.srna);
310  }
311  else {
312  BLI_freelinkN(&art->paneltypes, pt);
313  }
314 
315  /* The order of panel types will be altered on re-registration. */
316  if (dummypt.parent_id[0] && (parent == NULL)) {
317  for (pt = pt_next; pt; pt = pt->next) {
318  if (STREQ(pt->idname, dummypt.parent_id)) {
319  parent = pt;
320  break;
321  }
322  }
323  }
324 
325  break;
326  }
327 
328  if (dummypt.parent_id[0] && STREQ(pt->idname, dummypt.parent_id)) {
329  parent = pt;
330  }
331  }
332 
333  if (!RNA_struct_available_or_report(reports, dummypt.idname)) {
334  return NULL;
335  }
336  if (!RNA_struct_bl_idname_ok_or_report(reports, dummypt.idname, "_PT_")) {
337  return NULL;
338  }
339  if (dummypt.parent_id[0] && !parent) {
340  BKE_reportf(reports,
341  RPT_ERROR,
342  "Registering panel class: parent '%s' for '%s' not found",
343  dummypt.parent_id,
344  dummypt.idname);
345  return NULL;
346  }
347 
348  /* create a new panel type */
349  if (_panel_descr[0]) {
350  description_size = strlen(_panel_descr) + 1;
351  over_alloc += description_size;
352  }
353  pt = MEM_callocN(sizeof(PanelType) + over_alloc, "python buttons panel");
354  memcpy(pt, &dummypt, sizeof(dummypt));
355 
356  if (_panel_descr[0]) {
357  char *buf = (char *)(pt + 1);
358  memcpy(buf, _panel_descr, description_size);
359  pt->description = buf;
360  }
361  else {
362  pt->description = NULL;
363  }
364 
365  pt->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, pt->idname, &RNA_Panel);
367  pt->rna_ext.data = data;
368  pt->rna_ext.call = call;
369  pt->rna_ext.free = free;
372 
373  pt->poll = (have_function[0]) ? panel_poll : NULL;
374  pt->draw = (have_function[1]) ? panel_draw : NULL;
375  pt->draw_header = (have_function[2]) ? panel_draw_header : NULL;
376  pt->draw_header_preset = (have_function[3]) ? panel_draw_header_preset : NULL;
377 
378  /* Find position to insert panel based on order. */
379  PanelType *pt_iter = art->paneltypes.last;
380 
381  for (; pt_iter; pt_iter = pt_iter->prev) {
382  /* No header has priority. */
383  if ((pt->flag & PANEL_TYPE_NO_HEADER) && !(pt_iter->flag & PANEL_TYPE_NO_HEADER)) {
384  continue;
385  }
386  if (pt_iter->order <= pt->order) {
387  break;
388  }
389  }
390 
391  /* Insert into list. */
392  BLI_insertlinkafter(&art->paneltypes, pt_iter, pt);
393 
394  if (parent) {
395  pt->parent = parent;
396  LinkData *pt_child_iter = parent->children.last;
397  for (; pt_child_iter; pt_child_iter = pt_child_iter->prev) {
398  PanelType *pt_child = pt_child_iter->data;
399  if (pt_child->order <= pt->order) {
400  break;
401  }
402  }
403  BLI_insertlinkafter(&parent->children, pt_child_iter, BLI_genericNodeN(pt));
404  }
405 
406  {
407  const char *owner_id = RNA_struct_state_owner_get();
408  if (owner_id) {
409  BLI_strncpy(pt->owner_id, owner_id, sizeof(pt->owner_id));
410  }
411  }
412 
413  WM_paneltype_add(pt);
414 
415  /* update while blender is running */
417 
418  return pt->rna_ext.srna;
419 }
420 
421 static StructRNA *rna_Panel_refine(PointerRNA *ptr)
422 {
423  Panel *menu = (Panel *)ptr->data;
424  return (menu->type && menu->type->rna_ext.srna) ? menu->type->rna_ext.srna : &RNA_Panel;
425 }
426 
427 static StructRNA *rna_Panel_custom_data_typef(PointerRNA *ptr)
428 {
429  Panel *panel = (Panel *)ptr->data;
430 
431  return UI_panel_custom_data_get(panel)->type;
432 }
433 
434 static PointerRNA rna_Panel_custom_data_get(PointerRNA *ptr)
435 {
436  Panel *panel = (Panel *)ptr->data;
437 
438  /* Because the panel custom data is general we can't refine the pointer type here. */
439  return *UI_panel_custom_data_get(panel);
440 }
441 
442 /* UIList */
443 static unsigned int rna_UIList_filter_const_FILTER_ITEM_get(PointerRNA *UNUSED(ptr))
444 {
445  return UILST_FLT_ITEM;
446 }
447 
448 static IDProperty **rna_UIList_idprops(PointerRNA *ptr)
449 {
450  uiList *ui_list = (uiList *)ptr->data;
451  return &ui_list->properties;
452 }
453 
454 static void rna_UIList_list_id_get(PointerRNA *ptr, char *value)
455 {
456  uiList *ui_list = (uiList *)ptr->data;
457  if (!ui_list->type) {
458  value[0] = '\0';
459  return;
460  }
461 
462  strcpy(value, WM_uilisttype_list_id_get(ui_list->type, ui_list));
463 }
464 
465 static int rna_UIList_list_id_length(PointerRNA *ptr)
466 {
467  uiList *ui_list = (uiList *)ptr->data;
468  if (!ui_list->type) {
469  return 0;
470  }
471 
472  return strlen(WM_uilisttype_list_id_get(ui_list->type, ui_list));
473 }
474 
475 static void uilist_draw_item(uiList *ui_list,
476  bContext *C,
477  uiLayout *layout,
478  PointerRNA *dataptr,
479  PointerRNA *itemptr,
480  int icon,
481  PointerRNA *active_dataptr,
482  const char *active_propname,
483  int index,
484  int flt_flag)
485 {
486  extern FunctionRNA rna_UIList_draw_item_func;
487 
488  PointerRNA ul_ptr;
489  ParameterList list;
490  FunctionRNA *func;
491 
492  RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->rna_ext.srna, ui_list, &ul_ptr);
493  func = &rna_UIList_draw_item_func; /* RNA_struct_find_function(&ul_ptr, "draw_item"); */
494 
495  RNA_parameter_list_create(&list, &ul_ptr, func);
496  RNA_parameter_set_lookup(&list, "context", &C);
497  RNA_parameter_set_lookup(&list, "layout", &layout);
498  RNA_parameter_set_lookup(&list, "data", dataptr);
499  RNA_parameter_set_lookup(&list, "item", itemptr);
500  RNA_parameter_set_lookup(&list, "icon", &icon);
501  RNA_parameter_set_lookup(&list, "active_data", active_dataptr);
502  RNA_parameter_set_lookup(&list, "active_property", &active_propname);
503  RNA_parameter_set_lookup(&list, "index", &index);
504  RNA_parameter_set_lookup(&list, "flt_flag", &flt_flag);
505  ui_list->type->rna_ext.call((bContext *)C, &ul_ptr, func, &list);
506 
508 }
509 
510 static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout)
511 {
512  extern FunctionRNA rna_UIList_draw_filter_func;
513 
514  PointerRNA ul_ptr;
515  ParameterList list;
516  FunctionRNA *func;
517 
518  RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->rna_ext.srna, ui_list, &ul_ptr);
519  func = &rna_UIList_draw_filter_func; /* RNA_struct_find_function(&ul_ptr, "draw_filter"); */
520 
521  RNA_parameter_list_create(&list, &ul_ptr, func);
522  RNA_parameter_set_lookup(&list, "context", &C);
523  RNA_parameter_set_lookup(&list, "layout", &layout);
524  ui_list->type->rna_ext.call((bContext *)C, &ul_ptr, func, &list);
525 
527 }
528 
529 static void uilist_filter_items(uiList *ui_list,
530  bContext *C,
531  PointerRNA *dataptr,
532  const char *propname)
533 {
534  extern FunctionRNA rna_UIList_filter_items_func;
535 
536  PointerRNA ul_ptr;
537  ParameterList list;
538  FunctionRNA *func;
539  PropertyRNA *parm;
540 
541  uiListDyn *flt_data = ui_list->dyn_data;
542  int *filter_flags, *filter_neworder;
543  void *ret1, *ret2;
544  int ret_len;
545  int len = flt_data->items_len = RNA_collection_length(dataptr, propname);
546 
547  RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->rna_ext.srna, ui_list, &ul_ptr);
548  func = &rna_UIList_filter_items_func; /* RNA_struct_find_function(&ul_ptr, "filter_items"); */
549 
550  RNA_parameter_list_create(&list, &ul_ptr, func);
551  RNA_parameter_set_lookup(&list, "context", &C);
552  RNA_parameter_set_lookup(&list, "data", dataptr);
553  RNA_parameter_set_lookup(&list, "property", &propname);
554 
555  ui_list->type->rna_ext.call((bContext *)C, &ul_ptr, func, &list);
556 
557  parm = RNA_function_find_parameter(NULL, func, "filter_flags");
558  ret_len = RNA_parameter_dynamic_length_get(&list, parm);
559  if (!ELEM(ret_len, len, 0)) {
560  printf("%s: Error, py func returned %d items in %s, %d or none were expected.\n",
561  __func__,
563  "filter_flags",
564  len);
565  /* NOTE: we cannot return here, we would let flt_data in inconsistent state... see T38356. */
566  filter_flags = NULL;
567  }
568  else {
569  RNA_parameter_get(&list, parm, &ret1);
570  filter_flags = (int *)ret1;
571  }
572 
573  parm = RNA_function_find_parameter(NULL, func, "filter_neworder");
574  ret_len = RNA_parameter_dynamic_length_get(&list, parm);
575  if (!ELEM(ret_len, len, 0)) {
576  printf("%s: Error, py func returned %d items in %s, %d or none were expected.\n",
577  __func__,
579  "filter_neworder",
580  len);
581  /* NOTE: we cannot return here, we would let flt_data in inconsistent state... see T38356. */
582  filter_neworder = NULL;
583  }
584  else {
585  RNA_parameter_get(&list, parm, &ret2);
586  filter_neworder = (int *)ret2;
587  }
588 
589  /* We have to do some final checks and transforms... */
590  {
591  int i, filter_exclude = ui_list->filter_flag & UILST_FLT_EXCLUDE;
592  if (filter_flags) {
593  flt_data->items_filter_flags = MEM_mallocN(sizeof(int) * len, __func__);
594  memcpy(flt_data->items_filter_flags, filter_flags, sizeof(int) * len);
595 
596  if (filter_neworder) {
597  /* For sake of simplicity, py filtering is expected to filter all items,
598  * but we actually only want reordering data for shown items!
599  */
600  int items_shown, shown_idx;
601  int t_idx, t_ni, prev_ni;
602  flt_data->items_shown = 0;
603  for (i = 0, shown_idx = 0; i < len; i++) {
604  if ((filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude) {
605  filter_neworder[shown_idx++] = filter_neworder[i];
606  }
607  }
608  items_shown = flt_data->items_shown = shown_idx;
609  flt_data->items_filter_neworder = MEM_mallocN(sizeof(int) * items_shown, __func__);
610  /* And now, bring back new indices into the [0, items_shown[ range!
611  * XXX This is O(N^2). :/
612  */
613  for (shown_idx = 0, prev_ni = -1; shown_idx < items_shown; shown_idx++) {
614  for (i = 0, t_ni = len, t_idx = -1; i < items_shown; i++) {
615  int ni = filter_neworder[i];
616  if (ni > prev_ni && ni < t_ni) {
617  t_idx = i;
618  t_ni = ni;
619  }
620  }
621  if (t_idx >= 0) {
622  prev_ni = t_ni;
623  flt_data->items_filter_neworder[t_idx] = shown_idx;
624  }
625  }
626  }
627  else {
628  /* we still have to set flt_data->items_shown... */
629  flt_data->items_shown = 0;
630  for (i = 0; i < len; i++) {
631  if ((filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude) {
632  flt_data->items_shown++;
633  }
634  }
635  }
636  }
637  else {
638  flt_data->items_shown = len;
639 
640  if (filter_neworder) {
641  flt_data->items_filter_neworder = MEM_mallocN(sizeof(int) * len, __func__);
642  memcpy(flt_data->items_filter_neworder, filter_neworder, sizeof(int) * len);
643  }
644  }
645  }
646 
648 }
649 
650 static void rna_UIList_unregister(Main *bmain, StructRNA *type)
651 {
653 
654  if (!ult) {
655  return;
656  }
657 
660 
661  WM_uilisttype_remove_ptr(bmain, ult);
662 
663  /* update while blender is running */
665 }
666 
667 static StructRNA *rna_UIList_register(Main *bmain,
668  ReportList *reports,
669  void *data,
670  const char *identifier,
671  StructValidateFunc validate,
672  StructCallbackFunc call,
674 {
675  uiListType *ult, dummyult = {NULL};
676  uiList dummyuilist = {NULL};
677  PointerRNA dummyul_ptr;
678  int have_function[3];
679  size_t over_alloc = 0; /* Warning, if this becomes a mess, we better do another allocation. */
680 
681  /* setup dummy menu & menu type to store static properties in */
682  dummyuilist.type = &dummyult;
683  RNA_pointer_create(NULL, &RNA_UIList, &dummyuilist, &dummyul_ptr);
684 
685  /* validate the python class */
686  if (validate(&dummyul_ptr, data, have_function) != 0) {
687  return NULL;
688  }
689 
690  if (strlen(identifier) >= sizeof(dummyult.idname)) {
691  BKE_reportf(reports,
692  RPT_ERROR,
693  "Registering uilist class: '%s' is too long, maximum length is %d",
694  identifier,
695  (int)sizeof(dummyult.idname));
696  return NULL;
697  }
698 
699  /* Check if we have registered this UI-list type before, and remove it. */
700  ult = WM_uilisttype_find(dummyult.idname, true);
701  if (ult && ult->rna_ext.srna) {
702  rna_UIList_unregister(bmain, ult->rna_ext.srna);
703  }
704  if (!RNA_struct_available_or_report(reports, dummyult.idname)) {
705  return NULL;
706  }
707  if (!RNA_struct_bl_idname_ok_or_report(reports, dummyult.idname, "_UL_")) {
708  return NULL;
709  }
710 
711  /* create a new menu type */
712  ult = MEM_callocN(sizeof(uiListType) + over_alloc, "python uilist");
713  memcpy(ult, &dummyult, sizeof(dummyult));
714 
715  ult->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ult->idname, &RNA_UIList);
716  ult->rna_ext.data = data;
717  ult->rna_ext.call = call;
718  ult->rna_ext.free = free;
720 
721  ult->draw_item = (have_function[0]) ? uilist_draw_item : NULL;
722  ult->draw_filter = (have_function[1]) ? uilist_draw_filter : NULL;
723  ult->filter_items = (have_function[2]) ? uilist_filter_items : NULL;
724 
725  WM_uilisttype_add(ult);
726 
727  /* update while blender is running */
729 
730  return ult->rna_ext.srna;
731 }
732 
733 static StructRNA *rna_UIList_refine(PointerRNA *ptr)
734 {
735  uiList *ui_list = (uiList *)ptr->data;
736  return (ui_list->type && ui_list->type->rna_ext.srna) ? ui_list->type->rna_ext.srna :
737  &RNA_UIList;
738 }
739 
740 /* Header */
741 
742 static void header_draw(const bContext *C, Header *hdr)
743 {
744  extern FunctionRNA rna_Header_draw_func;
745 
746  PointerRNA htr;
747  ParameterList list;
748  FunctionRNA *func;
749 
750  RNA_pointer_create(&CTX_wm_screen(C)->id, hdr->type->rna_ext.srna, hdr, &htr);
751  func = &rna_Header_draw_func; /* RNA_struct_find_function(&htr, "draw"); */
752 
753  RNA_parameter_list_create(&list, &htr, func);
754  RNA_parameter_set_lookup(&list, "context", &C);
755  hdr->type->rna_ext.call((bContext *)C, &htr, func, &list);
756 
758 }
759 
760 static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type)
761 {
762  ARegionType *art;
764 
765  if (!ht) {
766  return;
767  }
768  if (!(art = region_type_find(NULL, ht->space_type, ht->region_type))) {
769  return;
770  }
771 
774 
775  BLI_freelinkN(&art->headertypes, ht);
776 
777  /* update while blender is running */
779 }
780 
781 static StructRNA *rna_Header_register(Main *bmain,
782  ReportList *reports,
783  void *data,
784  const char *identifier,
785  StructValidateFunc validate,
786  StructCallbackFunc call,
788 {
789  ARegionType *art;
790  HeaderType *ht, dummyht = {NULL};
791  Header dummyheader = {NULL};
792  PointerRNA dummyhtr;
793  int have_function[1];
794 
795  /* setup dummy header & header type to store static properties in */
796  dummyheader.type = &dummyht;
797  dummyht.region_type = RGN_TYPE_HEADER; /* RGN_TYPE_HEADER by default, may be overridden */
798  RNA_pointer_create(NULL, &RNA_Header, &dummyheader, &dummyhtr);
799 
800  /* validate the python class */
801  if (validate(&dummyhtr, data, have_function) != 0) {
802  return NULL;
803  }
804 
805  if (strlen(identifier) >= sizeof(dummyht.idname)) {
806  BKE_reportf(reports,
807  RPT_ERROR,
808  "Registering header class: '%s' is too long, maximum length is %d",
809  identifier,
810  (int)sizeof(dummyht.idname));
811  return NULL;
812  }
813 
814  if (!(art = region_type_find(reports, dummyht.space_type, dummyht.region_type))) {
815  return NULL;
816  }
817 
818  /* check if we have registered this header type before, and remove it */
819  for (ht = art->headertypes.first; ht; ht = ht->next) {
820  if (STREQ(ht->idname, dummyht.idname)) {
821  if (ht->rna_ext.srna) {
822  rna_Header_unregister(bmain, ht->rna_ext.srna);
823  }
824  break;
825  }
826  }
827  if (!RNA_struct_available_or_report(reports, dummyht.idname)) {
828  return NULL;
829  }
830  if (!RNA_struct_bl_idname_ok_or_report(reports, dummyht.idname, "_HT_")) {
831  return NULL;
832  }
833 
834  /* create a new header type */
835  ht = MEM_mallocN(sizeof(HeaderType), "python buttons header");
836  memcpy(ht, &dummyht, sizeof(dummyht));
837 
838  ht->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ht->idname, &RNA_Header);
839  ht->rna_ext.data = data;
840  ht->rna_ext.call = call;
841  ht->rna_ext.free = free;
843 
844  ht->draw = (have_function[0]) ? header_draw : NULL;
845 
846  BLI_addtail(&art->headertypes, ht);
847 
848  /* update while blender is running */
850 
851  return ht->rna_ext.srna;
852 }
853 
854 static StructRNA *rna_Header_refine(PointerRNA *htr)
855 {
856  Header *hdr = (Header *)htr->data;
857  return (hdr->type && hdr->type->rna_ext.srna) ? hdr->type->rna_ext.srna : &RNA_Header;
858 }
859 
860 /* Menu */
861 
862 static bool menu_poll(const bContext *C, MenuType *pt)
863 {
864  extern FunctionRNA rna_Menu_poll_func;
865 
866  PointerRNA ptr;
867  ParameterList list;
868  FunctionRNA *func;
869  void *ret;
870  bool visible;
871 
872  RNA_pointer_create(NULL, pt->rna_ext.srna, NULL, &ptr); /* dummy */
873  func = &rna_Menu_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
874 
875  RNA_parameter_list_create(&list, &ptr, func);
876  RNA_parameter_set_lookup(&list, "context", &C);
877  pt->rna_ext.call((bContext *)C, &ptr, func, &list);
878 
879  RNA_parameter_get_lookup(&list, "visible", &ret);
880  visible = *(bool *)ret;
881 
883 
884  return visible;
885 }
886 
887 static void menu_draw(const bContext *C, Menu *menu)
888 {
889  extern FunctionRNA rna_Menu_draw_func;
890 
891  PointerRNA mtr;
892  ParameterList list;
893  FunctionRNA *func;
894 
895  RNA_pointer_create(&CTX_wm_screen(C)->id, menu->type->rna_ext.srna, menu, &mtr);
896  func = &rna_Menu_draw_func; /* RNA_struct_find_function(&mtr, "draw"); */
897 
898  RNA_parameter_list_create(&list, &mtr, func);
899  RNA_parameter_set_lookup(&list, "context", &C);
900  menu->type->rna_ext.call((bContext *)C, &mtr, func, &list);
901 
903 }
904 
905 static void rna_Menu_unregister(Main *UNUSED(bmain), StructRNA *type)
906 {
908 
909  if (!mt) {
910  return;
911  }
912 
915 
917 
918  /* update while blender is running */
920 }
921 
922 static StructRNA *rna_Menu_register(Main *bmain,
923  ReportList *reports,
924  void *data,
925  const char *identifier,
926  StructValidateFunc validate,
927  StructCallbackFunc call,
929 {
930  MenuType *mt, dummymt = {NULL};
931  Menu dummymenu = {NULL};
932  PointerRNA dummymtr;
933  int have_function[2];
934  size_t over_alloc = 0; /* Warning, if this becomes a mess, we better do another allocation. */
935  size_t description_size = 0;
936  char _menu_descr[RNA_DYN_DESCR_MAX];
937 
938  /* setup dummy menu & menu type to store static properties in */
939  dummymenu.type = &dummymt;
940  _menu_descr[0] = '\0';
941  dummymenu.type->description = _menu_descr;
942  RNA_pointer_create(NULL, &RNA_Menu, &dummymenu, &dummymtr);
943 
944  /* We have to set default context! Else we get a void string... */
946 
947  /* validate the python class */
948  if (validate(&dummymtr, data, have_function) != 0) {
949  return NULL;
950  }
951 
952  if (strlen(identifier) >= sizeof(dummymt.idname)) {
953  BKE_reportf(reports,
954  RPT_ERROR,
955  "Registering menu class: '%s' is too long, maximum length is %d",
956  identifier,
957  (int)sizeof(dummymt.idname));
958  return NULL;
959  }
960 
961  /* check if we have registered this menu type before, and remove it */
962  mt = WM_menutype_find(dummymt.idname, true);
963  if (mt && mt->rna_ext.srna) {
964  rna_Menu_unregister(bmain, mt->rna_ext.srna);
965  }
966  if (!RNA_struct_available_or_report(reports, dummymt.idname)) {
967  return NULL;
968  }
969  if (!RNA_struct_bl_idname_ok_or_report(reports, dummymt.idname, "_MT_")) {
970  return NULL;
971  }
972 
973  /* create a new menu type */
974  if (_menu_descr[0]) {
975  description_size = strlen(_menu_descr) + 1;
976  over_alloc += description_size;
977  }
978 
979  mt = MEM_callocN(sizeof(MenuType) + over_alloc, "python buttons menu");
980  memcpy(mt, &dummymt, sizeof(dummymt));
981 
982  if (_menu_descr[0]) {
983  char *buf = (char *)(mt + 1);
984  memcpy(buf, _menu_descr, description_size);
985  mt->description = buf;
986  }
987  else {
988  mt->description = NULL;
989  }
990 
991  mt->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, mt->idname, &RNA_Menu);
993  mt->rna_ext.data = data;
994  mt->rna_ext.call = call;
995  mt->rna_ext.free = free;
998 
999  mt->poll = (have_function[0]) ? menu_poll : NULL;
1000  mt->draw = (have_function[1]) ? menu_draw : NULL;
1001 
1002  {
1003  const char *owner_id = RNA_struct_state_owner_get();
1004  if (owner_id) {
1005  BLI_strncpy(mt->owner_id, owner_id, sizeof(mt->owner_id));
1006  }
1007  }
1008 
1009  WM_menutype_add(mt);
1010 
1011  /* update while blender is running */
1013 
1014  return mt->rna_ext.srna;
1015 }
1016 
1017 static StructRNA *rna_Menu_refine(PointerRNA *mtr)
1018 {
1019  Menu *menu = (Menu *)mtr->data;
1020  return (menu->type && menu->type->rna_ext.srna) ? menu->type->rna_ext.srna : &RNA_Menu;
1021 }
1022 
1023 static void rna_Panel_bl_description_set(PointerRNA *ptr, const char *value)
1024 {
1025  Panel *data = (Panel *)(ptr->data);
1026  char *str = (char *)data->type->description;
1027  if (!str[0]) {
1028  BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1029  }
1030  else {
1031  BLI_assert_msg(0, "setting the bl_description on a non-builtin panel");
1032  }
1033 }
1034 
1035 static void rna_Menu_bl_description_set(PointerRNA *ptr, const char *value)
1036 {
1037  Menu *data = (Menu *)(ptr->data);
1038  char *str = (char *)data->type->description;
1039  if (!str[0]) {
1040  BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1041  }
1042  else {
1043  BLI_assert_msg(0, "setting the bl_description on a non-builtin menu");
1044  }
1045 }
1046 
1047 /* UILayout */
1048 
1049 static bool rna_UILayout_active_get(PointerRNA *ptr)
1050 {
1051  return uiLayoutGetActive(ptr->data);
1052 }
1053 
1054 static void rna_UILayout_active_set(PointerRNA *ptr, bool value)
1055 {
1056  uiLayoutSetActive(ptr->data, value);
1057 }
1058 
1059 static bool rna_UILayout_active_default_get(PointerRNA *ptr)
1060 {
1062 }
1063 
1064 static void rna_UILayout_active_default_set(PointerRNA *ptr, bool value)
1065 {
1067 }
1068 
1069 static bool rna_UILayout_activate_init_get(PointerRNA *ptr)
1070 {
1071  return uiLayoutGetActivateInit(ptr->data);
1072 }
1073 
1074 static void rna_UILayout_activate_init_set(PointerRNA *ptr, bool value)
1075 {
1076  uiLayoutSetActivateInit(ptr->data, value);
1077 }
1078 
1079 static bool rna_UILayout_alert_get(PointerRNA *ptr)
1080 {
1081  return uiLayoutGetRedAlert(ptr->data);
1082 }
1083 
1084 static void rna_UILayout_alert_set(PointerRNA *ptr, bool value)
1085 {
1086  uiLayoutSetRedAlert(ptr->data, value);
1087 }
1088 
1089 static void rna_UILayout_op_context_set(PointerRNA *ptr, int value)
1090 {
1092 }
1093 
1094 static int rna_UILayout_op_context_get(PointerRNA *ptr)
1095 {
1097 }
1098 
1099 static bool rna_UILayout_enabled_get(PointerRNA *ptr)
1100 {
1101  return uiLayoutGetEnabled(ptr->data);
1102 }
1103 
1104 static void rna_UILayout_enabled_set(PointerRNA *ptr, bool value)
1105 {
1106  uiLayoutSetEnabled(ptr->data, value);
1107 }
1108 
1109 # if 0
1110 static int rna_UILayout_red_alert_get(PointerRNA *ptr)
1111 {
1112  return uiLayoutGetRedAlert(ptr->data);
1113 }
1114 
1115 static void rna_UILayout_red_alert_set(PointerRNA *ptr, bool value)
1116 {
1117  uiLayoutSetRedAlert(ptr->data, value);
1118 }
1119 
1120 static bool rna_UILayout_keep_aspect_get(PointerRNA *ptr)
1121 {
1122  return uiLayoutGetKeepAspect(ptr->data);
1123 }
1124 
1125 static void rna_UILayout_keep_aspect_set(PointerRNA *ptr, int value)
1126 {
1127  uiLayoutSetKeepAspect(ptr->data, value);
1128 }
1129 # endif
1130 
1131 static int rna_UILayout_alignment_get(PointerRNA *ptr)
1132 {
1133  return uiLayoutGetAlignment(ptr->data);
1134 }
1135 
1136 static void rna_UILayout_alignment_set(PointerRNA *ptr, int value)
1137 {
1138  uiLayoutSetAlignment(ptr->data, value);
1139 }
1140 
1141 static int rna_UILayout_direction_get(PointerRNA *ptr)
1142 {
1143  return uiLayoutGetLocalDir(ptr->data);
1144 }
1145 
1146 static float rna_UILayout_scale_x_get(PointerRNA *ptr)
1147 {
1148  return uiLayoutGetScaleX(ptr->data);
1149 }
1150 
1151 static void rna_UILayout_scale_x_set(PointerRNA *ptr, float value)
1152 {
1153  uiLayoutSetScaleX(ptr->data, value);
1154 }
1155 
1156 static float rna_UILayout_scale_y_get(PointerRNA *ptr)
1157 {
1158  return uiLayoutGetScaleY(ptr->data);
1159 }
1160 
1161 static void rna_UILayout_scale_y_set(PointerRNA *ptr, float value)
1162 {
1163  uiLayoutSetScaleY(ptr->data, value);
1164 }
1165 
1166 static float rna_UILayout_units_x_get(PointerRNA *ptr)
1167 {
1168  return uiLayoutGetUnitsX(ptr->data);
1169 }
1170 
1171 static void rna_UILayout_units_x_set(PointerRNA *ptr, float value)
1172 {
1173  uiLayoutSetUnitsX(ptr->data, value);
1174 }
1175 
1176 static float rna_UILayout_units_y_get(PointerRNA *ptr)
1177 {
1178  return uiLayoutGetUnitsY(ptr->data);
1179 }
1180 
1181 static void rna_UILayout_units_y_set(PointerRNA *ptr, float value)
1182 {
1183  uiLayoutSetUnitsY(ptr->data, value);
1184 }
1185 
1186 static int rna_UILayout_emboss_get(PointerRNA *ptr)
1187 {
1188  return uiLayoutGetEmboss(ptr->data);
1189 }
1190 
1191 static void rna_UILayout_emboss_set(PointerRNA *ptr, int value)
1192 {
1193  uiLayoutSetEmboss(ptr->data, value);
1194 }
1195 
1196 static bool rna_UILayout_property_split_get(PointerRNA *ptr)
1197 {
1198  return uiLayoutGetPropSep(ptr->data);
1199 }
1200 
1201 static void rna_UILayout_property_split_set(PointerRNA *ptr, bool value)
1202 {
1203  uiLayoutSetPropSep(ptr->data, value);
1204 }
1205 
1206 static bool rna_UILayout_property_decorate_get(PointerRNA *ptr)
1207 {
1208  return uiLayoutGetPropDecorate(ptr->data);
1209 }
1210 
1211 static void rna_UILayout_property_decorate_set(PointerRNA *ptr, bool value)
1212 {
1213  uiLayoutSetPropDecorate(ptr->data, value);
1214 }
1215 
1216 #else /* RNA_RUNTIME */
1217 
1218 static void rna_def_ui_layout(BlenderRNA *brna)
1219 {
1220  StructRNA *srna;
1221  PropertyRNA *prop;
1222 
1223  static const EnumPropertyItem alignment_items[] = {
1224  {UI_LAYOUT_ALIGN_EXPAND, "EXPAND", 0, "Expand", ""},
1225  {UI_LAYOUT_ALIGN_LEFT, "LEFT", 0, "Left", ""},
1226  {UI_LAYOUT_ALIGN_CENTER, "CENTER", 0, "Center", ""},
1227  {UI_LAYOUT_ALIGN_RIGHT, "RIGHT", 0, "Right", ""},
1228  {0, NULL, 0, NULL, NULL},
1229  };
1230 
1231  static const EnumPropertyItem direction_items[] = {
1232  {UI_LAYOUT_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""},
1233  {UI_LAYOUT_VERTICAL, "VERTICAL", 0, "Vertical", ""},
1234  {0, NULL, 0, NULL, NULL},
1235  };
1236 
1237  static const EnumPropertyItem emboss_items[] = {
1238  {UI_EMBOSS, "NORMAL", 0, "Regular", "Draw standard button emboss style"},
1239  {UI_EMBOSS_NONE, "NONE", 0, "None", "Draw only text and icons"},
1240  {UI_EMBOSS_PULLDOWN, "PULLDOWN_MENU", 0, "Pulldown Menu", "Draw pulldown menu style"},
1241  {UI_EMBOSS_RADIAL, "RADIAL_MENU", 0, "Radial Menu", "Draw radial menu style"},
1243  "NONE_OR_STATUS",
1244  0,
1245  "None or Status",
1246  "Draw with no emboss unless the button has a coloring status like an animation state"},
1247  {0, NULL, 0, NULL, NULL},
1248  };
1249 
1250  /* layout */
1251 
1252  srna = RNA_def_struct(brna, "UILayout", NULL);
1253  RNA_def_struct_sdna(srna, "uiLayout");
1254  RNA_def_struct_ui_text(srna, "UI Layout", "User interface layout in a panel or header");
1255 
1256  prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1257  RNA_def_property_boolean_funcs(prop, "rna_UILayout_active_get", "rna_UILayout_active_set");
1258 
1259  prop = RNA_def_property(srna, "active_default", PROP_BOOLEAN, PROP_NONE);
1261  prop, "rna_UILayout_active_default_get", "rna_UILayout_active_default_set");
1263  prop,
1264  "Active Default",
1265  "When true, an operator button defined after this will be activated when pressing return"
1266  "(use with popup dialogs)");
1267 
1268  prop = RNA_def_property(srna, "activate_init", PROP_BOOLEAN, PROP_NONE);
1270  prop, "rna_UILayout_activate_init_get", "rna_UILayout_activate_init_set");
1272  prop,
1273  "Activate on Init",
1274  "When true, buttons defined in popups will be activated on first display "
1275  "(use so you can type into a field without having to click on it first)");
1276 
1277  prop = RNA_def_property(srna, "operator_context", PROP_ENUM, PROP_NONE);
1280  prop, "rna_UILayout_op_context_get", "rna_UILayout_op_context_set", NULL);
1281 
1282  prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
1283  RNA_def_property_boolean_funcs(prop, "rna_UILayout_enabled_get", "rna_UILayout_enabled_set");
1284  RNA_def_property_ui_text(prop, "Enabled", "When false, this (sub)layout is grayed out");
1285 
1286  prop = RNA_def_property(srna, "alert", PROP_BOOLEAN, PROP_NONE);
1287  RNA_def_property_boolean_funcs(prop, "rna_UILayout_alert_get", "rna_UILayout_alert_set");
1288 
1289  prop = RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE);
1290  RNA_def_property_enum_items(prop, alignment_items);
1292  prop, "rna_UILayout_alignment_get", "rna_UILayout_alignment_set", NULL);
1293 
1294  prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
1295  RNA_def_property_enum_items(prop, direction_items);
1296  RNA_def_property_enum_funcs(prop, "rna_UILayout_direction_get", NULL, NULL);
1298 
1299 # if 0
1300  prop = RNA_def_property(srna, "keep_aspect", PROP_BOOLEAN, PROP_NONE);
1302  prop, "rna_UILayout_keep_aspect_get", "rna_UILayout_keep_aspect_set");
1303 # endif
1304 
1305  prop = RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_UNSIGNED);
1306  RNA_def_property_float_funcs(prop, "rna_UILayout_scale_x_get", "rna_UILayout_scale_x_set", NULL);
1308  prop, "Scale X", "Scale factor along the X for items in this (sub)layout");
1309 
1310  prop = RNA_def_property(srna, "scale_y", PROP_FLOAT, PROP_UNSIGNED);
1311  RNA_def_property_float_funcs(prop, "rna_UILayout_scale_y_get", "rna_UILayout_scale_y_set", NULL);
1313  prop, "Scale Y", "Scale factor along the Y for items in this (sub)layout");
1314 
1315  prop = RNA_def_property(srna, "ui_units_x", PROP_FLOAT, PROP_UNSIGNED);
1316  RNA_def_property_float_funcs(prop, "rna_UILayout_units_x_get", "rna_UILayout_units_x_set", NULL);
1318  prop, "Units X", "Fixed size along the X for items in this (sub)layout");
1319 
1320  prop = RNA_def_property(srna, "ui_units_y", PROP_FLOAT, PROP_UNSIGNED);
1321  RNA_def_property_float_funcs(prop, "rna_UILayout_units_y_get", "rna_UILayout_units_y_set", NULL);
1323  prop, "Units Y", "Fixed size along the Y for items in this (sub)layout");
1324  RNA_api_ui_layout(srna);
1325 
1326  prop = RNA_def_property(srna, "emboss", PROP_ENUM, PROP_NONE);
1327  RNA_def_property_enum_items(prop, emboss_items);
1328  RNA_def_property_enum_funcs(prop, "rna_UILayout_emboss_get", "rna_UILayout_emboss_set", NULL);
1329 
1330  prop = RNA_def_property(srna, "use_property_split", PROP_BOOLEAN, PROP_NONE);
1332  prop, "rna_UILayout_property_split_get", "rna_UILayout_property_split_set");
1333 
1334  prop = RNA_def_property(srna, "use_property_decorate", PROP_BOOLEAN, PROP_NONE);
1336  prop, "rna_UILayout_property_decorate_get", "rna_UILayout_property_decorate_set");
1337 }
1338 
1339 static void rna_def_panel(BlenderRNA *brna)
1340 {
1341  StructRNA *srna;
1342  PropertyRNA *prop;
1343  PropertyRNA *parm;
1344  FunctionRNA *func;
1345 
1346  static const EnumPropertyItem panel_flag_items[] = {
1348  "DEFAULT_CLOSED",
1349  0,
1350  "Default Closed",
1351  "Defines if the panel has to be open or collapsed at the time of its creation"},
1353  "HIDE_HEADER",
1354  0,
1355  "Hide Header",
1356  "If set to False, the panel shows a header, which contains a clickable "
1357  "arrow to collapse the panel and the label (see bl_label)"},
1359  "INSTANCED",
1360  0,
1361  "Instanced Panel",
1362  "Multiple panels with this type can be used as part of a list depending on data external "
1363  "to the UI. Used to create panels for the modifiers and other stacks"},
1365  "HEADER_LAYOUT_EXPAND",
1366  0,
1367  "Expand Header Layout",
1368  "Allow buttons in the header to stretch and shrink to fill the entire layout width"},
1369  {0, NULL, 0, NULL, NULL},
1370  };
1371 
1372  srna = RNA_def_struct(brna, "Panel", NULL);
1373  RNA_def_struct_ui_text(srna, "Panel", "Panel containing UI elements");
1374  RNA_def_struct_sdna(srna, "Panel");
1375  RNA_def_struct_refine_func(srna, "rna_Panel_refine");
1376  RNA_def_struct_register_funcs(srna, "rna_Panel_register", "rna_Panel_unregister", NULL);
1379 
1380  /* poll */
1381  func = RNA_def_function(srna, "poll", NULL);
1383  func, "If this method returns a non-null output, then the panel can be drawn");
1385  RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
1386  parm = RNA_def_pointer(func, "context", "Context", "", "");
1388 
1389  /* draw */
1390  func = RNA_def_function(srna, "draw", NULL);
1391  RNA_def_function_ui_description(func, "Draw UI elements into the panel UI layout");
1393  parm = RNA_def_pointer(func, "context", "Context", "", "");
1395 
1396  func = RNA_def_function(srna, "draw_header", NULL);
1397  RNA_def_function_ui_description(func, "Draw UI elements into the panel's header UI layout");
1399  parm = RNA_def_pointer(func, "context", "Context", "", "");
1401 
1402  func = RNA_def_function(srna, "draw_header_preset", NULL);
1403  RNA_def_function_ui_description(func, "Draw UI elements for presets in the panel's header");
1405  parm = RNA_def_pointer(func, "context", "Context", "", "");
1407 
1408  prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
1409  RNA_def_property_struct_type(prop, "UILayout");
1410  RNA_def_property_ui_text(prop, "Layout", "Defines the structure of the panel in the UI");
1411 
1412  prop = RNA_def_property(srna, "text", PROP_STRING, PROP_NONE);
1413  RNA_def_property_string_sdna(prop, NULL, "drawname");
1414  RNA_def_property_ui_text(prop, "Text", "XXX todo");
1415 
1416  prop = RNA_def_property(srna, "custom_data", PROP_POINTER, PROP_NONE);
1417  RNA_def_property_struct_type(prop, "Constraint");
1418  RNA_def_property_pointer_sdna(prop, NULL, "runtime.custom_data_ptr");
1420  prop, "rna_Panel_custom_data_get", NULL, "rna_Panel_custom_data_typef", NULL);
1421  RNA_def_property_ui_text(prop, "Custom Data", "Panel data");
1423 
1424  /* registration */
1425  prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1426  RNA_def_property_string_sdna(prop, NULL, "type->idname");
1429  "ID Name",
1430  "If this is set, the panel gets a custom ID, otherwise it takes the "
1431  "name of the class used to define the panel. For example, if the "
1432  "class name is \"OBJECT_PT_hello\", and bl_idname is not set by the "
1433  "script, then bl_idname = \"OBJECT_PT_hello\"");
1434 
1435  prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1436  RNA_def_property_string_sdna(prop, NULL, "type->label");
1439  "Label",
1440  "The panel label, shows up in the panel header at the right of the "
1441  "triangle used to collapse the panel");
1442 
1443  prop = RNA_def_property(srna, "bl_translation_context", PROP_STRING, PROP_NONE);
1444  RNA_def_property_string_sdna(prop, NULL, "type->translation_context");
1448  "",
1449  "Specific translation context, only define when the label needs to be "
1450  "disambiguated from others using the exact same label");
1451 
1452  RNA_define_verify_sdna(true);
1453 
1454  prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
1455  RNA_def_property_string_sdna(prop, NULL, "type->description");
1456  RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1457  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Panel_bl_description_set");
1458  // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1460  RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1461  RNA_def_property_ui_text(prop, "", "The panel tooltip");
1462 
1463  prop = RNA_def_property(srna, "bl_category", PROP_STRING, PROP_NONE);
1464  RNA_def_property_string_sdna(prop, NULL, "type->category");
1467  prop, "", "The category (tab) in which the panel will be displayed, when applicable");
1468 
1469  prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
1470  RNA_def_property_string_sdna(prop, NULL, "type->owner_id");
1472  RNA_def_property_ui_text(prop, "", "The ID owning the data displayed in the panel, if any");
1473 
1474  prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
1475  RNA_def_property_enum_sdna(prop, NULL, "type->space_type");
1478  RNA_def_property_ui_text(prop, "Space Type", "The space where the panel is going to be used in");
1479 
1480  prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
1481  RNA_def_property_enum_sdna(prop, NULL, "type->region_type");
1485  prop, "Region Type", "The region where the panel is going to be used in");
1486 
1487  prop = RNA_def_property(srna, "bl_context", PROP_STRING, PROP_NONE);
1488  RNA_def_property_string_sdna(prop, NULL, "type->context");
1490  prop, PROP_REGISTER_OPTIONAL); /* Only used in Properties Editor and 3D View - Thomas */
1492  "Context",
1493  "The context in which the panel belongs to. (TODO: explain the "
1494  "possible combinations bl_context/bl_region_type/bl_space_type)");
1495 
1496  prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1497  RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1498  RNA_def_property_enum_items(prop, panel_flag_items);
1500  RNA_def_property_ui_text(prop, "Options", "Options for this panel type");
1501 
1502  prop = RNA_def_property(srna, "bl_parent_id", PROP_STRING, PROP_NONE);
1503  RNA_def_property_string_sdna(prop, NULL, "type->parent_id");
1506  prop, "Parent ID Name", "If this is set, the panel becomes a sub-panel");
1507 
1508  prop = RNA_def_property(srna, "bl_ui_units_x", PROP_INT, PROP_UNSIGNED);
1509  RNA_def_property_int_sdna(prop, NULL, "type->ui_units_x");
1511  RNA_def_property_ui_text(prop, "Units X", "When set, defines popup panel width");
1512 
1513  prop = RNA_def_property(srna, "bl_order", PROP_INT, PROP_UNSIGNED);
1514  RNA_def_property_int_sdna(prop, NULL, "type->order");
1517  prop,
1518  "Order",
1519  "Panels with lower numbers are default ordered before panels with higher numbers");
1520 
1521  prop = RNA_def_property(srna, "use_pin", PROP_BOOLEAN, PROP_NONE);
1522  RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_PIN);
1523  RNA_def_property_ui_text(prop, "Pin", "Show the panel on all tabs");
1524  /* XXX, should only tag region for redraw */
1526 
1527  prop = RNA_def_property(srna, "is_popover", PROP_BOOLEAN, PROP_NONE);
1530  RNA_def_property_ui_text(prop, "Popover", "");
1531 }
1532 
1533 static void rna_def_uilist(BlenderRNA *brna)
1534 {
1535  StructRNA *srna;
1536  PropertyRNA *prop;
1537  PropertyRNA *parm;
1538  FunctionRNA *func;
1539 
1540  srna = RNA_def_struct(brna, "UIList", NULL);
1541  RNA_def_struct_ui_text(srna, "UIList", "UI list containing the elements of a collection");
1542  RNA_def_struct_sdna(srna, "uiList");
1543  RNA_def_struct_refine_func(srna, "rna_UIList_refine");
1544  RNA_def_struct_register_funcs(srna, "rna_UIList_register", "rna_UIList_unregister", NULL);
1545  RNA_def_struct_idprops_func(srna, "rna_UIList_idprops");
1547 
1548  /* Registration */
1549  prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1550  RNA_def_property_string_sdna(prop, NULL, "type->idname");
1553  "ID Name",
1554  "If this is set, the uilist gets a custom ID, otherwise it takes the "
1555  "name of the class used to define the uilist (for example, if the "
1556  "class name is \"OBJECT_UL_vgroups\", and bl_idname is not set by the "
1557  "script, then bl_idname = \"OBJECT_UL_vgroups\")");
1558 
1559  /* Data */
1560  /* Note that this is the "non-full" list-ID as obtained through #WM_uilisttype_list_id_get(),
1561  * which differs from the (internal) `uiList.list_id`. */
1562  prop = RNA_def_property(srna, "list_id", PROP_STRING, PROP_NONE);
1564  RNA_def_property_string_funcs(prop, "rna_UIList_list_id_get", "rna_UIList_list_id_length", NULL);
1566  "List Name",
1567  "Identifier of the list, if any was passed to the \"list_id\" "
1568  "parameter of \"template_list()\"");
1569 
1570  prop = RNA_def_property(srna, "layout_type", PROP_ENUM, PROP_NONE);
1573 
1574  /* Filter options */
1575  prop = RNA_def_property(srna, "use_filter_show", PROP_BOOLEAN, PROP_NONE);
1576  RNA_def_property_boolean_sdna(prop, NULL, "filter_flag", UILST_FLT_SHOW);
1577  RNA_def_property_ui_text(prop, "Show Filter", "Show filtering options");
1578 
1579  prop = RNA_def_property(srna, "filter_name", PROP_STRING, PROP_NONE);
1580  RNA_def_property_string_sdna(prop, NULL, "filter_byname");
1583  prop, "Filter by Name", "Only show items matching this name (use '*' as wildcard)");
1584 
1585  prop = RNA_def_property(srna, "use_filter_invert", PROP_BOOLEAN, PROP_NONE);
1586  RNA_def_property_boolean_sdna(prop, NULL, "filter_flag", UILST_FLT_EXCLUDE);
1587  RNA_def_property_ui_text(prop, "Invert", "Invert filtering (show hidden items, and vice versa)");
1588 
1589  /* WARNING: This is sort of an abuse, sort-by-alpha is actually a value,
1590  * should even be an enum in full logic (of two values, sort by index and sort by name).
1591  * But for default UIList, it's nicer (better UI-wise) to show this as a boolean bit-flag option,
1592  * avoids having to define custom setters/getters using UILST_FLT_SORT_MASK to mask out
1593  * actual bitflags on same var, etc.
1594  */
1595  prop = RNA_def_property(srna, "use_filter_sort_alpha", PROP_BOOLEAN, PROP_NONE);
1596  RNA_def_property_boolean_sdna(prop, NULL, "filter_sort_flag", UILST_FLT_SORT_ALPHA);
1597  RNA_def_property_ui_icon(prop, ICON_SORTALPHA, 0);
1598  RNA_def_property_ui_text(prop, "Sort by Name", "Sort items by their name");
1599 
1600  prop = RNA_def_property(srna, "use_filter_sort_reverse", PROP_BOOLEAN, PROP_NONE);
1601  RNA_def_property_boolean_sdna(prop, NULL, "filter_sort_flag", UILST_FLT_SORT_REVERSE);
1602  RNA_def_property_ui_text(prop, "Reverse", "Reverse the order of shown items");
1603 
1604  prop = RNA_def_property(srna, "use_filter_sort_lock", PROP_BOOLEAN, PROP_NONE);
1605  RNA_def_property_boolean_sdna(prop, NULL, "filter_sort_flag", UILST_FLT_SORT_LOCK);
1607  prop, "Lock Order", "Lock the order of shown items (user cannot change it)");
1608 
1609  /* draw_item */
1610  func = RNA_def_function(srna, "draw_item", NULL);
1612  func,
1613  "Draw an item in the list (NOTE: when you define your own draw_item "
1614  "function, you may want to check given 'item' is of the right type...)");
1616  parm = RNA_def_pointer(func, "context", "Context", "", "");
1618  parm = RNA_def_pointer(func, "layout", "UILayout", "", "Layout to draw the item");
1620  parm = RNA_def_pointer(
1621  func, "data", "AnyType", "", "Data from which to take Collection property");
1623  parm = RNA_def_pointer(func, "item", "AnyType", "", "Item of the collection property");
1625  parm = RNA_def_int(
1626  func, "icon", 0, 0, INT_MAX, "", "Icon of the item in the collection", 0, INT_MAX);
1628  parm = RNA_def_pointer(func,
1629  "active_data",
1630  "AnyType",
1631  "",
1632  "Data from which to take property for the active element");
1634  parm = RNA_def_string(func,
1635  "active_property",
1636  NULL,
1637  0,
1638  "",
1639  "Identifier of property in active_data, for the active element");
1641  RNA_def_int(func, "index", 0, 0, INT_MAX, "", "Index of the item in the collection", 0, INT_MAX);
1643  prop = RNA_def_property(func, "flt_flag", PROP_INT, PROP_UNSIGNED);
1644  RNA_def_property_ui_text(prop, "", "The filter-flag result for this item");
1646 
1647  /* draw_filter */
1648  func = RNA_def_function(srna, "draw_filter", NULL);
1649  RNA_def_function_ui_description(func, "Draw filtering options");
1651  parm = RNA_def_pointer(func, "context", "Context", "", "");
1653  parm = RNA_def_pointer(func, "layout", "UILayout", "", "Layout to draw the item");
1655 
1656  /* filter */
1657  func = RNA_def_function(srna, "filter_items", NULL);
1659  func,
1660  "Filter and/or re-order items of the collection (output filter results in "
1661  "filter_flags, and reorder results in filter_neworder arrays)");
1663  parm = RNA_def_pointer(func, "context", "Context", "", "");
1665  parm = RNA_def_pointer(
1666  func, "data", "AnyType", "", "Data from which to take Collection property");
1668  parm = RNA_def_string(
1669  func, "property", NULL, 0, "", "Identifier of property in data, for the collection");
1671  prop = RNA_def_property(func, "filter_flags", PROP_INT, PROP_UNSIGNED);
1673  RNA_def_property_array(prop, 1); /* XXX Dummy value, default 0 does not work */
1675  prop,
1676  "",
1677  "An array of filter flags, one for each item in the collection (NOTE: "
1678  "FILTER_ITEM bit is reserved, it defines whether the item is shown or not)");
1679  RNA_def_function_output(func, prop);
1680  prop = RNA_def_property(func, "filter_neworder", PROP_INT, PROP_UNSIGNED);
1682  RNA_def_property_array(prop, 1); /* XXX Dummy value, default 0 does not work */
1684  prop,
1685  "",
1686  "An array of indices, one for each item in the collection, mapping the org "
1687  "index to the new one");
1688  RNA_def_function_output(func, prop);
1689 
1690  /* "Constants"! */
1691  RNA_define_verify_sdna(0); /* not in sdna */
1692 
1693  prop = RNA_def_property(srna, "bitflag_filter_item", PROP_INT, PROP_UNSIGNED);
1695  prop,
1696  "FILTER_ITEM",
1697  "The value of the reserved bitflag 'FILTER_ITEM' (in filter_flags values)");
1698  RNA_def_property_int_funcs(prop, "rna_UIList_filter_const_FILTER_ITEM_get", NULL, NULL);
1700 }
1701 
1702 static void rna_def_header(BlenderRNA *brna)
1703 {
1704  StructRNA *srna;
1705  PropertyRNA *prop;
1706  PropertyRNA *parm;
1707  FunctionRNA *func;
1708 
1709  srna = RNA_def_struct(brna, "Header", NULL);
1710  RNA_def_struct_ui_text(srna, "Header", "Editor header containing UI elements");
1711  RNA_def_struct_sdna(srna, "Header");
1712  RNA_def_struct_refine_func(srna, "rna_Header_refine");
1713  RNA_def_struct_register_funcs(srna, "rna_Header_register", "rna_Header_unregister", NULL);
1715 
1716  /* draw */
1717  func = RNA_def_function(srna, "draw", NULL);
1718  RNA_def_function_ui_description(func, "Draw UI elements into the header UI layout");
1720  parm = RNA_def_pointer(func, "context", "Context", "", "");
1722 
1723  RNA_define_verify_sdna(0); /* not in sdna */
1724 
1725  prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
1726  RNA_def_property_pointer_sdna(prop, NULL, "layout");
1727  RNA_def_property_struct_type(prop, "UILayout");
1728  RNA_def_property_ui_text(prop, "Layout", "Structure of the header in the UI");
1729 
1730  /* registration */
1731  prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1732  RNA_def_property_string_sdna(prop, NULL, "type->idname");
1735  "ID Name",
1736  "If this is set, the header gets a custom ID, otherwise it takes the "
1737  "name of the class used to define the panel; for example, if the "
1738  "class name is \"OBJECT_HT_hello\", and bl_idname is not set by the "
1739  "script, then bl_idname = \"OBJECT_HT_hello\"");
1740 
1741  prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
1742  RNA_def_property_enum_sdna(prop, NULL, "type->space_type");
1746  prop, "Space Type", "The space where the header is going to be used in");
1747 
1748  prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
1749  RNA_def_property_enum_sdna(prop, NULL, "type->region_type");
1754  "Region Type",
1755  "The region where the header is going to be used in "
1756  "(defaults to header region)");
1757 
1759 }
1760 
1761 static void rna_def_menu(BlenderRNA *brna)
1762 {
1763  StructRNA *srna;
1764  PropertyRNA *prop;
1765  PropertyRNA *parm;
1766  FunctionRNA *func;
1767 
1768  srna = RNA_def_struct(brna, "Menu", NULL);
1769  RNA_def_struct_ui_text(srna, "Menu", "Editor menu containing buttons");
1770  RNA_def_struct_sdna(srna, "Menu");
1771  RNA_def_struct_refine_func(srna, "rna_Menu_refine");
1772  RNA_def_struct_register_funcs(srna, "rna_Menu_register", "rna_Menu_unregister", NULL);
1775 
1776  /* poll */
1777  func = RNA_def_function(srna, "poll", NULL);
1779  func, "If this method returns a non-null output, then the menu can be drawn");
1781  RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
1782  parm = RNA_def_pointer(func, "context", "Context", "", "");
1784 
1785  /* draw */
1786  func = RNA_def_function(srna, "draw", NULL);
1787  RNA_def_function_ui_description(func, "Draw UI elements into the menu UI layout");
1789  parm = RNA_def_pointer(func, "context", "Context", "", "");
1791 
1792  RNA_define_verify_sdna(false); /* not in sdna */
1793 
1794  prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
1795  RNA_def_property_pointer_sdna(prop, NULL, "layout");
1796  RNA_def_property_struct_type(prop, "UILayout");
1797  RNA_def_property_ui_text(prop, "Layout", "Defines the structure of the menu in the UI");
1798 
1799  /* registration */
1800  prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1801  RNA_def_property_string_sdna(prop, NULL, "type->idname");
1804  "ID Name",
1805  "If this is set, the menu gets a custom ID, otherwise it takes the "
1806  "name of the class used to define the menu (for example, if the "
1807  "class name is \"OBJECT_MT_hello\", and bl_idname is not set by the "
1808  "script, then bl_idname = \"OBJECT_MT_hello\")");
1809 
1810  prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1811  RNA_def_property_string_sdna(prop, NULL, "type->label");
1813  RNA_def_property_ui_text(prop, "Label", "The menu label");
1814 
1815  prop = RNA_def_property(srna, "bl_translation_context", PROP_STRING, PROP_NONE);
1816  RNA_def_property_string_sdna(prop, NULL, "type->translation_context");
1819 
1820  prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
1821  RNA_def_property_string_sdna(prop, NULL, "type->description");
1822  RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1823  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Menu_bl_description_set");
1824  // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1826  RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1827 
1828  prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
1829  RNA_def_property_string_sdna(prop, NULL, "type->owner_id");
1831 
1833 }
1834 
1836 {
1837  rna_def_ui_layout(brna);
1838  rna_def_panel(brna);
1839  rna_def_uilist(brna);
1840  rna_def_header(brna);
1841  rna_def_menu(brna);
1842 }
1843 
1844 #endif /* RNA_RUNTIME */
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:733
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
@ PANEL_TYPE_NO_HEADER
Definition: BKE_screen.h:280
@ PANEL_TYPE_INSTANCED
Definition: BKE_screen.h:285
@ PANEL_TYPE_DEFAULT_CLOSED
Definition: BKE_screen.h:279
@ PANEL_TYPE_HEADER_EXPAND
Definition: BKE_screen.h:282
struct SpaceType * BKE_spacetype_from_id(int spaceid)
Definition: screen.c:353
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
A dynamically sized string ADT.
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:102
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:239
struct LinkData * BLI_genericNodeN(void *data)
Definition: listbase.c:842
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition: listbase.c:301
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
void * BLI_findptr(const struct ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
#define UNUSED(x)
#define ELEM(...)
#define STREQ(a, b)
#define BLT_I18NCONTEXT_DEFAULT_BPYRNA
@ UILST_FLT_ITEM
@ PNL_PIN
@ PNL_POPOVER
@ UILST_LAYOUT_COMPACT
@ UILST_LAYOUT_DEFAULT
@ UILST_LAYOUT_GRID
@ RGN_TYPE_HEADER
#define RGN_TYPE_HAS_CATEGORY_MASK
#define PNL_CATEGORY_FALLBACK
@ UILST_FLT_SORT_LOCK
@ UILST_FLT_SORT_ALPHA
@ UILST_FLT_SORT_REVERSE
@ UILST_FLT_EXCLUDE
@ UILST_FLT_SHOW
_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 type
Read Guarded memory(de)allocation.
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
#define RNA_DYN_DESCR_MAX
Definition: RNA_define.h:576
@ PARM_RNAPTR
Definition: RNA_types.h:354
@ PARM_PYFUNC_OPTIONAL
Definition: RNA_types.h:362
@ PARM_REQUIRED
Definition: RNA_types.h:352
void(* StructFreeFunc)(void *data)
Definition: RNA_types.h:737
int(* StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function)
Definition: RNA_types.h:732
@ FUNC_NO_SELF
Definition: RNA_types.h:656
@ FUNC_REGISTER
Definition: RNA_types.h:670
@ FUNC_REGISTER_OPTIONAL
Definition: RNA_types.h:672
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
Definition: RNA_types.h:717
@ STRUCT_NO_IDPROPERTIES
Definition: RNA_types.h:715
@ STRUCT_PUBLIC_NAMESPACE_INHERIT
Definition: RNA_types.h:723
int(* StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list)
Definition: RNA_types.h:733
@ PROP_FLOAT
Definition: RNA_types.h:61
@ PROP_BOOLEAN
Definition: RNA_types.h:59
@ PROP_ENUM
Definition: RNA_types.h:63
@ PROP_INT
Definition: RNA_types.h:60
@ PROP_STRING
Definition: RNA_types.h:62
@ PROP_POINTER
Definition: RNA_types.h:64
@ PROP_DYNAMIC
Definition: RNA_types.h:290
@ PROP_EDITABLE
Definition: RNA_types.h:189
@ PROP_ENUM_FLAG
Definition: RNA_types.h:266
@ PROP_REGISTER_OPTIONAL
Definition: RNA_types.h:274
@ PROP_NEVER_NULL
Definition: RNA_types.h:239
@ PROP_REGISTER
Definition: RNA_types.h:273
@ PROP_TEXTEDIT_UPDATE
Definition: RNA_types.h:209
@ PROP_NONE
Definition: RNA_types.h:126
@ PROP_UNSIGNED
Definition: RNA_types.h:142
#define C
Definition: RandGen.cpp:25
@ UI_LAYOUT_ALIGN_LEFT
@ UI_LAYOUT_ALIGN_CENTER
@ UI_LAYOUT_ALIGN_RIGHT
@ UI_LAYOUT_ALIGN_EXPAND
@ UI_LAYOUT_VERTICAL
@ UI_LAYOUT_HORIZONTAL
bool uiLayoutGetActivateInit(uiLayout *layout)
void uiLayoutSetActive(uiLayout *layout, bool active)
bool uiLayoutGetPropDecorate(uiLayout *layout)
int uiLayoutGetAlignment(uiLayout *layout)
void uiLayoutSetUnitsY(uiLayout *layout, float unit)
@ UI_EMBOSS_NONE
Definition: UI_interface.h:109
@ UI_EMBOSS
Definition: UI_interface.h:108
@ UI_EMBOSS_RADIAL
Definition: UI_interface.h:111
@ UI_EMBOSS_PULLDOWN
Definition: UI_interface.h:110
@ UI_EMBOSS_NONE_OR_STATUS
Definition: UI_interface.h:116
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
float uiLayoutGetUnitsY(uiLayout *layout)
void uiLayoutSetScaleY(uiLayout *layout, float scale)
void uiLayoutSetActiveDefault(uiLayout *layout, bool active_default)
void uiLayoutSetRedAlert(uiLayout *layout, bool redalert)
struct PointerRNA * UI_panel_custom_data_get(const struct Panel *panel)
void uiLayoutSetScaleX(uiLayout *layout, float scale)
float uiLayoutGetUnitsX(uiLayout *layout)
void uiLayoutSetAlignment(uiLayout *layout, char alignment)
bool uiLayoutGetEnabled(uiLayout *layout)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
float uiLayoutGetScaleY(uiLayout *layout)
bool uiLayoutGetActive(uiLayout *layout)
void UI_panels_free_instanced(const struct bContext *C, struct ARegion *region)
bool uiLayoutGetKeepAspect(uiLayout *layout)
bool uiLayoutGetPropSep(uiLayout *layout)
void uiLayoutSetUnitsX(uiLayout *layout, float unit)
eUIEmbossType uiLayoutGetEmboss(uiLayout *layout)
int uiLayoutGetLocalDir(const uiLayout *layout)
void uiLayoutSetKeepAspect(uiLayout *layout, bool keepaspect)
bool uiLayoutGetActiveDefault(uiLayout *layout)
int uiLayoutGetOperatorContext(uiLayout *layout)
void uiLayoutSetEmboss(uiLayout *layout, eUIEmbossType emboss)
float uiLayoutGetScaleX(uiLayout *layout)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
void uiLayoutSetActivateInit(uiLayout *layout, bool activate_init)
void uiLayoutSetOperatorContext(uiLayout *layout, wmOperatorCallContext opcontext)
bool uiLayoutGetRedAlert(uiLayout *layout)
#define WM_TOOLSYSTEM_SPACE_MASK
Definition: WM_toolsystem.h:29
#define NC_WINDOW
Definition: WM_types.h:325
@ WM_OP_INVOKE_REGION_WIN
Definition: WM_types.h:202
@ WM_OP_EXEC_REGION_WIN
Definition: WM_types.h:209
@ WM_OP_INVOKE_SCREEN
Definition: WM_types.h:206
@ WM_OP_INVOKE_AREA
Definition: WM_types.h:205
@ WM_OP_EXEC_REGION_PREVIEW
Definition: WM_types.h:211
@ WM_OP_EXEC_SCREEN
Definition: WM_types.h:213
@ WM_OP_INVOKE_REGION_PREVIEW
Definition: WM_types.h:204
@ WM_OP_INVOKE_DEFAULT
Definition: WM_types.h:201
@ WM_OP_EXEC_REGION_CHANNELS
Definition: WM_types.h:210
@ WM_OP_INVOKE_REGION_CHANNELS
Definition: WM_types.h:203
@ WM_OP_EXEC_DEFAULT
Definition: WM_types.h:208
@ WM_OP_EXEC_AREA
Definition: WM_types.h:212
return(oflags[bm->toolflag_index].f &oflag) !=0
int len
Definition: draw_manager.c:108
#define str(s)
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
static void area(int d1, int d2, int e1, int e2, float weights[2])
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
return ret
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
int RNA_collection_length(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5239
void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void **value)
Definition: rna_access.c:6026
bool RNA_struct_available_or_report(ReportList *reports, const char *identifier)
Definition: rna_access.c:918
void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
Definition: rna_access.c:902
ParameterList * RNA_parameter_list_create(ParameterList *parms, PointerRNA *UNUSED(ptr), FunctionRNA *func)
Definition: rna_access.c:5826
void * RNA_struct_blender_type_get(StructRNA *srna)
Definition: rna_access.c:897
void RNA_parameter_list_free(ParameterList *parms)
Definition: rna_access.c:5922
void RNA_parameter_get(ParameterList *parms, PropertyRNA *parm, void **value)
Definition: rna_access.c:5997
void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, const void *value)
Definition: rna_access.c:6088
int RNA_parameter_dynamic_length_get(ParameterList *parms, PropertyRNA *parm)
Definition: rna_access.c:6104
PropertyRNA * RNA_function_find_parameter(PointerRNA *UNUSED(ptr), FunctionRNA *func, const char *identifier)
Definition: rna_access.c:5798
bool RNA_struct_bl_idname_ok_or_report(ReportList *reports, const char *identifier, const char *sep)
Definition: rna_access.c:948
const char * RNA_struct_state_owner_get(void)
Definition: rna_access.c:6816
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
Definition: rna_define.c:1148
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2740
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4170
void RNA_def_struct_flag(StructRNA *srna, int flag)
Definition: rna_define.c:1133
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2236
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
Definition: rna_define.c:3285
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4312
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
Definition: rna_define.c:2106
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3126
void RNA_define_verify_sdna(bool verify)
Definition: rna_define.c:737
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1645
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2695
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
Definition: rna_define.c:1653
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4273
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1237
void RNA_def_function_output(FunctionRNA *UNUSED(func), PropertyRNA *ret)
Definition: rna_define.c:4337
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
Definition: rna_define.c:2944
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
Definition: rna_define.c:1172
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
Definition: rna_define.c:900
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1872
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1048
void RNA_def_property_array(PropertyRNA *prop, int length)
Definition: rna_define.c:1539
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
Definition: rna_define.c:1920
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1772
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4347
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2900
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
Definition: rna_define.c:3224
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1257
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4342
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1495
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext)
Definition: rna_define.c:762
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
Definition: rna_define.c:3385
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1028
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2601
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3028
void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
Definition: rna_define.c:2065
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
Definition: rna_define.c:777
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
Definition: rna_define.c:1160
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2343
void RNA_def_struct_translation_context(StructRNA *srna, const char *context)
Definition: rna_define.c:1250
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1518
BlenderRNA BLENDER_RNA
void RNA_api_ui_layout(struct StructRNA *srna)
Definition: rna_ui_api.c:901
const EnumPropertyItem rna_enum_region_type_items[]
Definition: rna_screen.c:21
const EnumPropertyItem rna_enum_space_type_items[]
Definition: rna_space.c:86
const EnumPropertyItem rna_enum_operator_context_items[]
Definition: rna_ui.c:30
static void rna_def_header(BlenderRNA *brna)
Definition: rna_ui.c:1702
const EnumPropertyItem rna_enum_uilist_layout_type_items[]
Definition: rna_ui.c:46
static void rna_def_uilist(BlenderRNA *brna)
Definition: rna_ui.c:1533
static void rna_def_ui_layout(BlenderRNA *brna)
Definition: rna_ui.c:1218
static void rna_def_menu(BlenderRNA *brna)
Definition: rna_ui.c:1761
static void rna_def_panel(BlenderRNA *brna)
Definition: rna_ui.c:1339
void RNA_def_ui(BlenderRNA *brna)
Definition: rna_ui.c:1835
struct ARegionType * next
Definition: BKE_screen.h:142
ListBase headertypes
Definition: BKE_screen.h:201
ListBase paneltypes
Definition: BKE_screen.h:198
StructRNA * srna
Definition: RNA_types.h:766
StructCallbackFunc call
Definition: RNA_types.h:767
void * data
Definition: RNA_types.h:765
StructFreeFunc free
Definition: RNA_types.h:768
void(* draw)(const struct bContext *C, struct Header *header)
Definition: BKE_screen.h:345
int region_type
Definition: BKE_screen.h:341
struct HeaderType * next
Definition: BKE_screen.h:337
int space_type
Definition: BKE_screen.h:340
char idname[BKE_ST_MAXNAME]
Definition: BKE_screen.h:339
ExtensionRNA rna_ext
Definition: BKE_screen.h:348
struct HeaderType * type
Definition: BKE_screen.h:352
void * data
Definition: DNA_listBase.h:26
struct LinkData * prev
Definition: DNA_listBase.h:25
void * last
Definition: DNA_listBase.h:31
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
ListBase screens
Definition: BKE_main.h:183
const char * description
Definition: BKE_screen.h:365
char owner_id[BKE_ST_MAXNAME]
Definition: BKE_screen.h:364
ExtensionRNA rna_ext
Definition: BKE_screen.h:373
char idname[BKE_ST_MAXNAME]
Definition: BKE_screen.h:361
bool(* poll)(const struct bContext *C, struct MenuType *mt)
Definition: BKE_screen.h:368
void(* draw)(const struct bContext *C, struct Menu *menu)
Definition: BKE_screen.h:370
char translation_context[BKE_ST_MAXNAME]
Definition: BKE_screen.h:363
struct MenuType * type
Definition: BKE_screen.h:377
ExtensionRNA rna_ext
Definition: BKE_screen.h:274
char owner_id[BKE_ST_MAXNAME]
Definition: BKE_screen.h:229
struct PanelType * prev
Definition: BKE_screen.h:221
void(* draw)(const struct bContext *C, struct Panel *panel)
Definition: BKE_screen.h:248
void(* draw_header_preset)(const struct bContext *C, struct Panel *panel)
Definition: BKE_screen.h:246
bool(* poll)(const struct bContext *C, struct PanelType *pt)
Definition: BKE_screen.h:242
void(* draw_header)(const struct bContext *C, struct Panel *panel)
Definition: BKE_screen.h:244
short region_type
Definition: BKE_screen.h:234
char idname[BKE_ST_MAXNAME]
Definition: BKE_screen.h:223
struct PanelType * next
Definition: BKE_screen.h:221
short space_type
Definition: BKE_screen.h:233
char translation_context[BKE_ST_MAXNAME]
Definition: BKE_screen.h:226
ListBase children
Definition: BKE_screen.h:271
struct PanelType * parent
Definition: BKE_screen.h:270
char * description
Definition: BKE_screen.h:225
struct PanelType * type
ListBase children
struct StructRNA * type
Definition: RNA_types.h:37
void * data
Definition: RNA_types.h:38
int * items_filter_neworder
int * items_filter_flags
char idname[BKE_ST_MAXNAME]
Definition: BKE_screen.h:321
uiListFilterItemsFunc filter_items
Definition: BKE_screen.h:325
ExtensionRNA rna_ext
Definition: BKE_screen.h:331
uiListDrawFilterFunc draw_filter
Definition: BKE_screen.h:324
uiListDrawItemFunc draw_item
Definition: BKE_screen.h:323
IDProperty * properties
uiListDyn * dyn_data
struct uiListType * type
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3480
MenuType * WM_menutype_find(const char *idname, bool quiet)
Definition: wm_menu_type.c:30
bool WM_menutype_add(MenuType *mt)
Definition: wm_menu_type.c:51
void WM_menutype_freelink(MenuType *mt)
Definition: wm_menu_type.c:58
bool WM_paneltype_add(PanelType *pt)
Definition: wm_panel_type.c:44
void WM_paneltype_remove(PanelType *pt)
Definition: wm_panel_type.c:50
bool WM_uilisttype_add(uiListType *ult)
uiListType * WM_uilisttype_find(const char *idname, bool quiet)
const char * WM_uilisttype_list_id_get(const uiListType *ult, uiList *list)
void WM_uilisttype_remove_ptr(Main *bmain, uiListType *ult)