Blender V4.5
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
8
9#include <cstdlib>
10
12
13#include "BLT_translation.hh"
14
15#include "RNA_define.hh"
16#include "RNA_enum_types.hh"
17
18#include "rna_internal.hh"
19
20#include "WM_types.hh"
21
22#ifdef RNA_RUNTIME
23/* enum definitions */
24#endif /* RNA_RUNTIME */
25
26#ifdef RNA_RUNTIME
27
28# include "BLI_string.h"
29# include "BLI_string_utf8.h"
30# include "BLI_string_utils.hh"
31
32# include "WM_api.hh"
33
34# include "ED_screen.hh"
35
36# include "UI_interface.hh"
37
38# include "BKE_context.hh"
39# include "BKE_global.hh"
40# include "BKE_main.hh"
41# include "BKE_report.hh"
42# include "BKE_screen.hh"
43# include "BKE_workspace.hh"
44
45# include "GPU_state.hh"
46
47# ifdef WITH_PYTHON
48# include "BPY_extern.hh"
49# endif
50
51/* -------------------------------------------------------------------- */
54
55# ifdef WITH_PYTHON
56static void rna_gizmo_draw_cb(const bContext *C, wmGizmo *gz)
57{
58 extern FunctionRNA rna_Gizmo_draw_func;
59 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
60 ParameterList list;
61 FunctionRNA *func;
62 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
63 /* Reference `RNA_struct_find_function(&gz_ptr, "draw")` directly. */
64 func = &rna_Gizmo_draw_func;
65 RNA_parameter_list_create(&list, &gz_ptr, func);
66 RNA_parameter_set_lookup(&list, "context", &C);
67 gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
69 /* This callback may have called bgl functions. */
71}
72
73static void rna_gizmo_draw_select_cb(const bContext *C, wmGizmo *gz, int select_id)
74{
75 extern FunctionRNA rna_Gizmo_draw_select_func;
76 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
77 ParameterList list;
78 FunctionRNA *func;
79 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
80 /* Reference `RNA_struct_find_function(&gz_ptr, "draw_select")` directly. */
81 func = &rna_Gizmo_draw_select_func;
82 RNA_parameter_list_create(&list, &gz_ptr, func);
83 RNA_parameter_set_lookup(&list, "context", &C);
84 RNA_parameter_set_lookup(&list, "select_id", &select_id);
85 gzgroup->type->rna_ext.call((bContext *)C, &gz_ptr, func, &list);
87 /* This callback may have called bgl functions. */
89}
90
91static int rna_gizmo_test_select_cb(bContext *C, wmGizmo *gz, const int location[2])
92{
93 extern FunctionRNA rna_Gizmo_test_select_func;
94 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
95 ParameterList list;
96 FunctionRNA *func;
97 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
98 /* Reference `RNA_struct_find_function(&gz_ptr, "test_select")` directly. */
99 func = &rna_Gizmo_test_select_func;
100 RNA_parameter_list_create(&list, &gz_ptr, func);
101 RNA_parameter_set_lookup(&list, "context", &C);
102 RNA_parameter_set_lookup(&list, "location", location);
103 gzgroup->type->rna_ext.call(C, &gz_ptr, func, &list);
104
105 void *ret;
106 RNA_parameter_get_lookup(&list, "intersect_id", &ret);
107 int intersect_id = *(int *)ret;
108
110 return intersect_id;
111}
112
113static wmOperatorStatus rna_gizmo_modal_cb(bContext *C,
114 wmGizmo *gz,
115 const wmEvent *event,
116 eWM_GizmoFlagTweak tweak_flag)
117{
118 extern FunctionRNA rna_Gizmo_modal_func;
119 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
120 ParameterList list;
121 FunctionRNA *func;
122 const int tweak_flag_int = tweak_flag;
123 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
124 /* Reference `RNA_struct_find_function(&gz_ptr, "modal")` directly. */
125 func = &rna_Gizmo_modal_func;
126 RNA_parameter_list_create(&list, &gz_ptr, func);
127 RNA_parameter_set_lookup(&list, "context", &C);
128 RNA_parameter_set_lookup(&list, "event", &event);
129 RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int);
130 gzgroup->type->rna_ext.call(C, &gz_ptr, func, &list);
131
132 void *ret;
133 RNA_parameter_get_lookup(&list, "result", &ret);
134 wmOperatorStatus retval = wmOperatorStatus(*(int *)ret);
135
137
138 OPERATOR_RETVAL_CHECK(retval);
139 return retval;
140}
141
142static void rna_gizmo_setup_cb(wmGizmo *gz)
143{
144 extern FunctionRNA rna_Gizmo_setup_func;
145 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
146 ParameterList list;
147 FunctionRNA *func;
148 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
149 /* Reference `RNA_struct_find_function(&gz_ptr, "setup")` directly. */
150 func = &rna_Gizmo_setup_func;
151 RNA_parameter_list_create(&list, &gz_ptr, func);
152 gzgroup->type->rna_ext.call((bContext *)nullptr, &gz_ptr, func, &list);
154}
155
156static wmOperatorStatus rna_gizmo_invoke_cb(bContext *C, wmGizmo *gz, const wmEvent *event)
157{
158 extern FunctionRNA rna_Gizmo_invoke_func;
159 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
160 ParameterList list;
161 FunctionRNA *func;
162 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
163 /* Reference `RNA_struct_find_function(&gz_ptr, "invoke")` directly. */
164 func = &rna_Gizmo_invoke_func;
165 RNA_parameter_list_create(&list, &gz_ptr, func);
166 RNA_parameter_set_lookup(&list, "context", &C);
167 RNA_parameter_set_lookup(&list, "event", &event);
168 gzgroup->type->rna_ext.call(C, &gz_ptr, func, &list);
169
170 void *ret;
171 RNA_parameter_get_lookup(&list, "result", &ret);
172 const wmOperatorStatus retval = wmOperatorStatus(*(int *)ret);
173
175
176 OPERATOR_RETVAL_CHECK(retval);
177 return retval;
178}
179
180static void rna_gizmo_exit_cb(bContext *C, wmGizmo *gz, bool cancel)
181{
182 extern FunctionRNA rna_Gizmo_exit_func;
183 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
184 ParameterList list;
185 FunctionRNA *func;
186 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
187 /* Reference `RNA_struct_find_function(&gz_ptr, "exit")` directly. */
188 func = &rna_Gizmo_exit_func;
189 RNA_parameter_list_create(&list, &gz_ptr, func);
190 RNA_parameter_set_lookup(&list, "context", &C);
191 {
192 int cancel_i = cancel;
193 RNA_parameter_set_lookup(&list, "cancel", &cancel_i);
194 }
195 gzgroup->type->rna_ext.call(C, &gz_ptr, func, &list);
197}
198
199static void rna_gizmo_select_refresh_cb(wmGizmo *gz)
200{
201 extern FunctionRNA rna_Gizmo_select_refresh_func;
202 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
203 ParameterList list;
204 FunctionRNA *func;
205 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
206 /* Reference `RNA_struct_find_function(&gz_ptr, "select_refresh")` directly. */
207 func = &rna_Gizmo_select_refresh_func;
208 RNA_parameter_list_create(&list, &gz_ptr, func);
209 gzgroup->type->rna_ext.call((bContext *)nullptr, &gz_ptr, func, &list);
211}
212
213# endif /* WITH_PYTHON */
214
215/* just to work around 'const char *' warning and to ensure this is a python op */
216static void rna_Gizmo_bl_idname_set(PointerRNA *ptr, const char *value)
217{
218 wmGizmo *data = static_cast<wmGizmo *>(ptr->data);
219 char *str = (char *)data->type->idname;
220 if (!str[0]) {
221 /* Calling UTF8 copy is disputable since registering ensures the value isn't truncated.
222 * Use a UTF8 copy to ensure truncating never causes an incomplete UTF8 sequence,
223 * even before registration. */
225 }
226 else {
227 BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
228 }
229}
230
231static void rna_Gizmo_update_redraw(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
232{
233 wmGizmo *gizmo = static_cast<wmGizmo *>(ptr->data);
234 gizmo->do_draw = true;
235}
236
237static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr)
238{
239# if 0
240 wmWindowManager *wm = (wmWindowManager *)ptr->owner_id;
241# endif
242
243 /* We could try workaround this lookup, but not trivial. */
244 for (bScreen *screen = static_cast<bScreen *>(G_MAIN->screens.first); screen;
245 screen = static_cast<bScreen *>(screen->id.next))
246 {
247 IDProperty *properties = static_cast<IDProperty *>(ptr->data);
248 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
249 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
250 if (region->runtime->gizmo_map) {
251 wmGizmoMap *gzmap = region->runtime->gizmo_map;
253 LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
254 if (gz->properties == properties) {
255 return gz;
256 }
257 }
258 }
259 }
260 }
261 }
262 }
263 return nullptr;
264}
265
266static StructRNA *rna_GizmoProperties_refine(PointerRNA *ptr)
267{
268 wmGizmo *gz = rna_GizmoProperties_find_operator(ptr);
269
270 if (gz) {
271 return gz->type->srna;
272 }
273 return ptr->type;
274}
275
276static IDProperty **rna_GizmoProperties_idprops(PointerRNA *ptr)
277{
278 return (IDProperty **)&ptr->data;
279}
280
281static PointerRNA rna_Gizmo_properties_get(PointerRNA *ptr)
282{
283 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
285}
286
287/* wmGizmo.float */
288# define RNA_GIZMO_GENERIC_FLOAT_RW_DEF(func_id, member_id) \
289 static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
290 { \
291 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
292 return gz->member_id; \
293 } \
294 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \
295 { \
296 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
297 gz->member_id = value; \
298 }
299# define RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \
300 static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
301 { \
302 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
303 return gz->member_id[index]; \
304 } \
305 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \
306 { \
307 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
308 gz->member_id[index] = value; \
309 }
310/* wmGizmo.float[len] */
311# define RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \
312 static void rna_Gizmo_##func_id##_get(PointerRNA *ptr, float value[len]) \
313 { \
314 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
315 memcpy(value, gz->member_id, sizeof(float[len])); \
316 } \
317 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, const float value[len]) \
318 { \
319 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
320 memcpy(gz->member_id, value, sizeof(float[len])); \
321 }
322
323/* wmGizmo.flag */
324# define RNA_GIZMO_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \
325 static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
326 { \
327 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
328 return (gz->member_id & flag_value) != 0; \
329 } \
330 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \
331 { \
332 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
333 SET_FLAG_FROM_TEST(gz->member_id, value, flag_value); \
334 }
335
336/* wmGizmo.flag (negative) */
337# define RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \
338 static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
339 { \
340 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
341 return (gz->member_id & flag_value) == 0; \
342 } \
343 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \
344 { \
345 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
346 SET_FLAG_FROM_TEST(gz->member_id, !value, flag_value); \
347 }
348
349# define RNA_GIZMO_FLAG_RO_DEF(func_id, member_id, flag_value) \
350 static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
351 { \
352 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
353 return (gz->member_id & flag_value) != 0; \
354 }
355
356RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3);
357RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3);
358
359RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3);
360RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3);
361
362RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16);
363RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16);
364RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16);
365
366static void rna_Gizmo_matrix_world_get(PointerRNA *ptr, float value[16])
367{
368 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
369 WM_gizmo_calc_matrix_final(gz, (float(*)[4])value);
370}
371
372RNA_GIZMO_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis);
373RNA_GIZMO_GENERIC_FLOAT_RW_DEF(line_width, line_width);
374RNA_GIZMO_GENERIC_FLOAT_RW_DEF(select_bias, select_bias);
375
376RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_GIZMO_DRAW_HOVER);
377RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_GIZMO_DRAW_MODAL);
378RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_GIZMO_DRAW_VALUE);
379RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE);
380RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_GIZMO_DRAW_NO_SCALE);
381RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_GIZMO_HIDDEN);
382RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_select, flag, WM_GIZMO_HIDDEN_SELECT);
383RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_keymap, flag, WM_GIZMO_HIDDEN_KEYMAP);
384RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_GIZMO_MOVE_CURSOR);
385RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_GIZMO_SELECT_BACKGROUND);
386RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_operator_tool_properties,
387 flag,
389RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_event_handle_all, flag, WM_GIZMO_EVENT_HANDLE_ALL);
390RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_tooltip, flag, WM_GIZMO_NO_TOOLTIP);
391
392/* wmGizmo.state */
393RNA_GIZMO_FLAG_RO_DEF(state_is_highlight, state, WM_GIZMO_STATE_HIGHLIGHT);
394RNA_GIZMO_FLAG_RO_DEF(state_is_modal, state, WM_GIZMO_STATE_MODAL);
395RNA_GIZMO_FLAG_RO_DEF(state_select, state, WM_GIZMO_STATE_SELECT);
396
397static void rna_Gizmo_state_select_set(PointerRNA *ptr, bool value)
398{
399 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
400 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
401 WM_gizmo_select_set(gzgroup->parent_gzmap, gz, value);
402}
403
404static PointerRNA rna_Gizmo_group_get(PointerRNA *ptr)
405{
406 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
407 return RNA_pointer_create_with_parent(*ptr, &RNA_GizmoGroup, gz->parent_gzgroup);
408}
409
410# ifdef WITH_PYTHON
411
412static bool rna_Gizmo_unregister(Main *bmain, StructRNA *type);
413extern void BPY_RNA_gizmo_wrapper(wmGizmoType *gzgt, void *userdata);
414
415static StructRNA *rna_Gizmo_register(Main *bmain,
417 void *data,
418 const char *identifier,
419 StructValidateFunc validate,
422{
423 const char *error_prefix = "Registering gizmo class:";
424 struct {
425 char idname[MAX_NAME];
426 } temp_buffers;
427
428 wmGizmoType dummy_gt = {nullptr};
429 wmGizmo dummy_gizmo = {nullptr};
430
431 /* Two sets of functions. */
432 bool have_function[8];
433
434 /* setup dummy gizmo & gizmo type to store static properties in */
435 dummy_gizmo.type = &dummy_gt;
436 dummy_gt.idname = temp_buffers.idname;
437 PointerRNA dummy_gizmo_ptr = RNA_pointer_create_discrete(nullptr, &RNA_Gizmo, &dummy_gizmo);
438
439 /* Clear so we can detect if it's left unset. */
440 temp_buffers.idname[0] = '\0';
441
442 /* validate the python class */
443 if (validate(&dummy_gizmo_ptr, data, have_function) != 0) {
444 return nullptr;
445 }
446
447 if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
449 RPT_ERROR,
450 "%s '%s' is too long, maximum length is %d",
451 error_prefix,
452 identifier,
453 int(sizeof(temp_buffers.idname)));
454 return nullptr;
455 }
456
457 /* check if we have registered this gizmo type before, and remove it */
458 {
459 const wmGizmoType *gzt = WM_gizmotype_find(dummy_gt.idname, true);
460 if (gzt) {
462 RPT_INFO,
463 "%s '%s', bl_idname '%s' has been registered before, unregistering previous",
464 error_prefix,
465 identifier,
466 dummy_gt.idname);
467
468 StructRNA *srna = gzt->rna_ext.srna;
469 if (!(srna && rna_Gizmo_unregister(bmain, srna))) {
471 RPT_ERROR,
472 "%s '%s', bl_idname '%s' %s",
473 error_prefix,
474 identifier,
475 dummy_gt.idname,
476 srna ? "is built-in" : "could not be unregistered");
477 return nullptr;
478 }
479 }
480 }
482 return nullptr;
483 }
484
485 { /* allocate the idname */
486 /* For multiple strings see GizmoGroup. */
487 dummy_gt.idname = BLI_strdup(temp_buffers.idname);
488 }
489
490 /* create a new gizmo type */
491 dummy_gt.rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummy_gt.idname, &RNA_Gizmo);
492 /* gizmo properties are registered separately */
494 dummy_gt.rna_ext.data = data;
495 dummy_gt.rna_ext.call = call;
496 dummy_gt.rna_ext.free = free;
497
498 {
499 int i = 0;
500 dummy_gt.draw = (have_function[i++]) ? rna_gizmo_draw_cb : nullptr;
501 dummy_gt.draw_select = (have_function[i++]) ? rna_gizmo_draw_select_cb : nullptr;
502 dummy_gt.test_select = (have_function[i++]) ? rna_gizmo_test_select_cb : nullptr;
503 dummy_gt.modal = (have_function[i++]) ? rna_gizmo_modal_cb : nullptr;
504 // dummy_gt.property_update = (have_function[i++]) ? rna_gizmo_property_update : nullptr;
505 // dummy_gt.position_get = (have_function[i++]) ? rna_gizmo_position_get : nullptr;
506 dummy_gt.setup = (have_function[i++]) ? rna_gizmo_setup_cb : nullptr;
507 dummy_gt.invoke = (have_function[i++]) ? rna_gizmo_invoke_cb : nullptr;
508 dummy_gt.exit = (have_function[i++]) ? rna_gizmo_exit_cb : nullptr;
509 dummy_gt.select_refresh = (have_function[i++]) ? rna_gizmo_select_refresh_cb : nullptr;
510
511 BLI_assert(i == ARRAY_SIZE(have_function));
512 }
513
515
516 /* update while blender is running */
518
519 return dummy_gt.rna_ext.srna;
520}
521
522static bool rna_Gizmo_unregister(Main *bmain, StructRNA *type)
523{
524 wmGizmoType *gzt = static_cast<wmGizmoType *>(RNA_struct_blender_type_get(type));
525
526 if (!gzt) {
527 return false;
528 }
529
530 WM_gizmotype_remove_ptr(nullptr, bmain, gzt);
531
532 /* Free extension after removing instances so `__del__` doesn't crash, see: #85567. */
535
536 /* Free gizmo group after the extension as it owns the identifier memory. */
538
540 return true;
541}
542
543static void **rna_Gizmo_instance(PointerRNA *ptr)
544{
545 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
546 return &gz->py_instance;
547}
548
549# endif /* WITH_PYTHON */
550
551static StructRNA *rna_Gizmo_refine(PointerRNA *gz_ptr)
552{
553 wmGizmo *gz = static_cast<wmGizmo *>(gz_ptr->data);
554 return (gz->type && gz->type->rna_ext.srna) ? gz->type->rna_ext.srna : &RNA_Gizmo;
555}
556
558
559/* -------------------------------------------------------------------- */
562
563static wmGizmoGroupType *rna_GizmoGroupProperties_find_gizmo_group_type(PointerRNA *ptr)
564{
565 IDProperty *properties = (IDProperty *)ptr->data;
566 wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(properties->name, false);
567 return gzgt;
568}
569
570static StructRNA *rna_GizmoGroupProperties_refine(PointerRNA *ptr)
571{
572 wmGizmoGroupType *gzgt = rna_GizmoGroupProperties_find_gizmo_group_type(ptr);
573
574 if (gzgt) {
575 return gzgt->srna;
576 }
577 return ptr->type;
578}
579
580static IDProperty **rna_GizmoGroupProperties_idprops(PointerRNA *ptr)
581{
582 return (IDProperty **)&ptr->data;
583}
584
585static wmGizmo *rna_GizmoGroup_gizmo_new(wmGizmoGroup *gzgroup,
587 const char *idname)
588{
589 const wmGizmoType *gzt = WM_gizmotype_find(idname, true);
590 if (gzt == nullptr) {
591 BKE_reportf(reports, RPT_ERROR, "GizmoType '%s' not known", idname);
592 return nullptr;
593 }
594 if ((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0) {
595 /* Allow for neither callbacks to be set, while this doesn't seem like a valid use case,
596 * there may be rare situations where a developer wants a gizmo to be draw-only. */
597 if ((gzt->test_select == nullptr) && (gzt->draw_select != nullptr)) {
599 RPT_ERROR,
600 "GizmoType '%s' is for a 3D gizmo-group. "
601 "The 'draw_select' callback is set where only 'test_select' will be used.",
602 idname);
603 return nullptr;
604 }
605 }
606 wmGizmo *gz = WM_gizmo_new_ptr(gzt, gzgroup, nullptr);
607 return gz;
608}
609
610static void rna_GizmoGroup_gizmo_remove(wmGizmoGroup *gzgroup, bContext *C, wmGizmo *gz)
611{
612 WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gz, C);
613}
614
615static void rna_GizmoGroup_gizmo_clear(wmGizmoGroup *gzgroup, bContext *C)
616{
617 while (gzgroup->gizmos.first) {
619 &gzgroup->gizmos, gzgroup->parent_gzmap, static_cast<wmGizmo *>(gzgroup->gizmos.first), C);
620 }
621}
622
623static void rna_GizmoGroup_name_get(PointerRNA *ptr, char *value)
624{
625 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(ptr->data);
626 strcpy(value, gzgroup->type->name);
627}
628
629static int rna_GizmoGroup_name_length(PointerRNA *ptr)
630{
631 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(ptr->data);
632 return strlen(gzgroup->type->name);
633}
634
635/* just to work around 'const char *' warning and to ensure this is a python op */
636static void rna_GizmoGroup_bl_idname_set(PointerRNA *ptr, const char *value)
637{
638 wmGizmoGroup *data = static_cast<wmGizmoGroup *>(ptr->data);
639 char *str = (char *)data->type->idname;
640 if (!str[0]) {
641 /* Calling UTF8 copy is disputable since registering ensures the value isn't truncated.
642 * Use a UTF8 copy to ensure truncating never causes an incomplete UTF8 sequence,
643 * even before registration. */
645 }
646 else {
647 BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
648 }
649}
650
651static void rna_GizmoGroup_bl_label_set(PointerRNA *ptr, const char *value)
652{
653 wmGizmoGroup *data = static_cast<wmGizmoGroup *>(ptr->data);
654 char *str = (char *)data->type->name;
655 if (!str[0]) {
657 }
658 else {
659 BLI_assert_msg(0, "setting the bl_label on a non-builtin operator");
660 }
661}
662
663# ifdef WITH_PYTHON
664
665static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *gzgt)
666{
667
668 extern FunctionRNA rna_GizmoGroup_poll_func;
669
670 ParameterList list;
671 FunctionRNA *func;
672 void *ret;
673 bool visible;
674
675 PointerRNA ptr = RNA_pointer_create_discrete(nullptr, gzgt->rna_ext.srna, nullptr); /* dummy */
676 func = &rna_GizmoGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
677
678 RNA_parameter_list_create(&list, &ptr, func);
679 RNA_parameter_set_lookup(&list, "context", &C);
680 gzgt->rna_ext.call((bContext *)C, &ptr, func, &list);
681
682 RNA_parameter_get_lookup(&list, "visible", &ret);
683 visible = *(bool *)ret;
684
686
687 return visible;
688}
689
690static void rna_gizmogroup_setup_cb(const bContext *C, wmGizmoGroup *gzgroup)
691{
692 extern FunctionRNA rna_GizmoGroup_setup_func;
693
694 ParameterList list;
695 FunctionRNA *func;
696
698 nullptr, gzgroup->type->rna_ext.srna, gzgroup);
699 func = &rna_GizmoGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */
700
701 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
702 RNA_parameter_set_lookup(&list, "context", &C);
703 gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
704
706}
707
708static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *gzgt, wmKeyConfig *config)
709{
710 extern FunctionRNA rna_GizmoGroup_setup_keymap_func;
711 void *ret;
712
713 ParameterList list;
714 FunctionRNA *func;
715
716 PointerRNA ptr = RNA_pointer_create_discrete(nullptr, gzgt->rna_ext.srna, nullptr); /* dummy */
717 func =
718 &rna_GizmoGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */
719
720 RNA_parameter_list_create(&list, &ptr, func);
721 RNA_parameter_set_lookup(&list, "keyconfig", &config);
722 gzgt->rna_ext.call(nullptr, &ptr, func, &list);
723
724 RNA_parameter_get_lookup(&list, "keymap", &ret);
725 wmKeyMap *keymap = *(wmKeyMap **)ret;
726
728
729 return keymap;
730}
731
732static void rna_gizmogroup_refresh_cb(const bContext *C, wmGizmoGroup *gzgroup)
733{
734 extern FunctionRNA rna_GizmoGroup_refresh_func;
735
736 ParameterList list;
737 FunctionRNA *func;
738
740 nullptr, gzgroup->type->rna_ext.srna, gzgroup);
741 func = &rna_GizmoGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */
742
743 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
744 RNA_parameter_set_lookup(&list, "context", &C);
745 gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
746
748}
749
750static void rna_gizmogroup_draw_prepare_cb(const bContext *C, wmGizmoGroup *gzgroup)
751{
752 extern FunctionRNA rna_GizmoGroup_draw_prepare_func;
753
754 ParameterList list;
755 FunctionRNA *func;
756
758 nullptr, gzgroup->type->rna_ext.srna, gzgroup);
759 func =
760 &rna_GizmoGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */
761
762 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
763 RNA_parameter_set_lookup(&list, "context", &C);
764 gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
765
767}
768
769static void rna_gizmogroup_invoke_prepare_cb(const bContext *C,
770 wmGizmoGroup *gzgroup,
771 wmGizmo *gz,
772 const wmEvent *event)
773{
774 extern FunctionRNA rna_GizmoGroup_invoke_prepare_func;
775
776 ParameterList list;
777 FunctionRNA *func;
778
780 nullptr, gzgroup->type->rna_ext.srna, gzgroup);
781 /* Reference `RNA_struct_find_function(&wgroupr, "invoke_prepare")` directly. */
782 func = &rna_GizmoGroup_invoke_prepare_func;
783
784 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
785 RNA_parameter_set_lookup(&list, "context", &C);
786 RNA_parameter_set_lookup(&list, "gizmo", &gz);
787 RNA_parameter_set_lookup(&list, "event", &event);
788 gzgroup->type->rna_ext.call((bContext *)C, &gzgroup_ptr, func, &list);
789
791}
792
793extern void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata);
794static bool rna_GizmoGroup_unregister(Main *bmain, StructRNA *type);
795
796static StructRNA *rna_GizmoGroup_register(Main *bmain,
798 void *data,
799 const char *identifier,
800 StructValidateFunc validate,
803{
804 const char *error_prefix = "Registering gizmogroup class:";
805 struct {
806 char name[MAX_NAME];
807 char idname[MAX_NAME];
808 } temp_buffers;
809
810 wmGizmoGroupType dummy_wgt = {nullptr};
811 wmGizmoGroup dummy_gizmo_group = {nullptr};
812
813 /* Two sets of functions. */
814 bool have_function[6];
815
816 /* setup dummy gizmogroup & gizmogroup type to store static properties in */
817 dummy_gizmo_group.type = &dummy_wgt;
818 dummy_wgt.name = temp_buffers.name;
819 dummy_wgt.idname = temp_buffers.idname;
820
821 PointerRNA wgptr = RNA_pointer_create_discrete(nullptr, &RNA_GizmoGroup, &dummy_gizmo_group);
822
823 /* Clear so we can detect if it's left unset. */
824 temp_buffers.idname[0] = temp_buffers.name[0] = '\0';
825
826 /* validate the python class */
827 if (validate(&wgptr, data, have_function) != 0) {
828 return nullptr;
829 }
830
831 if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
833 RPT_ERROR,
834 "%s '%s' is too long, maximum length is %d",
835 error_prefix,
836 identifier,
837 int(sizeof(temp_buffers.idname)));
838 return nullptr;
839 }
840
841 /* check if the area supports widgets */
842 wmGizmoMapType_Params wmap_params{};
843 wmap_params.spaceid = dummy_wgt.gzmap_params.spaceid;
844 wmap_params.regionid = dummy_wgt.gzmap_params.regionid;
845
846 wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&wmap_params);
847 if (gzmap_type == nullptr) {
848 BKE_reportf(reports, RPT_ERROR, "%s area type does not support gizmos", error_prefix);
849 return nullptr;
850 }
851
852 /* check if we have registered this gizmogroup type before, and remove it */
853 {
854 wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(dummy_wgt.idname, true);
855 if (gzgt) {
856 StructRNA *srna = gzgt->rna_ext.srna;
857 if (!(srna && rna_GizmoGroup_unregister(bmain, srna))) {
859 RPT_ERROR,
860 "%s '%s', bl_idname '%s' %s",
861 error_prefix,
862 identifier,
863 dummy_wgt.idname,
864 srna ? "is built-in" : "could not be unregistered");
865 return nullptr;
866 }
867 }
868 }
870 return nullptr;
871 }
872
873 { /* allocate the idname */
874 const char *strings[] = {
875 temp_buffers.idname,
876 temp_buffers.name,
877 };
878 char *strings_table[ARRAY_SIZE(strings)];
880 '\0', strings_table, strings, ARRAY_SIZE(strings));
881
882 dummy_wgt.idname = strings_table[0]; /* allocated string stored here */
883 dummy_wgt.name = strings_table[1];
884 BLI_STATIC_ASSERT(ARRAY_SIZE(strings) == 2, "Unexpected number of strings")
885 }
886
887 /* create a new gizmogroup type */
888 dummy_wgt.rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummy_wgt.idname, &RNA_GizmoGroup);
889
890 /* Gizmo group properties are registered separately. */
892
893 dummy_wgt.rna_ext.data = data;
894 dummy_wgt.rna_ext.call = call;
895 dummy_wgt.rna_ext.free = free;
896
897 /* We used to register widget group types like this, now we do it similar to
898 * operator types. Thus we should be able to do the same as operator types now. */
899 dummy_wgt.poll = (have_function[0]) ? rna_gizmogroup_poll_cb : nullptr;
900 dummy_wgt.setup_keymap = (have_function[1]) ? rna_gizmogroup_setup_keymap_cb : nullptr;
901 dummy_wgt.setup = (have_function[2]) ? rna_gizmogroup_setup_cb : nullptr;
902 dummy_wgt.refresh = (have_function[3]) ? rna_gizmogroup_refresh_cb : nullptr;
903 dummy_wgt.draw_prepare = (have_function[4]) ? rna_gizmogroup_draw_prepare_cb : nullptr;
904 dummy_wgt.invoke_prepare = (have_function[5]) ? rna_gizmogroup_invoke_prepare_cb : nullptr;
905
907 (void *)&dummy_wgt);
908
909 {
910 const char *owner_id = RNA_struct_state_owner_get();
911 if (owner_id) {
912 STRNCPY(gzgt->owner_id, owner_id);
913 }
914 }
915
917 WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type);
918
919 /* update while blender is running */
921 }
922
923 return dummy_wgt.rna_ext.srna;
924}
925
926static bool rna_GizmoGroup_unregister(Main *bmain, StructRNA *type)
927{
929
930 if (!gzgt) {
931 return false;
932 }
933
935
936 /* Free extension after removing instances so `__del__` doesn't crash, see: #85567. */
939
940 /* Free gizmo group after the extension as it owns the identifier memory. */
942
944 return true;
945}
946
947static void **rna_GizmoGroup_instance(PointerRNA *ptr)
948{
949 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(ptr->data);
950 return &gzgroup->py_instance;
951}
952
953# endif /* WITH_PYTHON */
954
955static StructRNA *rna_GizmoGroup_refine(PointerRNA *gzgroup_ptr)
956{
957 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(gzgroup_ptr->data);
958 return (gzgroup->type && gzgroup->type->rna_ext.srna) ? gzgroup->type->rna_ext.srna :
959 &RNA_GizmoGroup;
960}
961
962static void rna_GizmoGroup_gizmos_begin(CollectionPropertyIterator *iter, PointerRNA *gzgroup_ptr)
963{
964 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(gzgroup_ptr->data);
965 rna_iterator_listbase_begin(iter, gzgroup_ptr, &gzgroup->gizmos, nullptr);
966}
967
969
970#else /* RNA_RUNTIME */
971
972/* GizmoGroup.gizmos */
973static void rna_def_gizmos(BlenderRNA *brna, PropertyRNA *cprop)
974{
975 StructRNA *srna;
976
977 FunctionRNA *func;
978 PropertyRNA *parm;
979
980 RNA_def_property_srna(cprop, "Gizmos");
981 srna = RNA_def_struct(brna, "Gizmos", nullptr);
982 RNA_def_struct_sdna(srna, "wmGizmoGroup");
983 RNA_def_struct_ui_text(srna, "Gizmos", "Collection of gizmos");
984
985 func = RNA_def_function(srna, "new", "rna_GizmoGroup_gizmo_new");
986 RNA_def_function_ui_description(func, "Add gizmo");
988 parm = RNA_def_string(func, "type", "Type", 0, "", "Gizmo identifier"); /* optional */
990 parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo");
991 RNA_def_function_return(func, parm);
992
993 func = RNA_def_function(srna, "remove", "rna_GizmoGroup_gizmo_remove");
995 RNA_def_function_ui_description(func, "Delete gizmo");
996 parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo");
999
1000 func = RNA_def_function(srna, "clear", "rna_GizmoGroup_gizmo_clear");
1002 RNA_def_function_ui_description(func, "Delete all gizmos");
1003}
1004
1005static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop)
1006{
1007 StructRNA *srna;
1008 PropertyRNA *prop;
1009
1010 FunctionRNA *func;
1011 PropertyRNA *parm;
1012
1013 RNA_def_property_srna(cprop, "Gizmo");
1014 srna = RNA_def_struct(brna, "Gizmo", nullptr);
1015 RNA_def_struct_sdna(srna, "wmGizmo");
1016 RNA_def_struct_ui_text(srna, "Gizmo", "Collection of gizmos");
1017 RNA_def_struct_refine_func(srna, "rna_Gizmo_refine");
1018
1019# ifdef WITH_PYTHON
1021 srna, "rna_Gizmo_register", "rna_Gizmo_unregister", "rna_Gizmo_instance");
1022# endif
1024
1025 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1027 RNA_def_property_struct_type(prop, "GizmoProperties");
1028 RNA_def_property_ui_text(prop, "Properties", "");
1029 RNA_def_property_pointer_funcs(prop, "rna_Gizmo_properties_get", nullptr, nullptr, nullptr);
1030
1031 /* -------------------------------------------------------------------- */
1032 /* Registerable Variables */
1033
1034 RNA_define_verify_sdna(false); /* not in sdna */
1035
1036 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1037 RNA_def_property_string_sdna(prop, nullptr, "type->idname");
1039 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Gizmo_bl_idname_set");
1040 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1042
1043 RNA_define_verify_sdna(true); /* not in sdna */
1044
1045 /* wmGizmo.draw */
1046 func = RNA_def_function(srna, "draw", nullptr);
1049 parm = RNA_def_pointer(func, "context", "Context", "", "");
1051
1052 /* wmGizmo.draw_select */
1053 func = RNA_def_function(srna, "draw_select", nullptr);
1056 parm = RNA_def_pointer(func, "context", "Context", "", "");
1058 parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
1059
1060 /* wmGizmo.test_select */
1061 func = RNA_def_function(srna, "test_select", nullptr);
1064 parm = RNA_def_pointer(func, "context", "Context", "", "");
1066 parm = RNA_def_int_array(func,
1067 "location",
1068 2,
1069 nullptr,
1070 INT_MIN,
1071 INT_MAX,
1072 "Location",
1073 "Region coordinates",
1074 INT_MIN,
1075 INT_MAX);
1077 parm = RNA_def_int(
1078 func, "intersect_id", -1, -1, INT_MAX, "", "Use -1 to skip this gizmo", -1, INT_MAX);
1079 RNA_def_function_return(func, parm);
1080
1081 /* wmGizmo.handler */
1082 static const EnumPropertyItem tweak_actions[] = {
1083 {WM_GIZMO_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""},
1084 {WM_GIZMO_TWEAK_SNAP, "SNAP", 0, "Snap", ""},
1085 {0, nullptr, 0, nullptr, nullptr},
1086 };
1087 func = RNA_def_function(srna, "modal", nullptr);
1090 parm = RNA_def_pointer(func, "context", "Context", "", "");
1092 parm = RNA_def_pointer(func, "event", "Event", "", "");
1094 /* TODO: should be a enum-flag. */
1095 parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", "");
1097 parm = RNA_def_enum_flag(
1098 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1099 RNA_def_function_return(func, parm);
1100 /* wmGizmo.property_update */
1101 /* TODO */
1102
1103 /* wmGizmo.setup */
1104 func = RNA_def_function(srna, "setup", nullptr);
1107
1108 /* wmGizmo.invoke */
1109 func = RNA_def_function(srna, "invoke", nullptr);
1112 parm = RNA_def_pointer(func, "context", "Context", "", "");
1114 parm = RNA_def_pointer(func, "event", "Event", "", "");
1116 parm = RNA_def_enum_flag(
1117 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1118 RNA_def_function_return(func, parm);
1119
1120 /* wmGizmo.exit */
1121 func = RNA_def_function(srna, "exit", nullptr);
1124 parm = RNA_def_pointer(func, "context", "Context", "", "");
1126 parm = RNA_def_boolean(func, "cancel", false, "Cancel, otherwise confirm", "");
1128
1129 /* wmGizmo.cursor_get */
1130 /* TODO */
1131
1132 /* wmGizmo.select_refresh */
1133 func = RNA_def_function(srna, "select_refresh", nullptr);
1136
1137 /* -------------------------------------------------------------------- */
1138 /* Instance Variables */
1139
1140 prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
1142 RNA_def_property_struct_type(prop, "GizmoGroup");
1143 RNA_def_property_pointer_funcs(prop, "rna_Gizmo_group_get", nullptr, nullptr, nullptr);
1144 RNA_def_property_ui_text(prop, "", "Gizmo group this gizmo is a member of");
1145
1146 /* Color & Alpha */
1147 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1148 RNA_def_property_array(prop, 3);
1149 RNA_def_property_float_funcs(prop, "rna_Gizmo_color_get", "rna_Gizmo_color_set", nullptr);
1150
1151 prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
1152 RNA_def_property_ui_text(prop, "Alpha", "");
1153 RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_get", "rna_Gizmo_alpha_set", nullptr);
1154 RNA_def_property_range(prop, 0.0f, 1.0f);
1155 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1156
1157 /* Color & Alpha (highlight) */
1158 prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR);
1159 RNA_def_property_array(prop, 3);
1160 RNA_def_property_float_funcs(prop, "rna_Gizmo_color_hi_get", "rna_Gizmo_color_hi_set", nullptr);
1161
1162 prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE);
1163 RNA_def_property_ui_text(prop, "Alpha", "");
1164 RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_hi_get", "rna_Gizmo_alpha_hi_set", nullptr);
1165 RNA_def_property_range(prop, 0.0f, 1.0f);
1166 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1167
1168 prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX);
1170 RNA_def_property_ui_text(prop, "Space Matrix", "");
1172 prop, "rna_Gizmo_matrix_space_get", "rna_Gizmo_matrix_space_set", nullptr);
1173 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1174
1175 prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
1177 RNA_def_property_ui_text(prop, "Basis Matrix", "");
1179 prop, "rna_Gizmo_matrix_basis_get", "rna_Gizmo_matrix_basis_set", nullptr);
1180 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1181
1182 prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX);
1184 RNA_def_property_ui_text(prop, "Offset Matrix", "");
1186 prop, "rna_Gizmo_matrix_offset_get", "rna_Gizmo_matrix_offset_set", nullptr);
1187 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1188
1189 prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
1192 RNA_def_property_ui_text(prop, "Final World Matrix", "");
1193 RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_world_get", nullptr, nullptr);
1194
1195 prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE);
1196 RNA_def_property_ui_text(prop, "Scale Basis", "");
1198 prop, "rna_Gizmo_scale_basis_get", "rna_Gizmo_scale_basis_set", nullptr);
1199 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1200 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1201
1202 prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL);
1203 RNA_def_property_ui_text(prop, "Line Width", "");
1205 prop, "rna_Gizmo_line_width_get", "rna_Gizmo_line_width_set", nullptr);
1206 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1207 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1208
1209 prop = RNA_def_property(srna, "select_bias", PROP_FLOAT, PROP_NONE);
1210 RNA_def_property_ui_text(prop, "Select Bias", "Depth bias used for selection");
1212 prop, "rna_Gizmo_select_bias_get", "rna_Gizmo_select_bias_set", nullptr);
1214
1215 /* wmGizmo.flag */
1216 /* WM_GIZMO_HIDDEN */
1217 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1218 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_flag_hide_get", "rna_Gizmo_flag_hide_set");
1219 RNA_def_property_ui_text(prop, "Hide", "");
1220 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1221 /* WM_GIZMO_HIDDEN_SELECT */
1222 prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
1224 prop, "rna_Gizmo_flag_hide_select_get", "rna_Gizmo_flag_hide_select_set");
1225 RNA_def_property_ui_text(prop, "Hide Select", "");
1226 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1227 /* WM_GIZMO_HIDDEN_KEYMAP */
1228 prop = RNA_def_property(srna, "hide_keymap", PROP_BOOLEAN, PROP_NONE);
1230 prop, "rna_Gizmo_flag_hide_keymap_get", "rna_Gizmo_flag_hide_keymap_set");
1231 RNA_def_property_ui_text(prop, "Hide Keymap", "Ignore the key-map for this gizmo");
1232 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1233 /* WM_GIZMO_MOVE_CURSOR */
1234 prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE);
1236 prop, "rna_Gizmo_flag_use_grab_cursor_get", "rna_Gizmo_flag_use_grab_cursor_set");
1237 RNA_def_property_ui_text(prop, "Grab Cursor", "");
1238 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1239
1240 /* WM_GIZMO_DRAW_HOVER */
1241 prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE);
1243 prop, "rna_Gizmo_flag_use_draw_hover_get", "rna_Gizmo_flag_use_draw_hover_set");
1244 RNA_def_property_ui_text(prop, "Show Hover", "");
1245 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1246 /* WM_GIZMO_DRAW_MODAL */
1247 prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE);
1249 prop, "rna_Gizmo_flag_use_draw_modal_get", "rna_Gizmo_flag_use_draw_modal_set");
1250 RNA_def_property_ui_text(prop, "Show Active", "Show while dragging");
1251 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1252 /* WM_GIZMO_DRAW_VALUE */
1253 prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE);
1255 prop, "rna_Gizmo_flag_use_draw_value_get", "rna_Gizmo_flag_use_draw_value_set");
1257 prop, "Show Value", "Show an indicator for the current value while dragging");
1258 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1259 /* WM_GIZMO_DRAW_OFFSET_SCALE */
1260 prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE);
1262 "rna_Gizmo_flag_use_draw_offset_scale_get",
1263 "rna_Gizmo_flag_use_draw_offset_scale_set");
1265 prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)");
1266 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1267 /* WM_GIZMO_DRAW_NO_SCALE (negated) */
1268 prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE);
1270 prop, "rna_Gizmo_flag_use_draw_scale_get", "rna_Gizmo_flag_use_draw_scale_set");
1272 RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix");
1273 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1274
1275 /* WM_GIZMO_SELECT_BACKGROUND */
1276 prop = RNA_def_property(srna, "use_select_background", PROP_BOOLEAN, PROP_NONE);
1278 "rna_Gizmo_flag_use_select_background_get",
1279 "rna_Gizmo_flag_use_select_background_set");
1280 RNA_def_property_ui_text(prop, "Select Background", "Don't write into the depth buffer");
1281 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1282
1283 /* WM_GIZMO_OPERATOR_TOOL_INIT */
1284 prop = RNA_def_property(srna, "use_operator_tool_properties", PROP_BOOLEAN, PROP_NONE);
1286 "rna_Gizmo_flag_use_operator_tool_properties_get",
1287 "rna_Gizmo_flag_use_operator_tool_properties_set");
1289 prop,
1290 "Tool Property Init",
1291 "Merge active tool properties on activation (does not overwrite existing)");
1292 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1293
1294 /* WM_GIZMO_EVENT_HANDLE_ALL */
1295 prop = RNA_def_property(srna, "use_event_handle_all", PROP_BOOLEAN, PROP_NONE);
1297 prop, "rna_Gizmo_flag_use_event_handle_all_get", "rna_Gizmo_flag_use_event_handle_all_set");
1299 "Handle All Events",
1300 "When highlighted, "
1301 "do not pass events through to be handled by other keymaps");
1302 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1303
1304 /* WM_GIZMO_NO_TOOLTIP (negated) */
1305 prop = RNA_def_property(srna, "use_tooltip", PROP_BOOLEAN, PROP_NONE);
1307 prop, "rna_Gizmo_flag_use_tooltip_get", "rna_Gizmo_flag_use_tooltip_set");
1309 RNA_def_property_ui_text(prop, "Use Tooltip", "Use tooltips when hovering over this gizmo");
1310 /* No update needed. */
1311
1312 /* wmGizmo.state (readonly) */
1313 /* WM_GIZMO_STATE_HIGHLIGHT */
1314 prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE);
1315 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_highlight_get", nullptr);
1316 RNA_def_property_ui_text(prop, "Highlight", "");
1318 /* WM_GIZMO_STATE_MODAL */
1319 prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
1320 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_modal_get", nullptr);
1321 RNA_def_property_ui_text(prop, "Highlight", "");
1323 /* WM_GIZMO_STATE_SELECT */
1324 /* (note that setting is involved, needs to handle array) */
1325 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1326 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_select_get", "rna_Gizmo_state_select_set");
1327 RNA_def_property_ui_text(prop, "Select", "");
1328
1329 RNA_api_gizmo(srna);
1330
1331 srna = RNA_def_struct(brna, "GizmoProperties", nullptr);
1332 RNA_def_struct_ui_text(srna, "Gizmo Properties", "Input properties of a Gizmo");
1333 RNA_def_struct_refine_func(srna, "rna_GizmoProperties_refine");
1334 RNA_def_struct_idprops_func(srna, "rna_GizmoProperties_idprops");
1336}
1337
1339{
1340 StructRNA *srna;
1341 PropertyRNA *prop;
1342
1343 FunctionRNA *func;
1344 PropertyRNA *parm;
1345
1346 srna = RNA_def_struct(brna, "GizmoGroup", nullptr);
1348 srna, "GizmoGroup", "Storage of an operator being executed, or registered after execution");
1349 RNA_def_struct_sdna(srna, "wmGizmoGroup");
1350 RNA_def_struct_refine_func(srna, "rna_GizmoGroup_refine");
1351# ifdef WITH_PYTHON
1353 srna, "rna_GizmoGroup_register", "rna_GizmoGroup_unregister", "rna_GizmoGroup_instance");
1354# endif
1356
1357 /* -------------------------------------------------------------------- */
1358 /* Registration */
1359
1360 RNA_define_verify_sdna(false); /* not in sdna */
1361
1362 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1363 RNA_def_property_string_sdna(prop, nullptr, "type->idname");
1365 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_GizmoGroup_bl_idname_set");
1367 RNA_def_struct_name_property(srna, prop);
1368
1369 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1370 RNA_def_property_string_sdna(prop, nullptr, "type->name");
1371 RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */
1372 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_GizmoGroup_bl_label_set");
1373 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1375
1376 prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
1377 RNA_def_property_enum_sdna(prop, nullptr, "type->gzmap_params.spaceid");
1380 RNA_def_property_ui_text(prop, "Space Type", "The space where the panel is going to be used in");
1381
1382 prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
1383 RNA_def_property_enum_sdna(prop, nullptr, "type->gzmap_params.regionid");
1387 prop, "Region Type", "The region where the panel is going to be used in");
1388
1389 prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
1390 RNA_def_property_string_sdna(prop, nullptr, "type->owner_id");
1392
1393 /* bl_options */
1394 static const EnumPropertyItem gizmogroup_flag_items[] = {
1395 {WM_GIZMOGROUPTYPE_3D, "3D", 0, "3D", "Use in 3D viewport"},
1397 "SCALE",
1398 0,
1399 "Scale",
1400 "Scale to respect zoom (otherwise zoom independent display size)"},
1402 "DEPTH_3D",
1403 0,
1404 "Depth 3D",
1405 "Supports culled depth by other objects in the view"},
1406 {WM_GIZMOGROUPTYPE_SELECT, "SELECT", 0, "Select", "Supports selection"},
1407 {WM_GIZMOGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent", ""},
1409 "SHOW_MODAL_ALL",
1410 0,
1411 "Show Modal All",
1412 "Show all while interacting, as well as this group when another is being interacted with"},
1414 "EXCLUDE_MODAL",
1415 0,
1416 "Exclude Modal",
1417 "Show all except this group while interacting"},
1419 "TOOL_INIT",
1420 0,
1421 "Tool Init",
1422 "Postpone running until tool operator run (when used with a tool)"},
1424 "TOOL_FALLBACK_KEYMAP",
1425 0,
1426 "Use fallback tools keymap",
1427 "Add fallback tools keymap to this gizmo type"},
1429 "VR_REDRAWS",
1430 0,
1431 "VR Redraws",
1432 "The gizmos are made for use with virtual reality sessions and require special redraw "
1433 "management"},
1434 {0, nullptr, 0, nullptr, nullptr},
1435 };
1436 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1437 RNA_def_property_enum_sdna(prop, nullptr, "type->flag");
1438 RNA_def_property_enum_items(prop, gizmogroup_flag_items);
1440 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1441
1442 RNA_define_verify_sdna(true); /* not in sdna */
1443
1444 /* Functions */
1445
1446 /* poll */
1447 func = RNA_def_function(srna, "poll", nullptr);
1448 RNA_def_function_ui_description(func, "Test if the gizmo group can be called or not");
1450 RNA_def_function_return(func, RNA_def_boolean(func, "visible", false, "", ""));
1451 parm = RNA_def_pointer(func, "context", "Context", "", "");
1453
1454 /* setup_keymap */
1455 func = RNA_def_function(srna, "setup_keymap", nullptr);
1457 func, "Initialize keymaps for this gizmo group, use fallback keymap when not present");
1459 parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", "");
1461 /* return */
1462 parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
1464 RNA_def_function_return(func, parm);
1465
1466 /* setup */
1467 func = RNA_def_function(srna, "setup", nullptr);
1468 RNA_def_function_ui_description(func, "Create gizmos function for the gizmo group");
1470 parm = RNA_def_pointer(func, "context", "Context", "", "");
1472
1473 /* refresh */
1474 func = RNA_def_function(srna, "refresh", nullptr);
1476 func, "Refresh data (called on common state changes such as selection)");
1478 parm = RNA_def_pointer(func, "context", "Context", "", "");
1480
1481 func = RNA_def_function(srna, "draw_prepare", nullptr);
1482 RNA_def_function_ui_description(func, "Run before each redraw");
1484 parm = RNA_def_pointer(func, "context", "Context", "", "");
1486
1487 func = RNA_def_function(srna, "invoke_prepare", nullptr);
1488 RNA_def_function_ui_description(func, "Run before invoke");
1490 parm = RNA_def_pointer(func, "context", "Context", "", "");
1492 parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "");
1494
1495 /* -------------------------------------------------------------------- */
1496 /* Instance Variables */
1497
1498 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1501 prop, "rna_GizmoGroup_name_get", "rna_GizmoGroup_name_length", nullptr);
1502 RNA_def_property_ui_text(prop, "Name", "");
1503
1504 RNA_define_verify_sdna(false); /* not in sdna */
1505
1506 prop = RNA_def_property(srna, "gizmos", PROP_COLLECTION, PROP_NONE);
1507 RNA_def_property_collection_sdna(prop, nullptr, "gizmos", nullptr);
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 nullptr,
1515 nullptr,
1516 nullptr,
1517 nullptr);
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(true); /* not in sdna */
1524
1525 RNA_api_gizmogroup(srna);
1526
1527 srna = RNA_def_struct(brna, "GizmoGroupProperties", nullptr);
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
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_STATIC_ASSERT(a, msg)
Definition BLI_assert.h:83
#define BLI_assert(a)
Definition BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:53
void BLI_kdtree_nd_ free(KDTree *tree)
#define LISTBASE_FOREACH(type, var, list)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.cc:41
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:688
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
@ OPERATOR_FINISHED
#define OPERATOR_RETVAL_CHECK(ret)
void GPU_bgl_end()
Definition gpu_state.cc:360
ParameterFlag
Definition RNA_types.hh:510
@ PARM_REQUIRED
Definition RNA_types.hh:511
@ FUNC_USE_REPORTS
Definition RNA_types.hh:805
@ FUNC_NO_SELF
Definition RNA_types.hh:798
@ FUNC_REGISTER
Definition RNA_types.hh:812
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:804
@ FUNC_REGISTER_OPTIONAL
Definition RNA_types.hh:814
@ FUNC_ALLOW_WRITE
Definition RNA_types.hh:820
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
Definition RNA_types.hh:856
@ STRUCT_NO_IDPROPERTIES
Definition RNA_types.hh:854
int(*)(PointerRNA *ptr, void *data, bool *have_function) StructValidateFunc
Definition RNA_types.hh:871
@ PROP_FLOAT
Definition RNA_types.hh:152
@ PROP_BOOLEAN
Definition RNA_types.hh:150
@ PROP_ENUM
Definition RNA_types.hh:154
@ PROP_STRING
Definition RNA_types.hh:153
@ PROP_POINTER
Definition RNA_types.hh:155
@ PROP_COLLECTION
Definition RNA_types.hh:156
int(*)(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *list) StructCallbackFunc
Definition RNA_types.hh:872
void(*)(void *data) StructFreeFunc
Definition RNA_types.hh:876
PropertyFlag
Definition RNA_types.hh:286
@ PROP_THICK_WRAP
Definition RNA_types.hh:397
@ PROP_EDITABLE
Definition RNA_types.hh:292
@ PROP_ENUM_FLAG
Definition RNA_types.hh:378
@ PROP_REGISTER_OPTIONAL
Definition RNA_types.hh:386
@ PROP_NEVER_NULL
Definition RNA_types.hh:351
@ PROP_REGISTER
Definition RNA_types.hh:385
@ PROP_MATRIX
Definition RNA_types.hh:253
@ PROP_COLOR
Definition RNA_types.hh:248
@ PROP_PIXEL
Definition RNA_types.hh:236
@ PROP_NONE
Definition RNA_types.hh:221
#define C
Definition RandGen.cpp:29
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:374
#define NA_EDITED
Definition WM_types.hh:581
ReportList * reports
Definition WM_types.hh:1025
BMesh const char void * data
void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata)
void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata)
#define str(s)
#define MAX_NAME
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, PointerRNA *ptr, ListBase *lb, IteratorSkipFunc skip)
void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, const void *value)
const char * RNA_struct_state_owner_get()
ParameterList * RNA_parameter_list_create(ParameterList *parms, PointerRNA *, FunctionRNA *func)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void **r_value)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
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:21
const EnumPropertyItem rna_enum_space_type_items[]
Definition rna_space.cc:72
const EnumPropertyItem rna_enum_operator_return_items[]
Definition rna_wm.cc:584
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:909
StructCallbackFunc call
Definition RNA_types.hh:910
StructFreeFunc free
Definition RNA_types.hh:911
char name[64]
Definition DNA_ID.h:154
void * first
void * data
Definition RNA_types.hh:53
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
i
Definition text_draw.cc:230
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4227
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition wm_gizmo.cc:570
wmGizmo * WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, PointerRNA *properties)
Definition wm_gizmo.cc:85
bool WM_gizmo_select_set(wmGizmoMap *gzmap, wmGizmo *gz, bool select)
Definition wm_gizmo.cc:399
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_find(const StringRef idname, bool quiet)
wmGizmoGroupType * WM_gizmogrouptype_append_ptr(void(*wtfunc)(wmGizmoGroupType *, void *), void *userdata)
void WM_gizmo_group_type_free_ptr(wmGizmoGroupType *gzgt)
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)
void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *gzt)
const wmGizmoType * WM_gizmotype_find(const StringRef idname, bool quiet)
void WM_gizmotype_free_ptr(wmGizmoType *gzt)
uint8_t flag
Definition wm_window.cc:139