[Bf-blender-cvs] [b1df82fc88c] blender2.8: Cleanup: de-duplicate poll function
Campbell Barton
noreply at git.blender.org
Fri Nov 9 07:20:05 CET 2018
Commit: b1df82fc88ca939ab9640962a6a8886264fcda04
Author: Campbell Barton
Date: Fri Nov 9 17:18:38 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBb1df82fc88ca939ab9640962a6a8886264fcda04
Cleanup: de-duplicate poll function
===================================================================
M source/blender/editors/gpencil/gpencil_ops.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index a343d9d680d..5ea8c0b783f 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -83,8 +83,7 @@ static bool gp_stroke_paintmode_poll(bContext *C)
return (gpd && (gpd->flag & GP_DATA_STROKE_PAINTMODE));
}
-/* Poll callback for stroke painting (draw brush) */
-static bool gp_stroke_paintmode_draw_poll(bContext *C)
+static bool gp_stroke_paintmode_poll_with_tool(bContext *C, const char gpencil_tool)
{
/* TODO: limit this to mode, but review 2D editors */
bGPdata *gpd = CTX_data_gpencil_data(C);
@@ -92,34 +91,26 @@ static bool gp_stroke_paintmode_draw_poll(bContext *C)
Brush *brush = BKE_brush_getactive_gpencil(ts);
return ((gpd) && (gpd->flag & GP_DATA_STROKE_PAINTMODE) &&
(brush && brush->gpencil_settings) &&
- (brush->gpencil_tool == GPAINT_TOOL_DRAW) &&
- WM_toolsystem_active_tool_is_brush(C));
+ WM_toolsystem_active_tool_is_brush(C) &&
+ (brush->gpencil_tool == gpencil_tool));
+}
+
+/* Poll callback for stroke painting (draw brush) */
+static bool gp_stroke_paintmode_draw_poll(bContext *C)
+{
+ return gp_stroke_paintmode_poll_with_tool(C, GPAINT_TOOL_DRAW);
}
/* Poll callback for stroke painting (erase brush) */
static bool gp_stroke_paintmode_erase_poll(bContext *C)
{
- /* TODO: limit this to mode, but review 2D editors */
- bGPdata *gpd = CTX_data_gpencil_data(C);
- ToolSettings *ts = CTX_data_tool_settings(C);
- Brush *brush = BKE_brush_getactive_gpencil(ts);
- return ((gpd) && (gpd->flag & GP_DATA_STROKE_PAINTMODE) &&
- (brush && brush->gpencil_settings) &&
- (brush->gpencil_tool == GPAINT_TOOL_ERASE) &&
- WM_toolsystem_active_tool_is_brush(C));
+ return gp_stroke_paintmode_poll_with_tool(C, GPAINT_TOOL_ERASE);
}
/* Poll callback for stroke painting (fill) */
static bool gp_stroke_paintmode_fill_poll(bContext *C)
{
- /* TODO: limit this to mode, but review 2D editors */
- bGPdata *gpd = CTX_data_gpencil_data(C);
- ToolSettings *ts = CTX_data_tool_settings(C);
- Brush *brush = BKE_brush_getactive_gpencil(ts);
- return ((gpd) && (gpd->flag & GP_DATA_STROKE_PAINTMODE) &&
- (brush && brush->gpencil_settings) &&
- (brush->gpencil_tool == GPAINT_TOOL_FILL) &&
- WM_toolsystem_active_tool_is_brush(C));
+ return gp_stroke_paintmode_poll_with_tool(C, GPAINT_TOOL_FILL);
}
/* Poll callback for stroke sculpting mode */
More information about the Bf-blender-cvs
mailing list