[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55967] trunk/blender/source/blender/ editors/sculpt_paint: Fix #34954, due to hardcoded key release it was impossible to change key

Antony Riakiotakis kalast at gmail.com
Thu Apr 11 16:15:26 CEST 2013


Revision: 55967
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55967
Author:   psy-fi
Date:     2013-04-11 14:15:25 +0000 (Thu, 11 Apr 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-04-11 14:13:20 UTC (rev 55966)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-04-11 14:15:25 UTC (rev 55967)
@@ -849,7 +849,6 @@
 }
 
 /******************** sample color operator ********************/
-
 static int sample_color_exec(bContext *C, wmOperator *op)
 {
 	Brush *brush = image_paint_brush(C);
@@ -869,6 +868,8 @@
 	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_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);

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c	2013-04-11 14:13:20 UTC (rev 55966)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c	2013-04-11 14:15:25 UTC (rev 55967)
@@ -470,6 +470,7 @@
 	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 @@
 	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 @@
 {
 	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);




More information about the Bf-blender-cvs mailing list