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