Blender V5.3
rna_wm_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cctype>
10#include <cstdlib>
11
12#include "RNA_define.hh"
13#include "RNA_enum_types.hh"
14
15#include "DNA_screen_types.h"
16#include "DNA_space_types.h"
18
19#include "ED_screen.hh"
20
21#include "UI_interface_c.hh"
22#include "UI_interface_icons.hh"
23#include "UI_interface_types.hh"
24
25#include "wm_cursors.hh"
26#include "wm_event_types.hh"
27
28#include "WM_api.hh"
29#include "WM_types.hh"
30
31#include "rna_internal.hh" /* own include */
32
33namespace blender {
34
35/* confusing 2 enums mixed up here */
37 {WM_CURSOR_DEFAULT, "DEFAULT", 0, "Default", ""},
38 {WM_CURSOR_NONE, "NONE", 0, "None", ""},
39 {WM_CURSOR_WAIT, "WAIT", 0, "Wait", ""},
40 {WM_CURSOR_EDIT, "CROSSHAIR", 0, "Crosshair", ""},
41 {WM_CURSOR_X_MOVE, "MOVE_X", 0, "Move-X", ""},
42 {WM_CURSOR_Y_MOVE, "MOVE_Y", 0, "Move-Y", ""},
43
44 /* new */
45 {WM_CURSOR_KNIFE, "KNIFE", 0, "Knife", ""},
46 {WM_CURSOR_TEXT_EDIT, "TEXT", 0, "Text", ""},
47 {WM_CURSOR_PAINT_BRUSH, "PAINT_BRUSH", 0, "Paint Brush", ""},
48 {WM_CURSOR_PAINT, "PAINT_CROSS", 0, "Paint Cross", ""},
49 {WM_CURSOR_DOT, "DOT", 0, "Dot Cursor", ""},
50 {WM_CURSOR_ERASER, "ERASER", 0, "Eraser", ""},
51 {WM_CURSOR_HAND, "HAND", 0, "Open Hand", ""},
52 {WM_CURSOR_HAND_POINT, "HAND_POINT", 0, "Pointing Hand", ""},
53 {WM_CURSOR_HAND_CLOSED, "HAND_CLOSED", 0, "Closed Hand", ""},
54 {WM_CURSOR_EW_SCROLL, "SCROLL_X", 0, "Scroll-X", ""},
55 {WM_CURSOR_NS_SCROLL, "SCROLL_Y", 0, "Scroll-Y", ""},
56 {WM_CURSOR_NSEW_SCROLL, "SCROLL_XY", 0, "Scroll-XY", ""},
57 {WM_CURSOR_EYEDROPPER, "EYEDROPPER", 0, "Eyedropper", ""},
58 {WM_CURSOR_PICK_AREA, "PICK_AREA", 0, "Pick Area", ""},
59 {WM_CURSOR_STOP, "STOP", 0, "Stop", ""},
60 {WM_CURSOR_COPY, "COPY", 0, "Copy", ""},
61 {WM_CURSOR_CROSS, "CROSS", 0, "Cross", ""},
62 {WM_CURSOR_MUTE, "MUTE", 0, "Mute", ""},
63 {WM_CURSOR_ZOOM_IN, "ZOOM_IN", 0, "Zoom In", ""},
64 {WM_CURSOR_ZOOM_OUT, "ZOOM_OUT", 0, "Zoom Out", ""},
65 {0, nullptr, 0, nullptr, nullptr},
66};
67
68} // namespace blender
69
70#ifdef RNA_RUNTIME
71
72# include "AS_remote_library.hh"
73
74# include "DNA_userdef_types.h"
75
76# include "ED_geometry.hh"
77# include "ED_screen.hh"
78
79# include "BLI_listbase.hh"
80# include "BLI_string.hh"
81# include "BLI_string_utf8.hh"
82
83# include "BKE_context.hh"
84# include "BKE_global.hh"
85# include "BKE_main.hh"
86# include "BKE_report.hh"
87# include "BKE_undo_system.hh"
88
89# include "UI_interface_c.hh"
90
91# include "WM_types.hh"
92
93namespace blender {
94
95/* Needed since RNA doesn't use `const` in function signatures. */
96static bool rna_KeyMapItem_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
97{
98 return WM_keymap_item_compare(k1, k2);
99}
100
101static void rna_KeyMapItem_to_string(wmKeyMapItem *kmi, bool compact, char *result)
102{
104 result, WM_keymap_item_to_string(kmi, compact).value_or("").c_str(), UI_MAX_SHORTCUT_STR);
105}
106
107static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C)
108{
110 return WM_keymap_active(wm, km);
111}
112
113static void rna_keymap_restore_to_default(wmKeyMap *km, bContext *C)
114{
116}
117
118static void rna_keymap_restore_item_to_default(wmKeyMap *km, bContext *C, wmKeyMapItem *kmi)
119{
121}
122
123static void rna_Operator_report(wmOperator *op, int type, const char *msg)
124{
125 BKE_report(op->reports, eReportType(type), msg);
126}
127
128static bool rna_Operator_is_repeat(wmOperator *op, bContext *C)
129{
130 return WM_operator_is_repeat(C, op);
131}
132
133/* since event isn't needed... */
134static void rna_Operator_enum_search_invoke(bContext *C, wmOperator *op)
135{
136 WM_enum_search_invoke(C, op, nullptr);
137}
138
139static int rna_Operator_ui_popup(bContext *C, wmOperator *op, int width, bool auto_keymap)
140{
141 return wmOperatorStatus(WM_operator_ui_popup(C, op, width, auto_keymap));
142}
143
144static bool rna_event_modal_handler_add(bContext *C, ReportList *reports, wmOperator *op)
145{
146 wmWindow *win = CTX_wm_window(C);
147 if (win == nullptr) {
148 BKE_report(reports, RPT_ERROR, "No active window in context!");
149 return false;
150 }
151 ScrArea *area = CTX_wm_area(C);
152 ARegion *region = CTX_wm_region(C);
153 return WM_event_add_modal_handler_ex(win, area, region, op) != nullptr;
154}
155
156static wmTimer *rna_event_timer_add(wmWindowManager *wm, float time_step, wmWindow *win)
157{
158 /* NOTE: we need a way for Python to know event types, `TIMER` is hard coded. */
159 return WM_event_timer_add(wm, win, TIMER, time_step);
160}
161
162static void rna_event_timer_remove(wmWindowManager *wm, wmTimer *timer)
163{
164 WM_event_timer_remove(wm, timer->win, timer);
165}
166
167static wmGizmoGroupType *wm_gizmogrouptype_find_for_add_remove(ReportList *reports,
168 const char *idname)
169{
170 wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, true);
171 if (gzgt == nullptr) {
172 BKE_reportf(reports, RPT_ERROR, "Gizmo group type '%s' not found!", idname);
173 return nullptr;
174 }
175 if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) {
176 BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' has 'PERSISTENT' option set!", idname);
177 return nullptr;
178 }
179 return gzgt;
180}
181
182static void rna_gizmo_group_type_ensure(ReportList *reports, const char *idname)
183{
184 wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
185 if (gzgt != nullptr) {
187 }
188}
189
190static void rna_gizmo_group_type_unlink_delayed(ReportList *reports, const char *idname)
191{
192 wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
193 if (gzgt != nullptr) {
195 }
196}
197
198/* Placeholder data for final implementation of a true progress-bar. */
199static struct wmStaticProgress {
200 float min;
201 float max;
202 bool is_valid;
203} wm_progress_state = {0, 0, false};
204
205static void rna_progress_begin(wmWindowManager * /*wm*/, float min, float max)
206{
207 float range = max - min;
208 if (range != 0) {
209 wm_progress_state.min = min;
210 wm_progress_state.max = max;
211 wm_progress_state.is_valid = true;
212 }
213 else {
214 wm_progress_state.is_valid = false;
215 }
216}
217
218static void rna_progress_update(wmWindowManager *wm, float value)
219{
220 if (wm_progress_state.is_valid) {
221 /* Map to factor 0..1. */
222 wmWindow *win = wm->runtime->winactive;
223 if (win) {
224 const float progress_factor = (value - wm_progress_state.min) /
225 (wm_progress_state.max - wm_progress_state.min);
226 WM_cursor_progress(win, progress_factor);
227 }
228 }
229}
230
231static void rna_progress_end(wmWindowManager *wm)
232{
233 if (wm_progress_state.is_valid) {
234 wmWindow *win = wm->runtime->winactive;
235 if (win) {
237 wm_progress_state.is_valid = false;
238 }
239 }
240}
241
242/* wrap these because of 'const wmEvent *' */
243static int rna_Operator_confirm(bContext *C,
244 wmOperator *op,
245 wmEvent * /*event*/,
246 const char *title,
247 const char *message,
248 const char *confirm_text,
249 const int icon,
250 const char *text_ctxt,
251 const bool translate)
252{
253 std::optional<StringRefNull> title_str = RNA_translate_ui_text(
254 title, text_ctxt, nullptr, nullptr, translate);
255 std::optional<StringRefNull> message_str = RNA_translate_ui_text(
256 message, text_ctxt, nullptr, nullptr, translate);
257 std::optional<StringRefNull> confirm_text_str = RNA_translate_ui_text(
258 confirm_text, text_ctxt, nullptr, nullptr, translate);
260 op,
261 title_str ? title_str->c_str() : nullptr,
262 message_str ? message_str->c_str() : nullptr,
263 confirm_text_str ? confirm_text_str->c_str() : nullptr,
264 ui::AlertIcon(icon));
265}
266
267static void rna_WM_try_activate_rna_button(blender::wmWindowManager * /*wm*/,
268 bContext *C,
269 ARegion *region,
270 PointerRNA *ptr,
271 const char *propname,
272 int state,
273 bool warp_cursor_at_button,
274 int index,
275 int **r_xy,
276 int *r_xy_total)
277{
278 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
279 if (!prop) {
280 RNA_warning_bare("WindowManager.try_activate_rna_button(): property not found: %s.%s",
281 RNA_struct_identifier(ptr->type),
282 propname);
283 return;
284 }
285 std::optional<int2> xy = ui::try_activate_rna_button(
286 C, region, ui::ActivationButtonState(state), ptr, prop, warp_cursor_at_button, index);
287
288 if (!xy) {
289 return;
290 }
291 *r_xy = MEM_new_array_uninitialized<int>(2, __func__);
292 (*r_xy)[0] = (*xy)[0];
293 (*r_xy)[1] = (*xy)[1];
294 *r_xy_total = 2;
295}
296
297static int rna_Operator_props_popup(bContext *C, wmOperator *op, wmEvent *event)
298{
299 return WM_operator_props_popup(C, op, event);
300}
301
302static int rna_Operator_props_dialog_popup(bContext *C,
303 wmOperator *op,
304 const int width,
305 const char *title,
306 const char *confirm_text,
307 const bool cancel_default,
308 const char *text_ctxt,
309 const bool translate)
310{
311 std::optional<StringRefNull> title_str = RNA_translate_ui_text(
312 title, text_ctxt, nullptr, nullptr, translate);
313 std::optional<StringRefNull> confirm_text_str = RNA_translate_ui_text(
314 confirm_text, text_ctxt, nullptr, nullptr, translate);
316 C,
317 op,
318 width,
319 title_str ? std::make_optional<std::string>(*title_str) : std::nullopt,
320 confirm_text_str ? std::make_optional<std::string>(*confirm_text_str) : std::nullopt,
321 cancel_default);
322}
323
324static int16_t keymap_item_modifier_flag_from_args(
325 bool any, int shift, int ctrl, int alt, int oskey, int hyper)
326{
327 int16_t modifier = 0;
328 if (any) {
330 }
331 else {
332# define MOD_VAR_ASSIGN_FLAG(mod_var, mod_flag) \
333 if (mod_var == KM_MOD_HELD) { \
334 modifier |= mod_flag; \
335 } \
336 else if (mod_var == KM_ANY) { \
337 modifier |= KMI_PARAMS_MOD_TO_ANY(mod_flag); \
338 } \
339 ((void)0)
340
341 MOD_VAR_ASSIGN_FLAG(shift, KM_SHIFT);
342 MOD_VAR_ASSIGN_FLAG(ctrl, KM_CTRL);
343 MOD_VAR_ASSIGN_FLAG(alt, KM_ALT);
344 MOD_VAR_ASSIGN_FLAG(oskey, KM_OSKEY);
345 MOD_VAR_ASSIGN_FLAG(hyper, KM_HYPER);
346
347# undef MOD_VAR_ASSIGN_FLAG
348 }
349 return modifier;
350}
351
352static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km,
353 ReportList *reports,
354 const char *idname,
355 int type,
356 int value,
357 bool any,
358 int shift,
359 int ctrl,
360 int alt,
361 int oskey,
362 int hyper,
363 int keymodifier,
364 int direction,
365 bool repeat,
366 bool head)
367{
368 /* only on non-modal maps */
369 if (km->flag & KEYMAP_MODAL) {
370 BKE_report(reports, RPT_ERROR, "Not a non-modal keymap");
371 return nullptr;
372 }
373
374 // wmWindowManager *wm = CTX_wm_manager(C);
375 wmKeyMapItem *kmi = nullptr;
376 char idname_bl[OP_MAX_TYPENAME];
377
378 WM_operator_bl_idname(idname_bl, idname);
379
380 KeyMapItem_Params params{};
381 params.type = type;
382 params.value = value;
383 params.modifier = keymap_item_modifier_flag_from_args(any, shift, ctrl, alt, oskey, hyper);
384 params.keymodifier = keymodifier;
385 params.direction = direction;
386
387 /* create keymap item */
388 kmi = WM_keymap_add_item(km, idname_bl, &params);
389
390 if (!repeat) {
391 kmi->flag |= KMI_REPEAT_IGNORE;
392 }
393
394 /* #32437 allow scripts to define hotkeys that get added to start of keymap
395 * so that they stand a chance against catch-all defines later on
396 */
397 if (head) {
398 BLI_remlink(&km->items, kmi);
399 BLI_addhead(&km->items, kmi);
400 }
401
402 return kmi;
403}
404
405static wmKeyMapItem *rna_KeyMap_item_new_from_item(wmKeyMap *km,
406 ReportList *reports,
407 wmKeyMapItem *kmi_src,
408 bool head)
409{
410 // wmWindowManager *wm = CTX_wm_manager(C);
411
412 if ((km->flag & KEYMAP_MODAL) == (kmi_src->idname[0] != '\0')) {
413 BKE_report(reports, RPT_ERROR, "Cannot mix modal/non-modal items");
414 return nullptr;
415 }
416
417 /* create keymap item */
418 wmKeyMapItem *kmi = WM_keymap_add_item_copy(km, kmi_src);
419 if (head) {
420 BLI_remlink(&km->items, kmi);
421 BLI_addhead(&km->items, kmi);
422 }
423 return kmi;
424}
425
426static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km,
427 ReportList *reports,
428 const char *propvalue_str,
429 int type,
430 int value,
431 bool any,
432 int shift,
433 int ctrl,
434 int alt,
435 int oskey,
436 int hyper,
437 int keymodifier,
438 int direction,
439 bool repeat)
440{
441 /* only modal maps */
442 if ((km->flag & KEYMAP_MODAL) == 0) {
443 BKE_report(reports, RPT_ERROR, "Not a modal keymap");
444 return nullptr;
445 }
446
447 wmKeyMapItem *kmi = nullptr;
448 int propvalue = 0;
449
450 KeyMapItem_Params params{};
451 params.type = type;
452 params.value = value;
453 params.modifier = keymap_item_modifier_flag_from_args(any, shift, ctrl, alt, oskey, hyper);
454 params.keymodifier = keymodifier;
455 params.direction = direction;
456
457 /* not initialized yet, do delayed lookup */
458 if (!km->modal_items) {
459 kmi = WM_modalkeymap_add_item_str(km, &params, propvalue_str);
460 }
461 else {
462 if (RNA_enum_value_from_id(static_cast<const EnumPropertyItem *>(km->modal_items),
463 propvalue_str,
464 &propvalue) == 0)
465 {
466 BKE_report(reports, RPT_WARNING, "Property value not in enumeration");
467 }
468 kmi = WM_modalkeymap_add_item(km, &params, propvalue);
469 }
470
471 if (!repeat) {
472 kmi->flag |= KMI_REPEAT_IGNORE;
473 }
474
475 return kmi;
476}
477
478static void rna_KeyMap_item_remove(wmKeyMap *km, ReportList *reports, PointerRNA *kmi_ptr)
479{
480 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(kmi_ptr->data);
481
482 if (BLI_findindex(&km->items, kmi) == -1) [[unlikely]] {
484 reports, RPT_ERROR, "KeyMapItem '%s' not found in KeyMap '%s'", kmi->idname, km->idname);
485 return;
486 }
487
488 WM_keymap_remove_item(km, kmi);
489 kmi_ptr->invalidate();
490}
491
492static PointerRNA rna_KeyMap_item_find_match(
493 ID *id, wmKeyMap *km_base, ReportList *reports, wmKeyMap *km_match, wmKeyMapItem *kmi_match)
494{
495 wmKeyMapItem *kmi_base = WM_keymap_item_find_match(km_base, km_match, kmi_match, reports);
496 if (kmi_base) {
497 return RNA_pointer_create_discrete(id, RNA_KeyMapItem, kmi_base);
498 }
499 return {};
500}
501
502static PointerRNA rna_KeyMap_item_find_from_operator(ID *id,
503 wmKeyMap *km,
504 const char *idname,
505 PointerRNA *properties,
506 int include_mask,
507 int exclude_mask)
508{
509 char idname_bl[OP_MAX_TYPENAME];
510 WM_operator_bl_idname(idname_bl, idname);
511
513 km, idname_bl, static_cast<IDProperty *>(properties->data), include_mask, exclude_mask);
514 PointerRNA kmi_ptr = RNA_pointer_create_discrete(id, RNA_KeyMapItem, kmi);
515 return kmi_ptr;
516}
517
518static PointerRNA rna_KeyMap_item_match_event(ID *id, wmKeyMap *km, bContext *C, wmEvent *event)
519{
520 wmKeyMapItem *kmi = WM_event_match_keymap_item(C, km, event);
521 PointerRNA kmi_ptr = RNA_pointer_create_discrete(id, RNA_KeyMapItem, kmi);
522 return kmi_ptr;
523}
524
525static wmKeyMap *rna_KeyMaps_new(wmKeyConfig *keyconf,
526 ReportList *reports,
527 const char *idname,
528 int spaceid,
529 int regionid,
530 bool modal,
531 bool tool)
532{
533 if (modal) {
534 /* Sanity check: Don't allow add-ons to override internal modal key-maps
535 * because this isn't supported, the restriction can be removed when
536 * add-ons can define modal key-maps.
537 * Currently this is only useful for add-ons to override built-in modal keymaps
538 * which is not the intended use for add-on keymaps. */
539 wmWindowManager *wm = G_MAIN->wm.first();
540 if (keyconf == wm->runtime->addonconf) {
541 BKE_reportf(reports, RPT_ERROR, "Modal key-maps not supported for add-on key-config");
542 return nullptr;
543 }
544 }
545
546 wmKeyMap *keymap;
547
548 if (modal == 0) {
549 keymap = WM_keymap_ensure(keyconf, idname, spaceid, regionid);
550 }
551 else {
552 keymap = WM_modalkeymap_ensure(keyconf, idname, nullptr); /* items will be lazy init */
553 }
554
555 if (keymap && tool) {
556 keymap->flag |= KEYMAP_TOOL;
557 }
558
559 return keymap;
560}
561
562static wmKeyMap *rna_KeyMaps_find(wmKeyConfig *keyconf,
563 const char *idname,
564 int spaceid,
565 int regionid)
566{
567 return WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
568}
569
570static wmKeyMap *rna_KeyMaps_find_match(wmKeyConfig *keyconf, wmKeyMap *km_match)
571{
572 return WM_keymap_list_find(
573 &keyconf->keymaps, km_match->idname, km_match->spaceid, km_match->regionid);
574}
575
576static wmKeyMap *rna_KeyMaps_find_modal(wmKeyConfig * /*keyconf*/, const char *idname)
577{
578 wmOperatorType *ot = WM_operatortype_find(idname, false);
579
580 if (!ot) {
581 return nullptr;
582 }
583 return ot->modalkeymap;
584}
585
586static void rna_KeyMaps_remove(wmKeyConfig *keyconfig, ReportList *reports, PointerRNA *keymap_ptr)
587{
588 wmKeyMap *keymap = static_cast<wmKeyMap *>(keymap_ptr->data);
589
590 if (BLI_findindex(&keyconfig->keymaps, keymap) == -1) [[unlikely]] {
591 BKE_reportf(reports,
592 RPT_ERROR,
593 "KeyMap '%s' not found in KeyConfig '%s'",
594 keymap->idname,
595 keyconfig->idname);
596 return;
597 }
598
599 WM_keymap_remove(keyconfig, keymap);
600 keymap_ptr->invalidate();
601}
602
603static void rna_KeyMaps_clear(wmKeyConfig *keyconfig)
604{
605 WM_keyconfig_clear(keyconfig);
606}
607
608wmKeyConfig *rna_KeyConfig_new(wmWindowManager *wm, const char *idname)
609{
610 return WM_keyconfig_ensure(wm, idname, true);
611}
612
613static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, PointerRNA *keyconf_ptr)
614{
615 wmKeyConfig *keyconf = static_cast<wmKeyConfig *>(keyconf_ptr->data);
616 if (BLI_findindex(&wm->runtime->keyconfigs, keyconf) == -1) [[unlikely]] {
617 BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keyconf->idname);
618 return;
619 }
620 WM_keyconfig_remove(wm, keyconf);
621 keyconf_ptr->invalidate();
622}
623
624static PointerRNA rna_KeyConfig_find_item_from_operator(wmWindowManager *wm,
625 bContext *C,
626 const char *idname,
627 int opcontext,
628 PointerRNA *properties,
629 int include_mask,
630 int exclude_mask,
631 PointerRNA *km_ptr)
632{
633 char idname_bl[OP_MAX_TYPENAME];
634 WM_operator_bl_idname(idname_bl, idname);
635
636 wmKeyMap *km = nullptr;
638 idname_bl,
639 wm::OpCallContext(opcontext),
640 static_cast<IDProperty *>(properties->data),
641 include_mask,
642 exclude_mask,
643 &km);
644 *km_ptr = RNA_pointer_create_discrete(&wm->id, RNA_KeyMap, km);
645 PointerRNA kmi_ptr = RNA_pointer_create_discrete(&wm->id, RNA_KeyMapItem, kmi);
646 return kmi_ptr;
647}
648
649static void rna_KeyConfig_update(wmWindowManager *wm, bool keep_properties)
650{
651 WM_keyconfig_update_ex(wm, keep_properties);
652}
653
655static bool rna_popup_context_ok_or_report(bContext *C, ReportList *reports)
656{
657 if (CTX_wm_window(C) == nullptr) {
658 BKE_report(reports, RPT_ERROR, "context \"window\" is None");
659 return false;
660 }
661 return true;
662}
663
664/* popup menu wrapper */
665static PointerRNA rna_PopMenuBegin(bContext *C,
666 ReportList *reports,
667 const char *title,
668 const int icon)
669{
670 if (!rna_popup_context_ok_or_report(C, reports)) {
671 return {};
672 }
673
674 void *data = static_cast<void *>(ui::popup_menu_begin(C, title, icon));
675 PointerRNA ptr_result = RNA_pointer_create_discrete(nullptr, RNA_UIPopupMenu, data);
676 return ptr_result;
677}
678
679static void rna_PopMenuEnd(bContext *C, PointerRNA *handle)
680{
681 ui::popup_menu_end(C, static_cast<ui::PopupMenu *>(handle->data));
682}
683
684/* popover wrapper */
685static PointerRNA rna_PopoverBegin(bContext *C,
686 ReportList *reports,
687 const int ui_units_x,
688 const bool from_active_button,
689 const bool auto_keymap)
690{
691 if (!rna_popup_context_ok_or_report(C, reports)) {
692 return {};
693 }
694
695 void *data = static_cast<void *>(
696 ui::popover_begin(C, U.widget_unit * ui_units_x, from_active_button, auto_keymap));
697 PointerRNA ptr_result = RNA_pointer_create_discrete(nullptr, RNA_UIPopover, data);
698 return ptr_result;
699}
700
701static void rna_PopoverEnd(bContext *C, PointerRNA *handle, wmKeyMap *keymap)
702{
703 ui::popover_end(C, static_cast<ui::Popover *>(handle->data), keymap);
704}
705
706/* pie menu wrapper */
707static PointerRNA rna_PieMenuBegin(
708 bContext *C, ReportList *reports, const char *title, const int icon, PointerRNA *event)
709{
710 if (!rna_popup_context_ok_or_report(C, reports)) {
711 return {};
712 }
713
714 void *data = (void *)ui::pie_menu_begin(
715 C, title, icon, static_cast<const wmEvent *>(event->data));
716
717 PointerRNA ptr_result = RNA_pointer_create_discrete(nullptr, RNA_UIPieMenu, data);
718 return ptr_result;
719}
720
721static void rna_PieMenuEnd(bContext *C, PointerRNA *handle)
722{
723 ui::pie_menu_end(C, static_cast<ui::PieMenu *>(handle->data));
724}
725
726static void rna_WindowManager_print_undo_steps(wmWindowManager *wm)
727{
728 BKE_undosys_print(wm->runtime->undo_stack);
729}
730
731static void rna_WindowManager_tag_script_reload()
732{
735}
736
737static PointerRNA rna_WindoManager_operator_properties_last(const char *idname)
738{
739 wmOperatorType *ot = WM_operatortype_find(idname, true);
740
741 if (ot != nullptr) {
742 PointerRNA ptr;
744 return ptr;
745 }
746 return {};
747}
748
749static wmEvent *rna_Window_event_add_simulate(wmWindow *win,
750 ReportList *reports,
751 int type,
752 int value,
753 const char *unicode,
754 int x,
755 int y,
756 bool shift,
757 bool ctrl,
758 bool alt,
759 bool oskey,
760 bool hyper)
761{
762 if ((G.f & G_FLAG_EVENT_SIMULATE) == 0) {
763 BKE_report(reports, RPT_ERROR, "Not running with '--enable-event-simulate' enabled");
764 return nullptr;
765 }
766
767 if (!ELEM(value, KM_PRESS, KM_RELEASE, KM_NOTHING)) {
768 BKE_report(reports, RPT_ERROR, "Value: only 'PRESS/RELEASE/NOTHING' are supported");
769 return nullptr;
770 }
771 if (ISKEYBOARD(type) || ISMOUSE_BUTTON(type)) {
772 if (!ELEM(value, KM_PRESS, KM_RELEASE)) {
773 BKE_report(reports, RPT_ERROR, "Value: must be 'PRESS/RELEASE' for keyboard/buttons");
774 return nullptr;
775 }
776 }
777 if (ISMOUSE_MOTION(type)) {
778 if (value != KM_NOTHING) {
779 BKE_report(reports, RPT_ERROR, "Value: must be 'NOTHING' for motion");
780 return nullptr;
781 }
782 }
783 if (unicode != nullptr) {
784 if (value != KM_PRESS) {
785 BKE_report(reports, RPT_ERROR, "Value: must be 'PRESS' when unicode is set");
786 return nullptr;
787 }
788 }
789 /* TODO: validate NDOF. */
790
791 if (unicode != nullptr) {
792 int len = BLI_str_utf8_size_or_error(unicode);
793 if (len == -1 || unicode[len] != '\0') {
794 BKE_report(reports, RPT_ERROR, "Only a single character supported");
795 return nullptr;
796 }
797 }
798
799 wmEvent e = *win->runtime->eventstate;
800 e.type = wmEventType(type);
801 e.val = value;
802 e.flag = eWM_EventFlag(0);
803 e.xy[0] = x;
804 e.xy[1] = y;
805
806 e.modifier = wmEventModifierFlag(0);
807 if (shift) {
808 e.modifier |= KM_SHIFT;
809 }
810 if (ctrl) {
811 e.modifier |= KM_CTRL;
812 }
813 if (alt) {
814 e.modifier |= KM_ALT;
815 }
816 if (oskey) {
817 e.modifier |= KM_OSKEY;
818 }
819 if (hyper) {
820 e.modifier |= KM_HYPER;
821 }
822
823 e.utf8_buf[0] = '\0';
824 if (unicode != nullptr) {
825 STRNCPY(e.utf8_buf, unicode);
826 }
827
828 /* Until we expose setting tablet values here. */
830
831 return WM_event_add_simulate(win, &e);
832}
833
834static Scene *rna_Window_find_playing_scene(wmWindow *win, const bool scrub)
835{
837}
838
839static wmWindow *rna_Windows_find_playing(wmWindowManager *wm, const bool scrub)
840{
842 if (!win) {
843 return nullptr;
844 }
845 if (scrub) {
847 if (screen->scrubbing) {
848 return win;
849 }
850 return nullptr;
851 }
852 return win;
853}
854
856
857static void rna_asset_library_status_begin_loading(const char *library_url, float timeout)
858{
859 RemoteLibraryLoadingStatus::begin_loading(library_url, timeout);
860}
861
862static void rna_asset_library_status_ping_still_loading(const char *library_url)
863{
865}
866
867static void rna_asset_library_status_ping_metafiles_in_place(const char *library_url)
868{
870}
871
872static void rna_asset_library_status_ping_loaded_new_pages(const char *library_url)
873{
875}
876
877static void rna_asset_library_status_ping_loaded_new_preview(bContext *C,
878 const char *preview_full_path)
879{
881}
882
883static void rna_asset_library_status_ping_asset_file_progress(const char *absolute_file_url,
884 const int size_written_high,
885 const int size_written_low)
886{
887 /* This splitting & merging of the size-in-bytes into 32-bit integers is just a temporary
888 * workaround for RNA's limitation on ints. Once that's been lifted, and the size in bytes can be
889 * passed directly as 64-bit int, this function should be updated for that. */
890 const int64_t size_in_bytes = (size_written_high << 31) + size_written_low;
891 RemoteLibraryLoadingStatus::ping_asset_file_progress(absolute_file_url, size_in_bytes);
892}
893
894static void rna_asset_library_status_ping_asset_file_succeeded(bContext *C,
895 const char *library_url,
896 const char *absolute_file_url,
897 const char *local_file_abspath)
898{
900 *C, library_url, absolute_file_url, local_file_abspath);
901}
902
903static void rna_asset_library_status_ping_asset_file_failed(bContext *C,
904 const char *library_url,
905 const char *absolute_file_url,
906 const char *local_file_abspath)
907{
909 *C, library_url, absolute_file_url, local_file_abspath);
910}
911
912static void rna_asset_library_status_ping_finished_download_queue(bContext *C)
913{
915}
916
917static void rna_asset_library_status_finished_loading(const char *library_url)
918{
920}
921
922static void rna_asset_library_status_failed_loading(const char *library_url, const char *message)
923{
925 library_url,
926 message && message[0] ? std::optional<blender::StringRefNull>{message} : std::nullopt);
927}
928
929static void rna_register_node_group_operators(bContext *C)
930{
932}
933
934} // namespace blender
935
936#else
937
938namespace blender {
939
940# define WM_GEN_INVOKE_EVENT (1 << 0)
941# define WM_GEN_INVOKE_SIZE (1 << 1)
942# define WM_GEN_INVOKE_RETURN (1 << 2)
943
944static void rna_generic_op_invoke(FunctionRNA *func, int flag)
945{
946 PropertyRNA *parm;
947
949 parm = RNA_def_pointer(func, "operator", "Operator", "", "Operator to call");
951
952 if (flag & WM_GEN_INVOKE_EVENT) {
953 parm = RNA_def_pointer(func, "event", "Event", "", "Event");
955 }
956
957 if (flag & WM_GEN_INVOKE_SIZE) {
958 RNA_def_int(func, "width", 300, 0, INT_MAX, "", "Width of the popup", 0, INT_MAX);
959 }
960
961 if (flag & WM_GEN_INVOKE_RETURN) {
962 parm = RNA_def_enum_flag(
963 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
964 RNA_def_function_return(func, parm);
965 }
966}
967
969{
970 FunctionRNA *func;
971 PropertyRNA *parm;
972
973 func = RNA_def_function(srna, "cursor_warp", "WM_cursor_warp");
974 parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
976 parm = RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
978 RNA_def_function_ui_description(func, "Set the cursor position");
979
980 func = RNA_def_function(srna, "cursor_set", "WM_cursor_set");
981 parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE);
984 RNA_def_function_ui_description(func, "Set the cursor");
985
986 func = RNA_def_function(srna, "cursor_modal_set", "WM_cursor_modal_set");
987 parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE);
990 RNA_def_function_ui_description(func, "Set the cursor, so the previous cursor can be restored");
991
992 func = RNA_def_function(srna, "cursor_modal_restore", "WM_cursor_modal_restore");
994 func, "Restore the previous cursor after calling ``cursor_modal_set``");
995
996 /* Arguments match 'rna_KeyMap_item_new'. */
997 func = RNA_def_function(srna, "event_simulate", "rna_Window_event_add_simulate");
999 parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
1001 parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
1003 parm = RNA_def_string(func, "unicode", nullptr, 0, "", "");
1005
1006 RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
1007 RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
1008
1009 RNA_def_boolean(func, "shift", false, "Shift", "");
1010 RNA_def_boolean(func, "ctrl", false, "Ctrl", "");
1011 RNA_def_boolean(func, "alt", false, "Alt", "");
1012 RNA_def_boolean(func, "oskey", false, "OS Key", "");
1013 RNA_def_boolean(func, "hyper", false, "Hyper", "");
1014 parm = RNA_def_pointer(func, "event", "Event", "Item", "Added key map item");
1016 RNA_def_function_return(func, parm);
1017
1018 func = RNA_def_function(srna, "find_playing_scene", "rna_Window_find_playing_scene");
1020 func, "scrub", false, "Scrubbing", "Check if time in the scene is being scrubbed");
1021 parm = RNA_def_pointer(func, "scene", "Scene", "Scene", "Scene that is currently playing");
1022 RNA_def_function_return(func, parm);
1023}
1024
1026{
1027 FunctionRNA *func;
1028 PropertyRNA *param;
1029
1030 func = RNA_def_function(srna, "find_playing", "rna_Windows_find_playing");
1032 func, "scrub", false, "Scrubbing", "Check if time in the window is being scrubbed");
1033 param = RNA_def_pointer(func, "window", "Window", "Window", "Window that is currently playing");
1034 RNA_def_function_return(func, param);
1035}
1036
1038 {int(ui::AlertIcon::None), "NONE", 0, "None", ""},
1039 {int(ui::AlertIcon::Warning), "WARNING", 0, "Warning", ""},
1040 {int(ui::AlertIcon::Question), "QUESTION", 0, "Question", ""},
1041 {int(ui::AlertIcon::Error), "ERROR", 0, "Error", ""},
1042 {int(ui::AlertIcon::Info), "INFO", 0, "Info", ""},
1043 {0, nullptr, 0, nullptr, nullptr},
1044};
1045
1047 {int(ui::ActivationButtonState::Highlight), "HIGHLIGHT", 0, "HIGHLIGHT", ""},
1048 {int(ui::ActivationButtonState::WaitKeyEvent), "WAIT_KEY_EVENT", 0, "WAIT_KEY_EVENT", ""},
1049 {int(ui::ActivationButtonState::NumEditing), "NUM_EDITING", 0, "NUM_EDITING", ""},
1050 {int(ui::ActivationButtonState::TextEditing), "TEXT_EDITING", 0, "TEXT_EDITING", ""},
1051 {0, nullptr, 0, nullptr, nullptr},
1052};
1053
1055{
1056 FunctionRNA *func;
1057 PropertyRNA *parm;
1058
1059 func = RNA_def_function(srna, "fileselect_add", "WM_event_add_fileselect");
1060 /* Note that a full description is located at:
1061 * `doc/python_api/examples/bpy.types.WindowManager.fileselect_add.py`. */
1062 RNA_def_function_ui_description(func, "Opens a file selector with an operator.");
1063 rna_generic_op_invoke(func, 0);
1064
1065 func = RNA_def_function(srna, "modal_handler_add", "rna_event_modal_handler_add");
1067 func,
1068 "Add a modal handler to the window manager, for the given modal operator "
1069 "(called by invoke() with self, just before returning {'RUNNING_MODAL'})");
1071 parm = RNA_def_pointer(func, "operator", "Operator", "", "Operator to call");
1074 func,
1075 RNA_def_boolean(func, "handle", true, "", "Whether adding the handler was successful"));
1076
1077 func = RNA_def_function(srna, "event_timer_add", "rna_event_timer_add");
1079 func, "Add a timer to the given window, to generate periodic 'TIMER' events");
1080 parm = RNA_def_property(func, "time_step", PROP_FLOAT, PROP_NONE);
1082 RNA_def_property_range(parm, 0.0, FLT_MAX);
1083 RNA_def_property_ui_text(parm, "Time Step", "Interval in seconds between timer events");
1084 RNA_def_pointer(func, "window", "Window", "", "Window to attach the timer to, or None");
1085 parm = RNA_def_pointer(func, "result", "Timer", "", "");
1087 RNA_def_function_return(func, parm);
1088
1089 func = RNA_def_function(srna, "event_timer_remove", "rna_event_timer_remove");
1090 parm = RNA_def_pointer(func, "timer", "Timer", "", "");
1092
1093 func = RNA_def_function(srna, "gizmo_group_type_ensure", "rna_gizmo_group_type_ensure");
1095 func, "Activate an existing widget group (when the persistent option isn't set)");
1097 parm = RNA_def_string(func, "identifier", nullptr, 0, "", "Gizmo group type name");
1099
1100 func = RNA_def_function(
1101 srna, "gizmo_group_type_unlink_delayed", "rna_gizmo_group_type_unlink_delayed");
1103 "Unlink a widget group (when the persistent option is set)");
1105 parm = RNA_def_string(func, "identifier", nullptr, 0, "", "Gizmo group type name");
1107
1108 /* Progress bar interface */
1109 func = RNA_def_function(srna, "progress_begin", "rna_progress_begin");
1110 RNA_def_function_ui_description(func, "Start progress report");
1111 parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_NONE);
1112 RNA_def_property_ui_text(parm, "min", "any value in range [0,9999]");
1114 parm = RNA_def_property(func, "max", PROP_FLOAT, PROP_NONE);
1116 RNA_def_property_ui_text(parm, "max", "any value in range [min+1,9998]");
1117
1118 func = RNA_def_function(srna, "progress_update", "rna_progress_update");
1119 RNA_def_function_ui_description(func, "Update the progress feedback");
1120 parm = RNA_def_property(func, "value", PROP_FLOAT, PROP_NONE);
1123 parm, "value", "Any value between min and max as set in progress_begin()");
1124
1125 func = RNA_def_function(srna, "progress_end", "rna_progress_end");
1126 RNA_def_function_ui_description(func, "Terminate progress report");
1127
1128 /* invoke functions, for use with python */
1129 func = RNA_def_function(srna, "invoke_props_popup", "rna_Operator_props_popup");
1131 func,
1132 "Operator popup invoke "
1133 "(show operator properties and execute it automatically on changes)");
1135
1136 /* invoked dialog opens popup with OK button, does not auto-exec operator. */
1137 func = RNA_def_function(srna, "invoke_props_dialog", "rna_Operator_props_dialog_popup");
1139 func,
1140 "Operator dialog (non-autoexec popup) invoke "
1141 "(show operator properties and only execute it on click on OK button)");
1143
1144 parm = RNA_def_property(func, "title", PROP_STRING, PROP_NONE);
1145 RNA_def_property_ui_text(parm, "Title", "Optional text to show as title of the popup");
1146 parm = RNA_def_property(func, "confirm_text", PROP_STRING, PROP_NONE);
1148 parm,
1149 "Confirm Text",
1150 "Optional text to show instead to the default \"OK\" confirmation button text");
1151 RNA_def_property(func, "cancel_default", PROP_BOOLEAN, PROP_NONE);
1153
1154 /* invoke enum */
1155 func = RNA_def_function(srna, "invoke_search_popup", "rna_Operator_enum_search_invoke");
1157 func,
1158 "Operator search popup invoke which "
1159 "searches values of the operator's :class:`bpy.types.Operator.bl_property` "
1160 "(which must be an EnumProperty), executing it on confirmation");
1161 rna_generic_op_invoke(func, 0);
1162
1163 /* invoke functions, for use with python */
1164 func = RNA_def_function(srna, "invoke_popup", "rna_Operator_ui_popup");
1166 "Operator popup invoke "
1167 "(only shows operator's properties, without executing it)");
1169 RNA_def_boolean(func,
1170 "auto_keymap",
1171 false,
1172 "Auto Keymap",
1173 "Assign accelerator keys to buttons, shown as underlined characters");
1174
1175 func = RNA_def_function(srna, "invoke_confirm", "rna_Operator_confirm");
1177 func,
1178 "Operator confirmation popup "
1179 "(only to let user confirm the execution, no operator properties shown)");
1181
1182 parm = RNA_def_property(func, "title", PROP_STRING, PROP_NONE);
1183 RNA_def_property_ui_text(parm, "Title", "Optional text to show as title of the popup");
1184
1185 parm = RNA_def_property(func, "message", PROP_STRING, PROP_NONE);
1186 RNA_def_property_ui_text(parm, "Message", "Optional first line of content text");
1187
1188 parm = RNA_def_property(func, "confirm_text", PROP_STRING, PROP_NONE);
1190 parm,
1191 "Confirm Text",
1192 "Optional text to show instead to the default \"OK\" confirmation button text");
1193
1194 parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
1197 RNA_def_property_ui_text(parm, "Icon", "Optional icon displayed in the dialog");
1198
1200
1201 func = RNA_def_function(srna, "try_activate_rna_button", "rna_WM_try_activate_rna_button");
1203 func,
1204 "Attempt to activate an button referencing an RNA property. If any other button in the "
1205 "screen is active, it will be deactivated");
1207 parm = RNA_def_pointer(func, "region", "Region", "", "");
1209 parm = RNA_def_pointer(func, "data", "AnyType", "", "");
1211 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in data");
1213 parm = RNA_def_property(func, "state", PROP_ENUM, PROP_NONE);
1215 parm,
1216 "State",
1217 "Activation state for button. Some states are specific to certain button types; when an "
1218 "incompatible state is provided, the button will be activated with the 'HIGHLIGHT' state.");
1221 parm = RNA_def_property(func, "warp_cursor_at_button", PROP_BOOLEAN, PROP_NONE);
1223 parm = RNA_def_property(func, "index", PROP_INT, PROP_NONE);
1225 parm,
1226 "Index",
1227 "RNA index of the button when a single member of the referenced RNA property is accessed");
1229 parm = RNA_def_property(func, "xy", PROP_INT, PROP_NONE);
1231 parm,
1232 "xy",
1233 "The center point of the button in window coordinates when successfully activated");
1234 RNA_def_property_array(parm, 2);
1236
1237 /* wrap popup_menu_begin */
1238 func = RNA_def_function(srna, "popmenu_begin__internal", "rna_PopMenuBegin");
1240 parm = RNA_def_string(func, "title", nullptr, 0, "", "");
1242 parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
1244 /* return */
1245 parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
1247 RNA_def_function_return(func, parm);
1248
1249 /* wrap popup_menu_end */
1250 func = RNA_def_function(srna, "popmenu_end__internal", "rna_PopMenuEnd");
1252 parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
1254
1255 /* wrap popover_begin */
1256 func = RNA_def_function(srna, "popover_begin__internal", "rna_PopoverBegin");
1258 RNA_def_property(func, "ui_units_x", PROP_INT, PROP_UNSIGNED);
1259 /* return */
1260 parm = RNA_def_pointer(func, "menu", "UIPopover", "", "");
1262 RNA_def_function_return(func, parm);
1264 func, "from_active_button", false, "Use Button", "Use the active button for positioning");
1265 RNA_def_boolean(func,
1266 "auto_keymap",
1267 false,
1268 "Auto Keymap",
1269 "Assign accelerator keys to buttons, shown as underlined characters");
1270
1271 /* wrap popover_end */
1272 func = RNA_def_function(srna, "popover_end__internal", "rna_PopoverEnd");
1274 parm = RNA_def_pointer(func, "menu", "UIPopover", "", "");
1276 RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map");
1277
1278 /* wrap ui::PieMenuBegin */
1279 func = RNA_def_function(srna, "piemenu_begin__internal", "rna_PieMenuBegin");
1281 parm = RNA_def_string(func, "title", nullptr, 0, "", "");
1283 parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
1285 parm = RNA_def_pointer(func, "event", "Event", "", "");
1287 /* return */
1288 parm = RNA_def_pointer(func, "menu_pie", "UIPieMenu", "", "");
1290 RNA_def_function_return(func, parm);
1291
1292 /* wrap ui::PieMenuEnd */
1293 func = RNA_def_function(srna, "piemenu_end__internal", "rna_PieMenuEnd");
1295 parm = RNA_def_pointer(func, "menu", "UIPieMenu", "", "");
1297
1298 /* access last operator options (optionally create). */
1299 func = RNA_def_function(
1300 srna, "operator_properties_last", "rna_WindoManager_operator_properties_last");
1302 parm = RNA_def_string(func, "operator", nullptr, 0, "", "");
1304 /* return */
1305 parm = RNA_def_pointer(func, "result", "OperatorProperties", "", "");
1307 RNA_def_function_return(func, parm);
1308
1309 RNA_def_function(srna, "print_undo_steps", "rna_WindowManager_print_undo_steps");
1310
1311 /* Used by (#SCRIPT_OT_reload). */
1312 func = RNA_def_function(srna, "tag_script_reload", "rna_WindowManager_tag_script_reload");
1314 func, "Tag for refreshing the interface after scripts have been reloaded");
1316
1317 parm = RNA_def_property(srna, "is_interface_locked", PROP_BOOLEAN, PROP_NONE);
1318 RNA_def_property_boolean_sdna(parm, nullptr, "runtime->is_interface_locked", 0);
1320 parm,
1321 "Is Interface Locked",
1322 "If true, the interface is currently locked by a running job and data should not be "
1323 "modified from application timers. Otherwise, the running job might conflict with the "
1324 "handler causing unexpected results or even crashes.");
1326}
1327
1329{
1330 FunctionRNA *func;
1331 PropertyRNA *parm;
1332
1333 /* utility, not for registering */
1334 func = RNA_def_function(srna, "report", "rna_Operator_report");
1335 parm = RNA_def_enum_flag(func, "type", rna_enum_wm_report_items, 0, "Type", "");
1337 parm = RNA_def_string(func, "message", nullptr, 0, "Report Message", "");
1339
1340 /* utility, not for registering */
1341 func = RNA_def_function(srna, "is_repeat", "rna_Operator_is_repeat");
1343 /* return */
1344 parm = RNA_def_boolean(func, "result", false, "result", "");
1345 RNA_def_function_return(func, parm);
1346
1347 /* Registration */
1348
1349 /* poll */
1350 func = RNA_def_function(srna, "poll", nullptr);
1351 RNA_def_function_ui_description(func, "Test if the operator can be called or not");
1353 RNA_def_function_return(func, RNA_def_boolean(func, "visible", false, "", ""));
1354 parm = RNA_def_pointer(func, "context", "Context", "", "");
1356
1357 /* exec */
1358 func = RNA_def_function(srna, "execute", nullptr);
1359 RNA_def_function_ui_description(func, "Execute the operator");
1361 parm = RNA_def_pointer(func, "context", "Context", "", "");
1363
1364 /* better name? */
1365 parm = RNA_def_enum_flag(
1366 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1367 RNA_def_function_return(func, parm);
1368
1369 /* check */
1370 func = RNA_def_function(srna, "check", nullptr);
1372 func, "Check the operator settings, return True to signal a change to redraw");
1374 parm = RNA_def_pointer(func, "context", "Context", "", "");
1376
1377 parm = RNA_def_boolean(func, "result", false, "result", ""); /* better name? */
1378 RNA_def_function_return(func, parm);
1379
1380 /* invoke */
1381 func = RNA_def_function(srna, "invoke", nullptr);
1382 RNA_def_function_ui_description(func, "Invoke the operator");
1384 parm = RNA_def_pointer(func, "context", "Context", "", "");
1386 parm = RNA_def_pointer(func, "event", "Event", "", "");
1388
1389 /* better name? */
1390 parm = RNA_def_enum_flag(
1391 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1392 RNA_def_function_return(func, parm);
1393
1394 func = RNA_def_function(srna, "modal", nullptr); /* same as invoke */
1395 RNA_def_function_ui_description(func, "Modal operator function");
1397 parm = RNA_def_pointer(func, "context", "Context", "", "");
1399 parm = RNA_def_pointer(func, "event", "Event", "", "");
1401
1402 /* better name? */
1403 parm = RNA_def_enum_flag(
1404 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1405 RNA_def_function_return(func, parm);
1406
1407 /* draw */
1408 func = RNA_def_function(srna, "draw", nullptr);
1409 RNA_def_function_ui_description(func, "Draw function for the operator");
1411 parm = RNA_def_pointer(func, "context", "Context", "", "");
1413
1414 /* cancel */
1415 func = RNA_def_function(srna, "cancel", nullptr);
1416 RNA_def_function_ui_description(func, "Called when the operator is canceled");
1418 parm = RNA_def_pointer(func, "context", "Context", "", "");
1420
1421 /* description */
1422 func = RNA_def_function(srna, "description", nullptr);
1423 RNA_def_function_ui_description(func, "Compute a description string that depends on parameters");
1425 parm = RNA_def_string(func, "result", nullptr, 4096, "result", "");
1428 RNA_def_function_output(func, parm);
1429 parm = RNA_def_pointer(func, "context", "Context", "", "");
1431 parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
1433}
1434
1436{
1437 FunctionRNA *func;
1438 PropertyRNA *parm;
1439
1440 /* utility, not for registering */
1441 func = RNA_def_function(srna, "report", "rna_Operator_report");
1442 parm = RNA_def_enum_flag(func, "type", rna_enum_wm_report_items, 0, "Type", "");
1444 parm = RNA_def_string(func, "message", nullptr, 0, "Report Message", "");
1446
1447 /* Registration */
1448
1449 /* poll */
1450 func = RNA_def_function(srna, "poll", nullptr);
1451 RNA_def_function_ui_description(func, "Test if the operator can be called or not");
1453 RNA_def_function_return(func, RNA_def_boolean(func, "visible", false, "", ""));
1454 parm = RNA_def_pointer(func, "context", "Context", "", "");
1456
1457 /* draw */
1458 func = RNA_def_function(srna, "draw", nullptr);
1459 RNA_def_function_ui_description(func, "Draw function for the operator");
1461 parm = RNA_def_pointer(func, "context", "Context", "", "");
1463}
1464
1466{
1467 // FunctionRNA *func;
1468 // PropertyRNA *parm;
1469}
1470
1472{
1473 FunctionRNA *func;
1474 PropertyRNA *parm;
1475
1476 func = RNA_def_function(srna, "active", "rna_keymap_active");
1478 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map");
1480 RNA_def_function_return(func, parm);
1481
1482 func = RNA_def_function(srna, "restore_to_default", "rna_keymap_restore_to_default");
1484
1485 func = RNA_def_function(srna, "restore_item_to_default", "rna_keymap_restore_item_to_default");
1487 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1489}
1490
1492{
1493 FunctionRNA *func;
1494 PropertyRNA *parm;
1495
1496 func = RNA_def_function(srna, "compare", "rna_KeyMapItem_compare");
1497 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1499 parm = RNA_def_boolean(func, "result", false, "Comparison result", "");
1500 RNA_def_function_return(func, parm);
1501
1502 func = RNA_def_function(srna, "to_string", "rna_KeyMapItem_to_string");
1503 RNA_def_boolean(func, "compact", false, "Compact", "");
1504 parm = RNA_def_string(func, "result", nullptr, UI_MAX_SHORTCUT_STR, "result", "");
1506 RNA_def_function_output(func, parm);
1507}
1508
1510{
1511 FunctionRNA *func;
1512 PropertyRNA *parm;
1513
1514 func = RNA_def_function(srna, "new", "rna_KeyMap_item_new");
1516 parm = RNA_def_string(func, "idname", nullptr, 0, "Operator Identifier", "");
1518 parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
1520 parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
1522 RNA_def_boolean(func, "any", false, "Any", "");
1523 RNA_def_int(func, "shift", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Shift", "", KM_ANY, KM_MOD_HELD);
1524 RNA_def_int(func, "ctrl", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Ctrl", "", KM_ANY, KM_MOD_HELD);
1525 RNA_def_int(func, "alt", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Alt", "", KM_ANY, KM_MOD_HELD);
1526 RNA_def_int(func, "oskey", KM_NOTHING, KM_ANY, KM_MOD_HELD, "OS Key", "", KM_ANY, KM_MOD_HELD);
1527 RNA_def_int(func, "hyper", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Hyper", "", KM_ANY, KM_MOD_HELD);
1528 RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
1529 RNA_def_enum(func, "direction", rna_enum_event_direction_items, KM_ANY, "Direction", "");
1530 RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
1531 RNA_def_boolean(func,
1532 "head",
1533 false,
1534 "At Head",
1535 "Force item to be added at start (not end) of key map so that "
1536 "it doesn't get blocked by an existing key map item");
1537 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
1539 RNA_def_function_return(func, parm);
1540
1541 func = RNA_def_function(srna, "new_modal", "rna_KeyMap_item_new_modal");
1543 parm = RNA_def_string(func, "propvalue", nullptr, 0, "Property Value", "");
1545 parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
1547 parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
1549 RNA_def_boolean(func, "any", false, "Any", "");
1550 RNA_def_int(func, "shift", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Shift", "", KM_ANY, KM_MOD_HELD);
1551 RNA_def_int(func, "ctrl", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Ctrl", "", KM_ANY, KM_MOD_HELD);
1552 RNA_def_int(func, "alt", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Alt", "", KM_ANY, KM_MOD_HELD);
1553 RNA_def_int(func, "oskey", KM_NOTHING, KM_ANY, KM_MOD_HELD, "OS Key", "", KM_ANY, KM_MOD_HELD);
1554 RNA_def_int(func, "hyper", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Hyper", "", KM_ANY, KM_MOD_HELD);
1555 RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
1556 RNA_def_enum(func, "direction", rna_enum_event_direction_items, KM_ANY, "Direction", "");
1557 RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
1558 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
1560 RNA_def_function_return(func, parm);
1561
1562 func = RNA_def_function(srna, "new_from_item", "rna_KeyMap_item_new_from_item");
1564 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Item to use as a reference");
1566 RNA_def_boolean(func, "head", false, "At Head", "");
1567 parm = RNA_def_pointer(func, "result", "KeyMapItem", "Item", "Added key map item");
1569 RNA_def_function_return(func, parm);
1570
1571 func = RNA_def_function(srna, "remove", "rna_KeyMap_item_remove");
1573 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1576
1577 func = RNA_def_function(srna, "from_id", "WM_keymap_item_find_id");
1578 parm = RNA_def_property(func, "id", PROP_INT, PROP_NONE);
1580 RNA_def_property_ui_text(parm, "id", "ID of the item");
1581 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1582 RNA_def_function_return(func, parm);
1583
1584 /* Keymap introspection
1585 * Args follow: KeyConfigs.find_item_from_operator */
1586 func = RNA_def_function(srna, "find_from_operator", "rna_KeyMap_item_find_from_operator");
1588 parm = RNA_def_string(func, "idname", nullptr, 0, "Operator Identifier", "");
1590 parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
1593 func, "include", rna_enum_event_type_mask_items, EVT_TYPE_MASK_ALL, "Include", "");
1594 RNA_def_enum_flag(func, "exclude", rna_enum_event_type_mask_items, 0, "Exclude", "");
1595 parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
1597 RNA_def_function_return(func, parm);
1598
1599 func = RNA_def_function(srna, "find_match", "rna_KeyMap_item_find_match");
1601 parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "The matching keymap");
1603 parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "The matching keymap item");
1605 parm = RNA_def_pointer(func,
1606 "result",
1607 "KeyMapItem",
1608 "",
1609 "The keymap item from this keymap which matches the keymap item from the "
1610 "arguments passed in");
1612 RNA_def_function_return(func, parm);
1613
1614 func = RNA_def_function(srna, "match_event", "rna_KeyMap_item_match_event");
1616 parm = RNA_def_pointer(func, "event", "Event", "", "Event to match against");
1618 parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
1620 RNA_def_function_return(func, parm);
1621}
1622
1624{
1625 FunctionRNA *func;
1626 PropertyRNA *parm;
1627
1628 func = RNA_def_function(srna, "new", "rna_KeyMaps_new");
1631 func,
1632 "Ensure the keymap exists. This will return the one with the given name/space type/region "
1633 "type, or create a new one if it does not exist yet.");
1634
1635 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "");
1637 RNA_def_enum(func, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
1639 func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
1640 RNA_def_boolean(func,
1641 "modal",
1642 false,
1643 "Modal",
1644 "Keymap for modal operators. "
1645 "Modal keymaps are not supported for :class:`KeyConfigs.addons`.");
1646 RNA_def_boolean(func, "tool", false, "Tool", "Keymap for active tools");
1647 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Added key map");
1649 RNA_def_function_return(func, parm);
1650
1651 func = RNA_def_function(srna, "remove", "rna_KeyMaps_remove");
1653 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Removed key map");
1656
1657 func = RNA_def_function(srna, "clear", "rna_KeyMaps_clear");
1658 RNA_def_function_ui_description(func, "Remove all keymaps.");
1659
1660 func = RNA_def_function(srna, "find", "rna_KeyMaps_find");
1661 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "");
1663 RNA_def_enum(func, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
1665 func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
1666 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map");
1667 RNA_def_function_return(func, parm);
1668
1669 func = RNA_def_function(srna, "find_match", "rna_KeyMaps_find_match");
1670 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "The key map for comparison");
1672 parm = RNA_def_pointer(func, "result", "KeyMap", "Key Map", "Corresponding key map");
1673 RNA_def_function_return(func, parm);
1674
1675 func = RNA_def_function(srna, "find_modal", "rna_KeyMaps_find_modal");
1676 parm = RNA_def_string(func, "name", nullptr, 0, "Operator Name", "");
1678 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map");
1679 RNA_def_function_return(func, parm);
1680}
1681
1683{
1684 FunctionRNA *func;
1685 PropertyRNA *parm;
1686
1687 func = RNA_def_function(srna, "new", "rna_KeyConfig_new"); /* add_keyconfig */
1688 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "");
1690 parm = RNA_def_pointer(
1691 func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration");
1693 RNA_def_function_return(func, parm);
1694
1695 func = RNA_def_function(srna, "remove", "rna_KeyConfig_remove"); /* remove_keyconfig */
1697 parm = RNA_def_pointer(
1698 func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration");
1701
1702 /* Helper functions */
1703
1704 /* Keymap introspection */
1705 func = RNA_def_function(
1706 srna, "find_item_from_operator", "rna_KeyConfig_find_item_from_operator");
1708 parm = RNA_def_string(func, "idname", nullptr, 0, "Operator Identifier", "");
1710 parm = RNA_def_property(func, "context", PROP_ENUM, PROP_NONE);
1712 parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
1715 func, "include", rna_enum_event_type_mask_items, EVT_TYPE_MASK_ALL, "Include", "");
1716 RNA_def_enum_flag(func, "exclude", rna_enum_event_type_mask_items, 0, "Exclude", "");
1717 parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
1719 parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
1721 RNA_def_function_return(func, parm);
1722
1723 func = RNA_def_function(srna, "update", "rna_KeyConfig_update"); /* WM_keyconfig_update */
1725 func,
1726 "keep_properties",
1727 false,
1728 "Keep Properties",
1729 "Operator properties are kept to allow the operators to be registered again in the future");
1730}
1731
1732/* Exposes the #blender::asset_system::asset_library_status_xxx() functions in the WM API, for the
1733 * lack of a better place. */
1735{
1736 FunctionRNA *func;
1737 PropertyRNA *parm;
1738
1739 func = RNA_def_function(
1740 srna, "asset_library_status_begin_loading", "rna_asset_library_status_begin_loading");
1742 func, "Inform the asset system that the asset library at the given URL is being loaded.");
1744 parm = RNA_def_string(func,
1745 "library_url",
1746 nullptr,
1747 0,
1748 "URL",
1749 "The URL identifying the asset library being loaded");
1751 parm = RNA_def_float(
1752 func,
1753 "timeout",
1754 0.3,
1755 0.0,
1756 FLT_MAX,
1757 "Timeout",
1758 "Maximum time in seconds after which the asset library loading will be considered "
1759 "cancelled, if no further status reporting is done (e.g. by repeated calls to "
1760 "`asset_library_status_ping_still_loading()`).",
1761 0.0,
1762 FLT_MAX);
1763
1764 func = RNA_def_function(srna,
1765 "asset_library_status_ping_still_loading",
1766 "rna_asset_library_status_ping_still_loading");
1768 "Inform the asset system that the loading is still ongoing. "
1769 "Call this regularly to prevent the loading status to timeout.");
1771 parm = RNA_def_string(func,
1772 "library_url",
1773 nullptr,
1774 0,
1775 "URL",
1776 "The URL identifying the asset library being loaded");
1778
1779 func = RNA_def_function(srna,
1780 "asset_library_status_ping_metafiles_in_place",
1781 "rna_asset_library_status_ping_metafiles_in_place");
1783 func,
1784 "Inform the asset system that the asset meta files (_asset-library-meta.json, "
1785 "asset-listing.json, blender_assets.cats.txt) are in place and ready to be loaded");
1787 parm = RNA_def_string(func,
1788 "library_url",
1789 nullptr,
1790 0,
1791 "URL",
1792 "The URL identifying the asset library being loaded");
1794
1795 func = RNA_def_function(srna,
1796 "asset_library_status_ping_loaded_new_pages",
1797 "rna_asset_library_status_ping_loaded_new_pages");
1798 RNA_def_function_ui_description(func, "Inform the asset system that new content");
1800 parm = RNA_def_string(func,
1801 "library_url",
1802 nullptr,
1803 0,
1804 "URL",
1805 "The URL identifying the asset library being loaded");
1807
1808 func = RNA_def_function(srna,
1809 "asset_library_status_ping_loaded_new_preview",
1810 "rna_asset_library_status_ping_loaded_new_preview");
1812 func, "Inform the asset system that a new preview is available and ready for display");
1814 parm = RNA_def_string(
1815 func,
1816 "preview_full_path",
1817 nullptr,
1818 0,
1819 "URL",
1820 "The full path (not URL!) pointing to the asset preview that should be available now");
1822
1823 func = RNA_def_function(srna,
1824 "asset_library_status_ping_asset_file_progress",
1825 "rna_asset_library_status_ping_asset_file_progress");
1827 func, "Inform the asset system about the current progress of an asset file.");
1829 parm = RNA_def_string(func,
1830 "absolute_file_url",
1831 nullptr,
1832 0,
1833 "URL",
1834 "The absolute URL this file was downloaded from");
1836 parm = RNA_def_int(func,
1837 "size_written_high",
1838 0,
1839 0,
1840 INT_MAX,
1841 "Size Written to Disk (high bits)",
1842 "The high 31 bits of the number of bytes written to disk (after "
1843 "uncompressing the download data, if needed)",
1844 0,
1845 0);
1847 parm = RNA_def_int(func,
1848 "size_written_low",
1849 0,
1850 0,
1851 INT_MAX,
1852 "Size Written to Disk (low bits)",
1853 "The low 31 bits of the number of bytes written to disk (after "
1854 "uncompressing the download data, if needed)",
1855 0,
1856 0);
1858
1859 func = RNA_def_function(srna,
1860 "asset_library_status_ping_asset_file_succeeded",
1861 "rna_asset_library_status_ping_asset_file_succeeded");
1863 "Inform the asset system that a single asset file download has "
1864 "finished successfully.");
1866 parm = RNA_def_string(func,
1867 "library_url",
1868 nullptr,
1869 0,
1870 "URL",
1871 "The URL identifying the asset library being loaded");
1873 parm = RNA_def_string(func,
1874 "absolute_file_url",
1875 nullptr,
1876 0,
1877 "URL",
1878 "The absolute URL this file was downloaded from");
1880 parm = RNA_def_string(func,
1881 "local_file_abspath",
1882 nullptr,
1883 0,
1884 "Local Path",
1885 "The absolute path this file was downloaded to");
1887
1888 func = RNA_def_function(srna,
1889 "asset_library_status_ping_asset_file_failed",
1890 "rna_asset_library_status_ping_asset_file_failed");
1892 "Inform the asset system that a single asset file download has "
1893 "stopped because of some failure.");
1895 parm = RNA_def_string(func,
1896 "library_url",
1897 nullptr,
1898 0,
1899 "URL",
1900 "The URL identifying the asset library being loaded");
1902 parm = RNA_def_string(func,
1903 "absolute_file_url",
1904 nullptr,
1905 0,
1906 "URL",
1907 "The absolute URL this file was downloaded from");
1909 parm = RNA_def_string(func,
1910 "local_file_abspath",
1911 nullptr,
1912 0,
1913 "Local Path",
1914 "The absolute path this file was supposed to be downloaded to");
1916
1917 func = RNA_def_function(srna,
1918 "asset_library_status_ping_finished_download_queue",
1919 "rna_asset_library_status_ping_finished_download_queue");
1921 "Inform the asset system that there are no more pending asset "
1922 "file downloads for any asset library.");
1924
1925 func = RNA_def_function(
1926 srna, "asset_library_status_finished_loading", "rna_asset_library_status_finished_loading");
1928 "Inform the asset system that the asset library at the given "
1929 "URL has successfully finished loading.");
1931 parm = RNA_def_string(func,
1932 "library_url",
1933 nullptr,
1934 0,
1935 "URL",
1936 "The URL identifying the asset library being loaded");
1938
1939 func = RNA_def_function(
1940 srna, "asset_library_status_failed_loading", "rna_asset_library_status_failed_loading");
1942 "Inform the asset system that the asset library at the given "
1943 "URL failed loading, and should be aborted.");
1945 parm = RNA_def_string(func,
1946 "library_url",
1947 nullptr,
1948 0,
1949 "URL",
1950 "The URL identifying the asset library being loaded");
1952 RNA_def_string(func, "message", nullptr, 0, "Message", "An error message to show to users");
1953
1954 func = RNA_def_function(
1955 srna, "register_node_group_operators", "rna_register_node_group_operators");
1957 "Trigger manual re-registration of node group operators. Useful "
1958 "in background mode where this doesn't happen automatically.");
1960}
1961
1962} // namespace blender
1963
1964#endif
#define G_MAIN
#define OP_MAX_TYPENAME
#define RNA_warning_bare(format,...)
#define C
Definition RandGen.cpp:29
#define UI_MAX_SHORTCUT_STR
#define NC_WINDOW
Definition WM_types.hh:388
#define KM_MOD_HELD
Definition WM_types.hh:339
#define ELEM(...)
btScalar max
static void ping_asset_file_download_succeeded(const bContext &C, StringRef library_url, StringRef absolute_file_url, StringRef local_file_abspath)
static void set_failure(StringRef url, std::optional< StringRefNull > failure_message)
static void begin_loading(StringRef url, float timeout)
static void ping_download_queue_done(const bContext &C)
static void ping_asset_file_download_failed(const bContext &C, StringRef library_url, StringRef absolute_file_url, StringRef local_file_abspath)
static void ping_asset_file_progress(StringRef absolute_file_url, int64_t size_in_bytes)
static void ping_new_preview(const bContext &C, StringRef preview_full_filepath)
#define FLT_MAX
#define INT_MAX
bool any(VecOp< bool, D >) RET
float4x4 translate(float4x4 mat, float3 translation)
const int state
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
void register_node_group_operators(const bContext &C)
std::optional< int2 > try_activate_rna_button(bContext *C, ARegion *region, ActivationButtonState target_state, PointerRNA *ptr, PropertyRNA *prop, bool warp_cursor_at_button=false, int index=0)
PieMenu * pie_menu_begin(bContext *C, const char *title, int icon, const wmEvent *event) ATTR_NONNULL()
PopupMenu * popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
void popover_end(bContext *C, Popover *pup, wmKeyMap *keymap)
Popover * popover_begin(bContext *C, int ui_menu_width, bool from_active_button, bool use_numselect) ATTR_NONNULL(1)
void popup_menu_end(bContext *C, PopupMenu *pup)
void pie_menu_end(bContext *C, PieMenu *pie)
BMesh Iterators.
wmKeyConfig * WM_keyconfig_ensure(wmWindowManager *wm, const char *idname, bool user_defined)
Definition wm_keymap.cc:310
void WM_main_add_notifier(uint type, void *reference)
void RNA_api_keymap(StructRNA *srna)
UserDef U
Definition blender.cc:58
wmKeyMap * WM_keymap_active(const wmWindowManager *wm, wmKeyMap *keymap)
ScrArea * CTX_wm_area(const bContext *C)
__int64 int64_t
Definition BKE_text.h:90
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
char * STRNCPY(char(&dst)[N], const char *src)
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_function_output(FunctionRNA *, PropertyRNA *ret)
@ RPT_WARNING
Definition BKE_report.hh:40
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool WM_gizmo_group_type_ensure_ptr(wmGizmoGroupType *gzgt)
const EnumPropertyItem rna_enum_space_type_items[]
Definition rna_space.cc:91
wmKeyMapItem * WM_modalkeymap_add_item(wmKeyMap *km, const KeyMapItem_Params *params, int value)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
void WM_keymap_remove(wmKeyConfig *keyconf, wmKeyMap *keymap)
Definition wm_keymap.cc:477
wmKeyMapItem * WM_event_match_keymap_item(bContext *C, wmKeyMap *keymap, const wmEvent *event)
wmKeyMapItem * WM_key_event_operator_from_keymap(wmKeyMap *keymap, const char *opname, IDProperty *properties, const short include_mask, const short exclude_mask)
const EnumPropertyItem rna_enum_event_value_items[]
Definition rna_wm.cc:488
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_api_keyconfig(StructRNA *srna)
void WM_gizmo_group_type_unlink_delayed_ptr(wmGizmoGroupType *gzgt)
@ FUNC_ALLOW_WRITE
@ FUNC_USE_REPORTS
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:980
@ FUNC_NO_SELF
Definition RNA_types.hh:998
@ FUNC_REGISTER_OPTIONAL
@ FUNC_USE_CONTEXT
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
size_t WM_operator_bl_idname(char *dst, const char *src)
wmWindow * CTX_wm_window(const bContext *C)
const EnumPropertyItem rna_operator_popup_icon_items[]
wmGizmoGroupType * WM_gizmogrouptype_find(const StringRef idname, bool quiet)
const EnumPropertyItem rna_enum_event_type_mask_items[]
Definition rna_wm.cc:529
wmKeyMapItem * WM_keymap_add_item(wmKeyMap *keymap, const char *idname, const KeyMapItem_Params *params)
Definition wm_keymap.cc:563
wmKeyMapItem * WM_keymap_item_find_match(wmKeyMap *km_base, wmKeyMap *km_match, const wmKeyMapItem *kmi_match, ReportList *reports)
wmOperatorStatus WM_operator_ui_popup(bContext *C, wmOperator *op, int width, const bool use_numselect)
wmEventModifierFlag
Definition WM_types.hh:290
void WM_cursor_progress(wmWindow *win, float progress_factor)
void RNA_api_keymaps(StructRNA *srna)
Global G
Definition blender.cc:57
bool RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *r_value)
const EnumPropertyItem rna_enum_operator_return_items[]
Definition rna_wm.cc:595
const EnumPropertyItem rna_enum_event_direction_items[]
Definition rna_wm.cc:500
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
void RNA_api_keymapitems(StructRNA *srna)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
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)
const EnumPropertyItem rna_enum_window_cursor_items[]
Definition rna_wm_api.cc:36
std::optional< StringRefNull > RNA_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, int translate)
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_STRING
Definition RNA_types.hh:213
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void BKE_undosys_print(UndoStack *ustack)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
const EnumPropertyItem rna_enum_event_type_items[]
Definition rna_wm.cc:225
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
bool WM_keymap_item_compare(const wmKeyMapItem *k1, const wmKeyMapItem *k2)
void WM_keymap_item_restore_to_default(wmWindowManager *wm, wmKeyMap *keymap, wmKeyMapItem *kmi)
const EnumPropertyItem rna_enum_operator_context_items[]
Definition rna_ui.cc:36
wmWindowManager * CTX_wm_manager(const bContext *C)
void WM_event_tablet_data_default_set(wmTabletData *tablet_data)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
wmKeyMapItem * WM_keymap_add_item_copy(wmKeyMap *keymap, const wmKeyMapItem *kmi_src)
Definition wm_keymap.cc:582
void WM_operator_last_properties_ensure(wmOperatorType *ot, PointerRNA *ptr)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void WM_cursor_modal_restore(wmWindow *win)
wmOperatorStatus WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *)
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition wm_keymap.cc:935
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
wmOperatorStatus WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message, const bool show_icon)
const char int BLI_str_utf8_size_or_error(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
wmEventHandler_Op * WM_event_add_modal_handler_ex(wmWindow *win, ScrArea *area, ARegion *region, wmOperator *op)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, ui::AlertIcon icon, bool cancel_default)
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
void api_ui_item_common_translation(FunctionRNA *func)
void RNA_api_operator(StructRNA *srna)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
wmKeyMapItem * WM_key_event_operator(const bContext *C, const char *opname, wm::OpCallContext opcontext, IDProperty *properties, const short include_mask, const short exclude_mask, wmKeyMap **r_keymap)
const char * RNA_struct_identifier(const StructRNA *type)
std::optional< std::string > WM_keymap_item_to_string(const wmKeyMapItem *kmi, const bool compact)
@ WM_GIZMOGROUPTYPE_PERSISTENT
void WM_script_tag_reload()
wmKeyMap * WM_keymap_list_find(ListBaseT< wmKeyMap > *lb, const char *idname, int spaceid, int regionid)
Definition wm_keymap.cc:903
const EnumPropertyItem rna_enum_region_type_items[]
Definition rna_screen.cc:28
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag 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 BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
@ WM_CURSOR_NS_SCROLL
Definition wm_cursors.hh:55
@ WM_CURSOR_WAIT
Definition wm_cursors.hh:19
@ WM_CURSOR_HAND_CLOSED
Definition wm_cursors.hh:25
@ WM_CURSOR_TEXT_EDIT
Definition wm_cursors.hh:18
@ WM_CURSOR_MUTE
Definition wm_cursors.hh:62
@ WM_CURSOR_PAINT
Definition wm_cursors.hh:29
@ WM_CURSOR_Y_MOVE
Definition wm_cursors.hh:42
@ WM_CURSOR_EDIT
Definition wm_cursors.hh:21
@ WM_CURSOR_ZOOM_OUT
Definition wm_cursors.hh:59
@ WM_CURSOR_HAND
Definition wm_cursors.hh:24
@ WM_CURSOR_ZOOM_IN
Definition wm_cursors.hh:58
@ WM_CURSOR_PAINT_BRUSH
Definition wm_cursors.hh:36
@ WM_CURSOR_NSEW_SCROLL
Definition wm_cursors.hh:54
@ WM_CURSOR_DEFAULT
Definition wm_cursors.hh:17
@ WM_CURSOR_STOP
Definition wm_cursors.hh:20
@ WM_CURSOR_X_MOVE
Definition wm_cursors.hh:41
@ WM_CURSOR_HAND_POINT
Definition wm_cursors.hh:26
@ WM_CURSOR_DOT
Definition wm_cursors.hh:30
@ WM_CURSOR_NONE
Definition wm_cursors.hh:61
@ WM_CURSOR_EW_SCROLL
Definition wm_cursors.hh:56
@ WM_CURSOR_PICK_AREA
Definition wm_cursors.hh:64
@ WM_CURSOR_CROSS
Definition wm_cursors.hh:28
@ WM_CURSOR_ERASER
Definition wm_cursors.hh:37
@ WM_CURSOR_EYEDROPPER
Definition wm_cursors.hh:38
@ WM_CURSOR_COPY
Definition wm_cursors.hh:22
@ WM_CURSOR_KNIFE
Definition wm_cursors.hh:33
void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
Definition wm_keymap.cc:333
void RNA_api_window(StructRNA *srna)
void WM_keymap_restore_to_default(wmKeyMap *keymap, wmWindowManager *wm)
@ G_FLAG_EVENT_SIMULATE
static void rna_generic_op_invoke(FunctionRNA *func, int flag)
void RNA_api_keymapitem(StructRNA *srna)
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_DYNAMIC
Definition RNA_types.hh:498
@ PROP_THICK_WRAP
Definition RNA_types.hh:493
@ PROP_NEVER_NULL
Definition RNA_types.hh:447
void RNA_api_asset_library_loading_status(StructRNA *srna)
wmWindow * ED_window_animation_playing_no_scrub(const wmWindowManager *wm)
Scene * ED_screen_find_playing_scene(const bScreen *screen, bool scrub=false)
const EnumPropertyItem rna_button_activation[]
void RNA_api_wm(StructRNA *srna)
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)
const EnumPropertyItem rna_enum_wm_report_items[]
Definition rna_wm.cc:627
@ KM_NOTHING
Definition WM_types.hh:323
@ KM_RELEASE
Definition WM_types.hh:325
wmOperatorStatus WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool WM_operator_is_repeat(const bContext *C, const wmOperator *op)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)
void WM_keyconfig_clear(wmKeyConfig *keyconf)
Definition wm_keymap.cc:355
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
Definition wm_keymap.cc:972
wmTimer * WM_event_timer_add(wmWindowManager *wm, wmWindow *win, const wmEventType event_type, const double time_step)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ PROP_UNSIGNED
Definition RNA_types.hh:306
wmEvent * WM_event_add_simulate(wmWindow *win, const wmEvent *event_to_add)
@ PARM_REQUIRED
Definition RNA_types.hh:631
@ PARM_RNAPTR
Definition RNA_types.hh:633
@ PARM_OUTPUT
Definition RNA_types.hh:632
wmKeyMapItem * WM_modalkeymap_add_item_str(wmKeyMap *km, const KeyMapItem_Params *params, const char *value)
const EnumPropertyItem rna_enum_icon_items[]
Definition rna_ui_api.cc:30
void RNA_api_windows(StructRNA *srna)
void RNA_def_property_int_default(PropertyRNA *prop, int value)
bScreen * WM_window_get_active_screen(const wmWindow *win)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_array(PropertyRNA *prop, int length)
ARegion * CTX_wm_region(const bContext *C)
void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
Definition wm_keymap.cc:595
void WM_keyconfig_update_ex(wmWindowManager *wm, bool keep_properties)
void RNA_api_macro(StructRNA *srna)
void RNA_api_keyconfigs(StructRNA *srna)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
signed short int16_t
Definition BKE_text.h:77
#define WM_GEN_INVOKE_EVENT
#define WM_GEN_INVOKE_SIZE
#define WM_GEN_INVOKE_RETURN
#define min(a, b)
Definition sort.cc:38
#define ISMOUSE_BUTTON(event_type)
#define ISMOUSE_MOTION(event_type)
#define ISKEYBOARD(event_type)
#define EVT_TYPE_MASK_ALL