[Bf-blender-cvs] [05ec0108dca] blender2.8: WM: refresh tool on object mode switch

Campbell Barton noreply at git.blender.org
Tue May 8 07:28:05 CEST 2018


Commit: 05ec0108dca544785ae55cbe847eaa058457df3d
Author: Campbell Barton
Date:   Tue May 8 07:25:36 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB05ec0108dca544785ae55cbe847eaa058457df3d

WM: refresh tool on object mode switch

The tool manipulator could become disabled when set in the wrong mode.

===================================================================

M	source/blender/editors/mesh/editmesh_extrude.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_toolsystem.c

===================================================================

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);
+}



More information about the Bf-blender-cvs mailing list