diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-12-04 05:34:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-12-04 05:55:50 +0300 |
commit | 80816fc71235c07c8a0ae74d015116e852459114 (patch) | |
tree | a21944bb6ae82fb54f9e9236ef6b8b3bcb2f0eb3 /source | |
parent | 2ff79613a8335c43285c8d1e710d0f9e592dd8ff (diff) |
Fix T58256: error message w/ missing Select Box tool
Support space modes not having tools.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/WM_toolsystem.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 35 |
2 files changed, 34 insertions, 4 deletions
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index 4318179c203..23f9161025e 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -82,6 +82,9 @@ 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 3b91b351b25..f070ac59e8f 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -559,10 +559,12 @@ void WM_toolsystem_init(bContext *C) /* Rely on screen initialization for gizmos. */ } -int WM_toolsystem_mode_from_spacetype( - ViewLayer *view_layer, ScrArea *sa, int spacetype) +int WM_toolsystem_mode_from_spacetype_ex( + ViewLayer *view_layer, ScrArea *sa, int spacetype, + bool *r_ensure) { int mode = -1; + bool ensure = false; switch (spacetype) { case SPACE_VIEW3D: { @@ -575,23 +577,39 @@ int WM_toolsystem_mode_from_spacetype( 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) { @@ -787,6 +805,12 @@ static const char *toolsystem_default_tool(const bToolKey *tkey) return "Comb"; } break; + case SPACE_IMAGE: + switch (tkey->mode) { + case SI_MODE_PAINT: + return "Draw"; + } + break; } return "Select Box"; @@ -825,11 +849,14 @@ 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(view_layer, sa, sa->spacetype), + .mode = WM_toolsystem_mode_from_spacetype_ex(view_layer, sa, sa->spacetype, &ensure), }; - toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); + if (ensure) { + toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); + } } |