[Bf-blender-cvs] [2c9670b92d3] blender2.8: Tool System: support non-brush tools w/ paint modes
Campbell Barton
noreply at git.blender.org
Tue May 1 11:23:48 CEST 2018
Commit: 2c9670b92d32e79d0f071475731bcaf79aae42f5
Author: Campbell Barton
Date: Tue May 1 11:22:12 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2c9670b92d32e79d0f071475731bcaf79aae42f5
Tool System: support non-brush tools w/ paint modes
Allows select, gradient tools not to conflict with brush keymap.
===================================================================
M source/blender/editors/sculpt_paint/paint_image.c
M source/blender/editors/sculpt_paint/paint_vertex.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_toolsystem.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index dbb12282d0a..06df1632593 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -273,7 +273,9 @@ static int image_paint_poll(bContext *C)
obact = CTX_data_active_object(C);
if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) {
- return 1;
+ if (WM_toolsystem_active_tool_is_brush(C)) {
+ return 1;
+ }
}
else {
SpaceImage *sima = CTX_wm_space_image(C);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 7e9c98d3822..fc43fe97648 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -214,8 +214,11 @@ int vertex_paint_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype == SPACE_VIEW3D) {
ARegion *ar = CTX_wm_region(C);
- if (ar->regiontype == RGN_TYPE_WINDOW)
- return 1;
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ if (WM_toolsystem_active_tool_is_brush(C)) {
+ return 1;
+ }
+ }
}
}
return 0;
@@ -241,7 +244,9 @@ int weight_paint_poll(bContext *C)
{
ARegion *ar = CTX_wm_region(C);
if (ar->regiontype == RGN_TYPE_WINDOW) {
- return 1;
+ if (WM_toolsystem_active_tool_is_brush(C)) {
+ return 1;
+ }
}
}
return 0;
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index c65f1064830..febf69aa789 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -595,6 +595,8 @@ void WM_toolsystem_link(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);
+
/* 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 66e84406ebb..690628bbd3b 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -140,3 +140,13 @@ void WM_toolsystem_init(bContext *C)
WM_toolsystem_link(C, workspace);
}
}
+
+/**
+ * For paint modes to support non-brush tools.
+ */
+bool WM_toolsystem_active_tool_is_brush(const bContext *C)
+{
+ WorkSpace *workspace = CTX_wm_workspace(C);
+ /* Will need to become more comprehensive, for now check tool data-block. */
+ return workspace->tool.data_block[0] != '\0';
+}
More information about the Bf-blender-cvs
mailing list