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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user