diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-09-17 01:03:07 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-09-17 01:03:07 +0400 |
commit | 5ae75d5dc841a6fa33b8ead55bc6fbe89bb8b767 (patch) | |
tree | a3b7492ce70230babb9bf63ae5d632aa0294e108 | |
parent | 7d0e17922a817d940121d8eaf9f0812ece98b16e (diff) |
Fix #23652: texture paint RMB would translate the object after sampling
color, made sample a modal operator now to solve this. It's an indirect
solution, but couldn't think of anything better, and it's useful to have
anyway.
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 3f1a5af76b1..e7a06f27f67 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5135,11 +5135,40 @@ static int sample_color_invoke(bContext *C, wmOperator *op, wmEvent *event) ARegion *ar= CTX_wm_region(C); int location[2]; - location[0]= event->x - ar->winrct.xmin; - location[1]= event->y - ar->winrct.ymin; - RNA_int_set_array(op->ptr, "location", location); + if(ar) { + location[0]= event->x - ar->winrct.xmin; + location[1]= event->y - ar->winrct.ymin; + RNA_int_set_array(op->ptr, "location", location); - return sample_color_exec(C, op); + sample_color_exec(C, op); + } + + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +static int sample_color_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + int location[2]; + + switch(event->type) { + case LEFTMOUSE: + case RIGHTMOUSE: // XXX hardcoded + return OPERATOR_FINISHED; + case MOUSEMOVE: + if(ar) { + location[0]= event->x - ar->winrct.xmin; + location[1]= event->y - ar->winrct.ymin; + RNA_int_set_array(op->ptr, "location", location); + + sample_color_exec(C, op); + } + break; + } + + return OPERATOR_RUNNING_MODAL; } void PAINT_OT_sample_color(wmOperatorType *ot) @@ -5151,6 +5180,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot) /* api callbacks */ ot->exec= sample_color_exec; ot->invoke= sample_color_invoke; + ot->modal= sample_color_modal; ot->poll= image_paint_poll; /* flags */ |