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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-04-17 19:40:04 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-04-17 19:40:04 +0400
commit8ae502ae99be5171d8da6643b5bbeab0794d3d7c (patch)
treee059f6399d1399b91c172a1c307ee47592d6eaad /source/blender/windowmanager
parent3f9fce6542e92f4a62af326572bccd3a4cbcfce1 (diff)
Fix #30977: error loading modal keymaps from keyconfiguration presets.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_keymap.h1
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c45
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c8
3 files changed, 50 insertions, 4 deletions
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index db448397065..78dbd253cd6 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -80,6 +80,7 @@ int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2);
wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, struct EnumPropertyItem *items);
wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, const char *idname);
wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value);
+wmKeyMapItem *WM_modalkeymap_add_item_str(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value);
void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname);
/* Keymap Editor */
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index af56211a4e3..247eadbb698 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -710,6 +710,22 @@ wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, int type, int val, int modif
return kmi;
}
+wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value)
+{
+ wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
+
+ BLI_addtail(&km->items, kmi);
+ BLI_strncpy(kmi->propvalue_str, value, sizeof(kmi->propvalue_str));
+
+ keymap_event_set(kmi, type, val, modifier, keymodifier);
+
+ keymap_item_set_id(km, kmi);
+
+ WM_keyconfig_update_tag(km, kmi);
+
+ return kmi;
+}
+
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0);
@@ -720,6 +736,33 @@ void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
printf("error: modalkeymap_assign, unknown operator %s\n", opname);
}
+static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km)
+{
+ /* here we convert propvalue string values delayed, due to python keymaps
+ * being created before the actual modal keymaps, so no modal_items */
+ wmKeyMap *defaultkm;
+ wmKeyMapItem *kmi;
+ int propvalue;
+
+ if (km && (km->flag & KEYMAP_MODAL) && !km->modal_items) {
+ defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0);
+
+ if (!defaultkm)
+ return;
+
+ km->modal_items = defaultkm->modal_items;
+ km->poll = defaultkm->poll;
+
+ for (kmi = km->items.first; kmi; kmi = kmi->next) {
+ if (kmi->propvalue_str[0]) {
+ if (RNA_enum_value_from_id(km->modal_items, kmi->propvalue_str, &propvalue))
+ kmi->propvalue = propvalue;
+ kmi->propvalue_str[0] = '\0';
+ }
+ }
+ }
+}
+
/* ***************** get string from key events **************** */
const char *WM_key_event_string(short type)
@@ -1034,6 +1077,8 @@ void WM_keyconfig_update(wmWindowManager *wm)
addonmap = WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
usermap = WM_keymap_list_find(&U.user_keymaps, km->idname, km->spaceid, km->regionid);
+ wm_user_modal_keymap_set_items(wm, defaultmap);
+
/* add */
kmn = wm_keymap_patch_update(&wm->userconf->keymaps, defaultmap, addonmap, usermap);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index b15d408df64..028f7b5c41f 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3711,7 +3711,7 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Gesture Circle");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap) return;
+ if (keymap && keymap->modal_items) return;
keymap = WM_modalkeymap_add(keyconf, "View3D Gesture Circle", modal_items);
@@ -3758,7 +3758,7 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Straight Line");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap) return;
+ if (keymap && keymap->modal_items) return;
keymap = WM_modalkeymap_add(keyconf, "Gesture Straight Line", modal_items);
@@ -3787,7 +3787,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Border");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap) return;
+ if (keymap && keymap->modal_items) return;
keymap = WM_modalkeymap_add(keyconf, "Gesture Border", modal_items);
@@ -3846,7 +3846,7 @@ static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Zoom Border");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap) return;
+ if (keymap && keymap->modal_items) return;
keymap = WM_modalkeymap_add(keyconf, "Gesture Zoom Border", modal_items);