diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-27 09:33:52 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-27 09:52:15 +0300 |
commit | 1f8360171cd80c0c1918486703926709cb5db7aa (patch) | |
tree | 25ce56039ec95d156c4eaddc4134d639f3b900c3 /source/blender/windowmanager/intern/wm_keymap.c | |
parent | a58f0eea4f1e9b04e519e123eb656009cf718f9e (diff) |
Keymap: share annotation tool keymaps between spaces
Not sharing caused duplication in the keymap and
required a factory class generator.
Simplify tool & keymap definitions by sharing them.
It's highly unlikely we will ever want these to use different keys
once they're set as the active tool.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_keymap.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 27c816a4d7d..4c00b99e13e 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -806,6 +806,18 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int return NULL; } +wmKeyMap *WM_keymap_list_find_spaceid_or_empty(ListBase *lb, const char *idname, int spaceid, int regionid) +{ + wmKeyMap *km; + + for (km = lb->first; km; km = km->next) + if (ELEM(km->spaceid, spaceid, SPACE_EMPTY) && km->regionid == regionid) + if (STREQLEN(idname, km->idname, KMAP_MAX_NAME)) + return km; + + return NULL; +} + wmKeyMap *WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid) { wmKeyMap *km = WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid); @@ -827,6 +839,13 @@ wmKeyMap *WM_keymap_find_all(const bContext *C, const char *idname, int spaceid, return WM_keymap_list_find(&wm->userconf->keymaps, idname, spaceid, regionid); } +wmKeyMap *WM_keymap_find_all_spaceid_or_empty(const bContext *C, const char *idname, int spaceid, int regionid) +{ + wmWindowManager *wm = CTX_wm_manager(C); + + return WM_keymap_list_find_spaceid_or_empty(&wm->userconf->keymaps, idname, spaceid, regionid); +} + /* ****************** modal keymaps ************ */ /* modal maps get linked to a running operator, and filter the keys before sending to modal() callback */ |