diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-11-14 09:34:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-11-14 09:34:56 +0300 |
commit | 079fd1579c258527de3f9619912af999c106f54d (patch) | |
tree | de15adc8fae7f3ce6f2517f07731911e3bbcec4b /source/blender/windowmanager | |
parent | 11198ce48a200029f6cd837e7e897dccd551ed64 (diff) | |
parent | 47da01a4db1dcedcaaae1ba22626f340cb90a530 (diff) |
Merge branch 'blender-v2.81-release'
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_toolsystem.h | 12 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 16 |
2 files changed, 21 insertions, 7 deletions
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index 5afa0a88560..620150ba14f 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -54,11 +54,13 @@ struct bToolRef *WM_toolsystem_ref_find(struct WorkSpace *workspace, const bTool bool WM_toolsystem_ref_ensure(struct WorkSpace *workspace, const bToolKey *tkey, struct bToolRef **r_tref); -struct bToolRef *WM_toolsystem_ref_set_by_id(struct bContext *C, - struct WorkSpace *workspace, - const bToolKey *tkey, - const char *name, - bool cycle); + +struct bToolRef *WM_toolsystem_ref_set_by_id_ex(struct bContext *C, + struct WorkSpace *workspace, + const bToolKey *tkey, + const char *name, + bool cycle); +struct bToolRef *WM_toolsystem_ref_set_by_id(struct bContext *C, const char *name); struct bToolRef_Runtime *WM_toolsystem_runtime_from_context(struct bContext *C); struct bToolRef_Runtime *WM_toolsystem_runtime_find(struct WorkSpace *workspace, diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 11286a822a7..f64acf20581 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -633,7 +633,7 @@ static void toolsystem_refresh_screen_from_active_tool(Main *bmain, } } -bToolRef *WM_toolsystem_ref_set_by_id( +bToolRef *WM_toolsystem_ref_set_by_id_ex( bContext *C, WorkSpace *workspace, const bToolKey *tkey, const char *name, bool cycle) { wmOperatorType *ot = WM_operatortype_find("WM_OT_tool_set_by_id", false); @@ -663,13 +663,25 @@ bToolRef *WM_toolsystem_ref_set_by_id( return (tref && STREQ(tref->idname, name)) ? tref : NULL; } +bToolRef *WM_toolsystem_ref_set_by_id(bContext *C, const char *name) +{ + ViewLayer *view_layer = CTX_data_view_layer(C); + ScrArea *sa = CTX_wm_area(C); + bToolKey tkey; + if (WM_toolsystem_key_from_context(view_layer, sa, &tkey)) { + WorkSpace *workspace = CTX_wm_workspace(C); + return WM_toolsystem_ref_set_by_id_ex(C, workspace, &tkey, name, false); + } + return NULL; +} + static void toolsystem_reinit_with_toolref(bContext *C, WorkSpace *workspace, bToolRef *tref) { bToolKey tkey = { .space_type = tref->space_type, .mode = tref->mode, }; - WM_toolsystem_ref_set_by_id(C, workspace, &tkey, tref->idname, false); + WM_toolsystem_ref_set_by_id_ex(C, workspace, &tkey, tref->idname, false); } static const char *toolsystem_default_tool(const bToolKey *tkey) |