Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_curve.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_curve.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c
index 82fe2fb01b0..6ca0a041388 100644
--- a/source/blender/editors/sculpt_paint/paint_curve.c
+++ b/source/blender/editors/sculpt_paint/paint_curve.c
@@ -743,31 +743,44 @@ void PAINTCURVE_OT_draw(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+static int paintcurve_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- PaintMode mode = BKE_paintmode_get_active_from_context(C);
+ op->customdata = SET_INT_IN_POINTER(event->type);
+ WM_event_add_modal_handler(C, op);
- switch (mode) {
- case PAINT_TEXTURE_2D:
- {
- ARegion *ar = CTX_wm_region(C);
- SpaceImage *sima = CTX_wm_space_image(C);
- float location[2];
+ return OPERATOR_RUNNING_MODAL;
+}
- if (!sima)
- return OPERATOR_CANCELLED;
+static int paintcurve_cursor_modal(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ if (event->type == GET_INT_FROM_POINTER(op->customdata) && event->val == KM_RELEASE)
+ return OPERATOR_FINISHED;
- UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
- copy_v2_v2(sima->cursor, location);
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL);
- break;
+ if (event->type == MOUSEMOVE) {
+ PaintMode mode = BKE_paintmode_get_active_from_context(C);
+
+ switch (mode) {
+ case PAINT_TEXTURE_2D:
+ {
+ ARegion *ar = CTX_wm_region(C);
+ SpaceImage *sima = CTX_wm_space_image(C);
+ float location[2];
+
+ if (!sima)
+ return OPERATOR_CANCELLED;
+
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
+ copy_v2_v2(sima->cursor, location);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL);
+ break;
+ }
+ default:
+ ED_view3d_cursor3d_update(C, event->mval);
+ break;
}
- default:
- ED_view3d_cursor3d_update(C, event->mval);
- break;
}
- return OPERATOR_FINISHED;
+ return OPERATOR_RUNNING_MODAL;
}
void PAINTCURVE_OT_cursor(wmOperatorType *ot)
@@ -779,6 +792,7 @@ void PAINTCURVE_OT_cursor(wmOperatorType *ot)
/* api callbacks */
ot->invoke = paintcurve_cursor_invoke;
+ ot->modal = paintcurve_cursor_modal;
ot->poll = paint_curve_poll;
/* flags */