Blender  V3.3
rna_wm_gizmo.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 #include "DNA_userdef_types.h"
12 #include "DNA_view3d_types.h"
14 
15 #include "BLI_listbase.h"
16 #include "BLI_utildefines.h"
17 
18 #include "BLT_translation.h"
19 
20 #include "RNA_access.h"
21 #include "RNA_define.h"
22 #include "RNA_enum_types.h"
23 
24 #include "rna_internal.h"
25 
26 #include "WM_types.h"
27 
28 #ifdef RNA_RUNTIME
29 /* enum definitions */
30 #endif /* RNA_RUNTIME */
31 
32 #ifdef RNA_RUNTIME
33 
34 # include "BLI_string_utils.h"
35 
36 # include "WM_api.h"
37 
38 # include "DNA_workspace_types.h"
39 
40 # include "ED_screen.h"
41 
42 # include "UI_interface.h"
43 
44 # include "BKE_global.h"
45 # include "BKE_idprop.h"
46 # include "BKE_workspace.h"
47 
48 # include "MEM_guardedalloc.h"
49 
50 # include "GPU_state.h"
51 
52 # ifdef WITH_PYTHON
53 # include "BPY_extern.h"
54 # endif
55 
56 /* -------------------------------------------------------------------- */
60 # ifdef WITH_PYTHON
61 static void rna_gizmo_draw_cb(const struct bContext *C, struct wmGizmo *gz)
62 {
63  extern FunctionRNA rna_Gizmo_draw_func;
64  wmGizmoGroup *gzgroup = gz->parent_gzgroup;
65  PointerRNA gz_ptr;
66  ParameterList list;
67  FunctionRNA *func;
68  RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr);
69  /* Reference `RNA_struct_find_function(&gz_ptr, "draw")` directly. */
70  func = &rna_Gizmo_draw_func;
71  RNA_parameter_list_create(&list, &gz_ptr, func);
72  RNA_parameter_set_lookup(&list, "context", &C);
73  gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
75  /* This callback may have called bgl functions. */
76  GPU_bgl_end();
77 }
78 
79 static void rna_gizmo_draw_select_cb(const struct bContext *C, struct wmGizmo *gz, int select_id)
80 {
81  extern FunctionRNA rna_Gizmo_draw_select_func;
82  wmGizmoGroup *gzgroup = gz->parent_gzgroup;
83  PointerRNA gz_ptr;
84  ParameterList list;
85  FunctionRNA *func;
86  RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr);
87  /* Reference `RNA_struct_find_function(&gz_ptr, "draw_select")` directly. */
88  func = &rna_Gizmo_draw_select_func;
89  RNA_parameter_list_create(&list, &gz_ptr, func);
90  RNA_parameter_set_lookup(&list, "context", &C);
91  RNA_parameter_set_lookup(&list, "select_id", &select_id);
92  gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
94  /* This callback may have called bgl functions. */
95  GPU_bgl_end();
96 }
97 
98 static int rna_gizmo_test_select_cb(struct bContext *C, struct wmGizmo *gz, const int location[2])
99 {
100  extern FunctionRNA rna_Gizmo_test_select_func;
101  wmGizmoGroup *gzgroup = gz->parent_gzgroup;
102  PointerRNA gz_ptr;
103  ParameterList list;
104  FunctionRNA *func;
105  RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr);
106  /* Reference `RNA_struct_find_function(&gz_ptr, "test_select")` directly. */
107  func = &rna_Gizmo_test_select_func;
108  RNA_parameter_list_create(&list, &gz_ptr, func);
109  RNA_parameter_set_lookup(&list, "context", &C);
110  RNA_parameter_set_lookup(&list, "location", location);
111  gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
112 
113  void *ret;
114  RNA_parameter_get_lookup(&list, "intersect_id", &ret);
115  int intersect_id = *(int *)ret;
116 
118  return intersect_id;
119 }
120 
121 static int rna_gizmo_modal_cb(struct bContext *C,
122  struct wmGizmo *gz,
123  const struct wmEvent *event,
124  eWM_GizmoFlagTweak tweak_flag)
125 {
126  extern FunctionRNA rna_Gizmo_modal_func;
127  wmGizmoGroup *gzgroup = gz->parent_gzgroup;
128  PointerRNA gz_ptr;
129  ParameterList list;
130  FunctionRNA *func;
131  const int tweak_flag_int = tweak_flag;
132  RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr);
133  /* Reference `RNA_struct_find_function(&gz_ptr, "modal")` directly. */
134  func = &rna_Gizmo_modal_func;
135  RNA_parameter_list_create(&list, &gz_ptr, func);
136  RNA_parameter_set_lookup(&list, "context", &C);
137  RNA_parameter_set_lookup(&list, "event", &event);
138  RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int);
139  gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
140 
141  void *ret;
142  RNA_parameter_get_lookup(&list, "result", &ret);
143  int ret_enum = *(int *)ret;
144 
146  return ret_enum;
147 }
148 
149 static void rna_gizmo_setup_cb(struct wmGizmo *gz)
150 {
151  extern FunctionRNA rna_Gizmo_setup_func;
152  wmGizmoGroup *gzgroup = gz->parent_gzgroup;
153  PointerRNA gz_ptr;
154  ParameterList list;
155  FunctionRNA *func;
156  RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr);
157  /* Reference `RNA_struct_find_function(&gz_ptr, "setup")` directly. */
158  func = &rna_Gizmo_setup_func;
159  RNA_parameter_list_create(&list, &gz_ptr, func);
160  gzgroup->type->rna_ext.call((bContext *)NULL, &gz_ptr, func, &list);
162 }
163 
164 static int rna_gizmo_invoke_cb(struct bContext *C, struct wmGizmo *gz, const struct wmEvent *event)
165 {
166  extern FunctionRNA rna_Gizmo_invoke_func;
167  wmGizmoGroup *gzgroup = gz->parent_gzgroup;
168  PointerRNA gz_ptr;
169  ParameterList list;
170  FunctionRNA *func;
171  RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr);
172  /* Reference `RNA_struct_find_function(&gz_ptr, "invoke")` directly. */
173  func = &rna_Gizmo_invoke_func;
174  RNA_parameter_list_create(&list, &gz_ptr, func);
175  RNA_parameter_set_lookup(&list, "context", &C);
176  RNA_parameter_set_lookup(&list, "event", &event);
177  gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
178 
179  void *ret;
180  RNA_parameter_get_lookup(&list, "result", &ret);
181  int ret_enum = *(int *)ret;
182 
184  return ret_enum;
185 }
186 
187 static void rna_gizmo_exit_cb(struct bContext *C, struct wmGizmo *gz, bool cancel)
188 {
189  extern FunctionRNA rna_Gizmo_exit_func;
190  wmGizmoGroup *gzgroup = gz->parent_gzgroup;
191  PointerRNA gz_ptr;
192  ParameterList list;
193  FunctionRNA *func;
194  RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr);
195  /* Reference `RNA_struct_find_function(&gz_ptr, "exit")` directly. */
196  func = &rna_Gizmo_exit_func;
197  RNA_parameter_list_create(&list, &gz_ptr, func);
198  RNA_parameter_set_lookup(&list, "context", &C);
199  {
200  int cancel_i = cancel;
201  RNA_parameter_set_lookup(&list, "cancel", &cancel_i);
202  }
203  gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
205 }
206 
207 static void rna_gizmo_select_refresh_cb(struct wmGizmo *gz)
208 {
209  extern FunctionRNA rna_Gizmo_select_refresh_func;
210  wmGizmoGroup *gzgroup = gz->parent_gzgroup;
211  PointerRNA gz_ptr;
212  ParameterList list;
213  FunctionRNA *func;
214  RNA_pointer_create(NULL, gz->type->rna_ext.srna, gz, &gz_ptr);
215  /* Reference `RNA_struct_find_function(&gz_ptr, "select_refresh")` directly. */
216  func = &rna_Gizmo_select_refresh_func;
217  RNA_parameter_list_create(&list, &gz_ptr, func);
218  gzgroup->type->rna_ext.call((bContext *)NULL, &gz_ptr, func, &list);
220 }
221 
222 # endif /* WITH_PYTHON */
223 
224 /* just to work around 'const char *' warning and to ensure this is a python op */
225 static void rna_Gizmo_bl_idname_set(PointerRNA *ptr, const char *value)
226 {
227  wmGizmo *data = ptr->data;
228  char *str = (char *)data->type->idname;
229  if (!str[0]) {
230  BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
231  }
232  else {
233  BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
234  }
235 }
236 
237 static void rna_Gizmo_update_redraw(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
238 {
239  wmGizmo *gizmo = ptr->data;
240  gizmo->do_draw = true;
241 }
242 
243 static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr)
244 {
245 # if 0
247 # endif
248 
249  /* We could try workaround this lookup, but not trivial. */
250  for (bScreen *screen = G_MAIN->screens.first; screen; screen = screen->id.next) {
251  IDProperty *properties = ptr->data;
252  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
253  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
254  if (region->gizmo_map) {
255  wmGizmoMap *gzmap = region->gizmo_map;
257  LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
258  if (gz->properties == properties) {
259  return gz;
260  }
261  }
262  }
263  }
264  }
265  }
266  }
267  return NULL;
268 }
269 
270 static StructRNA *rna_GizmoProperties_refine(PointerRNA *ptr)
271 {
272  wmGizmo *gz = rna_GizmoProperties_find_operator(ptr);
273 
274  if (gz) {
275  return gz->type->srna;
276  }
277  else {
278  return ptr->type;
279  }
280 }
281 
282 static IDProperty **rna_GizmoProperties_idprops(PointerRNA *ptr)
283 {
284  return (IDProperty **)&ptr->data;
285 }
286 
287 static PointerRNA rna_Gizmo_properties_get(PointerRNA *ptr)
288 {
289  wmGizmo *gz = ptr->data;
291 }
292 
293 /* wmGizmo.float */
294 # define RNA_GIZMO_GENERIC_FLOAT_RW_DEF(func_id, member_id) \
295  static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
296  { \
297  wmGizmo *gz = ptr->data; \
298  return gz->member_id; \
299  } \
300  static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \
301  { \
302  wmGizmo *gz = ptr->data; \
303  gz->member_id = value; \
304  }
305 # define RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \
306  static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
307  { \
308  wmGizmo *gz = ptr->data; \
309  return gz->member_id[index]; \
310  } \
311  static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \
312  { \
313  wmGizmo *gz = ptr->data; \
314  gz->member_id[index] = value; \
315  }
316 /* wmGizmo.float[len] */
317 # define RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \
318  static void rna_Gizmo_##func_id##_get(PointerRNA *ptr, float value[len]) \
319  { \
320  wmGizmo *gz = ptr->data; \
321  memcpy(value, gz->member_id, sizeof(float[len])); \
322  } \
323  static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, const float value[len]) \
324  { \
325  wmGizmo *gz = ptr->data; \
326  memcpy(gz->member_id, value, sizeof(float[len])); \
327  }
328 
329 /* wmGizmo.flag */
330 # define RNA_GIZMO_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \
331  static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
332  { \
333  wmGizmo *gz = ptr->data; \
334  return (gz->member_id & flag_value) != 0; \
335  } \
336  static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \
337  { \
338  wmGizmo *gz = ptr->data; \
339  SET_FLAG_FROM_TEST(gz->member_id, value, flag_value); \
340  }
341 
342 /* wmGizmo.flag (negative) */
343 # define RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \
344  static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
345  { \
346  wmGizmo *gz = ptr->data; \
347  return (gz->member_id & flag_value) == 0; \
348  } \
349  static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \
350  { \
351  wmGizmo *gz = ptr->data; \
352  SET_FLAG_FROM_TEST(gz->member_id, !value, flag_value); \
353  }
354 
355 # define RNA_GIZMO_FLAG_RO_DEF(func_id, member_id, flag_value) \
356  static int rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
357  { \
358  wmGizmo *gz = ptr->data; \
359  return (gz->member_id & flag_value) != 0; \
360  }
361 
362 RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3);
363 RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3);
364 
365 RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3);
366 RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3);
367 
368 RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16);
369 RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16);
370 RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16);
371 
372 static void rna_Gizmo_matrix_world_get(PointerRNA *ptr, float value[16])
373 {
374  wmGizmo *gz = ptr->data;
375  WM_gizmo_calc_matrix_final(gz, (float(*)[4])value);
376 }
377 
378 RNA_GIZMO_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis);
379 RNA_GIZMO_GENERIC_FLOAT_RW_DEF(line_width, line_width);
380 RNA_GIZMO_GENERIC_FLOAT_RW_DEF(select_bias, select_bias);
381 
382 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_GIZMO_DRAW_HOVER);
383 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_GIZMO_DRAW_MODAL);
384 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_GIZMO_DRAW_VALUE);
385 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE);
386 RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_GIZMO_DRAW_NO_SCALE);
387 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_GIZMO_HIDDEN);
388 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_select, flag, WM_GIZMO_HIDDEN_SELECT);
389 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_keymap, flag, WM_GIZMO_HIDDEN_KEYMAP);
390 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_GIZMO_MOVE_CURSOR);
391 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_GIZMO_SELECT_BACKGROUND);
392 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_operator_tool_properties,
393  flag,
395 RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_event_handle_all, flag, WM_GIZMO_EVENT_HANDLE_ALL);
396 RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_tooltip, flag, WM_GIZMO_NO_TOOLTIP);
397 
398 /* wmGizmo.state */
399 RNA_GIZMO_FLAG_RO_DEF(state_is_highlight, state, WM_GIZMO_STATE_HIGHLIGHT);
400 RNA_GIZMO_FLAG_RO_DEF(state_is_modal, state, WM_GIZMO_STATE_MODAL);
401 RNA_GIZMO_FLAG_RO_DEF(state_select, state, WM_GIZMO_STATE_SELECT);
402 
403 static void rna_Gizmo_state_select_set(struct PointerRNA *ptr, bool value)
404 {
405  wmGizmo *gz = ptr->data;
406  wmGizmoGroup *gzgroup = gz->parent_gzgroup;
407  WM_gizmo_select_set(gzgroup->parent_gzmap, gz, value);
408 }
409 
410 static PointerRNA rna_Gizmo_group_get(PointerRNA *ptr)
411 {
412  wmGizmo *gz = ptr->data;
413  return rna_pointer_inherit_refine(ptr, &RNA_GizmoGroup, gz->parent_gzgroup);
414 }
415 
416 # ifdef WITH_PYTHON
417 
418 static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type);
419 void BPY_RNA_gizmo_wrapper(wmGizmoType *gzgt, void *userdata);
420 
421 static StructRNA *rna_Gizmo_register(Main *bmain,
422  ReportList *reports,
423  void *data,
424  const char *identifier,
425  StructValidateFunc validate,
426  StructCallbackFunc call,
428 {
429  struct {
430  char idname[MAX_NAME];
431  } temp_buffers;
432 
433  wmGizmoType dummygt = {NULL};
434  wmGizmo dummymnp = {NULL};
435  PointerRNA mnp_ptr;
436 
437  /* Two sets of functions. */
438  int have_function[8];
439 
440  /* setup dummy gizmo & gizmo type to store static properties in */
441  dummymnp.type = &dummygt;
442  dummygt.idname = temp_buffers.idname;
443  RNA_pointer_create(NULL, &RNA_Gizmo, &dummymnp, &mnp_ptr);
444 
445  /* Clear so we can detect if it's left unset. */
446  temp_buffers.idname[0] = '\0';
447 
448  /* validate the python class */
449  if (validate(&mnp_ptr, data, have_function) != 0) {
450  return NULL;
451  }
452 
453  if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
454  BKE_reportf(reports,
455  RPT_ERROR,
456  "Registering gizmo class: '%s' is too long, maximum length is %d",
457  identifier,
458  (int)sizeof(temp_buffers.idname));
459  return NULL;
460  }
461 
462  /* check if we have registered this gizmo type before, and remove it */
463  {
464  const wmGizmoType *gzt = WM_gizmotype_find(dummygt.idname, true);
465  if (gzt && gzt->rna_ext.srna) {
466  rna_Gizmo_unregister(bmain, gzt->rna_ext.srna);
467  }
468  }
469  if (!RNA_struct_available_or_report(reports, dummygt.idname)) {
470  return NULL;
471  }
472 
473  { /* allocate the idname */
474  /* For multiple strings see GizmoGroup. */
475  dummygt.idname = BLI_strdup(temp_buffers.idname);
476  }
477 
478  /* create a new gizmo type */
479  dummygt.rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummygt.idname, &RNA_Gizmo);
480  /* gizmo properties are registered separately */
482  dummygt.rna_ext.data = data;
483  dummygt.rna_ext.call = call;
484  dummygt.rna_ext.free = free;
485 
486  {
487  int i = 0;
488  dummygt.draw = (have_function[i++]) ? rna_gizmo_draw_cb : NULL;
489  dummygt.draw_select = (have_function[i++]) ? rna_gizmo_draw_select_cb : NULL;
490  dummygt.test_select = (have_function[i++]) ? rna_gizmo_test_select_cb : NULL;
491  dummygt.modal = (have_function[i++]) ? rna_gizmo_modal_cb : NULL;
492  // dummygt.property_update = (have_function[i++]) ? rna_gizmo_property_update : NULL;
493  // dummygt.position_get = (have_function[i++]) ? rna_gizmo_position_get : NULL;
494  dummygt.setup = (have_function[i++]) ? rna_gizmo_setup_cb : NULL;
495  dummygt.invoke = (have_function[i++]) ? rna_gizmo_invoke_cb : NULL;
496  dummygt.exit = (have_function[i++]) ? rna_gizmo_exit_cb : NULL;
497  dummygt.select_refresh = (have_function[i++]) ? rna_gizmo_select_refresh_cb : NULL;
498 
499  BLI_assert(i == ARRAY_SIZE(have_function));
500  }
501 
503 
504  /* update while blender is running */
506 
507  return dummygt.rna_ext.srna;
508 }
509 
510 static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type)
511 {
513 
514  if (!gzt) {
515  return;
516  }
517 
518  WM_gizmotype_remove_ptr(NULL, bmain, gzt);
519 
520  /* Free extension after removing instances so `__del__` doesn't crash, see: T85567. */
523 
524  /* Free gizmo group after the extension as it owns the identifier memory. */
526 
528 }
529 
530 static void **rna_Gizmo_instance(PointerRNA *ptr)
531 {
532  wmGizmo *gz = ptr->data;
533  return &gz->py_instance;
534 }
535 
536 # endif /* WITH_PYTHON */
537 
538 static StructRNA *rna_Gizmo_refine(PointerRNA *mnp_ptr)
539 {
540  wmGizmo *gz = mnp_ptr->data;
541  return (gz->type && gz->type->rna_ext.srna) ? gz->type->rna_ext.srna : &RNA_Gizmo;
542 }
543 
546 /* -------------------------------------------------------------------- */
550 static wmGizmoGroupType *rna_GizmoGroupProperties_find_gizmo_group_type(PointerRNA *ptr)
551 {
552  IDProperty *properties = (IDProperty *)ptr->data;
553  wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(properties->name, false);
554  return gzgt;
555 }
556 
557 static StructRNA *rna_GizmoGroupProperties_refine(PointerRNA *ptr)
558 {
559  wmGizmoGroupType *gzgt = rna_GizmoGroupProperties_find_gizmo_group_type(ptr);
560 
561  if (gzgt) {
562  return gzgt->srna;
563  }
564  else {
565  return ptr->type;
566  }
567 }
568 
569 static IDProperty **rna_GizmoGroupProperties_idprops(PointerRNA *ptr)
570 {
571  return (IDProperty **)&ptr->data;
572 }
573 
574 static wmGizmo *rna_GizmoGroup_gizmo_new(wmGizmoGroup *gzgroup,
575  ReportList *reports,
576  const char *idname)
577 {
578  const wmGizmoType *gzt = WM_gizmotype_find(idname, true);
579  if (gzt == NULL) {
580  BKE_reportf(reports, RPT_ERROR, "GizmoType '%s' not known", idname);
581  return NULL;
582  }
583  if ((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0) {
584  /* Allow for neither callbacks to be set, while this doesn't seem like a valid use case,
585  * there may be rare situations where a developer wants a gizmo to be draw-only. */
586  if ((gzt->test_select == NULL) && (gzt->draw_select != NULL)) {
587  BKE_reportf(reports,
588  RPT_ERROR,
589  "GizmoType '%s' is for a 3D gizmo-group. "
590  "The 'draw_select' callback is set where only 'test_select' will be used",
591  idname);
592  return NULL;
593  }
594  }
595  wmGizmo *gz = WM_gizmo_new_ptr(gzt, gzgroup, NULL);
596  return gz;
597 }
598 
599 static void rna_GizmoGroup_gizmo_remove(wmGizmoGroup *gzgroup, bContext *C, wmGizmo *gz)
600 {
601  WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gz, C);
602 }
603 
604 static void rna_GizmoGroup_gizmo_clear(wmGizmoGroup *gzgroup, bContext *C)
605 {
606  while (gzgroup->gizmos.first) {
607  WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gzgroup->gizmos.first, C);
608  }
609 }
610 
611 static void rna_GizmoGroup_name_get(PointerRNA *ptr, char *value)
612 {
613  wmGizmoGroup *gzgroup = ptr->data;
614  strcpy(value, gzgroup->type->name);
615 }
616 
617 static int rna_GizmoGroup_name_length(PointerRNA *ptr)
618 {
619  wmGizmoGroup *gzgroup = ptr->data;
620  return strlen(gzgroup->type->name);
621 }
622 
623 /* just to work around 'const char *' warning and to ensure this is a python op */
624 static void rna_GizmoGroup_bl_idname_set(PointerRNA *ptr, const char *value)
625 {
627  char *str = (char *)data->type->idname;
628  if (!str[0]) {
629  BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
630  }
631  else {
632  BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
633  }
634 }
635 
636 static void rna_GizmoGroup_bl_label_set(PointerRNA *ptr, const char *value)
637 {
639  char *str = (char *)data->type->name;
640  if (!str[0]) {
641  BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
642  }
643  else {
644  BLI_assert_msg(0, "setting the bl_label on a non-builtin operator");
645  }
646 }
647 
648 static bool rna_GizmoGroup_has_reports_get(PointerRNA *ptr)
649 {
650  wmGizmoGroup *gzgroup = ptr->data;
651  return (gzgroup->reports && gzgroup->reports->list.first);
652 }
653 
654 # ifdef WITH_PYTHON
655 
656 static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *gzgt)
657 {
658 
659  extern FunctionRNA rna_GizmoGroup_poll_func;
660 
661  PointerRNA ptr;
662  ParameterList list;
663  FunctionRNA *func;
664  void *ret;
665  bool visible;
666 
667  RNA_pointer_create(NULL, gzgt->rna_ext.srna, NULL, &ptr); /* dummy */
668  func = &rna_GizmoGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
669 
670  RNA_parameter_list_create(&list, &ptr, func);
671  RNA_parameter_set_lookup(&list, "context", &C);
672  gzgt->rna_ext.call((bContext *)C, &ptr, func, &list);
673 
674  RNA_parameter_get_lookup(&list, "visible", &ret);
675  visible = *(bool *)ret;
676 
678 
679  return visible;
680 }
681 
682 static void rna_gizmogroup_setup_cb(const bContext *C, wmGizmoGroup *gzgroup)
683 {
684  extern FunctionRNA rna_GizmoGroup_setup_func;
685 
686  PointerRNA gzgroup_ptr;
687  ParameterList list;
688  FunctionRNA *func;
689 
690  RNA_pointer_create(NULL, gzgroup->type->rna_ext.srna, gzgroup, &gzgroup_ptr);
691  func = &rna_GizmoGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */
692 
693  RNA_parameter_list_create(&list, &gzgroup_ptr, func);
694  RNA_parameter_set_lookup(&list, "context", &C);
695  gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
696 
698 }
699 
700 static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *gzgt, wmKeyConfig *config)
701 {
702  extern FunctionRNA rna_GizmoGroup_setup_keymap_func;
703  void *ret;
704 
705  PointerRNA ptr;
706  ParameterList list;
707  FunctionRNA *func;
708 
709  RNA_pointer_create(NULL, gzgt->rna_ext.srna, NULL, &ptr); /* dummy */
710  func =
711  &rna_GizmoGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */
712 
713  RNA_parameter_list_create(&list, &ptr, func);
714  RNA_parameter_set_lookup(&list, "keyconfig", &config);
715  gzgt->rna_ext.call(NULL, &ptr, func, &list);
716 
717  RNA_parameter_get_lookup(&list, "keymap", &ret);
718  wmKeyMap *keymap = *(wmKeyMap **)ret;
719 
721 
722  return keymap;
723 }
724 
725 static void rna_gizmogroup_refresh_cb(const bContext *C, wmGizmoGroup *gzgroup)
726 {
727  extern FunctionRNA rna_GizmoGroup_refresh_func;
728 
729  PointerRNA gzgroup_ptr;
730  ParameterList list;
731  FunctionRNA *func;
732 
733  RNA_pointer_create(NULL, gzgroup->type->rna_ext.srna, gzgroup, &gzgroup_ptr);
734  func = &rna_GizmoGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */
735 
736  RNA_parameter_list_create(&list, &gzgroup_ptr, func);
737  RNA_parameter_set_lookup(&list, "context", &C);
738  gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
739 
741 }
742 
743 static void rna_gizmogroup_draw_prepare_cb(const bContext *C, wmGizmoGroup *gzgroup)
744 {
745  extern FunctionRNA rna_GizmoGroup_draw_prepare_func;
746 
747  PointerRNA gzgroup_ptr;
748  ParameterList list;
749  FunctionRNA *func;
750 
751  RNA_pointer_create(NULL, gzgroup->type->rna_ext.srna, gzgroup, &gzgroup_ptr);
752  func =
753  &rna_GizmoGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */
754 
755  RNA_parameter_list_create(&list, &gzgroup_ptr, func);
756  RNA_parameter_set_lookup(&list, "context", &C);
757  gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
758 
760 }
761 
762 static void rna_gizmogroup_invoke_prepare_cb(const bContext *C,
763  wmGizmoGroup *gzgroup,
764  wmGizmo *gz,
765  const wmEvent *event)
766 {
767  extern FunctionRNA rna_GizmoGroup_invoke_prepare_func;
768 
769  PointerRNA gzgroup_ptr;
770  ParameterList list;
771  FunctionRNA *func;
772 
773  RNA_pointer_create(NULL, gzgroup->type->rna_ext.srna, gzgroup, &gzgroup_ptr);
774  /* Reference `RNA_struct_find_function(&wgroupr, "invoke_prepare")` directly. */
775  func = &rna_GizmoGroup_invoke_prepare_func;
776 
777  RNA_parameter_list_create(&list, &gzgroup_ptr, func);
778  RNA_parameter_set_lookup(&list, "context", &C);
779  RNA_parameter_set_lookup(&list, "gizmo", &gz);
780  RNA_parameter_set_lookup(&list, "event", &event);
781  gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
782 
784 }
785 
786 void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata);
787 static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type);
788 
789 static StructRNA *rna_GizmoGroup_register(Main *bmain,
790  ReportList *reports,
791  void *data,
792  const char *identifier,
793  StructValidateFunc validate,
794  StructCallbackFunc call,
796 {
797  struct {
798  char name[MAX_NAME];
799  char idname[MAX_NAME];
800  } temp_buffers;
801 
802  wmGizmoGroupType dummywgt = {NULL};
803  wmGizmoGroup dummywg = {NULL};
804  PointerRNA wgptr;
805 
806  /* Two sets of functions. */
807  int have_function[6];
808 
809  /* setup dummy gizmogroup & gizmogroup type to store static properties in */
810  dummywg.type = &dummywgt;
811  dummywgt.name = temp_buffers.name;
812  dummywgt.idname = temp_buffers.idname;
813 
814  RNA_pointer_create(NULL, &RNA_GizmoGroup, &dummywg, &wgptr);
815 
816  /* Clear so we can detect if it's left unset. */
817  temp_buffers.idname[0] = temp_buffers.name[0] = '\0';
818 
819  /* validate the python class */
820  if (validate(&wgptr, data, have_function) != 0) {
821  return NULL;
822  }
823 
824  if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
825  BKE_reportf(reports,
826  RPT_ERROR,
827  "Registering gizmogroup class: '%s' is too long, maximum length is %d",
828  identifier,
829  (int)sizeof(temp_buffers.idname));
830  return NULL;
831  }
832 
833  /* check if the area supports widgets */
834  const struct wmGizmoMapType_Params wmap_params = {
835  .spaceid = dummywgt.gzmap_params.spaceid,
836  .regionid = dummywgt.gzmap_params.regionid,
837  };
838 
839  wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&wmap_params);
840  if (gzmap_type == NULL) {
841  BKE_report(reports, RPT_ERROR, "Area type does not support gizmos");
842  return NULL;
843  }
844 
845  /* check if we have registered this gizmogroup type before, and remove it */
846  {
847  wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(dummywgt.idname, true);
848  if (gzgt && gzgt->rna_ext.srna) {
849  rna_GizmoGroup_unregister(bmain, gzgt->rna_ext.srna);
850  }
851  }
852  if (!RNA_struct_available_or_report(reports, dummywgt.idname)) {
853  return NULL;
854  }
855 
856  { /* allocate the idname */
857  const char *strings[] = {
858  temp_buffers.idname,
859  temp_buffers.name,
860  };
861  char *strings_table[ARRAY_SIZE(strings)];
863  '\0', strings_table, strings, ARRAY_SIZE(strings));
864 
865  dummywgt.idname = strings_table[0]; /* allocated string stored here */
866  dummywgt.name = strings_table[1];
867  BLI_assert(ARRAY_SIZE(strings) == 2);
868  }
869 
870  /* create a new gizmogroup type */
871  dummywgt.rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_GizmoGroup);
872 
873  /* Gizmo group properties are registered separately. */
875 
876  dummywgt.rna_ext.data = data;
877  dummywgt.rna_ext.call = call;
878  dummywgt.rna_ext.free = free;
879 
880  /* We used to register widget group types like this, now we do it similar to
881  * operator types. Thus we should be able to do the same as operator types now. */
882  dummywgt.poll = (have_function[0]) ? rna_gizmogroup_poll_cb : NULL;
883  dummywgt.setup_keymap = (have_function[1]) ? rna_gizmogroup_setup_keymap_cb : NULL;
884  dummywgt.setup = (have_function[2]) ? rna_gizmogroup_setup_cb : NULL;
885  dummywgt.refresh = (have_function[3]) ? rna_gizmogroup_refresh_cb : NULL;
886  dummywgt.draw_prepare = (have_function[4]) ? rna_gizmogroup_draw_prepare_cb : NULL;
887  dummywgt.invoke_prepare = (have_function[5]) ? rna_gizmogroup_invoke_prepare_cb : NULL;
888 
890  (void *)&dummywgt);
891 
892  {
893  const char *owner_id = RNA_struct_state_owner_get();
894  if (owner_id) {
895  BLI_strncpy(gzgt->owner_id, owner_id, sizeof(gzgt->owner_id));
896  }
897  }
898 
899  if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) {
900  WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type);
901 
902  /* update while blender is running */
904  }
905 
906  return dummywgt.rna_ext.srna;
907 }
908 
909 static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type)
910 {
912 
913  if (!gzgt) {
914  return;
915  }
916 
917  WM_gizmo_group_type_remove_ptr(bmain, gzgt);
918 
919  /* Free extension after removing instances so `__del__` doesn't crash, see: T85567. */
922 
923  /* Free gizmo group after the extension as it owns the identifier memory. */
925 
927 }
928 
929 static void **rna_GizmoGroup_instance(PointerRNA *ptr)
930 {
931  wmGizmoGroup *gzgroup = ptr->data;
932  return &gzgroup->py_instance;
933 }
934 
935 # endif /* WITH_PYTHON */
936 
937 static StructRNA *rna_GizmoGroup_refine(PointerRNA *gzgroup_ptr)
938 {
939  wmGizmoGroup *gzgroup = gzgroup_ptr->data;
940  return (gzgroup->type && gzgroup->type->rna_ext.srna) ? gzgroup->type->rna_ext.srna :
941  &RNA_GizmoGroup;
942 }
943 
944 static void rna_GizmoGroup_gizmos_begin(CollectionPropertyIterator *iter, PointerRNA *gzgroup_ptr)
945 {
946  wmGizmoGroup *gzgroup = gzgroup_ptr->data;
947  rna_iterator_listbase_begin(iter, &gzgroup->gizmos, NULL);
948 }
949 
952 #else /* RNA_RUNTIME */
953 
954 /* GizmoGroup.gizmos */
955 static void rna_def_gizmos(BlenderRNA *brna, PropertyRNA *cprop)
956 {
957  StructRNA *srna;
958 
959  FunctionRNA *func;
960  PropertyRNA *parm;
961 
962  RNA_def_property_srna(cprop, "Gizmos");
963  srna = RNA_def_struct(brna, "Gizmos", NULL);
964  RNA_def_struct_sdna(srna, "wmGizmoGroup");
965  RNA_def_struct_ui_text(srna, "Gizmos", "Collection of gizmos");
966 
967  func = RNA_def_function(srna, "new", "rna_GizmoGroup_gizmo_new");
968  RNA_def_function_ui_description(func, "Add gizmo");
970  parm = RNA_def_string(func, "type", "Type", 0, "", "Gizmo identifier"); /* optional */
972  parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo");
973  RNA_def_function_return(func, parm);
974 
975  func = RNA_def_function(srna, "remove", "rna_GizmoGroup_gizmo_remove");
977  RNA_def_function_ui_description(func, "Delete gizmo");
978  parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo");
981 
982  func = RNA_def_function(srna, "clear", "rna_GizmoGroup_gizmo_clear");
984  RNA_def_function_ui_description(func, "Delete all gizmos");
985 }
986 
987 static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop)
988 {
989  StructRNA *srna;
990  PropertyRNA *prop;
991 
992  FunctionRNA *func;
993  PropertyRNA *parm;
994 
995  RNA_def_property_srna(cprop, "Gizmo");
996  srna = RNA_def_struct(brna, "Gizmo", NULL);
997  RNA_def_struct_sdna(srna, "wmGizmo");
998  RNA_def_struct_ui_text(srna, "Gizmo", "Collection of gizmos");
999  RNA_def_struct_refine_func(srna, "rna_Gizmo_refine");
1000 
1001 # ifdef WITH_PYTHON
1003  srna, "rna_Gizmo_register", "rna_Gizmo_unregister", "rna_Gizmo_instance");
1004 # endif
1006 
1007  prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1009  RNA_def_property_struct_type(prop, "GizmoProperties");
1010  RNA_def_property_ui_text(prop, "Properties", "");
1011  RNA_def_property_pointer_funcs(prop, "rna_Gizmo_properties_get", NULL, NULL, NULL);
1012 
1013  /* -------------------------------------------------------------------- */
1014  /* Registerable Variables */
1015 
1016  RNA_define_verify_sdna(0); /* not in sdna */
1017 
1018  prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1019  RNA_def_property_string_sdna(prop, NULL, "type->idname");
1021  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Gizmo_bl_idname_set");
1022  // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1024 
1025  RNA_define_verify_sdna(1); /* not in sdna */
1026 
1027  /* wmGizmo.draw */
1028  func = RNA_def_function(srna, "draw", NULL);
1031  parm = RNA_def_pointer(func, "context", "Context", "", "");
1033 
1034  /* wmGizmo.draw_select */
1035  func = RNA_def_function(srna, "draw_select", NULL);
1038  parm = RNA_def_pointer(func, "context", "Context", "", "");
1040  parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
1041 
1042  /* wmGizmo.test_select */
1043  func = RNA_def_function(srna, "test_select", NULL);
1046  parm = RNA_def_pointer(func, "context", "Context", "", "");
1048  parm = RNA_def_int_array(func,
1049  "location",
1050  2,
1051  NULL,
1052  INT_MIN,
1053  INT_MAX,
1054  "Location",
1055  "Region coordinates",
1056  INT_MIN,
1057  INT_MAX);
1059  parm = RNA_def_int(
1060  func, "intersect_id", -1, -1, INT_MAX, "", "Use -1 to skip this gizmo", -1, INT_MAX);
1061  RNA_def_function_return(func, parm);
1062 
1063  /* wmGizmo.handler */
1064  static EnumPropertyItem tweak_actions[] = {
1065  {WM_GIZMO_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""},
1066  {WM_GIZMO_TWEAK_SNAP, "SNAP", 0, "Snap", ""},
1067  {0, NULL, 0, NULL, NULL},
1068  };
1069  func = RNA_def_function(srna, "modal", NULL);
1072  parm = RNA_def_pointer(func, "context", "Context", "", "");
1074  parm = RNA_def_pointer(func, "event", "Event", "", "");
1076  /* TODO: should be a enum-flag. */
1077  parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", "");
1079  parm = RNA_def_enum_flag(
1080  func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1081  RNA_def_function_return(func, parm);
1082  /* wmGizmo.property_update */
1083  /* TODO */
1084 
1085  /* wmGizmo.setup */
1086  func = RNA_def_function(srna, "setup", NULL);
1089 
1090  /* wmGizmo.invoke */
1091  func = RNA_def_function(srna, "invoke", NULL);
1094  parm = RNA_def_pointer(func, "context", "Context", "", "");
1096  parm = RNA_def_pointer(func, "event", "Event", "", "");
1098  parm = RNA_def_enum_flag(
1099  func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1100  RNA_def_function_return(func, parm);
1101 
1102  /* wmGizmo.exit */
1103  func = RNA_def_function(srna, "exit", NULL);
1106  parm = RNA_def_pointer(func, "context", "Context", "", "");
1108  parm = RNA_def_boolean(func, "cancel", 0, "Cancel, otherwise confirm", "");
1110 
1111  /* wmGizmo.cursor_get */
1112  /* TODO */
1113 
1114  /* wmGizmo.select_refresh */
1115  func = RNA_def_function(srna, "select_refresh", NULL);
1118 
1119  /* -------------------------------------------------------------------- */
1120  /* Instance Variables */
1121 
1122  prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
1124  RNA_def_property_struct_type(prop, "GizmoGroup");
1125  RNA_def_property_pointer_funcs(prop, "rna_Gizmo_group_get", NULL, NULL, NULL);
1126  RNA_def_property_ui_text(prop, "", "Gizmo group this gizmo is a member of");
1127 
1128  /* Color & Alpha */
1129  prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1130  RNA_def_property_array(prop, 3);
1131  RNA_def_property_float_funcs(prop, "rna_Gizmo_color_get", "rna_Gizmo_color_set", NULL);
1132 
1133  prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
1134  RNA_def_property_ui_text(prop, "Alpha", "");
1135  RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_get", "rna_Gizmo_alpha_set", NULL);
1136  RNA_def_property_range(prop, 0.0f, 1.0f);
1137  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1138 
1139  /* Color & Alpha (highlight) */
1140  prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR);
1141  RNA_def_property_array(prop, 3);
1142  RNA_def_property_float_funcs(prop, "rna_Gizmo_color_hi_get", "rna_Gizmo_color_hi_set", NULL);
1143 
1144  prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE);
1145  RNA_def_property_ui_text(prop, "Alpha", "");
1146  RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_hi_get", "rna_Gizmo_alpha_hi_set", NULL);
1147  RNA_def_property_range(prop, 0.0f, 1.0f);
1148  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1149 
1150  prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX);
1152  RNA_def_property_ui_text(prop, "Space Matrix", "");
1154  prop, "rna_Gizmo_matrix_space_get", "rna_Gizmo_matrix_space_set", NULL);
1155  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1156 
1157  prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
1159  RNA_def_property_ui_text(prop, "Basis Matrix", "");
1161  prop, "rna_Gizmo_matrix_basis_get", "rna_Gizmo_matrix_basis_set", NULL);
1162  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1163 
1164  prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX);
1166  RNA_def_property_ui_text(prop, "Offset Matrix", "");
1168  prop, "rna_Gizmo_matrix_offset_get", "rna_Gizmo_matrix_offset_set", NULL);
1169  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1170 
1171  prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
1174  RNA_def_property_ui_text(prop, "Final World Matrix", "");
1175  RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_world_get", NULL, NULL);
1176 
1177  prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE);
1178  RNA_def_property_ui_text(prop, "Scale Basis", "");
1180  prop, "rna_Gizmo_scale_basis_get", "rna_Gizmo_scale_basis_set", NULL);
1181  RNA_def_property_range(prop, 0.0f, FLT_MAX);
1182  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1183 
1184  prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL);
1185  RNA_def_property_ui_text(prop, "Line Width", "");
1186  RNA_def_property_float_funcs(prop, "rna_Gizmo_line_width_get", "rna_Gizmo_line_width_set", NULL);
1187  RNA_def_property_range(prop, 0.0f, FLT_MAX);
1188  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1189 
1190  prop = RNA_def_property(srna, "select_bias", PROP_FLOAT, PROP_NONE);
1191  RNA_def_property_ui_text(prop, "Select Bias", "Depth bias used for selection");
1193  prop, "rna_Gizmo_select_bias_get", "rna_Gizmo_select_bias_set", NULL);
1194  RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
1195 
1196  /* wmGizmo.flag */
1197  /* WM_GIZMO_HIDDEN */
1198  prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1199  RNA_def_property_boolean_funcs(prop, "rna_Gizmo_flag_hide_get", "rna_Gizmo_flag_hide_set");
1200  RNA_def_property_ui_text(prop, "Hide", "");
1201  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1202  /* WM_GIZMO_HIDDEN_SELECT */
1203  prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
1205  prop, "rna_Gizmo_flag_hide_select_get", "rna_Gizmo_flag_hide_select_set");
1206  RNA_def_property_ui_text(prop, "Hide Select", "");
1207  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1208  /* WM_GIZMO_HIDDEN_KEYMAP */
1209  prop = RNA_def_property(srna, "hide_keymap", PROP_BOOLEAN, PROP_NONE);
1211  prop, "rna_Gizmo_flag_hide_keymap_get", "rna_Gizmo_flag_hide_keymap_set");
1212  RNA_def_property_ui_text(prop, "Hide Keymap", "Ignore the key-map for this gizmo");
1213  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1214  /* WM_GIZMO_MOVE_CURSOR */
1215  prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE);
1217  prop, "rna_Gizmo_flag_use_grab_cursor_get", "rna_Gizmo_flag_use_grab_cursor_set");
1218  RNA_def_property_ui_text(prop, "Grab Cursor", "");
1219  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1220 
1221  /* WM_GIZMO_DRAW_HOVER */
1222  prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE);
1224  prop, "rna_Gizmo_flag_use_draw_hover_get", "rna_Gizmo_flag_use_draw_hover_set");
1225  RNA_def_property_ui_text(prop, "Show Hover", "");
1226  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1227  /* WM_GIZMO_DRAW_MODAL */
1228  prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE);
1230  prop, "rna_Gizmo_flag_use_draw_modal_get", "rna_Gizmo_flag_use_draw_modal_set");
1231  RNA_def_property_ui_text(prop, "Show Active", "Show while dragging");
1232  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1233  /* WM_GIZMO_DRAW_VALUE */
1234  prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE);
1236  prop, "rna_Gizmo_flag_use_draw_value_get", "rna_Gizmo_flag_use_draw_value_set");
1238  prop, "Show Value", "Show an indicator for the current value while dragging");
1239  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1240  /* WM_GIZMO_DRAW_OFFSET_SCALE */
1241  prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE);
1243  "rna_Gizmo_flag_use_draw_offset_scale_get",
1244  "rna_Gizmo_flag_use_draw_offset_scale_set");
1246  prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)");
1247  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1248  /* WM_GIZMO_DRAW_NO_SCALE (negated) */
1249  prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE);
1251  prop, "rna_Gizmo_flag_use_draw_scale_get", "rna_Gizmo_flag_use_draw_scale_set");
1252  RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix");
1253  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1254  /* WM_GIZMO_SELECT_BACKGROUND */
1255  prop = RNA_def_property(srna, "use_select_background", PROP_BOOLEAN, PROP_NONE);
1257  "rna_Gizmo_flag_use_select_background_get",
1258  "rna_Gizmo_flag_use_select_background_set");
1259  RNA_def_property_ui_text(prop, "Select Background", "Don't write into the depth buffer");
1260  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1261 
1262  /* WM_GIZMO_OPERATOR_TOOL_INIT */
1263  prop = RNA_def_property(srna, "use_operator_tool_properties", PROP_BOOLEAN, PROP_NONE);
1265  "rna_Gizmo_flag_use_operator_tool_properties_get",
1266  "rna_Gizmo_flag_use_operator_tool_properties_set");
1268  prop,
1269  "Tool Property Init",
1270  "Merge active tool properties on activation (does not overwrite existing)");
1271  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1272 
1273  /* WM_GIZMO_EVENT_HANDLE_ALL */
1274  prop = RNA_def_property(srna, "use_event_handle_all", PROP_BOOLEAN, PROP_NONE);
1276  prop, "rna_Gizmo_flag_use_event_handle_all_get", "rna_Gizmo_flag_use_event_handle_all_set");
1278  "Handle All Events",
1279  "When highlighted, "
1280  "do not pass events through to be handled by other keymaps");
1281  RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1282 
1283  /* WM_GIZMO_NO_TOOLTIP (negated) */
1284  prop = RNA_def_property(srna, "use_tooltip", PROP_BOOLEAN, PROP_NONE);
1286  prop, "rna_Gizmo_flag_use_tooltip_get", "rna_Gizmo_flag_use_tooltip_set");
1287  RNA_def_property_ui_text(prop, "Use Tooltip", "Use tooltips when hovering over this gizmo");
1288  /* No update needed. */
1289 
1290  /* wmGizmo.state (readonly) */
1291  /* WM_GIZMO_STATE_HIGHLIGHT */
1292  prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE);
1293  RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_highlight_get", NULL);
1294  RNA_def_property_ui_text(prop, "Highlight", "");
1296  /* WM_GIZMO_STATE_MODAL */
1297  prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
1298  RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_modal_get", NULL);
1299  RNA_def_property_ui_text(prop, "Highlight", "");
1301  /* WM_GIZMO_STATE_SELECT */
1302  /* (note that setting is involved, needs to handle array) */
1303  prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1304  RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_select_get", "rna_Gizmo_state_select_set");
1305  RNA_def_property_ui_text(prop, "Select", "");
1306 
1307  RNA_api_gizmo(srna);
1308 
1309  srna = RNA_def_struct(brna, "GizmoProperties", NULL);
1310  RNA_def_struct_ui_text(srna, "Gizmo Properties", "Input properties of an Gizmo");
1311  RNA_def_struct_refine_func(srna, "rna_GizmoProperties_refine");
1312  RNA_def_struct_idprops_func(srna, "rna_GizmoProperties_idprops");
1314 }
1315 
1316 static void rna_def_gizmogroup(BlenderRNA *brna)
1317 {
1318  StructRNA *srna;
1319  PropertyRNA *prop;
1320 
1321  FunctionRNA *func;
1322  PropertyRNA *parm;
1323 
1324  srna = RNA_def_struct(brna, "GizmoGroup", NULL);
1326  srna, "GizmoGroup", "Storage of an operator being executed, or registered after execution");
1327  RNA_def_struct_sdna(srna, "wmGizmoGroup");
1328  RNA_def_struct_refine_func(srna, "rna_GizmoGroup_refine");
1329 # ifdef WITH_PYTHON
1331  srna, "rna_GizmoGroup_register", "rna_GizmoGroup_unregister", "rna_GizmoGroup_instance");
1332 # endif
1334 
1335  /* -------------------------------------------------------------------- */
1336  /* Registration */
1337 
1338  RNA_define_verify_sdna(0); /* not in sdna */
1339 
1340  prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1341  RNA_def_property_string_sdna(prop, NULL, "type->idname");
1343  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GizmoGroup_bl_idname_set");
1345  RNA_def_struct_name_property(srna, prop);
1346 
1347  prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1348  RNA_def_property_string_sdna(prop, NULL, "type->name");
1349  RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */
1350  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GizmoGroup_bl_label_set");
1351  // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1353 
1354  prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
1355  RNA_def_property_enum_sdna(prop, NULL, "type->gzmap_params.spaceid");
1358  RNA_def_property_ui_text(prop, "Space Type", "The space where the panel is going to be used in");
1359 
1360  prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
1361  RNA_def_property_enum_sdna(prop, NULL, "type->gzmap_params.regionid");
1365  prop, "Region Type", "The region where the panel is going to be used in");
1366 
1367  prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
1368  RNA_def_property_string_sdna(prop, NULL, "type->owner_id");
1370 
1371  /* bl_options */
1372  static EnumPropertyItem gizmogroup_flag_items[] = {
1373  {WM_GIZMOGROUPTYPE_3D, "3D", 0, "3D", "Use in 3D viewport"},
1375  "SCALE",
1376  0,
1377  "Scale",
1378  "Scale to respect zoom (otherwise zoom independent display size)"},
1380  "DEPTH_3D",
1381  0,
1382  "Depth 3D",
1383  "Supports culled depth by other objects in the view"},
1384  {WM_GIZMOGROUPTYPE_SELECT, "SELECT", 0, "Select", "Supports selection"},
1385  {WM_GIZMOGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent", ""},
1387  "SHOW_MODAL_ALL",
1388  0,
1389  "Show Modal All",
1390  "Show all while interacting, as well as this group when another is being interacted with"},
1392  "EXCLUDE_MODAL",
1393  0,
1394  "Exclude Modal",
1395  "Show all except this group while interacting"},
1397  "TOOL_INIT",
1398  0,
1399  "Tool Init",
1400  "Postpone running until tool operator run (when used with a tool)"},
1402  "TOOL_FALLBACK_KEYMAP",
1403  0,
1404  "Use fallback tools keymap",
1405  "Add fallback tools keymap to this gizmo type"},
1407  "VR_REDRAWS",
1408  0,
1409  "VR Redraws",
1410  "The gizmos are made for use with virtual reality sessions and require special redraw "
1411  "management"},
1412  {0, NULL, 0, NULL, NULL},
1413  };
1414  prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1415  RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1416  RNA_def_property_enum_items(prop, gizmogroup_flag_items);
1418  RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1419 
1420  RNA_define_verify_sdna(1); /* not in sdna */
1421 
1422  /* Functions */
1423 
1424  /* poll */
1425  func = RNA_def_function(srna, "poll", NULL);
1426  RNA_def_function_ui_description(func, "Test if the gizmo group can be called or not");
1428  RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
1429  parm = RNA_def_pointer(func, "context", "Context", "", "");
1431 
1432  /* setup_keymap */
1433  func = RNA_def_function(srna, "setup_keymap", NULL);
1435  func, "Initialize keymaps for this gizmo group, use fallback keymap when not present");
1437  parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", "");
1439  /* return */
1440  parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
1442  RNA_def_function_return(func, parm);
1443 
1444  /* setup */
1445  func = RNA_def_function(srna, "setup", NULL);
1446  RNA_def_function_ui_description(func, "Create gizmos function for the gizmo group");
1448  parm = RNA_def_pointer(func, "context", "Context", "", "");
1450 
1451  /* refresh */
1452  func = RNA_def_function(srna, "refresh", NULL);
1454  func, "Refresh data (called on common state changes such as selection)");
1456  parm = RNA_def_pointer(func, "context", "Context", "", "");
1458 
1459  func = RNA_def_function(srna, "draw_prepare", NULL);
1460  RNA_def_function_ui_description(func, "Run before each redraw");
1462  parm = RNA_def_pointer(func, "context", "Context", "", "");
1464 
1465  func = RNA_def_function(srna, "invoke_prepare", NULL);
1466  RNA_def_function_ui_description(func, "Run before invoke");
1468  parm = RNA_def_pointer(func, "context", "Context", "", "");
1470  parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "");
1472 
1473  /* -------------------------------------------------------------------- */
1474  /* Instance Variables */
1475 
1476  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1479  prop, "rna_GizmoGroup_name_get", "rna_GizmoGroup_name_length", NULL);
1480  RNA_def_property_ui_text(prop, "Name", "");
1481 
1482  prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
1483  RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
1484  RNA_def_property_boolean_funcs(prop, "rna_GizmoGroup_has_reports_get", NULL);
1486  prop,
1487  "Has Reports",
1488  "GizmoGroup has a set of reports (warnings and errors) from last execution");
1489 
1490  RNA_define_verify_sdna(0); /* not in sdna */
1491 
1492  prop = RNA_def_property(srna, "gizmos", PROP_COLLECTION, PROP_NONE);
1493  RNA_def_property_collection_sdna(prop, NULL, "gizmos", NULL);
1494  RNA_def_property_struct_type(prop, "Gizmo");
1496  "rna_GizmoGroup_gizmos_begin",
1497  "rna_iterator_listbase_next",
1498  "rna_iterator_listbase_end",
1499  "rna_iterator_listbase_get",
1500  NULL,
1501  NULL,
1502  NULL,
1503  NULL);
1504 
1505  RNA_def_property_ui_text(prop, "Gizmos", "List of gizmos in the Gizmo Map");
1506  rna_def_gizmo(brna, prop);
1507  rna_def_gizmos(brna, prop);
1508 
1509  RNA_define_verify_sdna(1); /* not in sdna */
1510 
1511  RNA_api_gizmogroup(srna);
1512 
1513  srna = RNA_def_struct(brna, "GizmoGroupProperties", NULL);
1514  RNA_def_struct_ui_text(srna, "Gizmo Group Properties", "Input properties of a Gizmo Group");
1515  RNA_def_struct_refine_func(srna, "rna_GizmoGroupProperties_refine");
1516  RNA_def_struct_idprops_func(srna, "rna_GizmoGroupProperties_idprops");
1518 }
1519 
1521 {
1522  rna_def_gizmogroup(brna);
1523 }
1524 
1525 #endif /* RNA_RUNTIME */
#define G_MAIN
Definition: BKE_global.h:267
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
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:102
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:42
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
char * BLI_string_join_array_by_sep_char_with_tableN(char sep, char *table[], const char *strings[], uint strings_len) ATTR_NONNULL()
Definition: string_utils.c:424
#define ARRAY_SIZE(arr)
#define UNUSED(x)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define MAX_NAME
Definition: DNA_defs.h:48
@ OPERATOR_FINISHED
_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
void GPU_bgl_end(void)
Definition: gpu_state.cc:346
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
@ 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_USE_REPORTS
Definition: RNA_types.h:663
@ FUNC_NO_SELF
Definition: RNA_types.h:656
@ FUNC_REGISTER
Definition: RNA_types.h:670
@ FUNC_USE_CONTEXT
Definition: RNA_types.h:662
@ FUNC_REGISTER_OPTIONAL
Definition: RNA_types.h:672
@ FUNC_ALLOW_WRITE
Definition: RNA_types.h:678
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
Definition: RNA_types.h:717
@ STRUCT_NO_IDPROPERTIES
Definition: RNA_types.h:715
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_STRING
Definition: RNA_types.h:62
@ PROP_POINTER
Definition: RNA_types.h:64
@ PROP_COLLECTION
Definition: RNA_types.h:65
@ PROP_THICK_WRAP
Definition: RNA_types.h:285
@ 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_MATRIX
Definition: RNA_types.h:158
@ PROP_COLOR
Definition: RNA_types.h:153
@ PROP_PIXEL
Definition: RNA_types.h:141
@ PROP_NONE
Definition: RNA_types.h:126
#define C
Definition: RandGen.cpp:25
eWM_GizmoFlagTweak
Gizmo tweak flag. Bit-flag passed to gizmo while tweaking.
@ WM_GIZMO_TWEAK_PRECISE
@ WM_GIZMO_TWEAK_SNAP
@ WM_GIZMO_DRAW_NO_SCALE
@ WM_GIZMO_HIDDEN
@ WM_GIZMO_HIDDEN_KEYMAP
@ WM_GIZMO_EVENT_HANDLE_ALL
@ WM_GIZMO_OPERATOR_TOOL_INIT
@ WM_GIZMO_DRAW_VALUE
@ WM_GIZMO_MOVE_CURSOR
@ WM_GIZMO_DRAW_MODAL
@ WM_GIZMO_DRAW_HOVER
@ WM_GIZMO_DRAW_OFFSET_SCALE
@ WM_GIZMO_SELECT_BACKGROUND
@ WM_GIZMO_HIDDEN_SELECT
@ WM_GIZMO_NO_TOOLTIP
@ WM_GIZMOGROUPTYPE_VR_REDRAWS
@ WM_GIZMOGROUPTYPE_DRAW_MODAL_EXCLUDE
@ WM_GIZMOGROUPTYPE_SCALE
@ WM_GIZMOGROUPTYPE_TOOL_INIT
@ WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP
@ WM_GIZMOGROUPTYPE_DEPTH_3D
@ WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL
@ WM_GIZMOGROUPTYPE_3D
@ WM_GIZMOGROUPTYPE_PERSISTENT
@ WM_GIZMOGROUPTYPE_SELECT
@ WM_GIZMO_STATE_HIGHLIGHT
@ WM_GIZMO_STATE_MODAL
@ WM_GIZMO_STATE_SELECT
#define NC_SCREEN
Definition: WM_types.h:327
#define NA_EDITED
Definition: WM_types.h:523
void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata)
void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata)
Scene scene
#define str(s)
const int state
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:136
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
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_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
Definition: rna_access.c:4729
void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, const void *value)
Definition: rna_access.c:6088
PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *data)
Definition: rna_access.c:186
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
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_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3806
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_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1526
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3655
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_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
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4273
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
Definition: rna_define.c:3474
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
Definition: rna_define.c:3420
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1237
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
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
Definition: rna_define.c:1598
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_range(PropertyRNA *prop, double min, double max)
Definition: rna_define.c:1737
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_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
Definition: rna_define.c:2769
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
const int rna_matrix_dimsize_4x4[]
Definition: rna_define.c:1595
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1257
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
Definition: rna_define.c:1103
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_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_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_gizmogroup(struct StructRNA *srna)
void RNA_api_gizmo(struct StructRNA *srna)
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_return_items[]
Definition: rna_wm.c:463
static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_wm_gizmo.c:987
static void rna_def_gizmogroup(BlenderRNA *brna)
static void rna_def_gizmos(BlenderRNA *brna, PropertyRNA *cprop)
Definition: rna_wm_gizmo.c:955
void RNA_def_wm_gizmo(BlenderRNA *brna)
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
char name[64]
Definition: DNA_ID.h:111
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
struct StructRNA * type
Definition: RNA_types.h:37
void * data
Definition: RNA_types.h:38
struct ID * owner_id
Definition: RNA_types.h:36
wmGizmoGroupFnSetupKeymap setup_keymap
wmGizmoGroupFnRefresh refresh
wmGizmoGroupFnInit setup
const char * idname
wmGizmoGroupFnInvokePrepare invoke_prepare
eWM_GizmoFlagGroupTypeFlag flag
ExtensionRNA rna_ext
wmGizmoGroupFnPoll poll
struct StructRNA * srna
struct wmGizmoMapType_Params gzmap_params
const char * name
wmGizmoGroupFnDrawPrepare draw_prepare
ListBase gizmos
struct wmGizmoGroupType * type
void * py_instance
struct wmGizmoMap * parent_gzmap
struct ReportList * reports
wmGizmoFnSelectRefresh select_refresh
wmGizmoFnDraw draw
ExtensionRNA rna_ext
wmGizmoFnModal modal
wmGizmoFnSetup setup
const char * idname
wmGizmoFnTestSelect test_select
wmGizmoFnExit exit
struct StructRNA * srna
wmGizmoFnInvoke invoke
wmGizmoFnDrawSelect draw_select
bool do_draw
struct wmGizmoGroup * parent_gzgroup
void * py_instance
const struct wmGizmoType * type
struct IDProperty * properties
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3480
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition: wm_gizmo.c:554
wmGizmo * WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, PointerRNA *properties)
Definition: wm_gizmo.c:81
bool WM_gizmo_select_set(wmGizmoMap *gzmap, wmGizmo *gz, bool select)
Definition: wm_gizmo.c:397
void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C)
Definition: wm_gizmo.c:165
void WM_gizmo_group_type_add_ptr_ex(wmGizmoGroupType *gzgt, wmGizmoMapType *gzmap_type)
void WM_gizmo_group_type_remove_ptr(struct Main *bmain, wmGizmoGroupType *gzgt)
wmGizmoGroupType * WM_gizmogrouptype_append_ptr(void(*wtfunc)(struct wmGizmoGroupType *, void *), void *userdata)
void WM_gizmo_group_type_free_ptr(wmGizmoGroupType *gzgt)
wmGizmoGroupType * WM_gizmogrouptype_find(const char *idname, bool quiet)
wmGizmoMapType * WM_gizmomaptype_ensure(const struct wmGizmoMapType_Params *gzmap_params)
const ListBase * WM_gizmomap_group_list(wmGizmoMap *gzmap)
Definition: wm_gizmo_map.c:222
void WM_gizmotype_append_ptr(void(*gtfunc)(struct wmGizmoType *, void *), void *userdata)
void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *gzt)
const wmGizmoType * WM_gizmotype_find(const char *idname, bool quiet)
Definition: wm_gizmo_type.c:45
void WM_gizmotype_free_ptr(wmGizmoType *gzt)