2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * The Original Code is Copyright (C) 2009 Blender Foundation.
17 * All rights reserved.
28 #include "BLI_utildefines.h"
30 #include "RNA_define.h"
31 #include "RNA_enum_types.h"
33 #include "DNA_screen_types.h"
34 #include "DNA_space_types.h"
35 #include "DNA_windowmanager_types.h"
37 #include "UI_interface.h"
39 #include "wm_cursors.h"
40 #include "wm_event_types.h"
42 #include "rna_internal.h" /* own include */
44 /* confusing 2 enums mixed up here */
45 const EnumPropertyItem rna_enum_window_cursor_items[] = {
46 {WM_CURSOR_DEFAULT, "DEFAULT", 0, "Default", ""},
47 {WM_CURSOR_NONE, "NONE", 0, "None", ""},
48 {WM_CURSOR_WAIT, "WAIT", 0, "Wait", ""},
49 {WM_CURSOR_EDIT, "CROSSHAIR", 0, "Crosshair", ""},
50 {WM_CURSOR_X_MOVE, "MOVE_X", 0, "Move-X", ""},
51 {WM_CURSOR_Y_MOVE, "MOVE_Y", 0, "Move-Y", ""},
54 {WM_CURSOR_KNIFE, "KNIFE", 0, "Knife", ""},
55 {WM_CURSOR_TEXT_EDIT, "TEXT", 0, "Text", ""},
56 {WM_CURSOR_PAINT_BRUSH, "PAINT_BRUSH", 0, "Paint Brush", ""},
57 {WM_CURSOR_PAINT, "PAINT_CROSS", 0, "Paint Cross", ""},
58 {WM_CURSOR_DOT, "DOT", 0, "Dot Cursor", ""},
59 {WM_CURSOR_ERASER, "ERASER", 0, "Eraser", ""},
60 {WM_CURSOR_HAND, "HAND", 0, "Hand", ""},
61 {WM_CURSOR_EW_SCROLL, "SCROLL_X", 0, "Scroll-X", ""},
62 {WM_CURSOR_NS_SCROLL, "SCROLL_Y", 0, "Scroll-Y", ""},
63 {WM_CURSOR_NSEW_SCROLL, "SCROLL_XY", 0, "Scroll-XY", ""},
64 {WM_CURSOR_EYEDROPPER, "EYEDROPPER", 0, "Eyedropper", ""},
65 {0, NULL, 0, NULL, NULL},
70 # include "BKE_context.h"
71 # include "BKE_undo_system.h"
73 # include "WM_types.h"
75 static void rna_KeyMapItem_to_string(wmKeyMapItem *kmi, bool compact, char *result)
77 WM_keymap_item_to_string(kmi, compact, result, UI_MAX_SHORTCUT_STR);
80 static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C)
82 wmWindowManager *wm = CTX_wm_manager(C);
83 return WM_keymap_active(wm, km);
86 static void rna_keymap_restore_to_default(wmKeyMap *km, bContext *C)
88 WM_keymap_restore_to_default(km, CTX_wm_manager(C));
91 static void rna_keymap_restore_item_to_default(wmKeyMap *km, bContext *C, wmKeyMapItem *kmi)
93 WM_keymap_item_restore_to_default(CTX_wm_manager(C), km, kmi);
96 static void rna_Operator_report(wmOperator *op, int type, const char *msg)
98 BKE_report(op->reports, type, msg);
101 static bool rna_Operator_is_repeat(wmOperator *op, bContext *C)
103 return WM_operator_is_repeat(C, op);
106 /* since event isn't needed... */
107 static void rna_Operator_enum_search_invoke(bContext *C, wmOperator *op)
109 WM_enum_search_invoke(C, op, NULL);
112 static bool rna_event_modal_handler_add(struct bContext *C, struct wmOperator *operator)
114 return WM_event_add_modal_handler(C, operator) != NULL;
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)
120 return WM_event_add_timer(wm, win, 0x0110, time_step);
123 static void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer)
125 WM_event_remove_timer(wm, timer->win, timer);
128 static wmGizmoGroupType *wm_gizmogrouptype_find_for_add_remove(ReportList *reports,
131 wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, true);
133 BKE_reportf(reports, RPT_ERROR, "Gizmo group type '%s' not found!", idname);
136 if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) {
137 BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' has 'PERSISTENT' option set!", idname);
143 static void rna_gizmo_group_type_ensure(ReportList *reports, const char *idname)
145 wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
147 WM_gizmo_group_type_ensure_ptr(gzgt);
151 static void rna_gizmo_group_type_unlink_delayed(ReportList *reports, const char *idname)
153 wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname);
155 WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
159 /* placeholder data for final implementation of a true progressbar */
160 static struct wmStaticProgress {
164 } wm_progress_state = {0, 0, false};
166 static void rna_progress_begin(struct wmWindowManager *UNUSED(wm), float min, float max)
168 float range = max - min;
170 wm_progress_state.min = min;
171 wm_progress_state.max = max;
172 wm_progress_state.is_valid = true;
175 wm_progress_state.is_valid = false;
179 static void rna_progress_update(struct wmWindowManager *wm, float value)
181 if (wm_progress_state.is_valid) {
182 /* Map to cursor_time range [0,9999] */
183 wmWindow *win = wm->winactive;
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);
192 static void rna_progress_end(struct wmWindowManager *wm)
194 if (wm_progress_state.is_valid) {
195 wmWindow *win = wm->winactive;
197 WM_cursor_modal_restore(win);
198 wm_progress_state.is_valid = false;
203 /* wrap these because of 'const wmEvent *' */
204 static int rna_Operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
206 return WM_operator_confirm(C, op, event);
208 static int rna_Operator_props_popup(bContext *C, wmOperator *op, wmEvent *event)
210 return WM_operator_props_popup(C, op, event);
213 static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km,
227 /* wmWindowManager *wm = CTX_wm_manager(C); */
228 wmKeyMapItem *kmi = NULL;
229 char idname_bl[OP_MAX_TYPENAME];
232 /* only on non-modal maps */
233 if (km->flag & KEYMAP_MODAL) {
234 BKE_report(reports, RPT_ERROR, "Not a non-modal keymap");
238 WM_operator_bl_idname(idname_bl, idname);
241 modifier |= KM_SHIFT;
250 modifier |= KM_OSKEY;
257 /* create keymap item */
258 kmi = WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier);
261 kmi->flag |= KMI_REPEAT_IGNORE;
264 /* T32437 allow scripts to define hotkeys that get added to start of keymap
265 * so that they stand a chance against catch-all defines later on
268 BLI_remlink(&km->items, kmi);
269 BLI_addhead(&km->items, kmi);
275 static wmKeyMapItem *rna_KeyMap_item_new_from_item(wmKeyMap *km,
277 wmKeyMapItem *kmi_src,
280 /* wmWindowManager *wm = CTX_wm_manager(C); */
282 if ((km->flag & KEYMAP_MODAL) == (kmi_src->idname[0] != '\0')) {
283 BKE_report(reports, RPT_ERROR, "Can not mix modal/non-modal items");
287 /* create keymap item */
288 wmKeyMapItem *kmi = WM_keymap_add_item_copy(km, kmi_src);
290 BLI_remlink(&km->items, kmi);
291 BLI_addhead(&km->items, kmi);
296 static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km,
298 const char *propvalue_str,
309 wmKeyMapItem *kmi = NULL;
313 /* only modal maps */
314 if ((km->flag & KEYMAP_MODAL) == 0) {
315 BKE_report(reports, RPT_ERROR, "Not a modal keymap");
320 modifier |= KM_SHIFT;
329 modifier |= KM_OSKEY;
336 /* not initialized yet, do delayed lookup */
337 if (!km->modal_items) {
338 kmi = WM_modalkeymap_add_item_str(km, type, value, modifier, keymodifier, propvalue_str);
341 if (RNA_enum_value_from_id(km->modal_items, propvalue_str, &propvalue) == 0) {
342 BKE_report(reports, RPT_WARNING, "Property value not in enumeration");
344 kmi = WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue);
348 kmi->flag |= KMI_REPEAT_IGNORE;
354 static void rna_KeyMap_item_remove(wmKeyMap *km, ReportList *reports, PointerRNA *kmi_ptr)
356 wmKeyMapItem *kmi = kmi_ptr->data;
358 if (WM_keymap_remove_item(km, kmi) == false) {
361 "KeyMapItem '%s' cannot be removed from '%s'",
367 RNA_POINTER_INVALIDATE(kmi_ptr);
370 static PointerRNA rna_KeyMap_item_find_from_operator(ID *id,
373 PointerRNA *properties,
377 char idname_bl[OP_MAX_TYPENAME];
378 WM_operator_bl_idname(idname_bl, idname);
380 wmKeyMapItem *kmi = WM_key_event_operator_from_keymap(
381 km, idname_bl, properties->data, include_mask, exclude_mask);
383 RNA_pointer_create(id, &RNA_KeyMapItem, kmi, &kmi_ptr);
387 static PointerRNA rna_KeyMap_item_match_event(ID *id, wmKeyMap *km, bContext *C, wmEvent *event)
389 wmKeyMapItem *kmi = WM_event_match_keymap_item(C, km, event);
391 RNA_pointer_create(id, &RNA_KeyMapItem, kmi, &kmi_ptr);
395 static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf,
404 /* Sanity check: Don't allow add-ons to override internal modal key-maps
405 * because this isn't supported, the restriction can be removed when
406 * add-ons can define modal key-maps.
407 * Currently this is only useful for add-ons to override built-in modal keymaps
408 * which is not the intended use for add-on keymaps. */
409 wmWindowManager *wm = G_MAIN->wm.first;
410 if (keyconf == wm->addonconf) {
411 BKE_reportf(reports, RPT_ERROR, "Modal key-maps not supported for add-on key-config");
419 keymap = WM_keymap_ensure(keyconf, idname, spaceid, regionid);
422 keymap = WM_modalkeymap_ensure(keyconf, idname, NULL); /* items will be lazy init */
425 if (keymap && tool) {
426 keymap->flag |= KEYMAP_TOOL;
432 static wmKeyMap *rna_keymap_find(wmKeyConfig *keyconf,
437 return WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
440 static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *UNUSED(keyconf), const char *idname)
442 wmOperatorType *ot = WM_operatortype_find(idname, 0);
448 return ot->modalkeymap;
452 static void rna_KeyMap_remove(wmKeyConfig *keyconfig, ReportList *reports, PointerRNA *keymap_ptr)
454 wmKeyMap *keymap = keymap_ptr->data;
456 if (WM_keymap_remove(keyconfig, keymap) == false) {
457 BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keymap->idname);
461 RNA_POINTER_INVALIDATE(keymap_ptr);
464 static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, PointerRNA *keyconf_ptr)
466 wmKeyConfig *keyconf = keyconf_ptr->data;
468 if (WM_keyconfig_remove(wm, keyconf) == false) {
469 BKE_reportf(reports, RPT_ERROR, "KeyConfig '%s' cannot be removed", keyconf->idname);
473 RNA_POINTER_INVALIDATE(keyconf_ptr);
476 static PointerRNA rna_KeyConfig_find_item_from_operator(wmWindowManager *wm,
480 PointerRNA *properties,
485 char idname_bl[OP_MAX_TYPENAME];
486 WM_operator_bl_idname(idname_bl, idname);
489 wmKeyMapItem *kmi = WM_key_event_operator(
490 C, idname_bl, opcontext, properties->data, include_mask, exclude_mask, &km);
492 RNA_pointer_create(&wm->id, &RNA_KeyMap, km, km_ptr);
493 RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &kmi_ptr);
497 static void rna_KeyConfig_update(wmWindowManager *wm)
499 WM_keyconfig_update(wm);
502 /* popup menu wrapper */
503 static PointerRNA rna_PopMenuBegin(bContext *C, const char *title, int icon)
508 data = (void *)UI_popup_menu_begin(C, title, icon);
510 RNA_pointer_create(NULL, &RNA_UIPopupMenu, data, &r_ptr);
515 static void rna_PopMenuEnd(bContext *C, PointerRNA *handle)
517 UI_popup_menu_end(C, handle->data);
520 /* popover wrapper */
521 static PointerRNA rna_PopoverBegin(bContext *C, int ui_units_x, bool from_active_button)
526 data = (void *)UI_popover_begin(C, U.widget_unit * ui_units_x, from_active_button);
528 RNA_pointer_create(NULL, &RNA_UIPopover, data, &r_ptr);
533 static void rna_PopoverEnd(bContext *C, PointerRNA *handle, wmKeyMap *keymap)
535 UI_popover_end(C, handle->data, keymap);
538 /* pie menu wrapper */
539 static PointerRNA rna_PieMenuBegin(bContext *C, const char *title, int icon, PointerRNA *event)
544 data = (void *)UI_pie_menu_begin(C, title, icon, event->data);
546 RNA_pointer_create(NULL, &RNA_UIPieMenu, data, &r_ptr);
551 static void rna_PieMenuEnd(bContext *C, PointerRNA *handle)
553 UI_pie_menu_end(C, handle->data);
556 static void rna_WindowManager_print_undo_steps(wmWindowManager *wm)
558 BKE_undosys_print(wm->undo_stack);
561 static void rna_WindowManager_tag_script_reload(void)
563 WM_script_tag_reload();
564 WM_main_add_notifier(NC_WINDOW, NULL);
567 static PointerRNA rna_WindoManager_operator_properties_last(const char *idname)
569 wmOperatorType *ot = WM_operatortype_find(idname, true);
573 WM_operator_last_properties_ensure(ot, &ptr);
576 return PointerRNA_NULL;
579 static wmEvent *rna_Window_event_add_simulate(wmWindow *win,
591 if ((G.f & G_FLAG_EVENT_SIMULATE) == 0) {
592 BKE_report(reports, RPT_ERROR, "Not running with '--enable-event-simulate' enabled");
596 if (!ELEM(value, KM_PRESS, KM_RELEASE, KM_NOTHING)) {
597 BKE_report(reports, RPT_ERROR, "Value: only 'PRESS/RELEASE/NOTHING' are supported");
600 if (ISKEYBOARD(type) || ISMOUSE_BUTTON(type)) {
601 if (!ELEM(value, KM_PRESS, KM_RELEASE)) {
602 BKE_report(reports, RPT_ERROR, "Value: must be 'PRESS/RELEASE' for keyboard/buttons");
606 if (ELEM(type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
607 if (value != KM_NOTHING) {
608 BKE_report(reports, RPT_ERROR, "Value: must be 'NOTHING' for motion");
612 if (unicode != NULL) {
613 if (value != KM_PRESS) {
614 BKE_report(reports, RPT_ERROR, "Value: must be 'PRESS' when unicode is set");
618 /* TODO: validate NDOF. */
621 if (unicode != NULL) {
622 int len = BLI_str_utf8_size(unicode);
623 if (len == -1 || unicode[len] != '\0') {
624 BKE_report(reports, RPT_ERROR, "Only a single character supported");
627 if (len == 1 && isascii(unicode[0])) {
632 wmEvent e = *win->eventstate;
638 /* Note: KM_MOD_FIRST, KM_MOD_SECOND aren't used anywhere, set as bools */
644 e.prevx = win->eventstate->x;
645 e.prevy = win->eventstate->y;
646 e.prevval = win->eventstate->val;
647 e.prevtype = win->eventstate->type;
650 e.utf8_buf[0] = '\0';
651 if (unicode != NULL) {
653 STRNCPY(e.utf8_buf, unicode);
656 /* Until we expose setting tablet values here. */
657 WM_event_tablet_data_default_set(&e.tablet);
659 return WM_event_add_simulate(win, &e);
664 # define WM_GEN_INVOKE_EVENT (1 << 0)
665 # define WM_GEN_INVOKE_SIZE (1 << 1)
666 # define WM_GEN_INVOKE_RETURN (1 << 2)
668 static void rna_generic_op_invoke(FunctionRNA *func, int flag)
672 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
673 parm = RNA_def_pointer(func, "operator", "Operator", "", "Operator to call");
674 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
676 if (flag & WM_GEN_INVOKE_EVENT) {
677 parm = RNA_def_pointer(func, "event", "Event", "", "Event");
678 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
681 if (flag & WM_GEN_INVOKE_SIZE) {
682 RNA_def_int(func, "width", 300, 0, INT_MAX, "", "Width of the popup", 0, INT_MAX);
685 if (flag & WM_GEN_INVOKE_RETURN) {
686 parm = RNA_def_enum_flag(
687 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
688 RNA_def_function_return(func, parm);
692 void RNA_api_window(StructRNA *srna)
697 func = RNA_def_function(srna, "cursor_warp", "WM_cursor_warp");
698 parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
699 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
700 parm = RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
701 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
702 RNA_def_function_ui_description(func, "Set the cursor position");
704 func = RNA_def_function(srna, "cursor_set", "WM_cursor_set");
705 parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE);
706 RNA_def_property_enum_items(parm, rna_enum_window_cursor_items);
707 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
708 RNA_def_function_ui_description(func, "Set the cursor");
710 func = RNA_def_function(srna, "cursor_modal_set", "WM_cursor_modal_set");
711 parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE);
712 RNA_def_property_enum_items(parm, rna_enum_window_cursor_items);
713 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
714 RNA_def_function_ui_description(func, "Set the cursor, so the previous cursor can be restored");
716 RNA_def_function(srna, "cursor_modal_restore", "WM_cursor_modal_restore");
717 RNA_def_function_ui_description(
718 func, "Restore the previous cursor after calling ``cursor_modal_set``");
720 /* Arguments match 'rna_KeyMap_item_new'. */
721 func = RNA_def_function(srna, "event_simulate", "rna_Window_event_add_simulate");
722 RNA_def_function_flag(func, FUNC_USE_REPORTS);
723 parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
724 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
725 parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", "");
726 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
727 parm = RNA_def_string(func, "unicode", NULL, 0, "", "");
728 RNA_def_parameter_clear_flags(parm, PROP_NEVER_NULL, 0);
730 RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
731 RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "", "", INT_MIN, INT_MAX);
733 RNA_def_boolean(func, "shift", 0, "Shift", "");
734 RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
735 RNA_def_boolean(func, "alt", 0, "Alt", "");
736 RNA_def_boolean(func, "oskey", 0, "OS Key", "");
737 parm = RNA_def_pointer(func, "event", "Event", "Item", "Added key map item");
738 RNA_def_function_return(func, parm);
741 void RNA_api_wm(StructRNA *srna)
746 func = RNA_def_function(srna, "fileselect_add", "WM_event_add_fileselect");
747 RNA_def_function_ui_description(
749 "Opens a file selector with an operator. "
750 "The string properties 'filepath', 'filename', 'directory' and a 'files' "
751 "collection are assigned when present in the operator");
752 rna_generic_op_invoke(func, 0);
754 func = RNA_def_function(srna, "modal_handler_add", "rna_event_modal_handler_add");
755 RNA_def_function_ui_description(
757 "Add a modal handler to the window manager, for the given modal operator "
758 "(called by invoke() with self, just before returning {'RUNNING_MODAL'})");
759 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
760 parm = RNA_def_pointer(func, "operator", "Operator", "", "Operator to call");
761 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
762 RNA_def_function_return(
763 func, RNA_def_boolean(func, "handle", 1, "", "Whether adding the handler was successful"));
765 func = RNA_def_function(srna, "event_timer_add", "rna_event_timer_add");
766 RNA_def_function_ui_description(
767 func, "Add a timer to the given window, to generate periodic 'TIMER' events");
768 parm = RNA_def_property(func, "time_step", PROP_FLOAT, PROP_NONE);
769 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
770 RNA_def_property_range(parm, 0.0, FLT_MAX);
771 RNA_def_property_ui_text(parm, "Time Step", "Interval in seconds between timer events");
772 RNA_def_pointer(func, "window", "Window", "", "Window to attach the timer to, or None");
773 parm = RNA_def_pointer(func, "result", "Timer", "", "");
774 RNA_def_function_return(func, parm);
776 func = RNA_def_function(srna, "event_timer_remove", "rna_event_timer_remove");
777 parm = RNA_def_pointer(func, "timer", "Timer", "", "");
778 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
780 func = RNA_def_function(srna, "gizmo_group_type_ensure", "rna_gizmo_group_type_ensure");
781 RNA_def_function_ui_description(
782 func, "Activate an existing widget group (when the persistent option isn't set)");
783 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS);
784 parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name");
785 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
787 func = RNA_def_function(
788 srna, "gizmo_group_type_unlink_delayed", "rna_gizmo_group_type_unlink_delayed");
789 RNA_def_function_ui_description(func,
790 "Unlink a widget group (when the persistent option is set)");
791 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS);
792 parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name");
793 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
795 /* Progress bar interface */
796 func = RNA_def_function(srna, "progress_begin", "rna_progress_begin");
797 RNA_def_function_ui_description(func, "Start progress report");
798 parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_NONE);
799 RNA_def_property_ui_text(parm, "min", "any value in range [0,9999]");
800 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
801 parm = RNA_def_property(func, "max", PROP_FLOAT, PROP_NONE);
802 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
803 RNA_def_property_ui_text(parm, "max", "any value in range [min+1,9998]");
805 func = RNA_def_function(srna, "progress_update", "rna_progress_update");
806 RNA_def_function_ui_description(func, "Update the progress feedback");
807 parm = RNA_def_property(func, "value", PROP_FLOAT, PROP_NONE);
808 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
809 RNA_def_property_ui_text(
810 parm, "value", "Any value between min and max as set in progress_begin()");
812 func = RNA_def_function(srna, "progress_end", "rna_progress_end");
813 RNA_def_function_ui_description(func, "Terminate progress report");
815 /* invoke functions, for use with python */
816 func = RNA_def_function(srna, "invoke_props_popup", "rna_Operator_props_popup");
817 RNA_def_function_ui_description(
819 "Operator popup invoke "
820 "(show operator properties and execute it automatically on changes)");
821 rna_generic_op_invoke(func, WM_GEN_INVOKE_EVENT | WM_GEN_INVOKE_RETURN);
823 /* invoked dialog opens popup with OK button, does not auto-exec operator. */
824 func = RNA_def_function(srna, "invoke_props_dialog", "WM_operator_props_dialog_popup");
825 RNA_def_function_ui_description(
827 "Operator dialog (non-autoexec popup) invoke "
828 "(show operator properties and only execute it on click on OK button)");
829 rna_generic_op_invoke(func, WM_GEN_INVOKE_SIZE | WM_GEN_INVOKE_RETURN);
832 func = RNA_def_function(srna, "invoke_search_popup", "rna_Operator_enum_search_invoke");
833 RNA_def_function_ui_description(
835 "Operator search popup invoke which "
836 "searches values of the operator's :class:`bpy.types.Operator.bl_property` "
837 "(which must be an EnumProperty), executing it on confirmation");
838 rna_generic_op_invoke(func, 0);
840 /* invoke functions, for use with python */
841 func = RNA_def_function(srna, "invoke_popup", "WM_operator_ui_popup");
842 RNA_def_function_ui_description(func,
843 "Operator popup invoke "
844 "(only shows operator's properties, without executing it)");
845 rna_generic_op_invoke(func, WM_GEN_INVOKE_SIZE | WM_GEN_INVOKE_RETURN);
847 func = RNA_def_function(srna, "invoke_confirm", "rna_Operator_confirm");
848 RNA_def_function_ui_description(
850 "Operator confirmation popup "
851 "(only to let user confirm the execution, no operator properties shown)");
852 rna_generic_op_invoke(func, WM_GEN_INVOKE_EVENT | WM_GEN_INVOKE_RETURN);
854 /* wrap UI_popup_menu_begin */
855 func = RNA_def_function(srna, "popmenu_begin__internal", "rna_PopMenuBegin");
856 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
857 parm = RNA_def_string(func, "title", NULL, 0, "", "");
858 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
859 parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
860 RNA_def_property_enum_items(parm, rna_enum_icon_items);
862 parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
863 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
864 RNA_def_function_return(func, parm);
866 /* wrap UI_popup_menu_end */
867 func = RNA_def_function(srna, "popmenu_end__internal", "rna_PopMenuEnd");
868 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
869 parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
870 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED);
872 /* wrap UI_popover_begin */
873 func = RNA_def_function(srna, "popover_begin__internal", "rna_PopoverBegin");
874 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
875 RNA_def_property(func, "ui_units_x", PROP_INT, PROP_UNSIGNED);
877 parm = RNA_def_pointer(func, "menu", "UIPopover", "", "");
878 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
879 RNA_def_function_return(func, parm);
881 func, "from_active_button", 0, "Use Button", "Use the active button for positioning");
883 /* wrap UI_popover_end */
884 func = RNA_def_function(srna, "popover_end__internal", "rna_PopoverEnd");
885 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
886 parm = RNA_def_pointer(func, "menu", "UIPopover", "", "");
887 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED);
888 RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map");
890 /* wrap uiPieMenuBegin */
891 func = RNA_def_function(srna, "piemenu_begin__internal", "rna_PieMenuBegin");
892 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
893 parm = RNA_def_string(func, "title", NULL, 0, "", "");
894 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
895 parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
896 RNA_def_property_enum_items(parm, rna_enum_icon_items);
897 parm = RNA_def_pointer(func, "event", "Event", "", "");
898 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
900 parm = RNA_def_pointer(func, "menu_pie", "UIPieMenu", "", "");
901 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
902 RNA_def_function_return(func, parm);
904 /* wrap uiPieMenuEnd */
905 func = RNA_def_function(srna, "piemenu_end__internal", "rna_PieMenuEnd");
906 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
907 parm = RNA_def_pointer(func, "menu", "UIPieMenu", "", "");
908 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED);
910 /* access last operator options (optionally create). */
911 func = RNA_def_function(
912 srna, "operator_properties_last", "rna_WindoManager_operator_properties_last");
913 RNA_def_function_flag(func, FUNC_NO_SELF);
914 parm = RNA_def_string(func, "operator", NULL, 0, "", "");
915 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
917 parm = RNA_def_pointer(func, "result", "OperatorProperties", "", "");
918 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
919 RNA_def_function_return(func, parm);
921 RNA_def_function(srna, "print_undo_steps", "rna_WindowManager_print_undo_steps");
923 /* Used by (#SCRIPT_OT_reload). */
924 func = RNA_def_function(srna, "tag_script_reload", "rna_WindowManager_tag_script_reload");
925 RNA_def_function_ui_description(
926 func, "Tag for refreshing the interface after scripts have been reloaded");
927 RNA_def_function_flag(func, FUNC_NO_SELF);
929 parm = RNA_def_property(srna, "is_interface_locked", PROP_BOOLEAN, PROP_NONE);
930 RNA_def_property_ui_text(
932 "Is Interface Locked",
933 "If true, the interface is currently locked by a running job and data shouldn't be modified "
934 "from application timers. Otherwise, the running job might conflict with the handler "
935 "causing unexpected results or even crashes");
936 RNA_def_property_clear_flag(parm, PROP_EDITABLE);
939 void RNA_api_operator(StructRNA *srna)
944 /* utility, not for registering */
945 func = RNA_def_function(srna, "report", "rna_Operator_report");
946 parm = RNA_def_enum_flag(func, "type", rna_enum_wm_report_items, 0, "Type", "");
947 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
948 parm = RNA_def_string(func, "message", NULL, 0, "Report Message", "");
949 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
951 /* utility, not for registering */
952 func = RNA_def_function(srna, "is_repeat", "rna_Operator_is_repeat");
953 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
955 parm = RNA_def_boolean(func, "result", 0, "result", "");
956 RNA_def_function_return(func, parm);
961 func = RNA_def_function(srna, "poll", NULL);
962 RNA_def_function_ui_description(func, "Test if the operator can be called or not");
963 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
964 RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
965 parm = RNA_def_pointer(func, "context", "Context", "", "");
966 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
969 func = RNA_def_function(srna, "execute", NULL);
970 RNA_def_function_ui_description(func, "Execute the operator");
971 RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
972 parm = RNA_def_pointer(func, "context", "Context", "", "");
973 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
976 parm = RNA_def_enum_flag(
977 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
978 RNA_def_function_return(func, parm);
981 func = RNA_def_function(srna, "check", NULL);
982 RNA_def_function_ui_description(
983 func, "Check the operator settings, return True to signal a change to redraw");
984 RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
985 parm = RNA_def_pointer(func, "context", "Context", "", "");
986 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
988 parm = RNA_def_boolean(func, "result", 0, "result", ""); /* better name? */
989 RNA_def_function_return(func, parm);
992 func = RNA_def_function(srna, "invoke", NULL);
993 RNA_def_function_ui_description(func, "Invoke the operator");
994 RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
995 parm = RNA_def_pointer(func, "context", "Context", "", "");
996 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
997 parm = RNA_def_pointer(func, "event", "Event", "", "");
998 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1001 parm = RNA_def_enum_flag(
1002 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1003 RNA_def_function_return(func, parm);
1005 func = RNA_def_function(srna, "modal", NULL); /* same as invoke */
1006 RNA_def_function_ui_description(func, "Modal operator function");
1007 RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
1008 parm = RNA_def_pointer(func, "context", "Context", "", "");
1009 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1010 parm = RNA_def_pointer(func, "event", "Event", "", "");
1011 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1014 parm = RNA_def_enum_flag(
1015 func, "result", rna_enum_operator_return_items, OPERATOR_FINISHED, "result", "");
1016 RNA_def_function_return(func, parm);
1019 func = RNA_def_function(srna, "draw", NULL);
1020 RNA_def_function_ui_description(func, "Draw function for the operator");
1021 RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
1022 parm = RNA_def_pointer(func, "context", "Context", "", "");
1023 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1026 func = RNA_def_function(srna, "cancel", NULL);
1027 RNA_def_function_ui_description(func, "Called when the operator is canceled");
1028 RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL | FUNC_ALLOW_WRITE);
1029 parm = RNA_def_pointer(func, "context", "Context", "", "");
1030 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1033 func = RNA_def_function(srna, "description", NULL);
1034 RNA_def_function_ui_description(func, "Compute a description string that depends on parameters");
1035 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
1036 parm = RNA_def_string(func, "result", NULL, 4096, "result", "");
1037 RNA_def_parameter_clear_flags(parm, PROP_NEVER_NULL, 0);
1038 RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
1039 RNA_def_function_output(func, parm);
1040 parm = RNA_def_pointer(func, "context", "Context", "", "");
1041 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1042 parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
1043 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1046 void RNA_api_macro(StructRNA *srna)
1051 /* utility, not for registering */
1052 func = RNA_def_function(srna, "report", "rna_Operator_report");
1053 parm = RNA_def_enum_flag(func, "type", rna_enum_wm_report_items, 0, "Type", "");
1054 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1055 parm = RNA_def_string(func, "message", NULL, 0, "Report Message", "");
1056 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1061 func = RNA_def_function(srna, "poll", NULL);
1062 RNA_def_function_ui_description(func, "Test if the operator can be called or not");
1063 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
1064 RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
1065 parm = RNA_def_pointer(func, "context", "Context", "", "");
1066 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1069 func = RNA_def_function(srna, "draw", NULL);
1070 RNA_def_function_ui_description(func, "Draw function for the operator");
1071 RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
1072 parm = RNA_def_pointer(func, "context", "Context", "", "");
1073 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1076 void RNA_api_keyconfig(StructRNA *UNUSED(srna))
1078 /* FunctionRNA *func; */
1079 /* PropertyRNA *parm; */
1082 void RNA_api_keymap(StructRNA *srna)
1087 func = RNA_def_function(srna, "active", "rna_keymap_active");
1088 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
1089 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map");
1090 RNA_def_function_return(func, parm);
1092 func = RNA_def_function(srna, "restore_to_default", "rna_keymap_restore_to_default");
1093 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
1095 func = RNA_def_function(srna, "restore_item_to_default", "rna_keymap_restore_item_to_default");
1096 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
1097 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1098 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1101 void RNA_api_keymapitem(StructRNA *srna)
1106 func = RNA_def_function(srna, "compare", "WM_keymap_item_compare");
1107 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1108 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1109 parm = RNA_def_boolean(func, "result", 0, "Comparison result", "");
1110 RNA_def_function_return(func, parm);
1112 func = RNA_def_function(srna, "to_string", "rna_KeyMapItem_to_string");
1113 RNA_def_boolean(func, "compact", false, "Compact", "");
1114 parm = RNA_def_string(func, "result", NULL, UI_MAX_SHORTCUT_STR, "result", "");
1115 RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
1116 RNA_def_function_output(func, parm);
1119 void RNA_api_keymapitems(StructRNA *srna)
1124 func = RNA_def_function(srna, "new", "rna_KeyMap_item_new");
1125 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1126 parm = RNA_def_string(func, "idname", NULL, 0, "Operator Identifier", "");
1127 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1128 parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
1129 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1130 parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", "");
1131 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1132 RNA_def_boolean(func, "any", 0, "Any", "");
1133 RNA_def_boolean(func, "shift", 0, "Shift", "");
1134 RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
1135 RNA_def_boolean(func, "alt", 0, "Alt", "");
1136 RNA_def_boolean(func, "oskey", 0, "OS Key", "");
1137 RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
1138 RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
1139 RNA_def_boolean(func,
1143 "Force item to be added at start (not end) of key map so that "
1144 "it doesn't get blocked by an existing key map item");
1145 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
1146 RNA_def_function_return(func, parm);
1148 func = RNA_def_function(srna, "new_modal", "rna_KeyMap_item_new_modal");
1149 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1150 parm = RNA_def_string(func, "propvalue", NULL, 0, "Property Value", "");
1151 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1152 parm = RNA_def_enum(func, "type", rna_enum_event_type_items, 0, "Type", "");
1153 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1154 parm = RNA_def_enum(func, "value", rna_enum_event_value_all_items, 0, "Value", "");
1155 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1156 RNA_def_boolean(func, "any", 0, "Any", "");
1157 RNA_def_boolean(func, "shift", 0, "Shift", "");
1158 RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
1159 RNA_def_boolean(func, "alt", 0, "Alt", "");
1160 RNA_def_boolean(func, "oskey", 0, "OS Key", "");
1161 RNA_def_enum(func, "key_modifier", rna_enum_event_type_items, 0, "Key Modifier", "");
1162 RNA_def_boolean(func, "repeat", false, "Repeat", "When set, accept key-repeat events");
1163 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
1164 RNA_def_function_return(func, parm);
1166 func = RNA_def_function(srna, "new_from_item", "rna_KeyMap_item_new_from_item");
1167 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1168 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Item to use as a reference");
1169 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1170 RNA_def_boolean(func, "head", 0, "At Head", "");
1171 parm = RNA_def_pointer(func, "result", "KeyMapItem", "Item", "Added key map item");
1172 RNA_def_function_return(func, parm);
1174 func = RNA_def_function(srna, "remove", "rna_KeyMap_item_remove");
1175 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1176 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1177 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1178 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1180 func = RNA_def_function(srna, "from_id", "WM_keymap_item_find_id");
1181 parm = RNA_def_property(func, "id", PROP_INT, PROP_NONE);
1182 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1183 RNA_def_property_ui_text(parm, "id", "ID of the item");
1184 parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1185 RNA_def_function_return(func, parm);
1187 /* Keymap introspection
1188 * Args follow: KeyConfigs.find_item_from_operator */
1189 func = RNA_def_function(srna, "find_from_operator", "rna_KeyMap_item_find_from_operator");
1190 RNA_def_function_flag(func, FUNC_USE_SELF_ID);
1191 parm = RNA_def_string(func, "idname", NULL, 0, "Operator Identifier", "");
1192 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1193 parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
1194 RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
1196 func, "include", rna_enum_event_type_mask_items, EVT_TYPE_MASK_ALL, "Include", "");
1197 RNA_def_enum_flag(func, "exclude", rna_enum_event_type_mask_items, 0, "Exclude", "");
1198 parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
1199 RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
1200 RNA_def_function_return(func, parm);
1202 func = RNA_def_function(srna, "match_event", "rna_KeyMap_item_match_event");
1203 RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_CONTEXT);
1204 parm = RNA_def_pointer(func, "event", "Event", "", "");
1205 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1206 parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
1207 RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
1208 RNA_def_function_return(func, parm);
1211 void RNA_api_keymaps(StructRNA *srna)
1216 func = RNA_def_function(srna, "new", "rna_keymap_new"); /* add_keymap */
1217 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1218 parm = RNA_def_string(func, "name", NULL, 0, "Name", "");
1219 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1220 RNA_def_enum(func, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
1222 func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
1223 RNA_def_boolean(func, "modal", 0, "Modal", "Keymap for modal operators");
1224 RNA_def_boolean(func, "tool", 0, "Tool", "Keymap for active tools");
1225 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Added key map");
1226 RNA_def_function_return(func, parm);
1228 func = RNA_def_function(srna, "remove", "rna_KeyMap_remove"); /* remove_keymap */
1229 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1230 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Removed key map");
1231 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1232 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1234 func = RNA_def_function(srna, "find", "rna_keymap_find"); /* find_keymap */
1235 parm = RNA_def_string(func, "name", NULL, 0, "Name", "");
1236 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1237 RNA_def_enum(func, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", "");
1239 func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
1240 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map");
1241 RNA_def_function_return(func, parm);
1243 func = RNA_def_function(srna, "find_modal", "rna_keymap_find_modal"); /* find_keymap_modal */
1244 parm = RNA_def_string(func, "name", NULL, 0, "Operator Name", "");
1245 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1246 parm = RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map");
1247 RNA_def_function_return(func, parm);
1250 void RNA_api_keyconfigs(StructRNA *srna)
1255 func = RNA_def_function(srna, "new", "WM_keyconfig_new_user"); /* add_keyconfig */
1256 parm = RNA_def_string(func, "name", NULL, 0, "Name", "");
1257 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1258 parm = RNA_def_pointer(
1259 func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration");
1260 RNA_def_function_return(func, parm);
1262 func = RNA_def_function(srna, "remove", "rna_KeyConfig_remove"); /* remove_keyconfig */
1263 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1264 parm = RNA_def_pointer(
1265 func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration");
1266 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
1267 RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
1269 /* Helper functions */
1271 /* Keymap introspection */
1272 func = RNA_def_function(
1273 srna, "find_item_from_operator", "rna_KeyConfig_find_item_from_operator");
1274 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
1275 parm = RNA_def_string(func, "idname", NULL, 0, "Operator Identifier", "");
1276 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
1277 parm = RNA_def_property(func, "context", PROP_ENUM, PROP_NONE);
1278 RNA_def_property_enum_items(parm, rna_enum_operator_context_items);
1279 parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", "");
1280 RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
1282 func, "include", rna_enum_event_type_mask_items, EVT_TYPE_MASK_ALL, "Include", "");
1283 RNA_def_enum_flag(func, "exclude", rna_enum_event_type_mask_items, 0, "Exclude", "");
1284 parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
1285 RNA_def_parameter_flags(parm, 0, PARM_RNAPTR | PARM_OUTPUT);
1286 parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
1287 RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
1288 RNA_def_function_return(func, parm);
1290 RNA_def_function(srna, "update", "rna_KeyConfig_update"); /* WM_keyconfig_update */