diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-12-15 16:10:29 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-12-15 16:10:29 +0300 |
commit | d48f4b6012ccfc1a1da6a1a002d7c86cacbd98aa (patch) | |
tree | 17042a225366b4d6fc85e0b91534d9d1d952cf9d /source/blender/windowmanager/intern/wm_keymap.c | |
parent | b4aef1673369b8f0a4e8009f9aab38c7c586ef4f (diff) |
2.5: added support for setting RNA properties in keymap item,
which will then be set when the operator is called, example:
kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "dir", 'h');
kmi= WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "dir", 'v');
There is a hack I had to do here, since properties are defined
as member of wmOperator, will try to fix later, committing now
so it can be used already.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_keymap.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index f01ca55c319..0e962408b55 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -39,6 +39,9 @@ #include "BKE_library.h" #include "BKE_main.h" +#include "RNA_access.h" +#include "RNA_types.h" + #include "WM_api.h" #include "WM_types.h" #include "wm_window.h" @@ -47,7 +50,7 @@ /* ***************** generic call, exported **************** */ -static void keymap_set(wmKeymapItem *kmi, short type, short val, int modifier, short keymodifier) +static void keymap_event_set(wmKeymapItem *kmi, short type, short val, int modifier, short keymodifier) { kmi->type= type; kmi->val= val; @@ -71,6 +74,20 @@ static void keymap_set(wmKeymapItem *kmi, short type, short val, int modifier, s kmi->oskey= 2; } +static void keymap_properties_set(wmKeymapItem *kmi) +{ + wmOperatorType *ot; + + if(!kmi->ptr) { + ot= WM_operatortype_find(kmi->idname); + + if(ot) { + kmi->ptr= MEM_callocN(sizeof(PointerRNA), "wmKeymapItemPtr"); + RNA_pointer_create(NULL, NULL, ot->srna, kmi, kmi->ptr); + } + } +} + /* if item was added, then bail out */ wmKeymapItem *WM_keymap_verify_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier) { @@ -85,7 +102,8 @@ wmKeymapItem *WM_keymap_verify_item(ListBase *lb, char *idname, short type, shor BLI_addtail(lb, kmi); BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME); - keymap_set(kmi, type, val, modifier, keymodifier); + keymap_event_set(kmi, type, val, modifier, keymodifier); + keymap_properties_set(kmi); } return kmi; } @@ -104,7 +122,8 @@ wmKeymapItem *WM_keymap_set_item(ListBase *lb, char *idname, short type, short v BLI_addtail(lb, kmi); BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME); } - keymap_set(kmi, type, val, modifier, keymodifier); + keymap_event_set(kmi, type, val, modifier, keymodifier); + keymap_properties_set(kmi); return kmi; } @@ -116,15 +135,11 @@ wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, short v BLI_addtail(lb, kmi); BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME); - keymap_set(kmi, type, val, modifier, keymodifier); + keymap_event_set(kmi, type, val, modifier, keymodifier); + keymap_properties_set(kmi); return kmi; } -void WM_keymap_property_set(wmKeymapItem *km, const char *propname, const char *propval) -{ - /* todo */ -} - /* ****************** storage in WM ************ */ /* name id's are for storing general or multiple keymaps, |