diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-04-11 18:15:25 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-04-11 18:15:25 +0400 |
commit | 5c4a080021ef565611f52ea5ebc37e30224b3b3f (patch) | |
tree | 625c43fa0ed7681519da36fe9efb202795583c3b /source | |
parent | 4d7db8e59e02bc7281e54222a9e169719b183121 (diff) |
Fix #34954, due to hardcoded key release it was impossible to change key
for sample color and exit the operator. Also tweaked stencil to behave
similarly, so it is now possible to assign custom keys to stencil
control.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 8 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 15 |
2 files changed, 13 insertions, 10 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a47f364ac67..e1988215fc1 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -849,7 +849,6 @@ void PAINT_OT_grab_clone(wmOperatorType *ot) } /******************** sample color operator ********************/ - static int sample_color_exec(bContext *C, wmOperator *op) { Brush *brush = image_paint_brush(C); @@ -869,6 +868,8 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event RNA_int_set_array(op->ptr, "location", event->mval); sample_color_exec(C, op); + op->customdata = SET_INT_IN_POINTER(event->type); + WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -876,9 +877,10 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) { + if (event->type == (intptr_t)(op->customdata) && event->val == KM_RELEASE) + return OPERATOR_FINISHED; + switch (event->type) { - case SKEY: // XXX hardcoded - return OPERATOR_FINISHED; case MOUSEMOVE: RNA_int_set_array(op->ptr, "location", event->mval); sample_color_exec(C, op); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index f03c88bfb75..d5c5d9ee150 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -470,6 +470,7 @@ typedef struct { StencilControlMode mode; StencilConstraint constrain_mode; Brush *br; + short event_type; } StencilControlData; static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -490,6 +491,7 @@ static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *ev scd->init_rot = br->mtex.rot; scd->init_angle = atan2(mdiff[1], mdiff[0]); scd->mode = RNA_enum_get(op->ptr, "mode"); + scd->event_type = event->type; op->customdata = scd; WM_event_add_modal_handler(C, op); @@ -554,17 +556,16 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve { StencilControlData *scd = op->customdata; + if (event->type == scd->event_type && event->val == KM_RELEASE) { + MEM_freeN(op->customdata); + WM_event_add_notifier(C, NC_WINDOW, NULL); + return OPERATOR_FINISHED; + } + switch (event->type) { case MOUSEMOVE: stencil_control_calculate(scd, event->mval); break; - /* XXX hardcoded! */ - case RIGHTMOUSE: - if (event->val == KM_RELEASE) { - MEM_freeN(op->customdata); - WM_event_add_notifier(C, NC_WINDOW, NULL); - return OPERATOR_FINISHED; - } case ESCKEY: if (event->val == KM_PRESS) { stencil_control_cancel(C, op); |