diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-08 08:25:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-08 08:27:53 +0300 |
commit | 05ec0108dca544785ae55cbe847eaa058457df3d (patch) | |
tree | 9617df2a254b575cf7cef77dc527bab13ab05104 /source | |
parent | 469d43b1dbc54d2afcbfe104a2d8ca9c03df9b81 (diff) |
WM: refresh tool on object mode switch
The tool manipulator could become disabled when set in the wrong mode.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/mesh/editmesh_extrude.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 13 |
4 files changed, 33 insertions, 2 deletions
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 0e1f2f882bd..c8b2850cbad 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -448,7 +448,8 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro if (!ED_transform_calc_manipulator_stats( C, &(struct TransformCalcParams){ .orientation_type = orientation_type + 1, - }, &tbounds)) { + }, &tbounds)) + { return; } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index ff5eb46a38e..cd51474accf 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1018,7 +1018,7 @@ static void view3d_main_region_listener( static void view3d_main_region_message_subscribe( const struct bContext *UNUSED(C), - struct WorkSpace *UNUSED(workspace), struct Scene *scene, + struct WorkSpace *workspace, struct Scene *scene, struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), struct ARegion *ar, struct wmMsgBus *mbus) { @@ -1092,6 +1092,17 @@ static void view3d_main_region_message_subscribe( WM_msg_subscribe_rna_anon_type(mbus, ViewLayerEngineSettingsClay, &msg_sub_value_region_tag_redraw); } #endif + + if (workspace->tool.spacetype == SPACE_VIEW3D) { + wmMsgSubscribeValue msg_sub_value_region_tag_refresh = { + .owner = ar, + .user_data = ar, + .notify = WM_toolsystem_do_msg_notify_tag_refresh, + }; + WM_msg_subscribe_rna_anon_prop( + mbus, Object, mode, + &msg_sub_value_region_tag_refresh); + } } /* concept is to retrieve cursor type context-less */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 31c30388560..9176385c40d 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -53,6 +53,8 @@ struct wmEvent; struct wmEventHandler; struct wmGesture; struct wmJob; +struct wmMsgSubscribeKey; +struct wmMsgSubscribeValue; struct wmOperatorType; struct wmOperator; struct rcti; @@ -595,12 +597,16 @@ bool WM_event_is_ime_switch(const struct wmEvent *event); /* wm_toolsystem.c */ void WM_toolsystem_unlink(struct bContext *C, struct WorkSpace *workspace); void WM_toolsystem_link(struct bContext *C, struct WorkSpace *workspace); +void WM_toolsystem_refresh(struct bContext *C, struct WorkSpace *workspace); void WM_toolsystem_set(struct bContext *C, const struct bToolDef *tool); void WM_toolsystem_init(struct bContext *C); bool WM_toolsystem_active_tool_is_brush(const struct bContext *C); +void WM_toolsystem_do_msg_notify_tag_refresh( + struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val); + /* wm_tooltip.c */ typedef struct ARegion *(*wmTooltipInitFn)(struct bContext *, struct ARegion *, bool *); diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index e449695e3cf..04542717b24 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -114,6 +114,11 @@ void WM_toolsystem_link(bContext *C, WorkSpace *workspace) } } +void WM_toolsystem_refresh(bContext *C, WorkSpace *workspace) +{ + WM_toolsystem_link(C, workspace); +} + void WM_toolsystem_set(bContext *C, const bToolDef *tool) { WorkSpace *workspace = CTX_wm_workspace(C); @@ -159,3 +164,11 @@ bool WM_toolsystem_active_tool_is_brush(const bContext *C) /* Will need to become more comprehensive, for now check tool data-block. */ return workspace->tool.data_block[0] != '\0'; } + +/* Follow wmMsgNotifyFn spec */ +void WM_toolsystem_do_msg_notify_tag_refresh( + bContext *C, wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val) +{ + WorkSpace *workspace = CTX_wm_workspace(C); + WM_toolsystem_refresh(C, workspace); +} |