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:
authorMartin Poirier <theeth@yahoo.com>2009-11-15 22:25:34 +0300
committerMartin Poirier <theeth@yahoo.com>2009-11-15 22:25:34 +0300
commit11cfdfa2643bb380fc0596c737650643ce4a45be (patch)
tree6fd1c93b66c88222229c015449a9dae744006048 /source/blender/windowmanager/intern/wm_keymap.c
parent6ea605797c04ae2299d886c1bada06fe838c2be5 (diff)
=== Better support for user defined modal keymaps ===
Fixing/Missing RNA properties: - "virtual" property for "ANY" modifier for keymapitem - modal property for keymap - Look up modal_items in usermaps too Lazy init usermaps needs to init modal_items too. New function to initialize a user keymap (fill in modal_item and poll pointers). Operator modal keymaps now look up if there's a user defined keymap that overwrites it. Full Event UI buttons now show "Any" when modifier is set to that (instead of listing all of them). Note: Having the modifiers as boolean still doesn't express the full breath of values possible for them. There is commented code in this commit to represent them as enum, which would solve this, but make the keymap editor more cryptic.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_keymap.c')
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c67
1 files changed, 56 insertions, 11 deletions
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 48262e40ea7..a9cace65206 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -88,9 +88,14 @@ void WM_keyconfig_userdef(wmWindowManager *wm)
wmKeyMap *km;
wmKeyMapItem *kmi;
- for(km=U.keymaps.first; km; km=km->next)
- for(kmi=km->items.first; kmi; kmi=kmi->next)
- keymap_properties_set(kmi);
+ for(km=U.keymaps.first; km; km=km->next) {
+ /* modal keymaps don't have operator properties */
+ if ((km->flag & KEYMAP_MODAL) == 0) {
+ for(kmi=km->items.first; kmi; kmi=kmi->next) {
+ keymap_properties_set(kmi);
+ }
+ }
+ }
}
static wmKeyConfig *wm_keyconfig_list_find(ListBase *lb, char *idname)
@@ -295,17 +300,25 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
buf[0]= 0;
- if(kmi->shift)
- strcat(buf, "Shift ");
+ if (kmi->shift == KM_ANY &&
+ kmi->ctrl == KM_ANY &&
+ kmi->alt == KM_ANY &&
+ kmi->oskey == KM_ANY) {
- if(kmi->ctrl)
- strcat(buf, "Ctrl ");
+ strcat(buf, "Any ");
+ } else {
+ if(kmi->shift)
+ strcat(buf, "Shift ");
- if(kmi->alt)
- strcat(buf, "Alt ");
+ if(kmi->ctrl)
+ strcat(buf, "Ctrl ");
- if(kmi->oskey)
- strcat(buf, "Cmd ");
+ if(kmi->alt)
+ strcat(buf, "Alt ");
+
+ if(kmi->oskey)
+ strcat(buf, "Cmd ");
+ }
if(kmi->keymodifier) {
strcat(buf, WM_key_event_string(kmi->keymodifier));
@@ -410,6 +423,36 @@ char *WM_key_event_operator_string(const bContext *C, const char *opname, int op
/* ***************** user preferences ******************* */
+int WM_keymap_user_init(wmWindowManager *wm, wmKeyMap *keymap)
+{
+ wmKeyConfig *keyconf;
+ wmKeyMap *km;
+
+ if(!keymap)
+ return 0;
+
+ /* init from user key config */
+ keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
+ if(keyconf) {
+ km= wm_keymap_list_find(&keyconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
+ if(km) {
+ keymap->poll= km->poll; /* lazy init */
+ keymap->modal_items= km->modal_items;
+ return 1;
+ }
+ }
+
+ /* or from default */
+ km= wm_keymap_list_find(&wm->defaultconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
+ if(km) {
+ keymap->poll= km->poll; /* lazy init */
+ keymap->modal_items= km->modal_items;
+ return 1;
+ }
+
+ return 0;
+}
+
wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
{
wmKeyConfig *keyconf;
@@ -422,6 +465,7 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
km= wm_keymap_list_find(&U.keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
if(km) {
km->poll= keymap->poll; /* lazy init */
+ km->modal_items= keymap->modal_items;
return km;
}
@@ -431,6 +475,7 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
km= wm_keymap_list_find(&keyconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
if(km) {
km->poll= keymap->poll; /* lazy init */
+ km->modal_items= keymap->modal_items;
return km;
}
}