diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-25 08:06:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-25 08:06:47 +0300 |
commit | 6d49b623e2efce59b58bb1295024ab8ac492370a (patch) | |
tree | ebe29d04b2e9730dfb4f7cd733e63e2676794dfc /source/blender/editors | |
parent | 46587b3ccb0ec842500ce2c3f2359b78550aad0f (diff) |
WM: space, region type filtering for paint cursor
Avoids calling poll on mouse-move for unrelated space/region types.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/gpencil/annotate_paint.c | 1 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 7 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 1 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 7 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 21 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 6 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 12 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_uv.c | 4 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 30 |
9 files changed, 69 insertions, 20 deletions
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 31c66ac8d55..57be09d807c 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -1458,6 +1458,7 @@ static void gpencil_draw_toggle_eraser_cursor(bContext *C, tGPsdata *p, short en /* enable cursor */ p->erasercursor = WM_paint_cursor_activate( CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, NULL, /* XXX */ gpencil_draw_eraser, p); } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 711f77c5890..4e45db6aa76 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -2209,9 +2209,10 @@ static void gpencil_draw_toggle_eraser_cursor(bContext *C, tGPsdata *p, short en ED_gpencil_toggle_brush_cursor(p->C, false, NULL); /* enable cursor */ p->erasercursor = WM_paint_cursor_activate( - CTX_wm_manager(C), - NULL, /* XXX */ - gpencil_draw_eraser, p); + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + NULL, /* XXX */ + gpencil_draw_eraser, p); } } diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 77a838d2f22..fd7ce2d4139 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -1684,6 +1684,7 @@ void ED_gpencil_toggle_brush_cursor(bContext *C, bool enable, void *customdata) /* enable cursor */ gset->paintcursor = WM_paint_cursor_activate( CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, NULL, gp_brush_drawcursor, (lastpost) ? customdata : NULL); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 8009148480e..72ece2c8bd5 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2945,7 +2945,12 @@ static void toggle_particle_cursor(bContext *C, int enable) pset->paintcursor = NULL; } else if (enable) - pset->paintcursor = WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_view3d, brush_drawcursor, NULL); + pset->paintcursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_VIEW3D, RGN_TYPE_WINDOW, + PE_poll_view3d, + brush_drawcursor, + NULL); } /*************************** delete operator **************************/ diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 7d94e63e2bc..294981e7303 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -41,6 +41,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "DNA_userdef_types.h" #include "DNA_view3d_types.h" @@ -1153,8 +1154,14 @@ void paint_cursor_start(bContext *C, bool (*poll)(bContext *C)) { Paint *p = BKE_paint_get_active_from_context(C); - if (p && !p->paint_cursor) - p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL); + if (p && !p->paint_cursor) { + p->paint_cursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + poll, + paint_draw_cursor, + NULL); + } /* invalidate the paint cursors */ BKE_paint_invalidate_overlay_all(); @@ -1162,6 +1169,12 @@ void paint_cursor_start(bContext *C, bool (*poll)(bContext *C)) void paint_cursor_start_explicit(Paint *p, wmWindowManager *wm, bool (*poll)(bContext *C)) { - if (p && !p->paint_cursor) - p->paint_cursor = WM_paint_cursor_activate(wm, poll, paint_draw_cursor, NULL); + if (p && !p->paint_cursor) { + p->paint_cursor = WM_paint_cursor_activate( + wm, + SPACE_TYPE_ANY, RGN_TYPE_ANY, + poll, + paint_draw_cursor, + NULL); + } } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 897a74eb497..aaf82d8ef2b 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -485,7 +485,11 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const flo } if ((brush->imagepaint_tool == PAINT_TOOL_FILL) && (brush->flag & BRUSH_USE_GRADIENT)) { - pop->cursor = WM_paint_cursor_activate(CTX_wm_manager(C), image_paint_poll, gradient_draw_line, pop); + pop->cursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + image_paint_poll, gradient_draw_line, + pop); } settings->imapaint.flag |= IMAGEPAINT_DRAWING; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index af27ad5d307..a1ae32f2e9a 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -1201,8 +1201,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; if (paint_supports_smooth_stroke(br, mode)) - stroke->stroke_cursor = - WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_cursor, stroke); + stroke->stroke_cursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + paint_poll, paint_draw_smooth_cursor, stroke); stroke->stroke_init = true; first_modal = true; @@ -1220,8 +1222,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) stroke->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate); if (br->flag & BRUSH_LINE) { - stroke->stroke_cursor = - WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_line_cursor, stroke); + stroke->stroke_cursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + paint_poll, paint_draw_line_cursor, stroke); } first_dab = true; diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 8fafc545fa9..897539bddd7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -248,7 +248,9 @@ void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *sc BKE_paint_init(bmain, scene, ePaintSculptUV, PAINT_CURSOR_SCULPT); settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate( - wm, uv_sculpt_brush_poll, + wm, + SPACE_IMAGE, RGN_TYPE_WINDOW, + uv_sculpt_brush_poll, brush_drawcursor_uvsculpt, NULL); } else { diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 6dad6e96819..de41e6d3906 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2319,31 +2319,49 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); - t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); + t->draw_handle_cursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + helpline_poll, drawHelpline, t); } else if (t->spacetype == SPACE_IMAGE) { t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); - t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); + t->draw_handle_cursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + helpline_poll, drawHelpline, t); } else if (t->spacetype == SPACE_CLIP) { t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); - t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); + t->draw_handle_cursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + helpline_poll, drawHelpline, t); } else if (t->spacetype == SPACE_NODE) { /*t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);*/ t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); - t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); + t->draw_handle_cursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + helpline_poll, drawHelpline, t); } else if (t->spacetype == SPACE_IPO) { t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); - t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); + t->draw_handle_cursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + helpline_poll, drawHelpline, t); } else if (t->spacetype == SPACE_ACTION) { t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); - t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); + t->draw_handle_cursor = WM_paint_cursor_activate( + CTX_wm_manager(C), + SPACE_TYPE_ANY, RGN_TYPE_ANY, + helpline_poll, drawHelpline, t); } createTransData(C, t); // make TransData structs from selection |