[Bf-blender-cvs] [496064f1f3a] greasepencil-object: GP Add Primitives: Attempted fix for double-clicking on the toolbar button

Joshua Leung noreply at git.blender.org
Tue Jan 30 07:05:39 CET 2018


Commit: 496064f1f3a79f76d5d4488c1f1d5f729f673655
Author: Joshua Leung
Date:   Tue Jan 30 16:35:59 2018 +1300
Branches: greasepencil-object
https://developer.blender.org/rB496064f1f3a79f76d5d4488c1f1d5f729f673655

GP Add Primitives: Attempted fix for double-clicking on the toolbar button

Check for what type of mouse-press it was, instead of just assuming
that the clicks are what we think they are.

Note: If things still go wrong, there's also now a debug-print there
(debug-mode only) to help track things down.

===================================================================

M	source/blender/editors/gpencil/gpencil_primitive.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 719f4203aea..ab5d8275a4f 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -452,6 +452,11 @@ static int gpencil_primitive_invoke(bContext *C, wmOperator *op, const wmEvent *
 	gpencil_primitive_init(C, op);
 	tgpi = op->customdata;
 	
+	/* if in tools region, wait till we get to the main (3d-space)
+	 * region before allowing drawing to take place.
+	 */
+	op->flag |= OP_IS_MODAL_CURSOR_REGION;
+	
 	/* Enable custom drawing handlers */
 	tgpi->draw_handle_3d = ED_region_draw_cb_activate(tgpi->ar->type, gpencil_primitive_draw_3d, tgpi, REGION_DRAW_POST_VIEW);
 	
@@ -506,21 +511,29 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
 	
 	switch (event->type) {
 		case LEFTMOUSE:
-			tgpi->bottom[0] = event->mval[0];
-			tgpi->bottom[1] = event->mval[1];
-			
-			if (tgpi->flag == IDLE) {
+			if ((event->val == KM_PRESS) && (tgpi->flag == IDLE)) {
+				/* start drawing primitive */
+				/* TODO: Ignore if not in main region yet */
 				tgpi->flag = IN_PROGRESS;
 				
 				tgpi->top[0] = event->mval[0];
 				tgpi->top[1] = event->mval[1];
+				
+				tgpi->bottom[0] = event->mval[0];
+				tgpi->bottom[1] = event->mval[1];
 			}
-			else {
+			else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS)) {
+				/* stop drawing primitive */
 				tgpi->flag = IDLE;
 				gpencil_primitive_done(C, op, win, tgpi);
 				/* done! */
 				return OPERATOR_FINISHED;
 			}
+			else {
+				if (G.debug & G_DEBUG) {
+					printf("GP Add Primitive Modal: LEFTMOUSE %d, Status = %d\n", event->val, tgpi->flag);
+				}
+			}
 			break;
 		case RETKEY:  /* confirm */
 		{



More information about the Bf-blender-cvs mailing list