diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-12-04 06:29:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-12-04 06:33:45 +0300 |
commit | e7641b683427b724d104ad56c93c4c641a5f759b (patch) | |
tree | 22c8d87551803a3e3399098f266029119509a015 /source/blender/windowmanager/intern/wm_toolsystem.c | |
parent | 80816fc71235c07c8a0ae74d015116e852459114 (diff) |
Edit last commit
Split out ensure-tool check into its own function.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_toolsystem.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index f070ac59e8f..4b3b5695a8e 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -559,12 +559,26 @@ void WM_toolsystem_init(bContext *C) /* Rely on screen initialization for gizmos. */ } -int WM_toolsystem_mode_from_spacetype_ex( - ViewLayer *view_layer, ScrArea *sa, int spacetype, - bool *r_ensure) +static bool toolsystem_key_ensure_check(const bToolKey *tkey) +{ + switch (tkey->space_type) { + case SPACE_VIEW3D: + return true; + case SPACE_IMAGE: + if (ELEM(tkey->mode, SI_MODE_PAINT, SI_MODE_UV)) { + return true; + } + break; + case SPACE_NODE: + return true; + } + return false; +} + +int WM_toolsystem_mode_from_spacetype( + ViewLayer *view_layer, ScrArea *sa, int spacetype) { int mode = -1; - bool ensure = false; switch (spacetype) { case SPACE_VIEW3D: { @@ -577,39 +591,23 @@ int WM_toolsystem_mode_from_spacetype_ex( else { mode = CTX_MODE_OBJECT; } - ensure = true; break; } case SPACE_IMAGE: { SpaceImage *sima = sa->spacedata.first; mode = sima->mode; - if (ELEM(mode, SI_MODE_PAINT, SI_MODE_UV)) { - ensure = true; - } break; } case SPACE_NODE: { mode = 0; - ensure = true; break; } } - if (r_ensure) { - *r_ensure = ensure; - } return mode; } -int WM_toolsystem_mode_from_spacetype( - ViewLayer *view_layer, ScrArea *sa, int spacetype) -{ - return WM_toolsystem_mode_from_spacetype_ex( - view_layer, sa, spacetype, - NULL); -} - bool WM_toolsystem_key_from_context( ViewLayer *view_layer, ScrArea *sa, bToolKey *tkey) { @@ -849,12 +847,11 @@ void WM_toolsystem_update_from_context( bContext *C, WorkSpace *workspace, ViewLayer *view_layer, ScrArea *sa) { - bool ensure = false; const bToolKey tkey = { .space_type = sa->spacetype, - .mode = WM_toolsystem_mode_from_spacetype_ex(view_layer, sa, sa->spacetype, &ensure), + .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), }; - if (ensure) { + if (toolsystem_key_ensure_check(&tkey)) { toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); } } |