diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-11-16 00:28:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-16 00:31:00 +0300 |
commit | 088be7eb2f650f7849e3af33cbea76f7b3af0822 (patch) | |
tree | d0248368b79c2787dc87b4ba57cd3d836e36e0f4 /source/blender/blenloader | |
parent | 8ecc51e87fd0e3e9bb13622456d03d09926eab47 (diff) |
Keymaps: replace select / action mouse system
For Blender builtin configurations the option to choose the select mouse remains
and is now also in the splash screen. It works by changing the keymap dynamically
in the script, rather than using special events.
The system of automatic switching of events was not flexible enough to deal with
side effects that require further keymap changes, so it is now under more manual
control in the script.
This breaks compatibility for some scripts and exported key configurations.
These can be fixed by replacing SELECTMOUSE, ACTIONMOUSE, EVT_TWEAK_S and
EVT_TWEAK_A with appropriate LEFTMOUSE, RIGHTMOUSE, EVT_TWEAK_L and
EVT_TWEAK_R events.
Other than that, there should be no functional changes.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_userdef.c | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index e0453e71a05..49987cb860c 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -36,6 +36,7 @@ set(INC ../makesrna ../nodes ../render/extern/include + ../windowmanager ../../../intern/guardedalloc # for writefile.c: dna_type_offsets.h diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index b14b17cbd8f..2cf117067c2 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -40,6 +40,8 @@ #include "BLO_readfile.h" /* Own include. */ +#include "wm_event_types.h" + /* Disallow access to global userdef. */ #define U (_error_) @@ -92,6 +94,26 @@ static void do_versions_theme(UserDef *userdef, bTheme *btheme) #undef USER_VERSION_ATLEAST } +static void do_version_select_mouse(UserDef *userdef, wmKeyMapItem *kmi) +{ + /* Remove select/action mouse from user defined keymaps. */ + enum { + ACTIONMOUSE = 0x0005, + SELECTMOUSE = 0x0006, + EVT_TWEAK_A = 0x5005, + EVT_TWEAK_S = 0x5006, + }; + const bool left = (userdef->flag & USER_LMOUSESELECT) != 0; + + switch (kmi->type) { + case SELECTMOUSE: kmi->type = (left) ? LEFTMOUSE : RIGHTMOUSE; break; + case ACTIONMOUSE: kmi->type = (left) ? RIGHTMOUSE : LEFTMOUSE; break; + case EVT_TWEAK_S: kmi->type = (left) ? EVT_TWEAK_L : EVT_TWEAK_R; break; + case EVT_TWEAK_A: kmi->type = (left) ? EVT_TWEAK_R : EVT_TWEAK_L; break; + default: break; + } +} + /* patching UserDef struct and Themes */ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) { @@ -353,6 +375,24 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) } } + if (!USER_VERSION_ATLEAST(280, 31)) { + /* Remove select/action mouse from user defined keymaps. */ + for (wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) { + for (wmKeyMapDiffItem *kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) { + if (kmdi->remove_item) { + do_version_select_mouse(userdef, kmdi->remove_item); + } + if (kmdi->add_item) { + do_version_select_mouse(userdef, kmdi->add_item); + } + } + + for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + do_version_select_mouse(userdef, kmi); + } + } + } + /** * Include next version bump. */ |