diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/windowmanager/WM_toolsystem.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 43 |
2 files changed, 20 insertions, 26 deletions
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index 23f9161025e..4318179c203 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -82,9 +82,6 @@ void WM_toolsystem_ref_sync_from_context( void WM_toolsystem_init(struct bContext *C); -int WM_toolsystem_mode_from_spacetype_ex( - struct ViewLayer *view_layer, struct ScrArea *sa, int space_type, - bool *r_ensure); int WM_toolsystem_mode_from_spacetype( struct ViewLayer *view_layer, struct ScrArea *sa, int space_type); bool WM_toolsystem_key_from_context( 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); } } |