Blender V4.3
rna_wm_gizmo.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cstdlib>
10
11#include "DNA_screen_types.h"
12#include "DNA_space_types.h"
13#include "DNA_userdef_types.h"
14#include "DNA_view3d_types.h"
16
17#include "BLI_listbase.h"
18#include "BLI_utildefines.h"
19
20#include "BLT_translation.hh"
21
22#include "RNA_access.hh"
23#include "RNA_define.hh"
24#include "RNA_enum_types.hh"
25
26#include "rna_internal.hh"
27
28#include "WM_types.hh"
29
30#ifdef RNA_RUNTIME
31/* enum definitions */
32#endif /* RNA_RUNTIME */
33
34#ifdef RNA_RUNTIME
35
36# include "BLI_string_utils.hh"
37
38# include "WM_api.hh"
39
40# include "DNA_workspace_types.h"
41
42# include "ED_screen.hh"
43
44# include "UI_interface.hh"
45
46# include "BKE_global.hh"
47# include "BKE_idprop.hh"
48# include "BKE_workspace.hh"
49
50# include "MEM_guardedalloc.h"
51
52# include "GPU_state.hh"
53
54# ifdef WITH_PYTHON
55# include "BPY_extern.hh"
56# endif
57
58/* -------------------------------------------------------------------- */
62# ifdef WITH_PYTHON
63static void rna_gizmo_draw_cb(const bContext *C, wmGizmo *gz)
64{
65 extern FunctionRNA rna_Gizmo_draw_func;
66 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
67 ParameterList list;
68 FunctionRNA *func;
69 PointerRNA gz_ptr = RNA_pointer_create(nullptr, gz->type->rna_ext.srna, gz);
70 /* Reference `RNA_struct_find_function(&gz_ptr, "draw")` directly. */
71 func = &rna_Gizmo_draw_func;
72 RNA_parameter_list_create(&list, &gz_ptr, func);
73 RNA_parameter_set_lookup(&list, "context", &C);
74 gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
76 /* This callback may have called bgl functions. */
78}
79
80static void rna_gizmo_draw_select_cb(const bContext *C, wmGizmo *gz, int select_id)
81{
82 extern FunctionRNA rna_Gizmo_draw_select_func;
83 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
84 ParameterList list;
85 FunctionRNA *func;
86 PointerRNA gz_ptr = RNA_pointer_create(nullptr, gz->type->rna_ext.srna, gz);
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. */
96}
97
98static int rna_gizmo_test_select_cb(bContext *C, wmGizmo *gz, const int location[2])
99{
100 extern FunctionRNA rna_Gizmo_test_select_func;
101 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
102 ParameterList list;
103 FunctionRNA *func;
104 PointerRNA gz_ptr = RNA_pointer_create(nullptr, gz->type->rna_ext.srna, gz);
105 /* Reference `RNA_struct_find_function(&gz_ptr, "test_select")` directly. */
106 func = &rna_Gizmo_test_select_func;
107 RNA_parameter_list_create(&list, &gz_ptr, func);
108 RNA_parameter_set_lookup(&list, "context", &C);
109 RNA_parameter_set_lookup(&list, "location", location);
110 gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
111
112 void *ret;
113 RNA_parameter_get_lookup(&list, "intersect_id", &ret);
114 int intersect_id = *(int *)ret;
115
117 return intersect_id;
118}
119
120static int rna_gizmo_modal_cb(bContext *C,
121 wmGizmo *gz,
122 const wmEvent *event,
123 eWM_GizmoFlagTweak tweak_flag)
124{
125 extern FunctionRNA rna_Gizmo_modal_func;
126 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
127 ParameterList list;
128 FunctionRNA *func;
129 const int tweak_flag_int = tweak_flag;
130 PointerRNA gz_ptr = RNA_pointer_create(nullptr, gz->type->rna_ext.srna, gz);
131 /* Reference `RNA_struct_find_function(&gz_ptr, "modal")` directly. */
132 func = &rna_Gizmo_modal_func;
133 RNA_parameter_list_create(&list, &gz_ptr, func);
134 RNA_parameter_set_lookup(&list, "context", &C);
135 RNA_parameter_set_lookup(&list, "event", &event);
136 RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int);
137 gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
138
139 void *ret;
140 RNA_parameter_get_lookup(&list, "result", &ret);
141 int ret_enum = *(int *)ret;
142
144 return ret_enum;
145}
146
147static void rna_gizmo_setup_cb(wmGizmo *gz)
148{
149 extern FunctionRNA rna_Gizmo_setup_func;
150 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
151 ParameterList list;
152 FunctionRNA *func;
153 PointerRNA gz_ptr = RNA_pointer_create(nullptr, gz->type->rna_ext.srna, gz);
154 /* Reference `RNA_struct_find_function(&gz_ptr, "setup")` directly. */
155 func = &rna_Gizmo_setup_func;
156 RNA_parameter_list_create(&list, &gz_ptr, func);
157 gzgroup->type->rna_ext.call((bContext *)nullptr, &gz_ptr, func, &list);
159}
160
161static int rna_gizmo_invoke_cb(bContext *C, wmGizmo *gz, const wmEvent *event)
162{
163 extern FunctionRNA rna_Gizmo_invoke_func;
164 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
165 ParameterList list;
166 FunctionRNA *func;
167 PointerRNA gz_ptr = RNA_pointer_create(nullptr, gz->type->rna_ext.srna, gz);
168 /* Reference `RNA_struct_find_function(&gz_ptr, "invoke")` directly. */
169 func = &rna_Gizmo_invoke_func;
170 RNA_parameter_list_create(&list, &gz_ptr, func);
171 RNA_parameter_set_lookup(&list, "context", &C);
172 RNA_parameter_set_lookup(&list, "event", &event);
173 gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
174
175 void *ret;
176 RNA_parameter_get_lookup(&list, "result", &ret);
177 int ret_enum = *(int *)ret;
178
180 return ret_enum;
181}
182
183static void rna_gizmo_exit_cb(bContext *C, wmGizmo *gz, bool cancel)
184{
185 extern FunctionRNA rna_Gizmo_exit_func;
186 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
187 ParameterList list;
188 FunctionRNA *func;
189 PointerRNA gz_ptr = RNA_pointer_create(nullptr, gz->type->rna_ext.srna, gz);
190 /* Reference `RNA_struct_find_function(&gz_ptr, "exit")` directly. */
191 func = &rna_Gizmo_exit_func;
192 RNA_parameter_list_create(&list, &gz_ptr, func);
193 RNA_parameter_set_lookup(&list, "context", &C);
194 {
195 int cancel_i = cancel;
196 RNA_parameter_set_lookup(&list, "cancel", &cancel_i);
197 }
198 gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
200}
201
202static void rna_gizmo_select_refresh_cb(wmGizmo *gz)
203{
204 extern FunctionRNA rna_Gizmo_select_refresh_func;
205 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
206 ParameterList list;
207 FunctionRNA *func;
208 PointerRNA gz_ptr = RNA_pointer_create(nullptr, gz->type->rna_ext.srna, gz);
209 /* Reference `RNA_struct_find_function(&gz_ptr, "select_refresh")` directly. */
210 func = &rna_Gizmo_select_refresh_func;
211 RNA_parameter_list_create(&list, &gz_ptr, func);
212 gzgroup->type->rna_ext.call((bContext *)nullptr, &gz_ptr, func, &list);
214}
215
216# endif /* WITH_PYTHON */
217
218/* just to work around 'const char *' warning and to ensure this is a python op */
219static void rna_Gizmo_bl_idname_set(PointerRNA *ptr, const char *value)
220{
221 wmGizmo *data = static_cast<wmGizmo *>(ptr->data);
222 char *str = (char *)data->type->idname;
223 if (!str[0]) {
224 /* Calling UTF8 copy is disputable since registering ensures the value isn't truncated.
225 * Use a UTF8 copy to ensure truncating never causes an incomplete UTF8 sequence,
226 * even before registration. */
228 }
229 else {
230 BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
231 }
232}
233
234static void rna_Gizmo_update_redraw(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
235{
236 wmGizmo *gizmo = static_cast<wmGizmo *>(ptr->data);
237 gizmo->do_draw = true;
238}
239
240static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr)
241{
242# if 0
244# endif
245
246 /* We could try workaround this lookup, but not trivial. */
247 for (bScreen *screen = static_cast<bScreen *>(G_MAIN->screens.first); screen;
248 screen = static_cast<bScreen *>(screen->id.next))
249 {
250 IDProperty *properties = static_cast<IDProperty *>(ptr->data);
251 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
252 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
253 if (region->gizmo_map) {
254 wmGizmoMap *gzmap = region->gizmo_map;
256 LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
257 if (gz->properties == properties) {
258 return gz;
259 }
260 }
261 }
262 }
263 }
264 }
265 }
266 return nullptr;
267}
268
269static StructRNA *rna_GizmoProperties_refine(PointerRNA *ptr)
270{
271 wmGizmo *gz = rna_GizmoProperties_find_operator(ptr);
272
273 if (gz) {
274 return gz->type->srna;
275 }
276 else {
277 return ptr->type;
278 }
279}
280
281static IDProperty **rna_GizmoProperties_idprops(PointerRNA *ptr)
282{
283 return (IDProperty **)&ptr->data;
284}
285
286static PointerRNA rna_Gizmo_properties_get(PointerRNA *ptr)
287{
288 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
290}
291
292/* wmGizmo.float */
293# define RNA_GIZMO_GENERIC_FLOAT_RW_DEF(func_id, member_id) \
294 static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
295 { \
296 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
297 return gz->member_id; \
298 } \
299 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \
300 { \
301 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
302 gz->member_id = value; \
303 }
304# define RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \
305 static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
306 { \
307 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
308 return gz->member_id[index]; \
309 } \
310 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \
311 { \
312 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
313 gz->member_id[index] = value; \
314 }
315/* wmGizmo.float[len] */
316# define RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \
317 static void rna_Gizmo_##func_id##_get(PointerRNA *ptr, float value[len]) \
318 { \
319 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
320 memcpy(value, gz->member_id, sizeof(float[len])); \
321 } \
322 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, const float value[len]) \
323 { \
324 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
325 memcpy(gz->member_id, value, sizeof(float[len])); \
326 }
327
328/* wmGizmo.flag */
329# define RNA_GIZMO_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \
330 static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
331 { \
332 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
333 return (gz->member_id & flag_value) != 0; \
334 } \
335 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \
336 { \
337 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
338 SET_FLAG_FROM_TEST(gz->member_id, value, flag_value); \
339 }
340
341/* wmGizmo.flag (negative) */
342# define RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \
343 static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
344 { \
345 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
346 return (gz->member_id & flag_value) == 0; \
347 } \
348 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \
349 { \
350 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
351 SET_FLAG_FROM_TEST(gz->member_id, !value, flag_value); \
352 }
353
354# define RNA_GIZMO_FLAG_RO_DEF(func_id, member_id, flag_value) \
355 static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
356 { \
357 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
358 return (gz->member_id & flag_value) != 0; \
359 }
360
361RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3);
362RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3);
363
364RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3);
365RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3);
366
367RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16);
368RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16);
369RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16);
370
371static void rna_Gizmo_matrix_world_get(PointerRNA *ptr, float value[16])
372{
373 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
374 WM_gizmo_calc_matrix_final(gz, (float(*)[4])value);
375}
376
377RNA_GIZMO_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis);
378RNA_GIZMO_GENERIC_FLOAT_RW_DEF(line_width, line_width);
379RNA_GIZMO_GENERIC_FLOAT_RW_DEF(select_bias, select_bias);
380
381RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_GIZMO_DRAW_HOVER);
382RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_GIZMO_DRAW_MODAL);
383RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_GIZMO_DRAW_VALUE);
384RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE);
385RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_GIZMO_DRAW_NO_SCALE);
386RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_GIZMO_HIDDEN);
387RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_select, flag, WM_GIZMO_HIDDEN_SELECT);
388RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_keymap, flag, WM_GIZMO_HIDDEN_KEYMAP);
389RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_GIZMO_MOVE_CURSOR);
390RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_GIZMO_SELECT_BACKGROUND);
391RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_operator_tool_properties,
392 flag,
394RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_event_handle_all, flag, WM_GIZMO_EVENT_HANDLE_ALL);
395RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_tooltip, flag, WM_GIZMO_NO_TOOLTIP);
396
397/* wmGizmo.state */
398RNA_GIZMO_FLAG_RO_DEF(state_is_highlight, state, WM_GIZMO_STATE_HIGHLIGHT);
399RNA_GIZMO_FLAG_RO_DEF(state_is_modal, state, WM_GIZMO_STATE_MODAL);
400RNA_GIZMO_FLAG_RO_DEF(state_select, state, WM_GIZMO_STATE_SELECT);
401
402static void rna_Gizmo_state_select_set(PointerRNA *ptr, bool value)
403{
404 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
405 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
406 WM_gizmo_select_set(gzgroup->parent_gzmap, gz, value);
407}
408
409static PointerRNA rna_Gizmo_group_get(PointerRNA *ptr)
410{
411 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
412 return rna_pointer_inherit_refine(ptr, &RNA_GizmoGroup, gz->parent_gzgroup);
413}
414
415# ifdef WITH_PYTHON
416
417static bool rna_Gizmo_unregister(Main *bmain, StructRNA *type);
418extern void BPY_RNA_gizmo_wrapper(wmGizmoType *gzgt, void *userdata);
419
420static StructRNA *rna_Gizmo_register(Main *bmain,
421 ReportList *reports,
422 void *data,
423 const char *identifier,
424 StructValidateFunc validate,
427{
428 const char *error_prefix = "Registering gizmo class:";
429 struct {
430 char idname[MAX_NAME];
431 } temp_buffers;
432
433 wmGizmoType dummy_gt = {nullptr};
434 wmGizmo dummy_gizmo = {nullptr};
435
436 /* Two sets of functions. */
437 bool have_function[8];
438
439 /* setup dummy gizmo & gizmo type to store static properties in */
440 dummy_gizmo.type = &dummy_gt;
441 dummy_gt.idname = temp_buffers.idname;
442 PointerRNA dummy_gizmo_ptr = RNA_pointer_create(nullptr, &RNA_Gizmo, &dummy_gizmo);
443
444 /* Clear so we can detect if it's left unset. */
445 temp_buffers.idname[0] = '\0';
446
447 /* validate the python class */
448 if (validate(&dummy_gizmo_ptr, data, have_function) != 0) {
449 return nullptr;
450 }
451
452 if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
453 BKE_reportf(reports,
454 RPT_ERROR,
455 "%s '%s' is too long, maximum length is %d",
456 error_prefix,
457 identifier,
458 int(sizeof(temp_buffers.idname)));
459 return nullptr;
460 }
461
462 /* check if we have registered this gizmo type before, and remove it */
463 {
464 const wmGizmoType *gzt = WM_gizmotype_find(dummy_gt.idname, true);
465 if (gzt) {
466 BKE_reportf(reports,
467 RPT_INFO,
468 "%s '%s', bl_idname '%s' has been registered before, unregistering previous",
469 error_prefix,
470 identifier,
471 dummy_gt.idname);
472
473 StructRNA *srna = gzt->rna_ext.srna;
474 if (!(srna && rna_Gizmo_unregister(bmain, srna))) {
475 BKE_reportf(reports,
476 RPT_ERROR,
477 "%s '%s', bl_idname '%s' %s",
478 error_prefix,
479 identifier,
480 dummy_gt.idname,
481 srna ? "is built-in" : "could not be unregistered");
482 return nullptr;
483 }
484 }
485 }
486 if (!RNA_struct_available_or_report(reports, dummy_gt.idname)) {
487 return nullptr;
488 }
489
490 { /* allocate the idname */
491 /* For multiple strings see GizmoGroup. */
492 dummy_gt.idname = BLI_strdup(temp_buffers.idname);
493 }
494
495 /* create a new gizmo type */
496 dummy_gt.rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummy_gt.idname, &RNA_Gizmo);
497 /* gizmo properties are registered separately */
499 dummy_gt.rna_ext.data = data;
500 dummy_gt.rna_ext.call = call;
501 dummy_gt.rna_ext.free = free;
502
503 {
504 int i = 0;
505 dummy_gt.draw = (have_function[i++]) ? rna_gizmo_draw_cb : nullptr;
506 dummy_gt.draw_select = (have_function[i++]) ? rna_gizmo_draw_select_cb : nullptr;
507 dummy_gt.test_select = (have_function[i++]) ? rna_gizmo_test_select_cb : nullptr;
508 dummy_gt.modal = (have_function[i++]) ? rna_gizmo_modal_cb : nullptr;
509 // dummy_gt.property_update = (have_function[i++]) ? rna_gizmo_property_update : nullptr;
510 // dummy_gt.position_get = (have_function[i++]) ? rna_gizmo_position_get : nullptr;
511 dummy_gt.setup = (have_function[i++]) ? rna_gizmo_setup_cb : nullptr;
512 dummy_gt.invoke = (have_function[i++]) ? rna_gizmo_invoke_cb : nullptr;
513 dummy_gt.exit = (have_function[i++]) ? rna_gizmo_exit_cb : nullptr;
514 dummy_gt.select_refresh = (have_function[i++]) ? rna_gizmo_select_refresh_cb : nullptr;
515
516 BLI_assert(i == ARRAY_SIZE(have_function));
517 }
518
520
521 /* update while blender is running */
523
524 return dummy_gt.rna_ext.srna;
525}
526
527static bool rna_Gizmo_unregister(Main *bmain, StructRNA *type)
528{
529 wmGizmoType *gzt = static_cast<wmGizmoType *>(RNA_struct_blender_type_get(type));
530
531 if (!gzt) {
532 return false;
533 }
534
535 WM_gizmotype_remove_ptr(nullptr, bmain, gzt);
536
537 /* Free extension after removing instances so `__del__` doesn't crash, see: #85567. */
540
541 /* Free gizmo group after the extension as it owns the identifier memory. */
543
545 return true;
546}
547
548static void **rna_Gizmo_instance(PointerRNA *ptr)
549{
550 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
551 return &gz->py_instance;
552}
553
554# endif /* WITH_PYTHON */
555
556static StructRNA *rna_Gizmo_refine(PointerRNA *gz_ptr)
557{
558 wmGizmo *gz = static_cast<wmGizmo *>(gz_ptr->data);
559 return (gz->type && gz->type->rna_ext.srna) ? gz->type->rna_ext.srna : &RNA_Gizmo;
560}
561
564/* -------------------------------------------------------------------- */
568static wmGizmoGroupType *rna_GizmoGroupProperties_find_gizmo_group_type(PointerRNA *ptr)
569{
570 IDProperty *properties = (IDProperty *)ptr->data;
571 wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(properties->name, false);
572 return gzgt;
573}
574
575static StructRNA *rna_GizmoGroupProperties_refine(PointerRNA *ptr)
576{
577 wmGizmoGroupType *gzgt = rna_GizmoGroupProperties_find_gizmo_group_type(ptr);
578
579 if (gzgt) {
580 return gzgt->srna;
581 }
582 else {
583 return ptr->type;
584 }
585}
586
587static IDProperty **rna_GizmoGroupProperties_idprops(PointerRNA *ptr)
588{
589 return (IDProperty **)&ptr->data;
590}
591
592static wmGizmo *rna_GizmoGroup_gizmo_new(wmGizmoGroup *gzgroup,
593 ReportList *reports,
594 const char *idname)
595{
596 const wmGizmoType *gzt = WM_gizmotype_find(idname, true);
597 if (gzt == nullptr) {
598 BKE_reportf(reports, RPT_ERROR, "GizmoType '%s' not known", idname);
599 return nullptr;
600 }
601 if ((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0) {
602 /* Allow for neither callbacks to be set, while this doesn't seem like a valid use case,
603 * there may be rare situations where a developer wants a gizmo to be draw-only. */
604 if ((gzt->test_select == nullptr) && (gzt->draw_select != nullptr)) {
605 BKE_reportf(reports,
606 RPT_ERROR,
607 "GizmoType '%s' is for a 3D gizmo-group. "
608 "The 'draw_select' callback is set where only 'test_select' will be used.",
609 idname);
610 return nullptr;
611 }
612 }
613 wmGizmo *gz = WM_gizmo_new_ptr(gzt, gzgroup, nullptr);
614 return gz;
615}
616
617static void rna_GizmoGroup_gizmo_remove(wmGizmoGroup *gzgroup, bContext *C, wmGizmo *gz)
618{
619 WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gz, C);
620}
621
622static void rna_GizmoGroup_gizmo_clear(wmGizmoGroup *gzgroup, bContext *C)
623{
624 while (gzgroup->gizmos.first) {
626 &gzgroup->gizmos, gzgroup->parent_gzmap, static_cast<wmGizmo *>(gzgroup->gizmos.first), C);
627 }
628}
629
630static void rna_GizmoGroup_name_get(PointerRNA *ptr, char *value)
631{
632 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(ptr->data);
633 strcpy(value, gzgroup->type->name);
634}
635
636static int rna_GizmoGroup_name_length(PointerRNA *ptr)
637{
638 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(ptr->data);
639 return strlen(gzgroup->type->name);
640}
641
642/* just to work around 'const char *' warning and to ensure this is a python op */
643static void rna_GizmoGroup_bl_idname_set(PointerRNA *ptr, const char *value)
644{
645 wmGizmoGroup *data = static_cast<wmGizmoGroup *>(ptr->data);
646 char *str = (char *)data->type->idname;
647 if (!str[0]) {
648 /* Calling UTF8 copy is disputable since registering ensures the value isn't truncated.
649 * Use a UTF8 copy to ensure truncating never causes an incomplete UTF8 sequence,
650 * even before registration. */
652 }
653 else {
654 BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
655 }
656}
657
658static void rna_GizmoGroup_bl_label_set(PointerRNA *ptr, const char *value)
659{
660 wmGizmoGroup *data = static_cast<wmGizmoGroup *>(ptr->data);
661 char *str = (char *)data->type->name;
662 if (!str[0]) {
664 }
665 else {
666 BLI_assert_msg(0, "setting the bl_label on a non-builtin operator");
667 }
668}
669
670# ifdef WITH_PYTHON
671
672static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *gzgt)
673{
674
675 extern FunctionRNA rna_GizmoGroup_poll_func;
676
677 ParameterList list;
678 FunctionRNA *func;
679 void *ret;
680 bool visible;
681
682 PointerRNA ptr = RNA_pointer_create(nullptr, gzgt->rna_ext.srna, nullptr); /* dummy */
683 func = &rna_GizmoGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
684
685 RNA_parameter_list_create(&list, &ptr, func);
686 RNA_parameter_set_lookup(&list, "context", &C);
687 gzgt->rna_ext.call((bContext *)C, &ptr, func, &list);
688
689 RNA_parameter_get_lookup(&list, "visible", &ret);
690 visible = *(bool *)ret;
691
693
694 return visible;
695}
696
697static void rna_gizmogroup_setup_cb(const bContext *C, wmGizmoGroup *gzgroup)
698{
699 extern FunctionRNA rna_GizmoGroup_setup_func;
700
701 ParameterList list;
702 FunctionRNA *func;
703
704 PointerRNA gzgroup_ptr = RNA_pointer_create(nullptr, gzgroup->type->rna_ext.srna, gzgroup);
705 func = &rna_GizmoGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */
706
707 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
708 RNA_parameter_set_lookup(&list, "context", &C);
709 gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
710
712}
713
714static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *gzgt, wmKeyConfig *config)
715{
716 extern FunctionRNA rna_GizmoGroup_setup_keymap_func;
717 void *ret;
718
719 ParameterList list;
720 FunctionRNA *func;
721
722 PointerRNA ptr = RNA_pointer_create(nullptr, gzgt->rna_ext.srna, nullptr); /* dummy */
723 func =
724 &rna_GizmoGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */
725
726 RNA_parameter_list_create(&list, &ptr, func);
727 RNA_parameter_set_lookup(&list, "keyconfig", &config);
728 gzgt->rna_ext.call(nullptr, &ptr, func, &list);
729
730 RNA_parameter_get_lookup(&list, "keymap", &ret);
731 wmKeyMap *keymap = *(wmKeyMap **)ret;
732
734
735 return keymap;
736}
737
738static void rna_gizmogroup_refresh_cb(const bContext *C, wmGizmoGroup *gzgroup)
739{
740 extern FunctionRNA rna_GizmoGroup_refresh_func;
741
742 ParameterList list;
743 FunctionRNA *func;
744
745 PointerRNA gzgroup_ptr = RNA_pointer_create(nullptr, gzgroup->type->rna_ext.srna, gzgroup);
746 func = &rna_GizmoGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */
747
748 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
749 RNA_parameter_set_lookup(&list, "context", &C);
750 gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
751
753}
754
755static void rna_gizmogroup_draw_prepare_cb(const bContext *C, wmGizmoGroup *gzgroup)
756{
757 extern FunctionRNA rna_GizmoGroup_draw_prepare_func;
758
759 ParameterList list;
760 FunctionRNA *func;
761
762 PointerRNA gzgroup_ptr = RNA_pointer_create(nullptr, gzgroup->type->rna_ext.srna, gzgroup);
763 func =
764 &rna_GizmoGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */
765
766 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
767 RNA_parameter_set_lookup(&list, "context", &C);
768 gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
769
771}
772
773static void rna_gizmogroup_invoke_prepare_cb(const bContext *C,
774 wmGizmoGroup *gzgroup,
775 wmGizmo *gz,
776 const wmEvent *event)
777{
778 extern FunctionRNA rna_GizmoGroup_invoke_prepare_func;
779
780 ParameterList list;
781 FunctionRNA *func;
782
783 PointerRNA gzgroup_ptr = RNA_pointer_create(nullptr, gzgroup->type->rna_ext.srna, gzgroup);
784 /* Reference `RNA_struct_find_function(&wgroupr, "invoke_prepare")` directly. */
785 func = &rna_GizmoGroup_invoke_prepare_func;
786
787 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
788 RNA_parameter_set_lookup(&list, "context", &C);
789 RNA_parameter_set_lookup(&list, "gizmo", &gz);
790 RNA_parameter_set_lookup(&list, "event", &event);
791 gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
792
794}
795
796extern void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata);
797static bool rna_GizmoGroup_unregister(Main *bmain, StructRNA *type);
798
799static StructRNA *rna_GizmoGroup_register(Main *bmain,
800 ReportList *reports,
801 void *data,
802 const char *identifier,
803 StructValidateFunc validate,
806{
807 const char *error_prefix = "Registering gizmogroup class:";
808 struct {
809 char name[MAX_NAME];
810 char idname[MAX_NAME];
811 } temp_buffers;
812
813 wmGizmoGroupType dummy_wgt = {nullptr};
814 wmGizmoGroup dummy_gizmo_group = {nullptr};
815
816 /* Two sets of functions. */
817 bool have_function[6];
818
819 /* setup dummy gizmogroup & gizmogroup type to store static properties in */
820 dummy_gizmo_group.type = &dummy_wgt;
821 dummy_wgt.name = temp_buffers.name;
822 dummy_wgt.idname = temp_buffers.idname;
823
824 PointerRNA wgptr = RNA_pointer_create(nullptr, &RNA_GizmoGroup, &dummy_gizmo_group);
825
826 /* Clear so we can detect if it's left unset. */
827 temp_buffers.idname[0] = temp_buffers.name[0] = '\0';
828
829 /* validate the python class */
830 if (validate(&wgptr, data, have_function) != 0) {
831 return nullptr;
832 }
833
834 if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
835 BKE_reportf(reports,
836 RPT_ERROR,
837 "%s '%s' is too long, maximum length is %d",
838 error_prefix,
839 identifier,
840 int(sizeof(temp_buffers.idname)));
841 return nullptr;
842 }
843
844 /* check if the area supports widgets */
845 wmGizmoMapType_Params wmap_params{};
846 wmap_params.spaceid = dummy_wgt.gzmap_params.spaceid;
847 wmap_params.regionid = dummy_wgt.gzmap_params.regionid;
848
849 wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&wmap_params);
850 if (gzmap_type == nullptr) {
851 BKE_reportf(reports, RPT_ERROR, "%s area type does not support gizmos", error_prefix);
852 return nullptr;
853 }
854
855 /* check if we have registered this gizmogroup type before, and remove it */
856 {
857 wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(dummy_wgt.idname, true);
858 if (gzgt) {
859 StructRNA *srna = gzgt->rna_ext.srna;
860 if (!(srna && rna_GizmoGroup_unregister(bmain, srna))) {
861 BKE_reportf(reports,
862 RPT_ERROR,
863 "%s '%s', bl_idname '%s' %s",
864 error_prefix,
865 identifier,
866 dummy_wgt.idname,
867 srna ? "is built-in" : "could not be unregistered");
868 return nullptr;
869 }
870 }
871 }
872 if (!RNA_struct_available_or_report(reports, dummy_wgt.idname)) {
873 return nullptr;
874 }
875
876 { /* allocate the idname */
877 const char *strings[] = {
878 temp_buffers.idname,
879 temp_buffers.name,
880 };
881 char *strings_table[ARRAY_SIZE(strings)];
883 '\0', strings_table, strings, ARRAY_SIZE(strings));
884
885 dummy_wgt.idname = strings_table[0]; /* allocated string stored here */
886 dummy_wgt.name = strings_table[1];
887 BLI_assert(ARRAY_SIZE(strings) == 2);
888 }
889
890 /* create a new gizmogroup type */
891 dummy_wgt.rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummy_wgt.idname, &RNA_GizmoGroup);
892
893 /* Gizmo group properties are registered separately. */
895
896 dummy_wgt.rna_ext.data = data;
897 dummy_wgt.rna_ext.call = call;
898 dummy_wgt.rna_ext.free = free;
899
900 /* We used to register widget group types like this, now we do it similar to
901 * operator types. Thus we should be able to do the same as operator types now. */
902 dummy_wgt.poll = (have_function[0]) ? rna_gizmogroup_poll_cb : nullptr;
903 dummy_wgt.setup_keymap = (have_function[1]) ? rna_gizmogroup_setup_keymap_cb : nullptr;
904 dummy_wgt.setup = (have_function[2]) ? rna_gizmogroup_setup_cb : nullptr;
905 dummy_wgt.refresh = (have_function[3]) ? rna_gizmogroup_refresh_cb : nullptr;
906 dummy_wgt.draw_prepare = (have_function[4]) ? rna_gizmogroup_draw_prepare_cb : nullptr;
907 dummy_wgt.invoke_prepare = (have_function[5]) ? rna_gizmogroup_invoke_prepare_cb : nullptr;
908
910 (void *)&dummy_wgt);
911
912 {
913 const char *owner_id = RNA_struct_state_owner_get();
914 if (owner_id) {
915 STRNCPY(gzgt->owner_id, owner_id);
916 }
917 }
918
920 WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type);
921
922 /* update while blender is running */
924 }
925
926 return dummy_wgt.rna_ext.srna;
927}
928
929static bool rna_GizmoGroup_unregister(Main *bmain, StructRNA *type)
930{
932
933 if (!gzgt) {
934 return false;
935 }
936
938
939 /* Free extension after removing instances so `__del__` doesn't crash, see: #85567. */
942
943 /* Free gizmo group after the extension as it owns the identifier memory. */
945
947 return true;
948}
949
950static void **rna_GizmoGroup_instance(PointerRNA *ptr)
951{
952 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(ptr->data);
953 return &gzgroup->py_instance;
954}
955
956# endif /* WITH_PYTHON */
957
958static StructRNA *rna_GizmoGroup_refine(PointerRNA *gzgroup_ptr)
959{
960 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(gzgroup_ptr->data);
961 return (gzgroup->type && gzgroup->type->rna_ext.srna) ? gzgroup->type->rna_ext.srna :
962 &RNA_GizmoGroup;
963}
964
965static void rna_GizmoGroup_gizmos_begin(CollectionPropertyIterator *iter, PointerRNA *gzgroup_ptr)
966{
967 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(gzgroup_ptr->data);
968 rna_iterator_listbase_begin(iter, &gzgroup->gizmos, nullptr);
969}
970
973#else /* RNA_RUNTIME */
974
975/* GizmoGroup.gizmos */
976static void rna_def_gizmos(BlenderRNA *brna, PropertyRNA *cprop)
977{
978 StructRNA *srna;
979
980 FunctionRNA *func;
981 PropertyRNA *parm;
982
983 RNA_def_property_srna(cprop, "Gizmos");
984 srna = RNA_def_struct(brna, "Gizmos", nullptr);
985 RNA_def_struct_sdna(srna, "wmGizmoGroup");
986 RNA_def_struct_ui_text(srna, "Gizmos", "Collection of gizmos");
987
988 func = RNA_def_function(srna, "new", "rna_GizmoGroup_gizmo_new");
989 RNA_def_function_ui_description(func, "Add gizmo");
991 parm = RNA_def_string(func, "type", "Type", 0, "", "Gizmo identifier"); /* optional */
993 parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo");
994 RNA_def_function_return(func, parm);
995
996 func = RNA_def_function(srna, "remove", "rna_GizmoGroup_gizmo_remove");
998 RNA_def_function_ui_description(func, "Delete gizmo");
999 parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo");
1002
1003 func = RNA_def_function(srna, "clear", "rna_GizmoGroup_gizmo_clear");
1005 RNA_def_function_ui_description(func, "Delete all gizmos");
1006}
1007
1008static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop)
1009{
1010 StructRNA *srna;
1011 PropertyRNA *prop;
1012
1013 FunctionRNA *func;
1014 PropertyRNA *parm;
1015
1016 RNA_def_property_srna(cprop, "Gizmo");
1017 srna = RNA_def_struct(brna, "Gizmo", nullptr);
1018 RNA_def_struct_sdna(srna, "wmGizmo");
1019 RNA_def_struct_ui_text(srna, "Gizmo", "Collection of gizmos");
1020 RNA_def_struct_refine_func(srna, "rna_Gizmo_refine");
1021
1022# ifdef WITH_PYTHON
1024 srna, "rna_Gizmo_register", "rna_Gizmo_unregister", "rna_Gizmo_instance");
1025# endif
1027
1028 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1030 RNA_def_property_struct_type(prop, "GizmoProperties");
1031 RNA_def_property_ui_text(prop, "Properties", "");
1032 RNA_def_property_pointer_funcs(prop, "rna_Gizmo_properties_get", nullptr, nullptr, nullptr);
1033
1034 /* -------------------------------------------------------------------- */
1035 /* Registerable Variables */
1036
1037 RNA_define_verify_sdna(false); /* not in sdna */
1038
1039 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1040 RNA_def_property_string_sdna(prop, nullptr, "type->idname");
1042 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Gizmo_bl_idname_set");
1043 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1045
1046 RNA_define_verify_sdna(true); /* not in sdna */
1047
1048 /* wmGizmo.draw */
1049 func = RNA_def_function(srna, "draw", nullptr);
1052 parm = RNA_def_pointer(func, "context", "Context", "", "");
1054
1055 /* wmGizmo.draw_select */
1056 func = RNA_def_function(srna, "draw_select", nullptr);
1059 parm = RNA_def_pointer(func, "context", "Context", "", "");
1061 parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
1062
1063 /* wmGizmo.test_select */
1064 func = RNA_def_function(srna, "test_select", nullptr);
1067 parm = RNA_def_pointer(func, "context", "Context", "", "");
1069 parm = RNA_def_int_array(func,
1070 "location",
1071 2,
1072 nullptr,
1073 INT_MIN,
1074 INT_MAX,
1075 "Location",
1076 "Region coordinates",
1077 INT_MIN,
1078 INT_MAX);
1080 parm = RNA_def_int(
1081 func, "intersect_id", -1, -1, INT_MAX, "", "Use -1 to skip this gizmo", -1, INT_MAX);
1082 RNA_def_function_return(func, parm);
1083
1084 /* wmGizmo.handler */
1085 static const EnumPropertyItem tweak_actions[] = {
1086 {WM_GIZMO_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""},
1087 {WM_GIZMO_TWEAK_SNAP, "SNAP", 0, "Snap", ""},
1088 {0, nullptr, 0, nullptr, nullptr},
1089 };
1090 func = RNA_def_function(srna, "modal", nullptr);
1093 parm = RNA_def_pointer(func, "context", "Context", "", "");
1095 parm = RNA_def_pointer(func, "event", "Event", "", "");
1097 /* TODO: should be a enum-flag. */
1098 parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", "");
1100 parm = RNA_def_enum_flag(
1101 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1102 RNA_def_function_return(func, parm);
1103 /* wmGizmo.property_update */
1104 /* TODO */
1105
1106 /* wmGizmo.setup */
1107 func = RNA_def_function(srna, "setup", nullptr);
1110
1111 /* wmGizmo.invoke */
1112 func = RNA_def_function(srna, "invoke", nullptr);
1115 parm = RNA_def_pointer(func, "context", "Context", "", "");
1117 parm = RNA_def_pointer(func, "event", "Event", "", "");
1119 parm = RNA_def_enum_flag(
1120 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1121 RNA_def_function_return(func, parm);
1122
1123 /* wmGizmo.exit */
1124 func = RNA_def_function(srna, "exit", nullptr);
1127 parm = RNA_def_pointer(func, "context", "Context", "", "");
1129 parm = RNA_def_boolean(func, "cancel", false, "Cancel, otherwise confirm", "");
1131
1132 /* wmGizmo.cursor_get */
1133 /* TODO */
1134
1135 /* wmGizmo.select_refresh */
1136 func = RNA_def_function(srna, "select_refresh", nullptr);
1139
1140 /* -------------------------------------------------------------------- */
1141 /* Instance Variables */
1142
1143 prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
1145 RNA_def_property_struct_type(prop, "GizmoGroup");
1146 RNA_def_property_pointer_funcs(prop, "rna_Gizmo_group_get", nullptr, nullptr, nullptr);
1147 RNA_def_property_ui_text(prop, "", "Gizmo group this gizmo is a member of");
1148
1149 /* Color & Alpha */
1150 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1151 RNA_def_property_array(prop, 3);
1152 RNA_def_property_float_funcs(prop, "rna_Gizmo_color_get", "rna_Gizmo_color_set", nullptr);
1153
1154 prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
1155 RNA_def_property_ui_text(prop, "Alpha", "");
1156 RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_get", "rna_Gizmo_alpha_set", nullptr);
1157 RNA_def_property_range(prop, 0.0f, 1.0f);
1158 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1159
1160 /* Color & Alpha (highlight) */
1161 prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR);
1162 RNA_def_property_array(prop, 3);
1163 RNA_def_property_float_funcs(prop, "rna_Gizmo_color_hi_get", "rna_Gizmo_color_hi_set", nullptr);
1164
1165 prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE);
1166 RNA_def_property_ui_text(prop, "Alpha", "");
1167 RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_hi_get", "rna_Gizmo_alpha_hi_set", nullptr);
1168 RNA_def_property_range(prop, 0.0f, 1.0f);
1169 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1170
1171 prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX);
1173 RNA_def_property_ui_text(prop, "Space Matrix", "");
1175 prop, "rna_Gizmo_matrix_space_get", "rna_Gizmo_matrix_space_set", nullptr);
1176 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1177
1178 prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
1180 RNA_def_property_ui_text(prop, "Basis Matrix", "");
1182 prop, "rna_Gizmo_matrix_basis_get", "rna_Gizmo_matrix_basis_set", nullptr);
1183 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1184
1185 prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX);
1187 RNA_def_property_ui_text(prop, "Offset Matrix", "");
1189 prop, "rna_Gizmo_matrix_offset_get", "rna_Gizmo_matrix_offset_set", nullptr);
1190 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1191
1192 prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
1195 RNA_def_property_ui_text(prop, "Final World Matrix", "");
1196 RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_world_get", nullptr, nullptr);
1197
1198 prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE);
1199 RNA_def_property_ui_text(prop, "Scale Basis", "");
1201 prop, "rna_Gizmo_scale_basis_get", "rna_Gizmo_scale_basis_set", nullptr);
1202 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1203 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1204
1205 prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL);
1206 RNA_def_property_ui_text(prop, "Line Width", "");
1208 prop, "rna_Gizmo_line_width_get", "rna_Gizmo_line_width_set", nullptr);
1209 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1210 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1211
1212 prop = RNA_def_property(srna, "select_bias", PROP_FLOAT, PROP_NONE);
1213 RNA_def_property_ui_text(prop, "Select Bias", "Depth bias used for selection");
1215 prop, "rna_Gizmo_select_bias_get", "rna_Gizmo_select_bias_set", nullptr);
1217
1218 /* wmGizmo.flag */
1219 /* WM_GIZMO_HIDDEN */
1220 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1221 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_flag_hide_get", "rna_Gizmo_flag_hide_set");
1222 RNA_def_property_ui_text(prop, "Hide", "");
1223 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1224 /* WM_GIZMO_HIDDEN_SELECT */
1225 prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
1227 prop, "rna_Gizmo_flag_hide_select_get", "rna_Gizmo_flag_hide_select_set");
1228 RNA_def_property_ui_text(prop, "Hide Select", "");
1229 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1230 /* WM_GIZMO_HIDDEN_KEYMAP */
1231 prop = RNA_def_property(srna, "hide_keymap", PROP_BOOLEAN, PROP_NONE);
1233 prop, "rna_Gizmo_flag_hide_keymap_get", "rna_Gizmo_flag_hide_keymap_set");
1234 RNA_def_property_ui_text(prop, "Hide Keymap", "Ignore the key-map for this gizmo");
1235 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1236 /* WM_GIZMO_MOVE_CURSOR */
1237 prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE);
1239 prop, "rna_Gizmo_flag_use_grab_cursor_get", "rna_Gizmo_flag_use_grab_cursor_set");
1240 RNA_def_property_ui_text(prop, "Grab Cursor", "");
1241 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1242
1243 /* WM_GIZMO_DRAW_HOVER */
1244 prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE);
1246 prop, "rna_Gizmo_flag_use_draw_hover_get", "rna_Gizmo_flag_use_draw_hover_set");
1247 RNA_def_property_ui_text(prop, "Show Hover", "");
1248 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1249 /* WM_GIZMO_DRAW_MODAL */
1250 prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE);
1252 prop, "rna_Gizmo_flag_use_draw_modal_get", "rna_Gizmo_flag_use_draw_modal_set");
1253 RNA_def_property_ui_text(prop, "Show Active", "Show while dragging");
1254 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1255 /* WM_GIZMO_DRAW_VALUE */
1256 prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE);
1258 prop, "rna_Gizmo_flag_use_draw_value_get", "rna_Gizmo_flag_use_draw_value_set");
1260 prop, "Show Value", "Show an indicator for the current value while dragging");
1261 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1262 /* WM_GIZMO_DRAW_OFFSET_SCALE */
1263 prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE);
1265 "rna_Gizmo_flag_use_draw_offset_scale_get",
1266 "rna_Gizmo_flag_use_draw_offset_scale_set");
1268 prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)");
1269 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1270 /* WM_GIZMO_DRAW_NO_SCALE (negated) */
1271 prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE);
1273 prop, "rna_Gizmo_flag_use_draw_scale_get", "rna_Gizmo_flag_use_draw_scale_set");
1275 RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix");
1276 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1277
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");
1312 RNA_def_property_ui_text(prop, "Use Tooltip", "Use tooltips when hovering over this gizmo");
1313 /* No update needed. */
1314
1315 /* wmGizmo.state (readonly) */
1316 /* WM_GIZMO_STATE_HIGHLIGHT */
1317 prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE);
1318 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_highlight_get", nullptr);
1319 RNA_def_property_ui_text(prop, "Highlight", "");
1321 /* WM_GIZMO_STATE_MODAL */
1322 prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
1323 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_modal_get", nullptr);
1324 RNA_def_property_ui_text(prop, "Highlight", "");
1326 /* WM_GIZMO_STATE_SELECT */
1327 /* (note that setting is involved, needs to handle array) */
1328 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1329 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_select_get", "rna_Gizmo_state_select_set");
1330 RNA_def_property_ui_text(prop, "Select", "");
1331
1332 RNA_api_gizmo(srna);
1333
1334 srna = RNA_def_struct(brna, "GizmoProperties", nullptr);
1335 RNA_def_struct_ui_text(srna, "Gizmo Properties", "Input properties of a Gizmo");
1336 RNA_def_struct_refine_func(srna, "rna_GizmoProperties_refine");
1337 RNA_def_struct_idprops_func(srna, "rna_GizmoProperties_idprops");
1339}
1340
1342{
1343 StructRNA *srna;
1344 PropertyRNA *prop;
1345
1346 FunctionRNA *func;
1347 PropertyRNA *parm;
1348
1349 srna = RNA_def_struct(brna, "GizmoGroup", nullptr);
1351 srna, "GizmoGroup", "Storage of an operator being executed, or registered after execution");
1352 RNA_def_struct_sdna(srna, "wmGizmoGroup");
1353 RNA_def_struct_refine_func(srna, "rna_GizmoGroup_refine");
1354# ifdef WITH_PYTHON
1356 srna, "rna_GizmoGroup_register", "rna_GizmoGroup_unregister", "rna_GizmoGroup_instance");
1357# endif
1359
1360 /* -------------------------------------------------------------------- */
1361 /* Registration */
1362
1363 RNA_define_verify_sdna(false); /* not in sdna */
1364
1365 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1366 RNA_def_property_string_sdna(prop, nullptr, "type->idname");
1368 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_GizmoGroup_bl_idname_set");
1370 RNA_def_struct_name_property(srna, prop);
1371
1372 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1373 RNA_def_property_string_sdna(prop, nullptr, "type->name");
1374 RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */
1375 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_GizmoGroup_bl_label_set");
1376 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1378
1379 prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
1380 RNA_def_property_enum_sdna(prop, nullptr, "type->gzmap_params.spaceid");
1383 RNA_def_property_ui_text(prop, "Space Type", "The space where the panel is going to be used in");
1384
1385 prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
1386 RNA_def_property_enum_sdna(prop, nullptr, "type->gzmap_params.regionid");
1390 prop, "Region Type", "The region where the panel is going to be used in");
1391
1392 prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
1393 RNA_def_property_string_sdna(prop, nullptr, "type->owner_id");
1395
1396 /* bl_options */
1397 static const EnumPropertyItem gizmogroup_flag_items[] = {
1398 {WM_GIZMOGROUPTYPE_3D, "3D", 0, "3D", "Use in 3D viewport"},
1400 "SCALE",
1401 0,
1402 "Scale",
1403 "Scale to respect zoom (otherwise zoom independent display size)"},
1405 "DEPTH_3D",
1406 0,
1407 "Depth 3D",
1408 "Supports culled depth by other objects in the view"},
1409 {WM_GIZMOGROUPTYPE_SELECT, "SELECT", 0, "Select", "Supports selection"},
1410 {WM_GIZMOGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent", ""},
1412 "SHOW_MODAL_ALL",
1413 0,
1414 "Show Modal All",
1415 "Show all while interacting, as well as this group when another is being interacted with"},
1417 "EXCLUDE_MODAL",
1418 0,
1419 "Exclude Modal",
1420 "Show all except this group while interacting"},
1422 "TOOL_INIT",
1423 0,
1424 "Tool Init",
1425 "Postpone running until tool operator run (when used with a tool)"},
1427 "TOOL_FALLBACK_KEYMAP",
1428 0,
1429 "Use fallback tools keymap",
1430 "Add fallback tools keymap to this gizmo type"},
1432 "VR_REDRAWS",
1433 0,
1434 "VR Redraws",
1435 "The gizmos are made for use with virtual reality sessions and require special redraw "
1436 "management"},
1437 {0, nullptr, 0, nullptr, nullptr},
1438 };
1439 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1440 RNA_def_property_enum_sdna(prop, nullptr, "type->flag");
1441 RNA_def_property_enum_items(prop, gizmogroup_flag_items);
1443 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1444
1445 RNA_define_verify_sdna(true); /* not in sdna */
1446
1447 /* Functions */
1448
1449 /* poll */
1450 func = RNA_def_function(srna, "poll", nullptr);
1451 RNA_def_function_ui_description(func, "Test if the gizmo group can be called or not");
1453 RNA_def_function_return(func, RNA_def_boolean(func, "visible", false, "", ""));
1454 parm = RNA_def_pointer(func, "context", "Context", "", "");
1456
1457 /* setup_keymap */
1458 func = RNA_def_function(srna, "setup_keymap", nullptr);
1460 func, "Initialize keymaps for this gizmo group, use fallback keymap when not present");
1462 parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", "");
1464 /* return */
1465 parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
1467 RNA_def_function_return(func, parm);
1468
1469 /* setup */
1470 func = RNA_def_function(srna, "setup", nullptr);
1471 RNA_def_function_ui_description(func, "Create gizmos function for the gizmo group");
1473 parm = RNA_def_pointer(func, "context", "Context", "", "");
1475
1476 /* refresh */
1477 func = RNA_def_function(srna, "refresh", nullptr);
1479 func, "Refresh data (called on common state changes such as selection)");
1481 parm = RNA_def_pointer(func, "context", "Context", "", "");
1483
1484 func = RNA_def_function(srna, "draw_prepare", nullptr);
1485 RNA_def_function_ui_description(func, "Run before each redraw");
1487 parm = RNA_def_pointer(func, "context", "Context", "", "");
1489
1490 func = RNA_def_function(srna, "invoke_prepare", nullptr);
1491 RNA_def_function_ui_description(func, "Run before invoke");
1493 parm = RNA_def_pointer(func, "context", "Context", "", "");
1495 parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "");
1497
1498 /* -------------------------------------------------------------------- */
1499 /* Instance Variables */
1500
1501 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1504 prop, "rna_GizmoGroup_name_get", "rna_GizmoGroup_name_length", nullptr);
1505 RNA_def_property_ui_text(prop, "Name", "");
1506
1507 RNA_define_verify_sdna(false); /* not in sdna */
1508
1509 prop = RNA_def_property(srna, "gizmos", PROP_COLLECTION, PROP_NONE);
1510 RNA_def_property_collection_sdna(prop, nullptr, "gizmos", nullptr);
1511 RNA_def_property_struct_type(prop, "Gizmo");
1513 "rna_GizmoGroup_gizmos_begin",
1514 "rna_iterator_listbase_next",
1515 "rna_iterator_listbase_end",
1516 "rna_iterator_listbase_get",
1517 nullptr,
1518 nullptr,
1519 nullptr,
1520 nullptr);
1521
1522 RNA_def_property_ui_text(prop, "Gizmos", "List of gizmos in the Gizmo Map");
1523 rna_def_gizmo(brna, prop);
1524 rna_def_gizmos(brna, prop);
1525
1526 RNA_define_verify_sdna(true); /* not in sdna */
1527
1528 RNA_api_gizmogroup(srna);
1529
1530 srna = RNA_def_struct(brna, "GizmoGroupProperties", nullptr);
1531 RNA_def_struct_ui_text(srna, "Gizmo Group Properties", "Input properties of a Gizmo Group");
1532 RNA_def_struct_refine_func(srna, "rna_GizmoGroupProperties_refine");
1533 RNA_def_struct_idprops_func(srna, "rna_GizmoGroupProperties_idprops");
1535}
1536
1538{
1539 rna_def_gizmogroup(brna);
1540}
1541
1542#endif /* RNA_RUNTIME */
#define G_MAIN
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_assert(a)
Definition BLI_assert.h:50
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:57
void BLI_kdtree_nd_ free(KDTree *tree)
#define LISTBASE_FOREACH(type, var, list)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.c:40
#define STRNCPY(dst, src)
Definition BLI_string.h:593
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void void char * BLI_string_join_array_by_sep_char_with_tableN(char sep, char *table[], const char *strings[], uint strings_num) ATTR_NONNULL(2
#define ARRAY_SIZE(arr)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define MAX_NAME
Definition DNA_defs.h:50
void GPU_bgl_end()
Definition gpu_state.cc:349
Read Guarded memory(de)allocation.
ParameterFlag
Definition RNA_types.hh:396
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_NO_SELF
Definition RNA_types.hh:673
@ FUNC_REGISTER
Definition RNA_types.hh:687
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:679
@ FUNC_REGISTER_OPTIONAL
Definition RNA_types.hh:689
@ FUNC_ALLOW_WRITE
Definition RNA_types.hh:695
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
Definition RNA_types.hh:731
@ STRUCT_NO_IDPROPERTIES
Definition RNA_types.hh:729
int(*)(PointerRNA *ptr, void *data, bool *have_function) StructValidateFunc
Definition RNA_types.hh:746
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
void(*)(void *data) StructFreeFunc
Definition RNA_types.hh:751
int(*)(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *list) StructCallbackFunc
Definition RNA_types.hh:747
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_ENUM_FLAG
Definition RNA_types.hh:293
@ PROP_REGISTER_OPTIONAL
Definition RNA_types.hh:301
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
@ PROP_REGISTER
Definition RNA_types.hh:300
@ PROP_MATRIX
Definition RNA_types.hh:168
@ PROP_COLOR
Definition RNA_types.hh:163
@ PROP_PIXEL
Definition RNA_types.hh:151
@ PROP_NONE
Definition RNA_types.hh:136
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.hh:344
#define NA_EDITED
Definition WM_types.hh:550
void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata)
void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata)
#define str(s)
static ulong state[N]
return ret
bool RNA_struct_available_or_report(ReportList *reports, const char *identifier)
void * RNA_struct_blender_type_get(StructRNA *srna)
void RNA_parameter_list_free(ParameterList *parms)
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, const void *value)
PointerRNA rna_pointer_inherit_refine(const PointerRNA *ptr, StructRNA *type, void *data)
const char * RNA_struct_state_owner_get()
ParameterList * RNA_parameter_list_create(ParameterList *parms, PointerRNA *, FunctionRNA *func)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void **r_value)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_struct_flag(StructRNA *srna, int flag)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_define_verify_sdna(bool verify)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
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)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
const int rna_matrix_dimsize_4x4[]
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_struct_translation_context(StructRNA *srna, const char *context)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_api_gizmo(StructRNA *srna)
BlenderRNA BLENDER_RNA
void RNA_api_gizmogroup(StructRNA *srna)
const EnumPropertyItem rna_enum_region_type_items[]
Definition rna_screen.cc:24
const EnumPropertyItem rna_enum_space_type_items[]
Definition rna_space.cc:97
const EnumPropertyItem rna_enum_operator_return_items[]
Definition rna_wm.cc:562
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)
void RNA_def_wm_gizmo(BlenderRNA *brna)
#define FLT_MAX
Definition stdcycles.h:14
StructRNA * srna
Definition RNA_types.hh:780
StructCallbackFunc call
Definition RNA_types.hh:781
StructFreeFunc free
Definition RNA_types.hh:782
char name[64]
Definition DNA_ID.h:163
void * first
ID * owner_id
Definition RNA_types.hh:40
StructRNA * type
Definition RNA_types.hh:41
void * data
Definition RNA_types.hh:42
const char * name
wmGizmoGroupFnSetupKeymap setup_keymap
wmGizmoGroupFnRefresh refresh
wmGizmoGroupFnInit setup
const char * idname
wmGizmoGroupFnInvokePrepare invoke_prepare
wmGizmoMapType_Params gzmap_params
eWM_GizmoFlagGroupTypeFlag flag
ExtensionRNA rna_ext
wmGizmoGroupFnPoll poll
wmGizmoGroupFnDrawPrepare draw_prepare
wmGizmoMap * parent_gzmap
wmGizmoGroupType * type
StructRNA * srna
wmGizmoFnSelectRefresh select_refresh
wmGizmoFnDraw draw
ExtensionRNA rna_ext
wmGizmoFnModal modal
wmGizmoFnSetup setup
const char * idname
wmGizmoFnTestSelect test_select
wmGizmoFnExit exit
wmGizmoFnInvoke invoke
wmGizmoFnDrawSelect draw_select
wmGizmoGroup * parent_gzgroup
const wmGizmoType * type
void * py_instance
IDProperty * properties
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition wm_gizmo.cc:569
wmGizmo * WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, PointerRNA *properties)
Definition wm_gizmo.cc:81
bool WM_gizmo_select_set(wmGizmoMap *gzmap, wmGizmo *gz, bool select)
Definition wm_gizmo.cc:396
void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C)
Definition wm_gizmo.cc:165
void WM_gizmo_group_type_remove_ptr(Main *bmain, wmGizmoGroupType *gzgt)
void WM_gizmo_group_type_add_ptr_ex(wmGizmoGroupType *gzgt, wmGizmoMapType *gzmap_type)
wmGizmoGroupType * WM_gizmogrouptype_append_ptr(void(*wtfunc)(wmGizmoGroupType *, void *), void *userdata)
void WM_gizmo_group_type_free_ptr(wmGizmoGroupType *gzgt)
wmGizmoGroupType * WM_gizmogrouptype_find(const char *idname, bool quiet)
const ListBase * WM_gizmomap_group_list(wmGizmoMap *gzmap)
wmGizmoMapType * WM_gizmomaptype_ensure(const wmGizmoMapType_Params *gzmap_params)
void WM_gizmotype_append_ptr(void(*gtfunc)(wmGizmoType *, void *), void *userdata)
const wmGizmoType * WM_gizmotype_find(const char *idname, bool quiet)
void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *gzt)
void WM_gizmotype_free_ptr(wmGizmoType *gzt)
uint8_t flag
Definition wm_window.cc:138