From 70d352d994d0f8187ad2c871ee22712b1bf4b855 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 May 2018 11:42:25 +0200 Subject: Tool System: add paint poll which ignores the tool Needed for tools which ensure paint context but aren't brushes (color sample & gradient). --- source/blender/editors/sculpt_paint/paint_image.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/sculpt_paint/paint_image.c') diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 06df1632593..3207b4f6a0a 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -264,7 +264,7 @@ static Brush *image_paint_brush(bContext *C) return BKE_paint_brush(&settings->imapaint.paint); } -static int image_paint_poll(bContext *C) +static int image_paint_poll_ex(bContext *C, bool check_tool) { Object *obact; @@ -273,7 +273,7 @@ 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)) { - if (WM_toolsystem_active_tool_is_brush(C)) { + if (!check_tool || WM_toolsystem_active_tool_is_brush(C)) { return 1; } } @@ -292,6 +292,16 @@ static int image_paint_poll(bContext *C) return 0; } +static int image_paint_poll(bContext *C) +{ + return image_paint_poll_ex(C, true); +} + +static int image_paint_poll_ignore_tool(bContext *C) +{ + return image_paint_poll_ex(C, false); +} + static int image_paint_2d_clone_poll(bContext *C) { Brush *brush = image_paint_brush(C); @@ -1001,7 +1011,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) static int sample_color_poll(bContext *C) { - return (image_paint_poll(C) || vertex_paint_poll(C)); + return (image_paint_poll_ignore_tool(C) || image_paint_poll_ignore_tool(C)); } void PAINT_OT_sample_color(wmOperatorType *ot) -- cgit v1.2.3