[Bf-blender-cvs] [ce8d6afb637] master: Fix T62230: Annotations corrupts GPencil brushes

Antonioya noreply at git.blender.org
Wed Mar 6 10:55:04 CET 2019


Commit: ce8d6afb63732771677eb54720903fc8a018a1bf
Author: Antonioya
Date:   Wed Mar 6 10:54:38 2019 +0100
Branches: master
https://developer.blender.org/rBce8d6afb63732771677eb54720903fc8a018a1bf

Fix T62230: Annotations corrupts GPencil brushes

Use annotations inside grease pencil drawing mode is something incompatible by design. Actually, the annotations are disabled in overlay panel for 2D template and the tool icon is not in the toolbar.

The unique way to get annotations was using D key, but this is wrong.

If you are inside drawing mode, all the events are captured by paint operator and to capture annotations, the operator must be canceled and the mode changed, but this change breaks several things.

It's not logic add annotation inside darwing mode, because you can simply add a new layer and write the text you want.

This change checks the mode and cancel the annotations if the mode is not thje right one.

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

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

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

diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 12f7032ef84..1c2ad3d2a95 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -219,12 +219,24 @@ static void gp_session_validatebuffer(tGPsdata *p);
 /* check if context is suitable for drawing */
 static bool gpencil_draw_poll(bContext *C)
 {
+	/* if is inside grease pencil draw mode cannot use annotations */
+	Object *obact = CTX_data_active_object(C);
+	ScrArea *sa = CTX_wm_area(C);
+	if ((sa) && (sa->spacetype == SPACE_VIEW3D)) {
+		if ((obact) && (obact->type == OB_GPENCIL)
+			&& (obact->mode == OB_MODE_PAINT_GPENCIL)) {
+			CTX_wm_operator_poll_msg_set(C,
+				"Annotation cannot be used in grease pencil draw mode");
+			return false;
+		}
+	}
+
 	if (ED_operator_regionactive(C)) {
 		/* check if current context can support GPencil data */
 		if (ED_gpencil_data_get_pointers(C, NULL) != NULL) {
 			/* check if Grease Pencil isn't already running */
 			if (ED_gpencil_session_active() == 0)
-				return 1;
+				return true;
 			else
 				CTX_wm_operator_poll_msg_set(C, "Annotation operator is already active");
 		}
@@ -236,7 +248,7 @@ static bool gpencil_draw_poll(bContext *C)
 		CTX_wm_operator_poll_msg_set(C, "Active region not set");
 	}
 
-	return 0;
+	return false;
 }
 
 /* check if projecting strokes into 3d-geometry in the 3D-View */



More information about the Bf-blender-cvs mailing list