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