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