Fix: GPv3: Wrong cursor for non brush tools

Brush cursor is being drawn even if the selected tool is non-brush in
GPv3 paint mode. To prevent this, use `ED_gpencil_brush_cursor_poll` for
`pc` poll function. Above poll function returns false if active tool is not
brush, this will avoid drawing of paint cursor in
`pc->draw`/`grease_pencil_brush_cursor_draw`.

Resolves #122541

Pull Request: https://projects.blender.org/blender/blender/pulls/122657
This commit is contained in:
Pratik Borhade
2024-06-03 19:13:49 +02:00
committed by Falk David
parent bbb7962b3c
commit 4b6479bf9e
3 changed files with 4 additions and 3 deletions

View File

@@ -391,7 +391,7 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
BKE_paint_init(bmain, scene, PaintMode::GPencil, PAINT_CURSOR_PAINT_GREASE_PENCIL);
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PaintMode::GPencil);
ED_paint_cursor_start(paint, gpencil_paint_poll_view3d);
ED_paint_cursor_start(paint, ED_gpencil_brush_cursor_poll);
mode = OB_MODE_PAINT_GPENCIL_LEGACY;
}
else {

View File

@@ -1727,7 +1727,7 @@ void ED_gpencil_brush_draw_eraser(Brush *brush, int x, int y)
GPU_line_smooth(false);
}
static bool gpencil_brush_cursor_poll(bContext *C)
bool ED_gpencil_brush_cursor_poll(bContext *C)
{
if (WM_toolsystem_active_tool_is_brush(C)) {
return true;
@@ -2018,7 +2018,7 @@ void ED_gpencil_toggle_brush_cursor(bContext *C, bool enable, void *customdata)
/* enable cursor */
gset->paintcursor = WM_paint_cursor_activate(SPACE_TYPE_ANY,
RGN_TYPE_ANY,
gpencil_brush_cursor_poll,
ED_gpencil_brush_cursor_poll,
gpencil_brush_cursor_draw,
(lastpost) ? customdata : nullptr);
}

View File

@@ -610,6 +610,7 @@ void ED_gpencil_stroke_close_by_distance(bGPDstroke *gps, float threshold);
* Calculate the brush cursor size in world space.
*/
float ED_gpencil_cursor_radius(bContext *C, int x, int y);
bool ED_gpencil_brush_cursor_poll(bContext *C);
float ED_gpencil_radial_control_scale(bContext *C,
Brush *brush,
float initial_value,