Blender V5.3
rna_wm_gizmo.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
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_listbase.hh"
29# include "BLI_string.hh"
30# include "BLI_string_utf8.hh"
31# include "BLI_string_utils.hh"
32
33# include "WM_api.hh"
34
35# include "ED_screen.hh"
36
37# include "UI_interface.hh"
38
39# include "BKE_context.hh"
40# include "BKE_global.hh"
41# include "BKE_main.hh"
42# include "BKE_report.hh"
43# include "BKE_screen.hh"
44# include "BKE_workspace.hh"
45
46# include "GPU_state.hh"
47
48# ifdef WITH_PYTHON
49# include "BPY_extern.hh"
50# endif
51
52namespace blender {
53
54/* -------------------------------------------------------------------- */
57
58# ifdef WITH_PYTHON
59static void rna_gizmo_draw_cb(const bContext *C, wmGizmo *gz)
60{
61 extern FunctionRNA *rna_Gizmo_draw_func;
62 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
64 FunctionRNA *func;
65 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
66 /* Reference `RNA_struct_find_function(&gz_ptr, "draw")` directly. */
67 func = rna_Gizmo_draw_func;
68 RNA_parameter_list_create(&list, &gz_ptr, func);
69 RNA_parameter_set_lookup(&list, "context", &C);
70 gzgroup->type->rna_ext.call(const_cast<bContext *>(C), &gz_ptr, func, &list);
72}
73
74static void rna_gizmo_draw_select_cb(const bContext *C, wmGizmo *gz, int select_id)
75{
76 extern FunctionRNA *rna_Gizmo_draw_select_func;
77 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
79 FunctionRNA *func;
80 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
81 /* Reference `RNA_struct_find_function(&gz_ptr, "draw_select")` directly. */
82 func = rna_Gizmo_draw_select_func;
83 RNA_parameter_list_create(&list, &gz_ptr, func);
84 RNA_parameter_set_lookup(&list, "context", &C);
85 RNA_parameter_set_lookup(&list, "select_id", &select_id);
86 gzgroup->type->rna_ext.call(const_cast<bContext *>(C), &gz_ptr, func, &list);
88}
89
90static int rna_gizmo_test_select_cb(bContext *C, wmGizmo *gz, const int location[2])
91{
92 extern FunctionRNA *rna_Gizmo_test_select_func;
93 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
95 FunctionRNA *func;
96 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
97 /* Reference `RNA_struct_find_function(&gz_ptr, "test_select")` directly. */
98 func = rna_Gizmo_test_select_func;
99 RNA_parameter_list_create(&list, &gz_ptr, func);
100 RNA_parameter_set_lookup(&list, "context", &C);
101 RNA_parameter_set_lookup(&list, "location", location);
102 gzgroup->type->rna_ext.call(C, &gz_ptr, func, &list);
103
104 void *ret;
105 RNA_parameter_get_lookup(&list, "intersect_id", &ret);
106 int intersect_id = *static_cast<int *>(ret);
107
109 return intersect_id;
110}
111
112static wmOperatorStatus rna_gizmo_modal_cb(bContext *C,
113 wmGizmo *gz,
114 const wmEvent *event,
115 eWM_GizmoFlagTweak tweak_flag)
116{
117 extern FunctionRNA *rna_Gizmo_modal_func;
118 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
120 FunctionRNA *func;
121 const int tweak_flag_int = tweak_flag;
122 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
123 /* Reference `RNA_struct_find_function(&gz_ptr, "modal")` directly. */
124 func = rna_Gizmo_modal_func;
125 RNA_parameter_list_create(&list, &gz_ptr, func);
126 RNA_parameter_set_lookup(&list, "context", &C);
127 RNA_parameter_set_lookup(&list, "event", &event);
128 RNA_parameter_set_lookup(&list, "tweak", &tweak_flag_int);
129 gzgroup->type->rna_ext.call(C, &gz_ptr, func, &list);
130
131 void *ret;
132 RNA_parameter_get_lookup(&list, "result", &ret);
133 wmOperatorStatus retval = wmOperatorStatus(*static_cast<int *>(ret));
134
136
137 OPERATOR_RETVAL_CHECK(retval);
138 return retval;
139}
140
141static void rna_gizmo_setup_cb(wmGizmo *gz)
142{
143 extern FunctionRNA *rna_Gizmo_setup_func;
144 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
146 FunctionRNA *func;
147 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
148 /* Reference `RNA_struct_find_function(&gz_ptr, "setup")` directly. */
149 func = rna_Gizmo_setup_func;
150 RNA_parameter_list_create(&list, &gz_ptr, func);
151 gzgroup->type->rna_ext.call(static_cast<bContext *>(nullptr), &gz_ptr, func, &list);
153}
154
155static wmOperatorStatus rna_gizmo_invoke_cb(bContext *C, wmGizmo *gz, const wmEvent *event)
156{
157 extern FunctionRNA *rna_Gizmo_invoke_func;
158 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
160 FunctionRNA *func;
161 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
162 /* Reference `RNA_struct_find_function(&gz_ptr, "invoke")` directly. */
163 func = rna_Gizmo_invoke_func;
164 RNA_parameter_list_create(&list, &gz_ptr, func);
165 RNA_parameter_set_lookup(&list, "context", &C);
166 RNA_parameter_set_lookup(&list, "event", &event);
167 gzgroup->type->rna_ext.call(C, &gz_ptr, func, &list);
168
169 void *ret;
170 RNA_parameter_get_lookup(&list, "result", &ret);
171 const wmOperatorStatus retval = wmOperatorStatus(*static_cast<int *>(ret));
172
174
175 OPERATOR_RETVAL_CHECK(retval);
176 return retval;
177}
178
179static void rna_gizmo_exit_cb(bContext *C, wmGizmo *gz, bool cancel)
180{
181 extern FunctionRNA *rna_Gizmo_exit_func;
182 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
184 FunctionRNA *func;
185 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
186 /* Reference `RNA_struct_find_function(&gz_ptr, "exit")` directly. */
187 func = rna_Gizmo_exit_func;
188 RNA_parameter_list_create(&list, &gz_ptr, func);
189 RNA_parameter_set_lookup(&list, "context", &C);
190 {
191 int cancel_i = cancel;
192 RNA_parameter_set_lookup(&list, "cancel", &cancel_i);
193 }
194 gzgroup->type->rna_ext.call(C, &gz_ptr, func, &list);
196}
197
198static void rna_gizmo_select_refresh_cb(wmGizmo *gz)
199{
200 extern FunctionRNA *rna_Gizmo_select_refresh_func;
201 wmGizmoGroup *gzgroup = gz->parent_gzgroup;
203 FunctionRNA *func;
204 PointerRNA gz_ptr = RNA_pointer_create_discrete(nullptr, gz->type->rna_ext.srna, gz);
205 /* Reference `RNA_struct_find_function(&gz_ptr, "select_refresh")` directly. */
206 func = rna_Gizmo_select_refresh_func;
207 RNA_parameter_list_create(&list, &gz_ptr, func);
208 gzgroup->type->rna_ext.call(static_cast<bContext *>(nullptr), &gz_ptr, func, &list);
210}
211
212# endif /* WITH_PYTHON */
213
214/* just to work around 'const char *' warning and to ensure this is a python op */
215static void rna_Gizmo_bl_idname_set(PointerRNA *ptr, const char *value)
216{
217 wmGizmo *data = static_cast<wmGizmo *>(ptr->data);
218 char *str = const_cast<char *>(data->type->idname);
219 if (!str[0]) {
220 /* Calling UTF8 copy is disputable since registering ensures the value isn't truncated.
221 * Use a UTF8 copy to ensure truncating never causes an incomplete UTF8 sequence,
222 * even before registration. */
224 }
225 else {
226 BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
227 }
228}
229
230static void rna_Gizmo_update_redraw(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
231{
232 wmGizmo *gizmo = static_cast<wmGizmo *>(ptr->data);
233 gizmo->do_draw = true;
234}
235
236static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr)
237{
238# if 0
239 wmWindowManager *wm = (wmWindowManager *)ptr->owner_id;
240# endif
241
242 /* We could try workaround this lookup, but not trivial. */
243 for (bScreen *screen = G_MAIN->screens.first(); screen;
244 screen = static_cast<bScreen *>(screen->id.next))
245 {
246 IDProperty *properties = static_cast<IDProperty *>(ptr->data);
247 for (ScrArea &area : screen->areabase) {
248 for (ARegion &region : area.regionbase) {
249 if (region.runtime->gizmo_map) {
250 wmGizmoMap *gzmap = region.runtime->gizmo_map;
251 for (wmGizmoGroup &gzgroup : *WM_gizmomap_group_list(gzmap)) {
252 for (wmGizmo &gz : gzgroup.gizmos) {
253 if (gz.properties == properties) {
254 return &gz;
255 }
256 }
257 }
258 }
259 }
260 }
261 }
262 return nullptr;
263}
264
265static StructRNA *rna_GizmoProperties_refine(PointerRNA *ptr)
266{
267 wmGizmo *gz = rna_GizmoProperties_find_operator(ptr);
268
269 if (gz) {
270 return gz->type->srna;
271 }
272 return ptr->type;
273}
274
275static IDProperty **rna_GizmoProperties_idprops(PointerRNA *ptr)
276{
277 return reinterpret_cast<IDProperty **>(&ptr->data);
278}
279
280static PointerRNA rna_Gizmo_properties_get(PointerRNA *ptr)
281{
282 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
283 return RNA_pointer_create_with_parent(*ptr, gz->type->srna, gz->properties);
284}
285
286/* wmGizmo.float */
287# define RNA_GIZMO_GENERIC_FLOAT_RW_DEF(func_id, member_id) \
288 static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
289 { \
290 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
291 return gz->member_id; \
292 } \
293 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \
294 { \
295 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
296 gz->member_id = value; \
297 }
298# define RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \
299 static float rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
300 { \
301 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
302 return gz->member_id[index]; \
303 } \
304 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, float value) \
305 { \
306 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
307 gz->member_id[index] = value; \
308 }
309/* wmGizmo.float[len] */
310# define RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \
311 static void rna_Gizmo_##func_id##_get(PointerRNA *ptr, float value[len]) \
312 { \
313 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
314 memcpy(value, gz->member_id, sizeof(float[len])); \
315 } \
316 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, const float value[len]) \
317 { \
318 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
319 memcpy(gz->member_id, value, sizeof(float[len])); \
320 }
321
322/* wmGizmo.flag */
323# define RNA_GIZMO_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \
324 static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
325 { \
326 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
327 return (gz->member_id & flag_value) != 0; \
328 } \
329 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \
330 { \
331 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
332 SET_FLAG_FROM_TEST(gz->member_id, value, flag_value); \
333 }
334
335/* wmGizmo.flag (negative) */
336# define RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(func_id, member_id, flag_value) \
337 static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
338 { \
339 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
340 return (gz->member_id & flag_value) == 0; \
341 } \
342 static void rna_Gizmo_##func_id##_set(PointerRNA *ptr, bool value) \
343 { \
344 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
345 SET_FLAG_FROM_TEST(gz->member_id, !value, flag_value); \
346 }
347
348# define RNA_GIZMO_FLAG_RO_DEF(func_id, member_id, flag_value) \
349 static bool rna_Gizmo_##func_id##_get(PointerRNA *ptr) \
350 { \
351 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data); \
352 return (gz->member_id & flag_value) != 0; \
353 }
354
355RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3);
356RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3);
357
358RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3);
359RNA_GIZMO_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3);
360
361RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_space, matrix_space, 16);
362RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16);
363RNA_GIZMO_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16);
364
365static void rna_Gizmo_matrix_world_get(PointerRNA *ptr, float value[16])
366{
367 wmGizmo *gz = static_cast<wmGizmo *>(ptr->data);
368 WM_gizmo_calc_matrix_final(gz, reinterpret_cast<float (*)[4]>(value));
369}
370
371RNA_GIZMO_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis);
372RNA_GIZMO_GENERIC_FLOAT_RW_DEF(line_width, line_width);
373RNA_GIZMO_GENERIC_FLOAT_RW_DEF(select_bias, select_bias);
374
375RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_GIZMO_DRAW_HOVER);
376RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_GIZMO_DRAW_MODAL);
377RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_GIZMO_DRAW_VALUE);
378RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE);
379RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_GIZMO_DRAW_NO_SCALE);
380RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_GIZMO_HIDDEN);
381RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_select, flag, WM_GIZMO_HIDDEN_SELECT);
382RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_keymap, flag, WM_GIZMO_HIDDEN_KEYMAP);
383RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_GIZMO_MOVE_CURSOR);
384RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_GIZMO_SELECT_BACKGROUND);
385RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_operator_tool_properties,
386 flag,
388RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_event_handle_all, flag, WM_GIZMO_EVENT_HANDLE_ALL);
389RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_tooltip, flag, WM_GIZMO_NO_TOOLTIP);
390RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_undo, flag, WM_GIZMO_NEEDS_UNDO);
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,
416 ReportList *reports,
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)) {
448 BKE_reportf(reports,
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) {
461 BKE_reportf(reports,
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))) {
470 BKE_reportf(reports,
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 }
481 if (!RNA_struct_available_or_report(reports, dummy_gt.idname)) {
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(&RNA_blender_rna_get(), dummy_gt.idname, RNA_Gizmo);
492 /* gizmo properties are registered separately */
493 RNA_def_struct_flag(dummy_gt.rna_ext.srna, STRUCT_NO_IDPROPERTIES);
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
514 WM_gizmotype_append_ptr(BPY_RNA_gizmo_wrapper, static_cast<void *>(&dummy_gt));
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. */
533 RNA_struct_free_extension(type, &gzt->rna_ext);
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 = static_cast<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 reinterpret_cast<IDProperty **>(&ptr->data);
583}
584
585static wmGizmo *rna_GizmoGroup_gizmo_new(wmGizmoGroup *gzgroup,
586 ReportList *reports,
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)) {
598 BKE_reportf(reports,
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()) {
618 WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gzgroup->gizmos.first(), C);
619 }
620}
621
622static void rna_GizmoGroup_name_get(PointerRNA *ptr, char *value)
623{
624 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(ptr->data);
625 strcpy(value, gzgroup->type->name);
626}
627
628static int rna_GizmoGroup_name_length(PointerRNA *ptr)
629{
630 wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(ptr->data);
631 return strlen(gzgroup->type->name);
632}
633
634/* just to work around 'const char *' warning and to ensure this is a python op */
635static void rna_GizmoGroup_bl_idname_set(PointerRNA *ptr, const char *value)
636{
637 wmGizmoGroup *data = static_cast<wmGizmoGroup *>(ptr->data);
638 char *str = const_cast<char *>(data->type->idname);
639 if (!str[0]) {
640 /* Calling UTF8 copy is disputable since registering ensures the value isn't truncated.
641 * Use a UTF8 copy to ensure truncating never causes an incomplete UTF8 sequence,
642 * even before registration. */
644 }
645 else {
646 BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
647 }
648}
649
650static void rna_GizmoGroup_bl_label_set(PointerRNA *ptr, const char *value)
651{
652 wmGizmoGroup *data = static_cast<wmGizmoGroup *>(ptr->data);
653 char *str = const_cast<char *>(data->type->name);
654 if (!str[0]) {
656 }
657 else {
658 BLI_assert_msg(0, "setting the bl_label on a non-builtin operator");
659 }
660}
661
662# ifdef WITH_PYTHON
663
664static bool rna_gizmogroup_poll_cb(const bContext *C, wmGizmoGroupType *gzgt)
665{
666
667 extern FunctionRNA *rna_GizmoGroup_poll_func;
668
670 FunctionRNA *func;
671 void *ret;
672 bool visible;
673
674 PointerRNA ptr = RNA_pointer_create_discrete(nullptr, gzgt->rna_ext.srna, nullptr); /* dummy */
675 func = rna_GizmoGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
676
677 RNA_parameter_list_create(&list, &ptr, func);
678 RNA_parameter_set_lookup(&list, "context", &C);
679 gzgt->rna_ext.call(const_cast<bContext *>(C), &ptr, func, &list);
680
681 RNA_parameter_get_lookup(&list, "visible", &ret);
682 visible = *static_cast<bool *>(ret);
683
685
686 return visible;
687}
688
689static void rna_gizmogroup_setup_cb(const bContext *C, wmGizmoGroup *gzgroup)
690{
691 extern FunctionRNA *rna_GizmoGroup_setup_func;
692
694 FunctionRNA *func;
695
697 nullptr, gzgroup->type->rna_ext.srna, gzgroup);
698 func = rna_GizmoGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */
699
700 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
701 RNA_parameter_set_lookup(&list, "context", &C);
702 gzgroup->type->rna_ext.call(const_cast<bContext *>(C), &gzgroup_ptr, func, &list);
703
705}
706
707static wmKeyMap *rna_gizmogroup_setup_keymap_cb(const wmGizmoGroupType *gzgt, wmKeyConfig *config)
708{
709 extern FunctionRNA *rna_GizmoGroup_setup_keymap_func;
710 void *ret;
711
713 FunctionRNA *func;
714
715 PointerRNA ptr = RNA_pointer_create_discrete(nullptr, gzgt->rna_ext.srna, nullptr); /* dummy */
716 func =
717 rna_GizmoGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */
718
719 RNA_parameter_list_create(&list, &ptr, func);
720 RNA_parameter_set_lookup(&list, "keyconfig", &config);
721 gzgt->rna_ext.call(nullptr, &ptr, func, &list);
722
723 RNA_parameter_get_lookup(&list, "keymap", &ret);
724 wmKeyMap *keymap = *static_cast<wmKeyMap **>(ret);
725
727
728 return keymap;
729}
730
731static void rna_gizmogroup_refresh_cb(const bContext *C, wmGizmoGroup *gzgroup)
732{
733 extern FunctionRNA *rna_GizmoGroup_refresh_func;
734
736 FunctionRNA *func;
737
739 nullptr, gzgroup->type->rna_ext.srna, gzgroup);
740 func = rna_GizmoGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */
741
742 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
743 RNA_parameter_set_lookup(&list, "context", &C);
744 gzgroup->type->rna_ext.call(const_cast<bContext *>(C), &gzgroup_ptr, func, &list);
745
747}
748
749static void rna_gizmogroup_draw_prepare_cb(const bContext *C, wmGizmoGroup *gzgroup)
750{
751 extern FunctionRNA *rna_GizmoGroup_draw_prepare_func;
752
754 FunctionRNA *func;
755
757 nullptr, gzgroup->type->rna_ext.srna, gzgroup);
758 func =
759 rna_GizmoGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */
760
761 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
762 RNA_parameter_set_lookup(&list, "context", &C);
763 gzgroup->type->rna_ext.call(const_cast<bContext *>(C), &gzgroup_ptr, func, &list);
764
766}
767
768static void rna_gizmogroup_invoke_prepare_cb(const bContext *C,
769 wmGizmoGroup *gzgroup,
770 wmGizmo *gz,
771 const wmEvent *event)
772{
773 extern FunctionRNA *rna_GizmoGroup_invoke_prepare_func;
774
776 FunctionRNA *func;
777
779 nullptr, gzgroup->type->rna_ext.srna, gzgroup);
780 /* Reference `RNA_struct_find_function(&wgroupr, "invoke_prepare")` directly. */
781 func = rna_GizmoGroup_invoke_prepare_func;
782
783 RNA_parameter_list_create(&list, &gzgroup_ptr, func);
784 RNA_parameter_set_lookup(&list, "context", &C);
785 RNA_parameter_set_lookup(&list, "gizmo", &gz);
786 RNA_parameter_set_lookup(&list, "event", &event);
787 gzgroup->type->rna_ext.call(const_cast<bContext *>(C), &gzgroup_ptr, func, &list);
788
790}
791
792extern void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata);
793static bool rna_GizmoGroup_unregister(Main *bmain, StructRNA *type);
794
795static StructRNA *rna_GizmoGroup_register(Main *bmain,
796 ReportList *reports,
797 void *data,
798 const char *identifier,
799 StructValidateFunc validate,
802{
803 const char *error_prefix = "Registering gizmogroup class:";
804 struct {
805 char name[MAX_NAME];
806 char idname[MAX_NAME];
807 } temp_buffers;
808
809 wmGizmoGroupType dummy_wgt = {nullptr};
810 wmGizmoGroup dummy_gizmo_group = {nullptr};
811
812 /* Two sets of functions. */
813 bool have_function[6];
814
815 /* setup dummy gizmogroup & gizmogroup type to store static properties in */
816 dummy_gizmo_group.type = &dummy_wgt;
817 dummy_wgt.name = temp_buffers.name;
818 dummy_wgt.idname = temp_buffers.idname;
819
820 PointerRNA wgptr = RNA_pointer_create_discrete(nullptr, RNA_GizmoGroup, &dummy_gizmo_group);
821
822 /* Clear so we can detect if it's left unset. */
823 temp_buffers.idname[0] = temp_buffers.name[0] = '\0';
824
825 /* validate the python class */
826 if (validate(&wgptr, data, have_function) != 0) {
827 return nullptr;
828 }
829
830 if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
831 BKE_reportf(reports,
832 RPT_ERROR,
833 "%s '%s' is too long, maximum length is %d",
834 error_prefix,
835 identifier,
836 int(sizeof(temp_buffers.idname)));
837 return nullptr;
838 }
839
840 /* check if the area supports widgets */
841 wmGizmoMapType_Params wmap_params{};
842 wmap_params.spaceid = dummy_wgt.gzmap_params.spaceid;
843 wmap_params.regionid = dummy_wgt.gzmap_params.regionid;
844
845 wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&wmap_params);
846 if (gzmap_type == nullptr) {
847 BKE_reportf(reports, RPT_ERROR, "%s area type does not support gizmos", error_prefix);
848 return nullptr;
849 }
850
851 /* check if we have registered this gizmogroup type before, and remove it */
852 {
853 wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(dummy_wgt.idname, true);
854 if (gzgt) {
855 StructRNA *srna = gzgt->rna_ext.srna;
856 if (!(srna && rna_GizmoGroup_unregister(bmain, srna))) {
857 BKE_reportf(reports,
858 RPT_ERROR,
859 "%s '%s', bl_idname '%s' %s",
860 error_prefix,
861 identifier,
862 dummy_wgt.idname,
863 srna ? "is built-in" : "could not be unregistered");
864 return nullptr;
865 }
866 }
867 }
868 if (!RNA_struct_available_or_report(reports, dummy_wgt.idname)) {
869 return nullptr;
870 }
871
872 { /* allocate the idname */
873 const char *strings[] = {
874 temp_buffers.idname,
875 temp_buffers.name,
876 };
877 char *strings_table[ARRAY_SIZE(strings)];
879 '\0', strings_table, strings, ARRAY_SIZE(strings));
880
881 dummy_wgt.idname = strings_table[0]; /* allocated string stored here */
882 dummy_wgt.name = strings_table[1];
883 BLI_STATIC_ASSERT(ARRAY_SIZE(strings) == 2, "Unexpected number of strings")
884 }
885
886 /* create a new gizmogroup type */
887 dummy_wgt.rna_ext.srna = RNA_def_struct_ptr(
888 &RNA_blender_rna_get(), dummy_wgt.idname, RNA_GizmoGroup);
889
890 /* Gizmo group properties are registered separately. */
891 RNA_def_struct_flag(dummy_wgt.rna_ext.srna, STRUCT_NO_IDPROPERTIES);
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 static_cast<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
916 if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) {
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. */
937 RNA_struct_free_extension(type, &gzgt->rna_ext);
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} // namespace blender
971
972#else /* RNA_RUNTIME */
973
974namespace blender {
975
976/* GizmoGroup.gizmos */
977static void rna_def_gizmos(BlenderRNA *brna, PropertyRNA *cprop)
978{
979 StructRNA *srna;
980
981 FunctionRNA *func;
982 PropertyRNA *parm;
983
984 RNA_def_property_srna(cprop, "Gizmos");
985 srna = RNA_def_struct(brna, "Gizmos", nullptr);
986 RNA_def_struct_sdna(srna, "wmGizmoGroup");
987 RNA_def_struct_ui_text(srna, "Gizmos", "Collection of gizmos");
988
989 func = RNA_def_function(srna, "new", "rna_GizmoGroup_gizmo_new");
990 RNA_def_function_ui_description(func, "Add gizmo");
992 parm = RNA_def_string(func, "type", "Type", 0, "", "Gizmo identifier"); /* optional */
994 parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo");
996 RNA_def_function_return(func, parm);
997
998 func = RNA_def_function(srna, "remove", "rna_GizmoGroup_gizmo_remove");
1000 RNA_def_function_ui_description(func, "Delete gizmo");
1001 parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "New gizmo");
1004
1005 func = RNA_def_function(srna, "clear", "rna_GizmoGroup_gizmo_clear");
1007 RNA_def_function_ui_description(func, "Delete all gizmos");
1008}
1009
1010static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop)
1011{
1012 StructRNA *srna;
1013 PropertyRNA *prop;
1014
1015 FunctionRNA *func;
1016 PropertyRNA *parm;
1017
1018 RNA_def_property_srna(cprop, "Gizmo");
1019 srna = RNA_def_struct(brna, "Gizmo", nullptr);
1020 RNA_def_struct_sdna(srna, "wmGizmo");
1021 RNA_def_struct_ui_text(srna, "Gizmo", "Collection of gizmos");
1022 RNA_def_struct_refine_func(srna, "rna_Gizmo_refine");
1023
1024# ifdef WITH_PYTHON
1026 srna, "rna_Gizmo_register", "rna_Gizmo_unregister", "rna_Gizmo_instance");
1027# endif
1029
1030 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1032 RNA_def_property_struct_type(prop, "GizmoProperties");
1033 RNA_def_property_ui_text(prop, "Properties", "");
1034 RNA_def_property_pointer_funcs(prop, "rna_Gizmo_properties_get", nullptr, nullptr, nullptr);
1035
1036 /* -------------------------------------------------------------------- */
1037 /* Registerable Variables */
1038
1039 RNA_define_verify_sdna(false); /* not in sdna */
1040
1041 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1042 RNA_def_property_string_sdna(prop, nullptr, "type->idname");
1044 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Gizmo_bl_idname_set");
1045 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1047
1048 RNA_define_verify_sdna(true); /* not in sdna */
1049
1050 /* wmGizmo.draw */
1051 func = RNA_def_function(srna, "draw", nullptr);
1054 parm = RNA_def_pointer(func, "context", "Context", "", "");
1056
1057 /* wmGizmo.draw_select */
1058 func = RNA_def_function(srna, "draw_select", nullptr);
1061 parm = RNA_def_pointer(func, "context", "Context", "", "");
1063 parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
1064
1065 /* wmGizmo.test_select */
1066 func = RNA_def_function(srna, "test_select", nullptr);
1069 parm = RNA_def_pointer(func, "context", "Context", "", "");
1071 parm = RNA_def_int_array(func,
1072 "location",
1073 2,
1074 nullptr,
1075 INT_MIN,
1076 INT_MAX,
1077 "Location",
1078 "Region coordinates",
1079 INT_MIN,
1080 INT_MAX);
1082 parm = RNA_def_int(
1083 func, "intersect_id", -1, -1, INT_MAX, "", "Use -1 to skip this gizmo", -1, INT_MAX);
1084 RNA_def_function_return(func, parm);
1085
1086 /* wmGizmo.handler */
1087 static const EnumPropertyItem tweak_actions[] = {
1088 {WM_GIZMO_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""},
1089 {WM_GIZMO_TWEAK_SNAP, "SNAP", 0, "Snap", ""},
1090 {0, nullptr, 0, nullptr, nullptr},
1091 };
1092 func = RNA_def_function(srna, "modal", nullptr);
1095 parm = RNA_def_pointer(func, "context", "Context", "", "");
1097 parm = RNA_def_pointer(func, "event", "Event", "", "");
1099 /* TODO: should be a enum-flag. */
1100 parm = RNA_def_enum_flag(func, "tweak", tweak_actions, 0, "Tweak", "");
1102 parm = RNA_def_enum_flag(
1103 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1104 RNA_def_function_return(func, parm);
1105 /* wmGizmo.property_update */
1106 /* TODO */
1107
1108 /* wmGizmo.setup */
1109 func = RNA_def_function(srna, "setup", nullptr);
1112
1113 /* wmGizmo.invoke */
1114 func = RNA_def_function(srna, "invoke", nullptr);
1117 parm = RNA_def_pointer(func, "context", "Context", "", "");
1119 parm = RNA_def_pointer(func, "event", "Event", "", "");
1121 parm = RNA_def_enum_flag(
1122 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1123 RNA_def_function_return(func, parm);
1124
1125 /* wmGizmo.exit */
1126 func = RNA_def_function(srna, "exit", nullptr);
1129 parm = RNA_def_pointer(func, "context", "Context", "", "");
1131 parm = RNA_def_boolean(func, "cancel", false, "Cancel, otherwise confirm", "");
1133
1134 /* wmGizmo.cursor_get */
1135 /* TODO */
1136
1137 /* wmGizmo.select_refresh */
1138 func = RNA_def_function(srna, "select_refresh", nullptr);
1141
1142 /* -------------------------------------------------------------------- */
1143 /* Instance Variables */
1144
1145 prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
1147 RNA_def_property_struct_type(prop, "GizmoGroup");
1148 RNA_def_property_pointer_funcs(prop, "rna_Gizmo_group_get", nullptr, nullptr, nullptr);
1149 RNA_def_property_ui_text(prop, "", "Gizmo group this gizmo is a member of");
1150
1151 /* Color & Alpha */
1152 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
1153 RNA_def_property_array(prop, 3);
1154 RNA_def_property_float_funcs(prop, "rna_Gizmo_color_get", "rna_Gizmo_color_set", nullptr);
1155
1156 prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
1157 RNA_def_property_ui_text(prop, "Alpha", "");
1158 RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_get", "rna_Gizmo_alpha_set", nullptr);
1159 RNA_def_property_range(prop, 0.0f, 1.0f);
1160 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1161
1162 /* Color & Alpha (highlight) */
1163 prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR_GAMMA);
1164 RNA_def_property_array(prop, 3);
1165 RNA_def_property_float_funcs(prop, "rna_Gizmo_color_hi_get", "rna_Gizmo_color_hi_set", nullptr);
1166
1167 prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE);
1168 RNA_def_property_ui_text(prop, "Alpha", "");
1169 RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_hi_get", "rna_Gizmo_alpha_hi_set", nullptr);
1170 RNA_def_property_range(prop, 0.0f, 1.0f);
1171 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1172
1173 prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX);
1175 RNA_def_property_ui_text(prop, "Space Matrix", "");
1177 prop, "rna_Gizmo_matrix_space_get", "rna_Gizmo_matrix_space_set", nullptr);
1178 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1179
1180 prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
1182 RNA_def_property_ui_text(prop, "Basis Matrix", "");
1184 prop, "rna_Gizmo_matrix_basis_get", "rna_Gizmo_matrix_basis_set", nullptr);
1185 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1186
1187 prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX);
1189 RNA_def_property_ui_text(prop, "Offset Matrix", "");
1191 prop, "rna_Gizmo_matrix_offset_get", "rna_Gizmo_matrix_offset_set", nullptr);
1192 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1193
1194 prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
1197 RNA_def_property_ui_text(prop, "Final World Matrix", "");
1198 RNA_def_property_float_funcs(prop, "rna_Gizmo_matrix_world_get", nullptr, nullptr);
1199
1200 prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE);
1201 RNA_def_property_ui_text(prop, "Scale Basis", "");
1203 prop, "rna_Gizmo_scale_basis_get", "rna_Gizmo_scale_basis_set", nullptr);
1204 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1205 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1206
1207 prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL);
1208 RNA_def_property_ui_text(prop, "Line Width", "");
1210 prop, "rna_Gizmo_line_width_get", "rna_Gizmo_line_width_set", nullptr);
1211 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1212 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1213
1214 prop = RNA_def_property(srna, "select_bias", PROP_FLOAT, PROP_NONE);
1215 RNA_def_property_ui_text(prop, "Select Bias", "Depth bias used for selection");
1217 prop, "rna_Gizmo_select_bias_get", "rna_Gizmo_select_bias_set", nullptr);
1219
1220 /* wmGizmo.flag */
1221 /* WM_GIZMO_HIDDEN */
1222 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1223 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_flag_hide_get", "rna_Gizmo_flag_hide_set");
1224 RNA_def_property_ui_text(prop, "Hide", "");
1225 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1226 /* WM_GIZMO_HIDDEN_SELECT */
1227 prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
1229 prop, "rna_Gizmo_flag_hide_select_get", "rna_Gizmo_flag_hide_select_set");
1230 RNA_def_property_ui_text(prop, "Hide Select", "");
1231 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1232 /* WM_GIZMO_HIDDEN_KEYMAP */
1233 prop = RNA_def_property(srna, "hide_keymap", PROP_BOOLEAN, PROP_NONE);
1235 prop, "rna_Gizmo_flag_hide_keymap_get", "rna_Gizmo_flag_hide_keymap_set");
1236 RNA_def_property_ui_text(prop, "Hide Keymap", "Ignore the key-map for this gizmo");
1237 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1238 /* WM_GIZMO_MOVE_CURSOR */
1239 prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE);
1241 prop, "rna_Gizmo_flag_use_grab_cursor_get", "rna_Gizmo_flag_use_grab_cursor_set");
1242 RNA_def_property_ui_text(prop, "Grab Cursor", "");
1243 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1244
1245 /* WM_GIZMO_DRAW_HOVER */
1246 prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE);
1248 prop, "rna_Gizmo_flag_use_draw_hover_get", "rna_Gizmo_flag_use_draw_hover_set");
1249 RNA_def_property_ui_text(prop, "Show Hover", "");
1250 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1251 /* WM_GIZMO_DRAW_MODAL */
1252 prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE);
1254 prop, "rna_Gizmo_flag_use_draw_modal_get", "rna_Gizmo_flag_use_draw_modal_set");
1255 RNA_def_property_ui_text(prop, "Show Active", "Show while dragging");
1256 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1257 /* WM_GIZMO_DRAW_VALUE */
1258 prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE);
1260 prop, "rna_Gizmo_flag_use_draw_value_get", "rna_Gizmo_flag_use_draw_value_set");
1262 prop, "Show Value", "Show an indicator for the current value while dragging");
1263 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1264 /* WM_GIZMO_DRAW_OFFSET_SCALE */
1265 prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE);
1267 "rna_Gizmo_flag_use_draw_offset_scale_get",
1268 "rna_Gizmo_flag_use_draw_offset_scale_set");
1270 prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)");
1271 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1272 /* WM_GIZMO_DRAW_NO_SCALE (negated) */
1273 prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE);
1275 prop, "rna_Gizmo_flag_use_draw_scale_get", "rna_Gizmo_flag_use_draw_scale_set");
1277 RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix");
1278 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1279
1280 /* WM_GIZMO_SELECT_BACKGROUND */
1281 prop = RNA_def_property(srna, "use_select_background", PROP_BOOLEAN, PROP_NONE);
1283 "rna_Gizmo_flag_use_select_background_get",
1284 "rna_Gizmo_flag_use_select_background_set");
1285 RNA_def_property_ui_text(prop, "Select Background", "Don't write into the depth buffer");
1286 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1287
1288 /* WM_GIZMO_OPERATOR_TOOL_INIT */
1289 prop = RNA_def_property(srna, "use_operator_tool_properties", PROP_BOOLEAN, PROP_NONE);
1291 "rna_Gizmo_flag_use_operator_tool_properties_get",
1292 "rna_Gizmo_flag_use_operator_tool_properties_set");
1294 prop,
1295 "Tool Property Init",
1296 "Merge active tool properties on activation (does not overwrite existing)");
1297 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1298
1299 /* WM_GIZMO_EVENT_HANDLE_ALL */
1300 prop = RNA_def_property(srna, "use_event_handle_all", PROP_BOOLEAN, PROP_NONE);
1302 prop, "rna_Gizmo_flag_use_event_handle_all_get", "rna_Gizmo_flag_use_event_handle_all_set");
1304 "Handle All Events",
1305 "When highlighted, "
1306 "do not pass events through to be handled by other keymaps");
1307 RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw");
1308
1309 /* WM_GIZMO_NO_TOOLTIP (negated) */
1310 prop = RNA_def_property(srna, "use_tooltip", PROP_BOOLEAN, PROP_NONE);
1312 prop, "rna_Gizmo_flag_use_tooltip_get", "rna_Gizmo_flag_use_tooltip_set");
1314 RNA_def_property_ui_text(prop, "Use Tooltip", "Use tooltips when hovering over this gizmo");
1315 /* No update needed. */
1316
1317 /* WM_GIZMO_NEEDS_UNDO */
1318 prop = RNA_def_property(srna, "use_undo", PROP_BOOLEAN, PROP_NONE);
1320 prop, "rna_Gizmo_flag_use_undo_get", "rna_Gizmo_flag_use_undo_set");
1322 RNA_def_property_ui_text(prop, "Use Undo", "Push an undo step after each use of the gizmo");
1323 /* No update needed. */
1324
1325 /* wmGizmo.state (readonly) */
1326 /* WM_GIZMO_STATE_HIGHLIGHT */
1327 prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE);
1328 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_highlight_get", nullptr);
1329 RNA_def_property_ui_text(prop, "Highlight", "");
1331 /* WM_GIZMO_STATE_MODAL */
1332 prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
1333 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_is_modal_get", nullptr);
1334 RNA_def_property_ui_text(prop, "Highlight", "");
1336 /* WM_GIZMO_STATE_SELECT */
1337 /* (note that setting is involved, needs to handle array) */
1338 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1339 RNA_def_property_boolean_funcs(prop, "rna_Gizmo_state_select_get", "rna_Gizmo_state_select_set");
1340 RNA_def_property_ui_text(prop, "Select", "");
1341
1342 RNA_api_gizmo(srna);
1343
1344 srna = RNA_def_struct(brna, "GizmoProperties", nullptr);
1345 RNA_def_struct_ui_text(srna, "Gizmo Properties", "Input properties of a Gizmo");
1346 RNA_def_struct_refine_func(srna, "rna_GizmoProperties_refine");
1347 RNA_def_struct_system_idprops_func(srna, "rna_GizmoProperties_idprops");
1349}
1350
1352{
1353 StructRNA *srna;
1354 PropertyRNA *prop;
1355
1356 FunctionRNA *func;
1357 PropertyRNA *parm;
1358
1359 srna = RNA_def_struct(brna, "GizmoGroup", nullptr);
1361 srna, "GizmoGroup", "Storage of an operator being executed, or registered after execution");
1362 RNA_def_struct_sdna(srna, "wmGizmoGroup");
1363 RNA_def_struct_refine_func(srna, "rna_GizmoGroup_refine");
1364# ifdef WITH_PYTHON
1366 srna, "rna_GizmoGroup_register", "rna_GizmoGroup_unregister", "rna_GizmoGroup_instance");
1367# endif
1369
1370 /* -------------------------------------------------------------------- */
1371 /* Registration */
1372
1373 RNA_define_verify_sdna(false); /* not in sdna */
1374
1375 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1376 RNA_def_property_string_sdna(prop, nullptr, "type->idname");
1378 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_GizmoGroup_bl_idname_set");
1380 RNA_def_struct_name_property(srna, prop);
1381
1382 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1383 RNA_def_property_string_sdna(prop, nullptr, "type->name");
1384 RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */
1385 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_GizmoGroup_bl_label_set");
1386 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1388
1389 prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
1390 RNA_def_property_enum_sdna(prop, nullptr, "type->gzmap_params.spaceid");
1393 RNA_def_property_ui_text(prop, "Space Type", "The space where the panel is going to be used in");
1394
1395 prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
1396 RNA_def_property_enum_sdna(prop, nullptr, "type->gzmap_params.regionid");
1400 prop, "Region Type", "The region where the panel is going to be used in");
1401
1402 prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
1403 RNA_def_property_string_sdna(prop, nullptr, "type->owner_id");
1405
1406 /* bl_options */
1407 static const EnumPropertyItem gizmogroup_flag_items[] = {
1408 {WM_GIZMOGROUPTYPE_3D, "3D", 0, "3D", "Use in 3D viewport"},
1410 "SCALE",
1411 0,
1412 "Scale",
1413 "Scale to respect zoom (otherwise zoom independent display size)"},
1415 "DEPTH_3D",
1416 0,
1417 "Depth 3D",
1418 "Supports culled depth by other objects in the view"},
1419 {WM_GIZMOGROUPTYPE_SELECT, "SELECT", 0, "Select", "Supports selection"},
1420 {WM_GIZMOGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent", ""},
1422 "SHOW_MODAL_ALL",
1423 0,
1424 "Show Modal All",
1425 "Show all while interacting, as well as this group when another is being interacted with"},
1427 "EXCLUDE_MODAL",
1428 0,
1429 "Exclude Modal",
1430 "Show all except this group while interacting"},
1432 "TOOL_INIT",
1433 0,
1434 "Tool Init",
1435 "Postpone running until tool operator run (when used with a tool)"},
1437 "TOOL_FALLBACK_KEYMAP",
1438 0,
1439 "Use fallback tools keymap",
1440 "Add fallback tools keymap to this gizmo type"},
1442 "VR_REDRAWS",
1443 0,
1444 "VR Redraws",
1445 "The gizmos are made for use with virtual reality sessions and require special redraw "
1446 "management"},
1447 {0, nullptr, 0, nullptr, nullptr},
1448 };
1449 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1451 RNA_def_property_enum_sdna(prop, nullptr, "type->flag");
1452 RNA_def_property_enum_items(prop, gizmogroup_flag_items);
1453 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1454
1455 RNA_define_verify_sdna(true); /* not in sdna */
1456
1457 /* Functions */
1458
1459 /* poll */
1460 func = RNA_def_function(srna, "poll", nullptr);
1461 RNA_def_function_ui_description(func, "Test if the gizmo group can be called or not");
1463 RNA_def_function_return(func, RNA_def_boolean(func, "visible", false, "", ""));
1464 parm = RNA_def_pointer(func, "context", "Context", "", "");
1466
1467 /* setup_keymap */
1468 func = RNA_def_function(srna, "setup_keymap", nullptr);
1470 func, "Initialize keymaps for this gizmo group, use fallback keymap when not present");
1472 parm = RNA_def_pointer(func, "keyconfig", "KeyConfig", "", "");
1474 /* return */
1475 parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
1477 RNA_def_function_return(func, parm);
1478
1479 /* setup */
1480 func = RNA_def_function(srna, "setup", nullptr);
1481 RNA_def_function_ui_description(func, "Create gizmos function for the gizmo group");
1483 parm = RNA_def_pointer(func, "context", "Context", "", "");
1485
1486 /* refresh */
1487 func = RNA_def_function(srna, "refresh", nullptr);
1489 func, "Refresh data (called on common state changes such as selection)");
1491 parm = RNA_def_pointer(func, "context", "Context", "", "");
1493
1494 func = RNA_def_function(srna, "draw_prepare", nullptr);
1495 RNA_def_function_ui_description(func, "Run before each redraw");
1497 parm = RNA_def_pointer(func, "context", "Context", "", "");
1499
1500 func = RNA_def_function(srna, "invoke_prepare", nullptr);
1501 RNA_def_function_ui_description(func, "Run before invoke");
1503 parm = RNA_def_pointer(func, "context", "Context", "", "");
1505 parm = RNA_def_pointer(func, "gizmo", "Gizmo", "", "");
1507
1508 /* -------------------------------------------------------------------- */
1509 /* Instance Variables */
1510
1511 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1514 prop, "rna_GizmoGroup_name_get", "rna_GizmoGroup_name_length", nullptr);
1515 RNA_def_property_ui_text(prop, "Name", "");
1516
1517 RNA_define_verify_sdna(false); /* not in sdna */
1518
1519 prop = RNA_def_property(srna, "gizmos", PROP_COLLECTION, PROP_NONE);
1520 RNA_def_property_collection_sdna(prop, nullptr, "gizmos", nullptr);
1521 RNA_def_property_struct_type(prop, "Gizmo");
1523 "rna_GizmoGroup_gizmos_begin",
1524 "rna_iterator_listbase_next",
1525 "rna_iterator_listbase_end",
1526 "rna_iterator_listbase_get",
1527 nullptr,
1528 nullptr,
1529 nullptr,
1530 nullptr);
1531
1532 RNA_def_property_ui_text(prop, "Gizmos", "List of gizmos in the Gizmo Map");
1533 rna_def_gizmo(brna, prop);
1534 rna_def_gizmos(brna, prop);
1535
1536 RNA_define_verify_sdna(true); /* not in sdna */
1537
1538 RNA_api_gizmogroup(srna);
1539
1540 srna = RNA_def_struct(brna, "GizmoGroupProperties", nullptr);
1541 RNA_def_struct_ui_text(srna, "Gizmo Group Properties", "Input properties of a Gizmo Group");
1542 RNA_def_struct_refine_func(srna, "rna_GizmoGroupProperties_refine");
1543 RNA_def_struct_system_idprops_func(srna, "rna_GizmoGroupProperties_idprops");
1545}
1546
1548{
1549 rna_def_gizmogroup(brna);
1550}
1551
1552} // namespace blender
1553
1554#endif /* RNA_RUNTIME */
#define G_MAIN
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define MAX_NAME
Definition DNA_defs.h:63
#define OPERATOR_RETVAL_CHECK(ret)
#define C
Definition RandGen.cpp:29
#define NC_SCREEN
Definition WM_types.hh:390
#define NA_EDITED
Definition WM_types.hh:634
#define BLI_assert_msg(a, msg)
#define str(s)
#define FLT_MAX
#define INT_MAX
const int state
void free(Subdiv *subdiv)
Definition subdiv.cc:192
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings)==CTX_MODE_NUM+1, "Must have a string for each context mode") const char *CTX_data_mode_string(const bContext *C)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
char * STRNCPY(char(&dst)[N], const char *src)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
int(*)(PointerRNA *ptr, void *data, bool *have_function) StructValidateFunc
const ListBaseT< wmGizmoGroup > * WM_gizmomap_group_list(wmGizmoMap *gzmap)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ STRUCT_NO_IDPROPERTIES
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *gzt)
const EnumPropertyItem rna_enum_space_type_items[]
Definition rna_space.cc:91
wmGizmoGroupType * WM_gizmogrouptype_append_ptr(void(*wtfunc)(wmGizmoGroupType *, void *), void *userdata)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
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_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
const wmGizmoType * WM_gizmotype_find(const StringRef idname, bool quiet)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
void RNA_def_struct_system_idprops_func(StructRNA *srna, const char *system_idproperties)
bool RNA_struct_available_or_report(ReportList *reports, const char *identifier)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_wm_gizmo(BlenderRNA *brna)
void WM_gizmo_group_type_free_ptr(wmGizmoGroupType *gzgt)
const char * RNA_struct_state_owner_get()
@ FUNC_ALLOW_WRITE
@ FUNC_USE_REPORTS
@ FUNC_NO_SELF
Definition RNA_types.hh:998
@ FUNC_REGISTER_OPTIONAL
@ FUNC_REGISTER
@ FUNC_USE_CONTEXT
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void RNA_api_gizmo(StructRNA *srna)
void * RNA_struct_blender_type_get(StructRNA *srna)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata)
void WM_gizmo_group_type_add_ptr_ex(wmGizmoGroupType *gzgt, wmGizmoMapType *gzmap_type)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition wm_gizmo.cc:569
wmGizmoGroupType * WM_gizmogrouptype_find(const StringRef idname, bool quiet)
static void rna_def_gizmogroup(BlenderRNA *brna)
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
void WM_gizmo_unlink(ListBaseT< wmGizmo > *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C)
Definition wm_gizmo.cc:161
ParameterList * RNA_parameter_list_create(ParameterList *parms, PointerRNA *, FunctionRNA *func)
const EnumPropertyItem rna_enum_operator_return_items[]
Definition rna_wm.cc:595
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_STRING
Definition RNA_types.hh:213
@ PROP_COLLECTION
Definition RNA_types.hh:216
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
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
eWM_GizmoFlagTweak
Gizmo tweak flag. Bit-flag passed to gizmo while tweaking.
@ WM_GIZMO_TWEAK_PRECISE
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)
BMesh const char void * data
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata)
static void rna_def_gizmos(BlenderRNA *brna, PropertyRNA *cprop)
void WM_gizmo_group_type_remove_ptr(Main *bmain, wmGizmoGroupType *gzgt)
void RNA_api_gizmogroup(StructRNA *srna)
void WM_gizmotype_free_ptr(wmGizmoType *gzt)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
void WM_gizmotype_append_ptr(void(*gtfunc)(wmGizmoType *, void *), void *userdata)
void(*)(void *data) StructFreeFunc
static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void **r_value)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
@ WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL
@ WM_GIZMOGROUPTYPE_VR_REDRAWS
@ WM_GIZMOGROUPTYPE_DEPTH_3D
@ WM_GIZMOGROUPTYPE_PERSISTENT
@ WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP
@ WM_GIZMOGROUPTYPE_TOOL_INIT
@ WM_GIZMOGROUPTYPE_SCALE
@ WM_GIZMOGROUPTYPE_SELECT
@ WM_GIZMOGROUPTYPE_DRAW_MODAL_EXCLUDE
@ WM_GIZMO_DRAW_NO_SCALE
@ WM_GIZMO_DRAW_HOVER
@ WM_GIZMO_OPERATOR_TOOL_INIT
@ WM_GIZMO_NO_TOOLTIP
@ WM_GIZMO_MOVE_CURSOR
@ WM_GIZMO_DRAW_OFFSET_SCALE
@ WM_GIZMO_DRAW_VALUE
@ WM_GIZMO_EVENT_HANDLE_ALL
@ WM_GIZMO_HIDDEN_KEYMAP
@ WM_GIZMO_NEEDS_UNDO
@ WM_GIZMO_DRAW_MODAL
@ WM_GIZMO_SELECT_BACKGROUND
@ WM_GIZMO_HIDDEN_SELECT
const EnumPropertyItem rna_enum_region_type_items[]
Definition rna_screen.cc:28
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
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_struct_flag(StructRNA *srna, StructFlag flag)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
@ WM_GIZMO_STATE_MODAL
@ WM_GIZMO_STATE_SELECT
@ WM_GIZMO_STATE_HIGHLIGHT
void RNA_def_struct_translation_context(StructRNA *srna, const char *context)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
bool WM_gizmo_select_set(wmGizmoMap *gzmap, wmGizmo *gz, bool select)
Definition wm_gizmo.cc:396
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_ENUM_FLAG
Definition RNA_types.hh:474
@ PROP_THICK_WRAP
Definition RNA_types.hh:493
@ PROP_REGISTER_OPTIONAL
Definition RNA_types.hh:482
@ PROP_REGISTER
Definition RNA_types.hh:481
@ PROP_NEVER_NULL
Definition RNA_types.hh:447
void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, const void *value)
wmGizmoMapType * WM_gizmomaptype_ensure(const wmGizmoMapType_Params *gzmap_params)
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)
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_property_update(PropertyRNA *prop, int noteflag, const char *func)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_define_verify_sdna(bool verify)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ PROP_MATRIX
Definition RNA_types.hh:322
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:329
@ PARM_REQUIRED
Definition RNA_types.hh:631
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, ListBase *lb, IteratorSkipFunc skip)
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext)
wmGizmo * WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, PointerRNA *properties)
Definition wm_gizmo.cc:84
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop, const bool allow_replace)
void RNA_def_property_array(PropertyRNA *prop, int length)
const int rna_matrix_dimsize_4x4[]
int(*)(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *list) StructCallbackFunc
void RNA_parameter_list_free(ParameterList *parms)
BlenderRNA RNA_blender_rna_get()
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
wmGizmoGroupType * type
const wmGizmoType * type