Blender  V3.3
rna_wm_api.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation. All rights reserved. */
3 
8 #include <ctype.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 
12 #include "BLI_utildefines.h"
13 
14 #include "RNA_define.h"
15 #include "RNA_enum_types.h"
16 
17 #include "DNA_screen_types.h"
18 #include "DNA_space_types.h"
20 
21 #include "UI_interface.h"
22 
23 #include "wm_cursors.h"
24 #include "wm_event_types.h"
25 
26 #include "WM_api.h"
27 #include "WM_types.h"
28 
29 #include "rna_internal.h" /* own include */
30 
31 /* confusing 2 enums mixed up here */
33  {WM_CURSOR_DEFAULT, "DEFAULT", 0, "Default", ""},
34  {WM_CURSOR_NONE, "NONE", 0, "None", ""},
35  {WM_CURSOR_WAIT, "WAIT", 0, "Wait", ""},
36  {WM_CURSOR_EDIT, "CROSSHAIR", 0, "Crosshair", ""},
37  {WM_CURSOR_X_MOVE, "MOVE_X", 0, "Move-X", ""},
38  {WM_CURSOR_Y_MOVE, "MOVE_Y", 0, "Move-Y", ""},
39 
40  /* new */
41  {WM_CURSOR_KNIFE, "KNIFE", 0, "Knife", ""},
42  {WM_CURSOR_TEXT_EDIT, "TEXT", 0, "Text", ""},
43  {WM_CURSOR_PAINT_BRUSH, "PAINT_BRUSH", 0, "Paint Brush", ""},
44  {WM_CURSOR_PAINT, "PAINT_CROSS", 0, "Paint Cross", ""},
45  {WM_CURSOR_DOT, "DOT", 0, "Dot Cursor", ""},
46  {WM_CURSOR_ERASER, "ERASER", 0, "Eraser", ""},
47  {WM_CURSOR_HAND, "HAND", 0, "Hand", ""},
48  {WM_CURSOR_EW_SCROLL, "SCROLL_X", 0, "Scroll-X", ""},
49  {WM_CURSOR_NS_SCROLL, "SCROLL_Y", 0, "Scroll-Y", ""},
50  {WM_CURSOR_NSEW_SCROLL, "SCROLL_XY", 0, "Scroll-XY", ""},
51  {WM_CURSOR_EYEDROPPER, "EYEDROPPER", 0, "Eyedropper", ""},
52  {WM_CURSOR_PICK_AREA, "PICK_AREA", 0, "Pick Area", ""},
53  {WM_CURSOR_STOP, "STOP", 0, "Stop", ""},
54  {WM_CURSOR_COPY, "COPY", 0, "Copy", ""},
55  {WM_CURSOR_CROSS, "CROSS", 0, "Cross", ""},
56  {WM_CURSOR_MUTE, "MUTE", 0, "Mute", ""},
57  {WM_CURSOR_ZOOM_IN, "ZOOM_IN", 0, "Zoom In", ""},
58  {WM_CURSOR_ZOOM_OUT, "ZOOM_OUT", 0, "Zoom Out", ""},
59  {0, NULL, 0, NULL, NULL},
60 };
61 
62 #ifdef RNA_RUNTIME
63 
64 # include "BKE_context.h"
65 # include "BKE_undo_system.h"
66 
67 # include "WM_types.h"
68 
69 /* Needed since RNA doesn't use `const` in function signatures. */
70 static bool rna_KeyMapItem_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2)
71 {
72  return WM_keymap_item_compare(k1, k2);
73 }
74 
75 static void rna_KeyMapItem_to_string(wmKeyMapItem *kmi, bool compact, char *result)
76 {
78 }
79 
80 static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C)
81 {
83  return WM_keymap_active(wm, km);
84 }
85 
86 static void rna_keymap_restore_to_default(wmKeyMap *km, bContext *C)
87 {
89 }
90 
91 static void rna_keymap_restore_item_to_default(wmKeyMap *km, bContext *C, wmKeyMapItem *kmi)
92 {
94 }
95 
96 static void rna_Operator_report(wmOperator *op, int type, const char *msg)
97 {
98  BKE_report(op->reports, type, msg);
99 }
100 
101 static bool rna_Operator_is_repeat(wmOperator *op, bContext *C)
102 {
103  return WM_operator_is_repeat(C, op);
104 }
105 
106 /* since event isn't needed... */
107 static void rna_Operator_enum_search_invoke(bContext *C, wmOperator *op)
108 {
110 }
111 
112 static bool rna_event_modal_handler_add(struct bContext *C, struct wmOperator *operator)
113 {
114  return WM_event_add_modal_handler(C, operator) != NULL;
115 }
116 
117 /* XXX, need a way for python to know event types, 0x0110 is hard coded */
118 static wmTimer *rna_event_timer_add(struct wmWindowManager *wm, float time_step, wmWindow *win)
119 {
120  return WM_event_add_timer(wm, win, 0x0110, time_step);
121 }
122 
123 static void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer)
124 {
125  WM_event_remove_timer(wm, timer->win, timer);
126 }
127 
128 static wmGizmoGroupType *wm_gizmogrouptype_find_for_add_remove(ReportList *reports,
129  const char *idname)
130 {
131  wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, true);
132  if (gzgt == NULL) {
133  BKE_reportf(reports, RPT_ERROR, "Gizmo group type '%s' not found!", idname);
134  return NULL;
135  }
136  if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) {
137  BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' has 'PERSISTENT' option set!", idname);
138  return NULL;
139  }
140  return gzgt;
141 }
142 
143 static void rna_gizmo_group_type_ensure(ReportList *reports, const char *idname)
144 {
145  wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
146  if (gzgt != NULL) {
148  }
149 }
150 
151 static void rna_gizmo_group_type_unlink_delayed(ReportList *reports, const char *idname)
152 {
153  wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
154  if (gzgt != NULL) {
156  }
157 }
158 
159 /* Placeholder data for final implementation of a true progress-bar. */
160 static struct wmStaticProgress {
161  float min;
162  float max;
163  bool is_valid;
164 } wm_progress_state = {0, 0, false};
165 
166 static void rna_progress_begin(struct wmWindowManager *UNUSED(wm), float min, float max)
167 {
168  float range = max - min;
169  if (range != 0) {
170  wm_progress_state.min = min;
171  wm_progress_state.max = max;
172  wm_progress_state.is_valid = true;
173  }
174  else {
175  wm_progress_state.is_valid = false;
176  }
177 }
178 
179 static void rna_progress_update(struct wmWindowManager *wm, float value)
180 {
181  if (wm_progress_state.is_valid) {
182  /* Map to cursor_time range [0,9999] */
183  wmWindow *win = wm->winactive;
184  if (win) {
185  int val = (int)(10000 * (value - wm_progress_state.min) /
186  (wm_progress_state.max - wm_progress_state.min));
187  WM_cursor_time(win, val);
188  }
189  }
190 }
191 
192 static void rna_progress_end(struct wmWindowManager *wm)
193 {
194  if (wm_progress_state.is_valid) {
195  wmWindow *win = wm->winactive;
196  if (win) {
198  wm_progress_state.is_valid = false;
199  }
200  }
201 }
202 
203 /* wrap these because of 'const wmEvent *' */
204 static int rna_Operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
205 {
206  return WM_operator_confirm(C, op, event);
207 }
208 static int rna_Operator_props_popup(bContext *C, wmOperator *op, wmEvent *event)
209 {
210  return WM_operator_props_popup(C, op, event);
211 }
212 
213 static int keymap_item_modifier_flag_from_args(bool any, int shift, int ctrl, int alt, int oskey)
214 {
215  int modifier = 0;
216  if (any) {
217  modifier = KM_ANY;
218  }
219  else {
220  if (shift == KM_MOD_HELD) {
221  modifier |= KM_SHIFT;
222  }
223  else if (shift == KM_ANY) {
224  modifier |= KM_SHIFT_ANY;
225  }
226 
227  if (ctrl == KM_MOD_HELD) {
228  modifier |= KM_CTRL;
229  }
230  else if (ctrl == KM_ANY) {
231  modifier |= KM_CTRL_ANY;
232  }
233 
234  if (alt == KM_MOD_HELD) {
235  modifier |= KM_ALT;
236  }
237  else if (alt == KM_ANY) {
238  modifier |= KM_ALT_ANY;
239  }
240 
241  if (oskey == KM_MOD_HELD) {
242  modifier |= KM_OSKEY;
243  }
244  else if (oskey == KM_ANY) {
245  modifier |= KM_OSKEY_ANY;
246  }
247  }
248  return modifier;
249 }
250 
251 static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km,
252  ReportList *reports,
253  const char *idname,
254  int type,
255  int value,
256  bool any,
257  int shift,
258  int ctrl,
259  int alt,
260  int oskey,
261  int keymodifier,
262  int direction,
263  bool repeat,
264  bool head)
265 {
266  /* only on non-modal maps */
267  if (km->flag & KEYMAP_MODAL) {
268  BKE_report(reports, RPT_ERROR, "Not a non-modal keymap");
269  return NULL;
270  }
271 
272  // wmWindowManager *wm = CTX_wm_manager(C);
273  wmKeyMapItem *kmi = NULL;
274  char idname_bl[OP_MAX_TYPENAME];
275  const int modifier = keymap_item_modifier_flag_from_args(any, shift, ctrl, alt, oskey);
276 
277  WM_operator_bl_idname(idname_bl, idname);
278 
279  /* create keymap item */
280  kmi = WM_keymap_add_item(km,
281  idname_bl,
282  &(const KeyMapItem_Params){
283  .type = type,
284  .value = value,
285  .modifier = modifier,
286  .keymodifier = keymodifier,
287  .direction = direction,
288  });
289 
290  if (!repeat) {
291  kmi->flag |= KMI_REPEAT_IGNORE;
292  }
293 
294  /* T32437 allow scripts to define hotkeys that get added to start of keymap
295  * so that they stand a chance against catch-all defines later on
296  */
297  if (head) {
298  BLI_remlink(&km->items, kmi);
299  BLI_addhead(&km->items, kmi);
300  }
301 
302  return kmi;
303 }
304 
305 static wmKeyMapItem *rna_KeyMap_item_new_from_item(wmKeyMap *km,
306  ReportList *reports,
307  wmKeyMapItem *kmi_src,
308  bool head)
309 {
310  // wmWindowManager *wm = CTX_wm_manager(C);
311 
312  if ((km->flag & KEYMAP_MODAL) == (kmi_src->idname[0] != '\0')) {
313  BKE_report(reports, RPT_ERROR, "Can not mix modal/non-modal items");
314  return NULL;
315  }
316 
317  /* create keymap item */
318  wmKeyMapItem *kmi = WM_keymap_add_item_copy(km, kmi_src);
319  if (head) {
320  BLI_remlink(&km->items, kmi);
321  BLI_addhead(&km->items, kmi);
322  }
323  return kmi;
324 }
325 
326 static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km,
327  ReportList *reports,
328  const char *propvalue_str,
329  int type,
330  int value,
331  bool any,
332  int shift,
333  int ctrl,
334  int alt,
335  int oskey,
336  int keymodifier,
337  int direction,
338  bool repeat)
339 {
340  /* only modal maps */
341  if ((km->flag & KEYMAP_MODAL) == 0) {
342  BKE_report(reports, RPT_ERROR, "Not a modal keymap");
343  return NULL;
344  }
345 
346  wmKeyMapItem *kmi = NULL;
347  const int modifier = keymap_item_modifier_flag_from_args(any, shift, ctrl, alt, oskey);
348  int propvalue = 0;
349 
351  .type = type,
352  .value = value,
353  .modifier = modifier,
354  .keymodifier = keymodifier,
355  .direction = direction,
356  };
357 
358  /* not initialized yet, do delayed lookup */
359  if (!km->modal_items) {
360  kmi = WM_modalkeymap_add_item_str(km, &params, propvalue_str);
361  }
362  else {
363  if (RNA_enum_value_from_id(km->modal_items, propvalue_str, &propvalue) == 0) {
364  BKE_report(reports, RPT_WARNING, "Property value not in enumeration");
365  }
366  kmi = WM_modalkeymap_add_item(km, &params, propvalue);
367  }
368 
369  if (!repeat) {
370  kmi->flag |= KMI_REPEAT_IGNORE;
371  }
372 
373  return kmi;
374 }
375 
376 static void rna_KeyMap_item_remove(wmKeyMap *km, ReportList *reports, PointerRNA *kmi_ptr)
377 {
378  wmKeyMapItem *kmi = kmi_ptr->data;
379 
380  if (WM_keymap_remove_item(km, kmi) == false) {
381  BKE_reportf(reports,
382  RPT_ERROR,
383  "KeyMapItem '%s' cannot be removed from '%s'",
384  kmi->idname,
385  km->idname);
386  return;
387  }
388 
389  RNA_POINTER_INVALIDATE(kmi_ptr);
390 }
391 
392 static PointerRNA rna_KeyMap_item_find_from_operator(ID *id,
393  wmKeyMap *km,
394  const char *idname,
395  PointerRNA *properties,
396  int include_mask,
397  int exclude_mask)
398 {
399  char idname_bl[OP_MAX_TYPENAME];
400  WM_operator_bl_idname(idname_bl, idname);
401 
403  km, idname_bl, properties->data, include_mask, exclude_mask);
404  PointerRNA kmi_ptr;
405  RNA_pointer_create(id, &RNA_KeyMapItem, kmi, &kmi_ptr);
406  return kmi_ptr;
407 }
408 
409 static PointerRNA rna_KeyMap_item_match_event(ID *id, wmKeyMap *km, bContext *C, wmEvent *event)
410 {
411  wmKeyMapItem *kmi = WM_event_match_keymap_item(C, km, event);
412  PointerRNA kmi_ptr;
413  RNA_pointer_create(id, &RNA_KeyMapItem, kmi, &kmi_ptr);
414  return kmi_ptr;
415 }
416 
417 static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf,
418  ReportList *reports,
419  const char *idname,
420  int spaceid,
421  int regionid,
422  bool modal,
423  bool tool)
424 {
425  if (modal) {
426  /* Sanity check: Don't allow add-ons to override internal modal key-maps
427  * because this isn't supported, the restriction can be removed when
428  * add-ons can define modal key-maps.
429  * Currently this is only useful for add-ons to override built-in modal keymaps
430  * which is not the intended use for add-on keymaps. */
431  wmWindowManager *wm = G_MAIN->wm.first;
432  if (keyconf == wm->addonconf) {
433  BKE_reportf(reports, RPT_ERROR, "Modal key-maps not supported for add-on key-config");
434  return NULL;
435  }
436  }
437 
438  wmKeyMap *keymap;
439 
440  if (modal == 0) {
441  keymap = WM_keymap_ensure(keyconf, idname, spaceid, regionid);
442  }
443  else {
444  keymap = WM_modalkeymap_ensure(keyconf, idname, NULL); /* items will be lazy init */
445  }
446 
447  if (keymap && tool) {
448  keymap->flag |= KEYMAP_TOOL;
449  }
450 
451  return keymap;
452 }
453 
454 static wmKeyMap *rna_keymap_find(wmKeyConfig *keyconf,
455  const char *idname,
456  int spaceid,
457  int regionid)
458 {
459  return WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
460 }
461 
462 static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *UNUSED(keyconf), const char *idname)
463 {
464  wmOperatorType *ot = WM_operatortype_find(idname, 0);
465 
466  if (!ot) {
467  return NULL;
468  }
469  else {
470  return ot->modalkeymap;
471  }
472 }
473 
474 static void rna_KeyMap_remove(wmKeyConfig *keyconfig, ReportList *reports, PointerRNA *keymap_ptr)
475 {
476  wmKeyMap *keymap = keymap_ptr->data;
477 
478  if (WM_keymap_remove(keyconfig, keymap) == false) {
479  BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keymap->idname);
480  return;
481  }
482 
483  RNA_POINTER_INVALIDATE(keymap_ptr);
484 }
485 
486 static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, PointerRNA *keyconf_ptr)
487 {
488  wmKeyConfig *keyconf = keyconf_ptr->data;
489 
490  if (WM_keyconfig_remove(wm, keyconf) == false) {
491  BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keyconf->idname);
492  return;
493  }
494 
495  RNA_POINTER_INVALIDATE(keyconf_ptr);
496 }
497 
498 static PointerRNA rna_KeyConfig_find_item_from_operator(wmWindowManager *wm,
499  bContext *C,
500  const char *idname,
501  int opcontext,
502  PointerRNA *properties,
503  int include_mask,
504  int exclude_mask,
505  PointerRNA *km_ptr)
506 {
507  char idname_bl[OP_MAX_TYPENAME];
508  WM_operator_bl_idname(idname_bl, idname);
509 
510  wmKeyMap *km = NULL;
512  C, idname_bl, opcontext, properties->data, include_mask, exclude_mask, &km);
513  PointerRNA kmi_ptr;
514  RNA_pointer_create(&wm->id, &RNA_KeyMap, km, km_ptr);
515  RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &kmi_ptr);
516  return kmi_ptr;
517 }
518 
519 static void rna_KeyConfig_update(wmWindowManager *wm)
520 {
522 }
523 
524 /* popup menu wrapper */
525 static PointerRNA rna_PopMenuBegin(bContext *C, const char *title, int icon)
526 {
527  PointerRNA r_ptr;
528  void *data;
529 
530  data = (void *)UI_popup_menu_begin(C, title, icon);
531 
532  RNA_pointer_create(NULL, &RNA_UIPopupMenu, data, &r_ptr);
533 
534  return r_ptr;
535 }
536 
537 static void rna_PopMenuEnd(bContext *C, PointerRNA *handle)
538 {
539  UI_popup_menu_end(C, handle->data);
540 }
541 
542 /* popover wrapper */
543 static PointerRNA rna_PopoverBegin(bContext *C, int ui_units_x, bool from_active_button)
544 {
545  PointerRNA r_ptr;
546  void *data;
547 
548  data = (void *)UI_popover_begin(C, U.widget_unit * ui_units_x, from_active_button);
549 
550  RNA_pointer_create(NULL, &RNA_UIPopover, data, &r_ptr);
551 
552  return r_ptr;
553 }
554 
555 static void rna_PopoverEnd(bContext *C, PointerRNA *handle, wmKeyMap *keymap)
556 {
557  UI_popover_end(C, handle->data, keymap);
558 }
559 
560 /* pie menu wrapper */
561 static PointerRNA rna_PieMenuBegin(bContext *C, const char *title, int icon, PointerRNA *event)
562 {
563  PointerRNA r_ptr;
564  void *data;
565 
566  data = (void *)UI_pie_menu_begin(C, title, icon, event->data);
567 
568  RNA_pointer_create(NULL, &RNA_UIPieMenu, data, &r_ptr);
569 
570  return r_ptr;
571 }
572 
573 static void rna_PieMenuEnd(bContext *C, PointerRNA *handle)
574 {
575  UI_pie_menu_end(C, handle->data);
576 }
577 
578 static void rna_WindowManager_print_undo_steps(wmWindowManager *wm)
579 {
581 }
582 
583 static void rna_WindowManager_tag_script_reload(void)
584 {
587 }
588 
589 static PointerRNA rna_WindoManager_operator_properties_last(const char *idname)
590 {
591  wmOperatorType *ot = WM_operatortype_find(idname, true);
592 
593  if (ot != NULL) {
594  PointerRNA ptr;
596  return ptr;
597  }
598  return PointerRNA_NULL;
599 }
600 
601 static wmEvent *rna_Window_event_add_simulate(wmWindow *win,
602  ReportList *reports,
603  int type,
604  int value,
605  const char *unicode,
606  int x,
607  int y,
608  bool shift,
609  bool ctrl,
610  bool alt,
611  bool oskey)
612 {
613  if ((G.f & G_FLAG_EVENT_SIMULATE) == 0) {
614  BKE_report(reports, RPT_ERROR, "Not running with '--enable-event-simulate' enabled");
615  return NULL;
616  }
617 
618  if (!ELEM(value, KM_PRESS, KM_RELEASE, KM_NOTHING)) {
619  BKE_report(reports, RPT_ERROR, "Value: only 'PRESS/RELEASE/NOTHING' are supported");
620  return NULL;
621  }
622  if (ISKEYBOARD(type) || ISMOUSE_BUTTON(type)) {
623  if (!ELEM(value, KM_PRESS, KM_RELEASE)) {
624  BKE_report(reports, RPT_ERROR, "Value: must be 'PRESS/RELEASE' for keyboard/buttons");
625  return NULL;
626  }
627  }
628  if (ISMOUSE_MOTION(type)) {
629  if (value != KM_NOTHING) {
630  BKE_report(reports, RPT_ERROR, "Value: must be 'NOTHING' for motion");
631  return NULL;
632  }
633  }
634  if (unicode != NULL) {
635  if (value != KM_PRESS) {
636  BKE_report(reports, RPT_ERROR, "Value: must be 'PRESS' when unicode is set");
637  return NULL;
638  }
639  }
640  /* TODO: validate NDOF. */
641 
642  if (unicode != NULL) {
643  int len = BLI_str_utf8_size(unicode);
644  if (len == -1 || unicode[len] != '\0') {
645  BKE_report(reports, RPT_ERROR, "Only a single character supported");
646  return NULL;
647  }
648  }
649 
650  wmEvent e = *win->eventstate;
651  e.type = type;
652  e.val = value;
653  e.flag = 0;
654  e.xy[0] = x;
655  e.xy[1] = y;
656 
657  e.modifier = 0;
658  if (shift) {
659  e.modifier |= KM_SHIFT;
660  }
661  if (ctrl) {
662  e.modifier |= KM_CTRL;
663  }
664  if (alt) {
665  e.modifier |= KM_ALT;
666  }
667  if (oskey) {
668  e.modifier |= KM_OSKEY;
669  }
670 
671  e.utf8_buf[0] = '\0';
672  if (unicode != NULL) {
673  STRNCPY(e.utf8_buf, unicode);
674  }
675 
676  /* Until we expose setting tablet values here. */
678 
679  return WM_event_add_simulate(win, &e);
680 }
681 
682 #else
683 
684 # define WM_GEN_INVOKE_EVENT (1 << 0)
685 # define WM_GEN_INVOKE_SIZE (1 << 1)
686 # define WM_GEN_INVOKE_RETURN (1 << 2)
687 
688 static void rna_generic_op_invoke(FunctionRNA *func, int flag)
689 {
690  PropertyRNA *parm;
691 
693  parm = RNA_def_pointer(func, "operator", "Operator", "", "Operator to call");
695 
696  if (flag & WM_GEN_INVOKE_EVENT) {
697  parm = RNA_def_pointer(func, "event", "Event", "", "Event");
699  }
700 
701  if (flag & WM_GEN_INVOKE_SIZE) {
702  RNA_def_int(func, "width", 300, 0, INT_MAX, "", "Width of the popup", 0, INT_MAX);
703  }
704 
705  if (flag & WM_GEN_INVOKE_RETURN) {
706  parm = RNA_def_enum_flag(
707  func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
708  RNA_def_function_return(func, parm);
709  }
710 }
711 
713 {
714  FunctionRNA *func;
715  PropertyRNA *parm;
716 
717  func = RNA_def_function(srna, "cursor_warp", "WM_cursor_warp");
718  parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
720  parm = RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
722  RNA_def_function_ui_description(func, "Set the cursor position");
723 
724  func = RNA_def_function(srna, "cursor_set", "WM_cursor_set");
725  parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE);
728  RNA_def_function_ui_description(func, "Set the cursor");
729 
730  func = RNA_def_function(srna, "cursor_modal_set", "WM_cursor_modal_set");
731  parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE);
734  RNA_def_function_ui_description(func, "Set the cursor, so the previous cursor can be restored");
735 
736  RNA_def_function(srna, "cursor_modal_restore", "WM_cursor_modal_restore");
738  func, "Restore the previous cursor after calling ``cursor_modal_set``");
739 
740  /* Arguments match 'rna_KeyMap_item_new'. */
741  func = RNA_def_function(srna, "event_simulate", "rna_Window_event_add_simulate");
743  parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
745  parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
747  parm = RNA_def_string(func, "unicode", NULL, 0, "", "");
749 
750  RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
751  RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
752 
753  RNA_def_boolean(func, "shift", 0, "Shift", "");
754  RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
755  RNA_def_boolean(func, "alt", 0, "Alt", "");
756  RNA_def_boolean(func, "oskey", 0, "OS Key", "");
757  parm = RNA_def_pointer(func, "event", "Event", "Item", "Added key map item");
758  RNA_def_function_return(func, parm);
759 }
760 
762 {
763  FunctionRNA *func;
764  PropertyRNA *parm;
765 
766  func = RNA_def_function(srna, "fileselect_add", "WM_event_add_fileselect");
768  func,
769  "Opens a file selector with an operator. "
770  "The string properties 'filepath', 'filename', 'directory' and a 'files' "
771  "collection are assigned when present in the operator");
772  rna_generic_op_invoke(func, 0);
773 
774  func = RNA_def_function(srna, "modal_handler_add", "rna_event_modal_handler_add");
776  func,
777  "Add a modal handler to the window manager, for the given modal operator "
778  "(called by invoke() with self, just before returning {'RUNNING_MODAL'})");
780  parm = RNA_def_pointer(func, "operator", "Operator", "", "Operator to call");
783  func, RNA_def_boolean(func, "handle", 1, "", "Whether adding the handler was successful"));
784 
785  func = RNA_def_function(srna, "event_timer_add", "rna_event_timer_add");
787  func, "Add a timer to the given window, to generate periodic 'TIMER' events");
788  parm = RNA_def_property(func, "time_step", PROP_FLOAT, PROP_NONE);
790  RNA_def_property_range(parm, 0.0, FLT_MAX);
791  RNA_def_property_ui_text(parm, "Time Step", "Interval in seconds between timer events");
792  RNA_def_pointer(func, "window", "Window", "", "Window to attach the timer to, or None");
793  parm = RNA_def_pointer(func, "result", "Timer", "", "");
794  RNA_def_function_return(func, parm);
795 
796  func = RNA_def_function(srna, "event_timer_remove", "rna_event_timer_remove");
797  parm = RNA_def_pointer(func, "timer", "Timer", "", "");
799 
800  func = RNA_def_function(srna, "gizmo_group_type_ensure", "rna_gizmo_group_type_ensure");
802  func, "Activate an existing widget group (when the persistent option isn't set)");
804  parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name");
806 
807  func = RNA_def_function(
808  srna, "gizmo_group_type_unlink_delayed", "rna_gizmo_group_type_unlink_delayed");
810  "Unlink a widget group (when the persistent option is set)");
812  parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name");
814 
815  /* Progress bar interface */
816  func = RNA_def_function(srna, "progress_begin", "rna_progress_begin");
817  RNA_def_function_ui_description(func, "Start progress report");
818  parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_NONE);
819  RNA_def_property_ui_text(parm, "min", "any value in range [0,9999]");
821  parm = RNA_def_property(func, "max", PROP_FLOAT, PROP_NONE);
823  RNA_def_property_ui_text(parm, "max", "any value in range [min+1,9998]");
824 
825  func = RNA_def_function(srna, "progress_update", "rna_progress_update");
826  RNA_def_function_ui_description(func, "Update the progress feedback");
827  parm = RNA_def_property(func, "value", PROP_FLOAT, PROP_NONE);
830  parm, "value", "Any value between min and max as set in progress_begin()");
831 
832  func = RNA_def_function(srna, "progress_end", "rna_progress_end");
833  RNA_def_function_ui_description(func, "Terminate progress report");
834 
835  /* invoke functions, for use with python */
836  func = RNA_def_function(srna, "invoke_props_popup", "rna_Operator_props_popup");
838  func,
839  "Operator popup invoke "
840  "(show operator properties and execute it automatically on changes)");
842 
843  /* invoked dialog opens popup with OK button, does not auto-exec operator. */
844  func = RNA_def_function(srna, "invoke_props_dialog", "WM_operator_props_dialog_popup");
846  func,
847  "Operator dialog (non-autoexec popup) invoke "
848  "(show operator properties and only execute it on click on OK button)");
850 
851  /* invoke enum */
852  func = RNA_def_function(srna, "invoke_search_popup", "rna_Operator_enum_search_invoke");
854  func,
855  "Operator search popup invoke which "
856  "searches values of the operator's :class:`bpy.types.Operator.bl_property` "
857  "(which must be an EnumProperty), executing it on confirmation");
858  rna_generic_op_invoke(func, 0);
859 
860  /* invoke functions, for use with python */
861  func = RNA_def_function(srna, "invoke_popup", "WM_operator_ui_popup");
863  "Operator popup invoke "
864  "(only shows operator's properties, without executing it)");
866 
867  func = RNA_def_function(srna, "invoke_confirm", "rna_Operator_confirm");
869  func,
870  "Operator confirmation popup "
871  "(only to let user confirm the execution, no operator properties shown)");
873 
874  /* wrap UI_popup_menu_begin */
875  func = RNA_def_function(srna, "popmenu_begin__internal", "rna_PopMenuBegin");
877  parm = RNA_def_string(func, "title", NULL, 0, "", "");
879  parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
881  /* return */
882  parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
884  RNA_def_function_return(func, parm);
885 
886  /* wrap UI_popup_menu_end */
887  func = RNA_def_function(srna, "popmenu_end__internal", "rna_PopMenuEnd");
889  parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
891 
892  /* wrap UI_popover_begin */
893  func = RNA_def_function(srna, "popover_begin__internal", "rna_PopoverBegin");
895  RNA_def_property(func, "ui_units_x", PROP_INT, PROP_UNSIGNED);
896  /* return */
897  parm = RNA_def_pointer(func, "menu", "UIPopover", "", "");
899  RNA_def_function_return(func, parm);
901  func, "from_active_button", 0, "Use Button", "Use the active button for positioning");
902 
903  /* wrap UI_popover_end */
904  func = RNA_def_function(srna, "popover_end__internal", "rna_PopoverEnd");
906  parm = RNA_def_pointer(func, "menu", "UIPopover", "", "");
908  RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map");
909 
910  /* wrap uiPieMenuBegin */
911  func = RNA_def_function(srna, "piemenu_begin__internal", "rna_PieMenuBegin");
913  parm = RNA_def_string(func, "title", NULL, 0, "", "");
915  parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
917  parm = RNA_def_pointer(func, "event", "Event", "", "");
919  /* return */
920  parm = RNA_def_pointer(func, "menu_pie", "UIPieMenu", "", "");
922  RNA_def_function_return(func, parm);
923 
924  /* wrap uiPieMenuEnd */
925  func = RNA_def_function(srna, "piemenu_end__internal", "rna_PieMenuEnd");
927  parm = RNA_def_pointer(func, "menu", "UIPieMenu", "", "");
929 
930  /* access last operator options (optionally create). */
931  func = RNA_def_function(
932  srna, "operator_properties_last", "rna_WindoManager_operator_properties_last");
934  parm = RNA_def_string(func, "operator", NULL, 0, "", "");
936  /* return */
937  parm = RNA_def_pointer(func, "result", "OperatorProperties", "", "");
939  RNA_def_function_return(func, parm);
940 
941  RNA_def_function(srna, "print_undo_steps", "rna_WindowManager_print_undo_steps");
942 
943  /* Used by (#SCRIPT_OT_reload). */
944  func = RNA_def_function(srna, "tag_script_reload", "rna_WindowManager_tag_script_reload");
946  func, "Tag for refreshing the interface after scripts have been reloaded");
948 
949  parm = RNA_def_property(srna, "is_interface_locked", PROP_BOOLEAN, PROP_NONE);
951  parm,
952  "Is Interface Locked",
953  "If true, the interface is currently locked by a running job and data shouldn't be modified "
954  "from application timers. Otherwise, the running job might conflict with the handler "
955  "causing unexpected results or even crashes");
957 }
958 
960 {
961  FunctionRNA *func;
962  PropertyRNA *parm;
963 
964  /* utility, not for registering */
965  func = RNA_def_function(srna, "report", "rna_Operator_report");
966  parm = RNA_def_enum_flag(func, "type", rna_enum_wm_report_items, 0, "Type", "");
968  parm = RNA_def_string(func, "message", NULL, 0, "Report Message", "");
970 
971  /* utility, not for registering */
972  func = RNA_def_function(srna, "is_repeat", "rna_Operator_is_repeat");
974  /* return */
975  parm = RNA_def_boolean(func, "result", 0, "result", "");
976  RNA_def_function_return(func, parm);
977 
978  /* Registration */
979 
980  /* poll */
981  func = RNA_def_function(srna, "poll", NULL);
982  RNA_def_function_ui_description(func, "Test if the operator can be called or not");
984  RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
985  parm = RNA_def_pointer(func, "context", "Context", "", "");
987 
988  /* exec */
989  func = RNA_def_function(srna, "execute", NULL);
990  RNA_def_function_ui_description(func, "Execute the operator");
992  parm = RNA_def_pointer(func, "context", "Context", "", "");
994 
995  /* better name? */
996  parm = RNA_def_enum_flag(
997  func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
998  RNA_def_function_return(func, parm);
999 
1000  /* check */
1001  func = RNA_def_function(srna, "check", NULL);
1003  func, "Check the operator settings, return True to signal a change to redraw");
1005  parm = RNA_def_pointer(func, "context", "Context", "", "");
1007 
1008  parm = RNA_def_boolean(func, "result", 0, "result", ""); /* better name? */
1009  RNA_def_function_return(func, parm);
1010 
1011  /* invoke */
1012  func = RNA_def_function(srna, "invoke", NULL);
1013  RNA_def_function_ui_description(func, "Invoke the operator");
1015  parm = RNA_def_pointer(func, "context", "Context", "", "");
1017  parm = RNA_def_pointer(func, "event", "Event", "", "");
1019 
1020  /* better name? */
1021  parm = RNA_def_enum_flag(
1022  func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1023  RNA_def_function_return(func, parm);
1024 
1025  func = RNA_def_function(srna, "modal", NULL); /* same as invoke */
1026  RNA_def_function_ui_description(func, "Modal operator function");
1028  parm = RNA_def_pointer(func, "context", "Context", "", "");
1030  parm = RNA_def_pointer(func, "event", "Event", "", "");
1032 
1033  /* better name? */
1034  parm = RNA_def_enum_flag(
1035  func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1036  RNA_def_function_return(func, parm);
1037 
1038  /* draw */
1039  func = RNA_def_function(srna, "draw", NULL);
1040  RNA_def_function_ui_description(func, "Draw function for the operator");
1042  parm = RNA_def_pointer(func, "context", "Context", "", "");
1044 
1045  /* cancel */
1046  func = RNA_def_function(srna, "cancel", NULL);
1047  RNA_def_function_ui_description(func, "Called when the operator is canceled");
1049  parm = RNA_def_pointer(func, "context", "Context", "", "");
1051 
1052  /* description */
1053  func = RNA_def_function(srna, "description", NULL);
1054  RNA_def_function_ui_description(func, "Compute a description string that depends on parameters");
1056  parm = RNA_def_string(func, "result", NULL, 4096, "result", "");
1059  RNA_def_function_output(func, parm);
1060  parm = RNA_def_pointer(func, "context", "Context", "", "");
1062  parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
1064 }
1065 
1067 {
1068  FunctionRNA *func;
1069  PropertyRNA *parm;
1070 
1071  /* utility, not for registering */
1072  func = RNA_def_function(srna, "report", "rna_Operator_report");
1073  parm = RNA_def_enum_flag(func, "type", rna_enum_wm_report_items, 0, "Type", "");
1075  parm = RNA_def_string(func, "message", NULL, 0, "Report Message", "");
1077 
1078  /* Registration */
1079 
1080  /* poll */
1081  func = RNA_def_function(srna, "poll", NULL);
1082  RNA_def_function_ui_description(func, "Test if the operator can be called or not");
1084  RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
1085  parm = RNA_def_pointer(func, "context", "Context", "", "");
1087 
1088  /* draw */
1089  func = RNA_def_function(srna, "draw", NULL);
1090  RNA_def_function_ui_description(func, "Draw function for the operator");
1092  parm = RNA_def_pointer(func, "context", "Context", "", "");
1094 }
1095 
1097 {
1098  /* FunctionRNA *func; */
1099  /* PropertyRNA *parm; */
1100 }
1101 
1103 {
1104  FunctionRNA *func;
1105  PropertyRNA *parm;
1106 
1107  func = RNA_def_function(srna, "active", "rna_keymap_active");
1109  parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map");
1110  RNA_def_function_return(func, parm);
1111 
1112  func = RNA_def_function(srna, "restore_to_default", "rna_keymap_restore_to_default");
1114 
1115  func = RNA_def_function(srna, "restore_item_to_default", "rna_keymap_restore_item_to_default");
1117  parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1119 }
1120 
1122 {
1123  FunctionRNA *func;
1124  PropertyRNA *parm;
1125 
1126  func = RNA_def_function(srna, "compare", "rna_KeyMapItem_compare");
1127  parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1129  parm = RNA_def_boolean(func, "result", 0, "Comparison result", "");
1130  RNA_def_function_return(func, parm);
1131 
1132  func = RNA_def_function(srna, "to_string", "rna_KeyMapItem_to_string");
1133  RNA_def_boolean(func, "compact", false, "Compact", "");
1134  parm = RNA_def_string(func, "result", NULL, UI_MAX_SHORTCUT_STR, "result", "");
1136  RNA_def_function_output(func, parm);
1137 }
1138 
1140 {
1141  FunctionRNA *func;
1142  PropertyRNA *parm;
1143 
1144  func = RNA_def_function(srna, "new", "rna_KeyMap_item_new");
1146  parm = RNA_def_string(func, "idname", NULL, 0, "Operator Identifier", "");
1148  parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
1150  parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
1152  RNA_def_boolean(func, "any", 0, "Any", "");
1153  RNA_def_int(func, "shift", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Shift", "", KM_ANY, KM_MOD_HELD);
1154  RNA_def_int(func, "ctrl", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Ctrl", "", KM_ANY, KM_MOD_HELD);
1155  RNA_def_int(func, "alt", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Alt", "", KM_ANY, KM_MOD_HELD);
1156  RNA_def_int(func, "oskey", KM_NOTHING, KM_ANY, KM_MOD_HELD, "OS Key", "", KM_ANY, KM_MOD_HELD);
1157  RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
1158  RNA_def_enum(func, "direction", rna_enum_event_direction_items, KM_ANY, "Direction", "");
1159  RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
1160  RNA_def_boolean(func,
1161  "head",
1162  0,
1163  "At Head",
1164  "Force item to be added at start (not end) of key map so that "
1165  "it doesn't get blocked by an existing key map item");
1166  parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
1167  RNA_def_function_return(func, parm);
1168 
1169  func = RNA_def_function(srna, "new_modal", "rna_KeyMap_item_new_modal");
1171  parm = RNA_def_string(func, "propvalue", NULL, 0, "Property Value", "");
1173  parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
1175  parm = RNA_def_enum(func, "value", rna_enum_event_value_items, 0, "Value", "");
1177  RNA_def_boolean(func, "any", 0, "Any", "");
1178  RNA_def_int(func, "shift", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Shift", "", KM_ANY, KM_MOD_HELD);
1179  RNA_def_int(func, "ctrl", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Ctrl", "", KM_ANY, KM_MOD_HELD);
1180  RNA_def_int(func, "alt", KM_NOTHING, KM_ANY, KM_MOD_HELD, "Alt", "", KM_ANY, KM_MOD_HELD);
1181  RNA_def_int(func, "oskey", KM_NOTHING, KM_ANY, KM_MOD_HELD, "OS Key", "", KM_ANY, KM_MOD_HELD);
1182  RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
1183  RNA_def_enum(func, "direction", rna_enum_event_direction_items, KM_ANY, "Direction", "");
1184  RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
1185  parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
1186  RNA_def_function_return(func, parm);
1187 
1188  func = RNA_def_function(srna, "new_from_item", "rna_KeyMap_item_new_from_item");
1190  parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Item to use as a reference");
1192  RNA_def_boolean(func, "head", 0, "At Head", "");
1193  parm = RNA_def_pointer(func, "result", "KeyMapItem", "Item", "Added key map item");
1194  RNA_def_function_return(func, parm);
1195 
1196  func = RNA_def_function(srna, "remove", "rna_KeyMap_item_remove");
1198  parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1201 
1202  func = RNA_def_function(srna, "from_id", "WM_keymap_item_find_id");
1203  parm = RNA_def_property(func, "id", PROP_INT, PROP_NONE);
1205  RNA_def_property_ui_text(parm, "id", "ID of the item");
1206  parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1207  RNA_def_function_return(func, parm);
1208 
1209  /* Keymap introspection
1210  * Args follow: KeyConfigs.find_item_from_operator */
1211  func = RNA_def_function(srna, "find_from_operator", "rna_KeyMap_item_find_from_operator");
1213  parm = RNA_def_string(func, "idname", NULL, 0, "Operator Identifier", "");
1215  parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
1218  func, "include", rna_enum_event_type_mask_items, EVT_TYPE_MASK_ALL, "Include", "");
1219  RNA_def_enum_flag(func, "exclude", rna_enum_event_type_mask_items, 0, "Exclude", "");
1220  parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
1222  RNA_def_function_return(func, parm);
1223 
1224  func = RNA_def_function(srna, "match_event", "rna_KeyMap_item_match_event");
1226  parm = RNA_def_pointer(func, "event", "Event", "", "");
1228  parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
1230  RNA_def_function_return(func, parm);
1231 }
1232 
1234 {
1235  FunctionRNA *func;
1236  PropertyRNA *parm;
1237 
1238  func = RNA_def_function(srna, "new", "rna_keymap_new"); /* add_keymap */
1241  func,
1242  "Ensure the keymap exists. This will return the one with the given name/space type/region "
1243  "type, or create a new one if it does not exist yet.");
1244 
1245  parm = RNA_def_string(func, "name", NULL, 0, "Name", "");
1247  RNA_def_enum(func, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
1248  RNA_def_enum(
1249  func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
1250  RNA_def_boolean(func, "modal", 0, "Modal", "Keymap for modal operators");
1251  RNA_def_boolean(func, "tool", 0, "Tool", "Keymap for active tools");
1252  parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Added key map");
1253  RNA_def_function_return(func, parm);
1254 
1255  func = RNA_def_function(srna, "remove", "rna_KeyMap_remove"); /* remove_keymap */
1257  parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Removed key map");
1260 
1261  func = RNA_def_function(srna, "find", "rna_keymap_find"); /* find_keymap */
1262  parm = RNA_def_string(func, "name", NULL, 0, "Name", "");
1264  RNA_def_enum(func, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
1265  RNA_def_enum(
1266  func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
1267  parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map");
1268  RNA_def_function_return(func, parm);
1269 
1270  func = RNA_def_function(srna, "find_modal", "rna_keymap_find_modal"); /* find_keymap_modal */
1271  parm = RNA_def_string(func, "name", NULL, 0, "Operator Name", "");
1273  parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map");
1274  RNA_def_function_return(func, parm);
1275 }
1276 
1278 {
1279  FunctionRNA *func;
1280  PropertyRNA *parm;
1281 
1282  func = RNA_def_function(srna, "new", "WM_keyconfig_new_user"); /* add_keyconfig */
1283  parm = RNA_def_string(func, "name", NULL, 0, "Name", "");
1285  parm = RNA_def_pointer(
1286  func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration");
1287  RNA_def_function_return(func, parm);
1288 
1289  func = RNA_def_function(srna, "remove", "rna_KeyConfig_remove"); /* remove_keyconfig */
1291  parm = RNA_def_pointer(
1292  func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration");
1295 
1296  /* Helper functions */
1297 
1298  /* Keymap introspection */
1299  func = RNA_def_function(
1300  srna, "find_item_from_operator", "rna_KeyConfig_find_item_from_operator");
1302  parm = RNA_def_string(func, "idname", NULL, 0, "Operator Identifier", "");
1304  parm = RNA_def_property(func, "context", PROP_ENUM, PROP_NONE);
1306  parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
1309  func, "include", rna_enum_event_type_mask_items, EVT_TYPE_MASK_ALL, "Include", "");
1310  RNA_def_enum_flag(func, "exclude", rna_enum_event_type_mask_items, 0, "Exclude", "");
1311  parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
1313  parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
1315  RNA_def_function_return(func, parm);
1316 
1317  RNA_def_function(srna, "update", "rna_KeyConfig_update"); /* WM_keyconfig_update */
1318 }
1319 
1320 #endif
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
#define G_MAIN
Definition: BKE_global.h:267
@ G_FLAG_EVENT_SIMULATE
Definition: BKE_global.h:151
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
void BKE_undosys_print(UndoStack *ustack)
Definition: undo_system.c:963
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:60
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
#define STRNCPY(dst, src)
Definition: BLI_string.h:483
int BLI_str_utf8_size(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: string_utf8.c:452
#define UNUSED(x)
#define ELEM(...)
@ RGN_TYPE_WINDOW
@ SPACE_EMPTY
#define OP_MAX_TYPENAME
@ OPERATOR_FINISHED
@ KMI_REPEAT_IGNORE
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
#define RNA_POINTER_INVALIDATE(ptr)
Definition: RNA_access.h:744
@ PARM_RNAPTR
Definition: RNA_types.h:354
@ PARM_REQUIRED
Definition: RNA_types.h:352
@ PARM_OUTPUT
Definition: RNA_types.h:353
@ FUNC_USE_REPORTS
Definition: RNA_types.h:663
@ FUNC_NO_SELF
Definition: RNA_types.h:656
@ FUNC_USE_CONTEXT
Definition: RNA_types.h:662
@ FUNC_USE_SELF_ID
Definition: RNA_types.h:650
@ FUNC_REGISTER_OPTIONAL
Definition: RNA_types.h:672
@ FUNC_ALLOW_WRITE
Definition: RNA_types.h:678
@ PROP_FLOAT
Definition: RNA_types.h:61
@ PROP_BOOLEAN
Definition: RNA_types.h:59
@ PROP_ENUM
Definition: RNA_types.h:63
@ PROP_INT
Definition: RNA_types.h:60
@ PROP_THICK_WRAP
Definition: RNA_types.h:285
@ PROP_EDITABLE
Definition: RNA_types.h:189
@ PROP_NEVER_NULL
Definition: RNA_types.h:239
@ PROP_NONE
Definition: RNA_types.h:126
@ PROP_UNSIGNED
Definition: RNA_types.h:142
#define C
Definition: RandGen.cpp:25
void UI_popover_end(struct bContext *C, struct uiPopover *pup, struct wmKeyMap *keymap)
#define UI_MAX_SHORTCUT_STR
Definition: UI_interface.h:93
void UI_pie_menu_end(struct bContext *C, uiPieMenu *pie)
void UI_popup_menu_end(struct bContext *C, struct uiPopupMenu *pup)
struct uiPieMenu * UI_pie_menu_begin(struct bContext *C, const char *title, int icon, const struct wmEvent *event) ATTR_NONNULL()
uiPopover * UI_popover_begin(struct bContext *C, int menu_width, bool from_active_button) ATTR_NONNULL(1)
uiPopupMenu * UI_popup_menu_begin(struct bContext *C, const char *title, int icon) ATTR_NONNULL()
@ WM_GIZMOGROUPTYPE_PERSISTENT
@ KM_NOTHING
Definition: WM_types.h:266
@ KM_ANY
Definition: WM_types.h:265
@ KM_PRESS
Definition: WM_types.h:267
@ KM_RELEASE
Definition: WM_types.h:268
#define NC_WINDOW
Definition: WM_types.h:325
@ KM_CTRL
Definition: WM_types.h:239
@ KM_ALT
Definition: WM_types.h:240
@ KM_ALT_ANY
Definition: WM_types.h:247
@ KM_OSKEY_ANY
Definition: WM_types.h:248
@ KM_SHIFT_ANY
Definition: WM_types.h:245
@ KM_OSKEY
Definition: WM_types.h:242
@ KM_CTRL_ANY
Definition: WM_types.h:246
@ KM_SHIFT
Definition: WM_types.h:238
#define KM_MOD_HELD
Definition: WM_types.h:253
__forceinline bool any(const avxb &b)
Definition: avxb.h:205
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
unsigned int U
Definition: btGjkEpa3.h:78
bool is_valid
int len
Definition: draw_manager.c:108
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
#define G(x, y, z)
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
bool RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *r_value)
Definition: rna_access.c:5076
const PointerRNA PointerRNA_NULL
Definition: rna_access.c:61
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3806
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4170
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1526
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4312
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1645
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4273
void RNA_def_function_output(FunctionRNA *UNUSED(func), PropertyRNA *ret)
Definition: rna_define.c:4337
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1872
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
Definition: rna_define.c:1737
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4347
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1257
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4342
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1495
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1518
const EnumPropertyItem rna_enum_region_type_items[]
Definition: rna_screen.c:21
const EnumPropertyItem rna_enum_space_type_items[]
Definition: rna_space.c:86
const EnumPropertyItem rna_enum_operator_context_items[]
Definition: rna_ui.c:30
const EnumPropertyItem rna_enum_icon_items[]
Definition: rna_ui_api.c:30
const EnumPropertyItem rna_enum_event_direction_items[]
Definition: rna_wm.c:389
const EnumPropertyItem rna_enum_event_value_items[]
Definition: rna_wm.c:377
const EnumPropertyItem rna_enum_event_type_mask_items[]
Definition: rna_wm.c:408
const EnumPropertyItem rna_enum_event_type_items[]
Definition: rna_wm.c:145
const EnumPropertyItem rna_enum_wm_report_items[]
Definition: rna_wm.c:495
const EnumPropertyItem rna_enum_operator_return_items[]
Definition: rna_wm.c:463
void RNA_api_keymapitem(StructRNA *srna)
Definition: rna_wm_api.c:1121
#define WM_GEN_INVOKE_EVENT
Definition: rna_wm_api.c:684
void RNA_api_window(StructRNA *srna)
Definition: rna_wm_api.c:712
void RNA_api_wm(StructRNA *srna)
Definition: rna_wm_api.c:761
#define WM_GEN_INVOKE_SIZE
Definition: rna_wm_api.c:685
void RNA_api_keyconfigs(StructRNA *srna)
Definition: rna_wm_api.c:1277
void RNA_api_macro(StructRNA *srna)
Definition: rna_wm_api.c:1066
void RNA_api_keyconfig(StructRNA *UNUSED(srna))
Definition: rna_wm_api.c:1096
void RNA_api_keymap(StructRNA *srna)
Definition: rna_wm_api.c:1102
void RNA_api_keymapitems(StructRNA *srna)
Definition: rna_wm_api.c:1139
#define WM_GEN_INVOKE_RETURN
Definition: rna_wm_api.c:686
void RNA_api_keymaps(StructRNA *srna)
Definition: rna_wm_api.c:1233
const EnumPropertyItem rna_enum_window_cursor_items[]
Definition: rna_wm_api.c:32
static void rna_generic_op_invoke(FunctionRNA *func, int flag)
Definition: rna_wm_api.c:688
void RNA_api_operator(StructRNA *srna)
Definition: rna_wm_api.c:959
#define min(a, b)
Definition: sort.c:35
Definition: DNA_ID.h:368
void * data
Definition: RNA_types.h:38
eWM_GizmoFlagGroupTypeFlag flag
const void * modal_items
struct wmKeyMap * modalkeymap
Definition: WM_types.h:987
struct ReportList * reports
struct wmWindow * win
Definition: WM_types.h:860
struct UndoStack * undo_stack
struct wmWindow * winactive
struct wmKeyConfig * addonconf
struct wmEvent * eventstate
float max
void WM_cursor_modal_restore(wmWindow *win)
Definition: wm_cursors.c:200
void WM_cursor_time(wmWindow *win, int nr)
Definition: wm_cursors.c:317
@ WM_CURSOR_WAIT
Definition: wm_cursors.h:20
@ WM_CURSOR_COPY
Definition: wm_cursors.h:23
@ WM_CURSOR_HAND
Definition: wm_cursors.h:24
@ WM_CURSOR_NSEW_SCROLL
Definition: wm_cursors.h:51
@ WM_CURSOR_CROSS
Definition: wm_cursors.h:26
@ WM_CURSOR_DEFAULT
Definition: wm_cursors.h:18
@ WM_CURSOR_PAINT
Definition: wm_cursors.h:27
@ WM_CURSOR_Y_MOVE
Definition: wm_cursors.h:39
@ WM_CURSOR_PICK_AREA
Definition: wm_cursors.h:61
@ WM_CURSOR_TEXT_EDIT
Definition: wm_cursors.h:19
@ WM_CURSOR_PAINT_BRUSH
Definition: wm_cursors.h:33
@ WM_CURSOR_NS_SCROLL
Definition: wm_cursors.h:52
@ WM_CURSOR_DOT
Definition: wm_cursors.h:28
@ WM_CURSOR_ZOOM_OUT
Definition: wm_cursors.h:56
@ WM_CURSOR_EDIT
Definition: wm_cursors.h:22
@ WM_CURSOR_ZOOM_IN
Definition: wm_cursors.h:55
@ WM_CURSOR_KNIFE
Definition: wm_cursors.h:31
@ WM_CURSOR_STOP
Definition: wm_cursors.h:21
@ WM_CURSOR_EYEDROPPER
Definition: wm_cursors.h:35
@ WM_CURSOR_ERASER
Definition: wm_cursors.h:34
@ WM_CURSOR_EW_SCROLL
Definition: wm_cursors.h:53
@ WM_CURSOR_MUTE
Definition: wm_cursors.h:59
@ WM_CURSOR_NONE
Definition: wm_cursors.h:58
@ WM_CURSOR_X_MOVE
Definition: wm_cursors.h:38
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_main_add_notifier(unsigned int type, void *reference)
wmKeyMapItem * WM_event_match_keymap_item(bContext *C, wmKeyMap *keymap, const wmEvent *event)
void WM_event_tablet_data_default_set(wmTabletData *tablet_data)
wmEvent * WM_event_add_simulate(wmWindow *win, const wmEvent *event_to_add)
bool WM_operator_is_repeat(const bContext *C, const wmOperator *op)
#define ISMOUSE_BUTTON(event_type)
#define ISMOUSE_MOTION(event_type)
#define ISKEYBOARD(event_type)
#define EVT_TYPE_MASK_ALL
PointerRNA * ptr
Definition: wm_files.c:3480
wmOperatorType * ot
Definition: wm_files.c:3479
bool WM_gizmo_group_type_ensure_ptr(wmGizmoGroupType *gzgt)
void WM_gizmo_group_type_unlink_delayed_ptr(wmGizmoGroupType *gzgt)
wmGizmoGroupType * WM_gizmogrouptype_find(const char *idname, bool quiet)
void WM_script_tag_reload(void)
Definition: wm_init_exit.c:663
void WM_keymap_item_restore_to_default(wmWindowManager *wm, wmKeyMap *keymap, wmKeyMapItem *kmi)
Definition: wm_keymap.c:1968
void WM_keymap_restore_to_default(wmKeyMap *keymap, wmWindowManager *wm)
Definition: wm_keymap.c:2026
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:852
void WM_keyconfig_update(wmWindowManager *wm)
Definition: wm_keymap.c:1829
wmKeyMapItem * WM_key_event_operator_from_keymap(wmKeyMap *keymap, const char *opname, IDProperty *properties, const short include_mask, const short exclude_mask)
Definition: wm_keymap.c:1695
wmKeyMap * WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:823
int WM_keymap_item_to_string(const wmKeyMapItem *kmi, const bool compact, char *result, const int result_len)
Definition: wm_keymap.c:1213
bool WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
Definition: wm_keymap.c:537
wmKeyMap * WM_keymap_active(const wmWindowManager *wm, wmKeyMap *keymap)
Definition: wm_keymap.c:1943
wmKeyMapItem * WM_modalkeymap_add_item(wmKeyMap *km, const KeyMapItem_Params *params, int value)
Definition: wm_keymap.c:927
bool WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
Definition: wm_keymap.c:295
bool WM_keymap_remove(wmKeyConfig *keyconf, wmKeyMap *keymap)
Definition: wm_keymap.c:419
wmKeyMapItem * WM_key_event_operator(const bContext *C, const char *opname, wmOperatorCallContext opcontext, IDProperty *properties, const short include_mask, const short exclude_mask, wmKeyMap **r_keymap)
Definition: wm_keymap.c:1672
wmKeyMapItem * WM_keymap_add_item(wmKeyMap *keymap, const char *idname, const KeyMapItem_Params *params)
Definition: wm_keymap.c:505
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
Definition: wm_keymap.c:888
bool WM_keymap_item_compare(const wmKeyMapItem *k1, const wmKeyMapItem *k2)
Definition: wm_keymap.c:1714
wmKeyMapItem * WM_modalkeymap_add_item_str(wmKeyMap *km, const KeyMapItem_Params *params, const char *value)
Definition: wm_keymap.c:943
wmKeyMapItem * WM_keymap_add_item_copy(struct wmKeyMap *keymap, wmKeyMapItem *kmi_src)
Definition: wm_keymap.c:524
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
void WM_operator_last_properties_ensure(wmOperatorType *ot, PointerRNA *ptr)
size_t WM_operator_bl_idname(char *dst, const char *src)
Definition: wm_operators.c:128
int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
Definition: wm_window.c:1682
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
Definition: wm_window.c:1630