Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-11-23 07:16:13 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-23 07:16:13 +0300
commitcfffe615f4794606fc2b7a1bdb148714e3c6e158 (patch)
tree3b43019ff5d9813c1e2c8e0707e0bebe508c8130 /source/blender/makesrna/intern/rna_wm_api.c
parent1fcb3e791f320563a997c83c3ea3063b606f17b8 (diff)
Keymap: add Keymap.keymap_items.new_from_item
Needed to copy keymap items from other keymaps.
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 84bb339b4c5..ef8607018d7 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -240,6 +240,25 @@ static wmKeyMapItem *rna_KeyMap_item_new(
return kmi;
}
+static wmKeyMapItem *rna_KeyMap_item_new_from_item(
+ wmKeyMap *km, ReportList *reports, wmKeyMapItem *kmi_src, bool head)
+{
+/* wmWindowManager *wm = CTX_wm_manager(C); */
+
+ if ((km->flag & KEYMAP_MODAL) == (kmi_src->idname[0] != '\0')) {
+ BKE_report(reports, RPT_ERROR, "Can not mix mondal/non-modal items");
+ return NULL;
+ }
+
+ /* create keymap item */
+ wmKeyMapItem *kmi = WM_keymap_add_item_copy(km, kmi_src);
+ if (head) {
+ BLI_remlink(&km->items, kmi);
+ BLI_addhead(&km->items, kmi);
+ }
+ return kmi;
+}
+
static wmKeyMapItem *rna_KeyMap_item_new_modal(
wmKeyMap *km, ReportList *reports, const char *propvalue_str,
int type, int value, bool any, bool shift, bool ctrl, bool alt,
@@ -855,6 +874,14 @@ void RNA_api_keymapitems(StructRNA *srna)
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item");
RNA_def_function_return(func, parm);
+ func = RNA_def_function(srna, "new_from_item", "rna_KeyMap_item_new_from_item");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Item to use as a reference");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ RNA_def_boolean(func, "head", 0, "At Head", "");
+ parm = RNA_def_pointer(func, "result", "KeyMapItem", "Item", "Added key map item");
+ RNA_def_function_return(func, parm);
+
func = RNA_def_function(srna, "remove", "rna_KeyMap_item_remove");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");