[Bf-blender-cvs] [5fc8ecd1290] greasepencil-object: Use Shift key to toggle Lazy Mouse

Antonio Vazquez noreply at git.blender.org
Mon Jan 29 17:45:11 CET 2018


Commit: 5fc8ecd1290b7c0fd3a19356b2cce9d0692cffcb
Author: Antonio Vazquez
Date:   Mon Jan 29 17:45:02 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB5fc8ecd1290b7c0fd3a19356b2cce9d0692cffcb

Use Shift key to toggle Lazy Mouse

Now while drawing you can enable or disable the lazy mouse with the shift key.

If the brush has lazy enabled, shift key disable it. If the brush has lazy disabled, shift key enable it.

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

M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/makesdna/DNA_gpencil_types.h

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

diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 18b483ce9bd..97475669a19 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -183,6 +183,7 @@ typedef struct tGPsdata {
 	bool no_fill;        /* the stroke is no fill mode */
 
 	short keymodifier;   /* key used for invoking the operator */
+	short shift;         /* shift modifier flag */
 
 	ReportList *reports;
 } tGPsdata;
@@ -301,13 +302,15 @@ static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2])
 	bGPDbrush *brush = p->brush;
 	int dx = abs(mval[0] - pmval[0]);
 	int dy = abs(mval[1] - pmval[1]);
+	brush->flag &= ~GP_BRUSH_LAZY_MOUSE_TEMP;
 
 	/* if buffer is empty, just let this go through (i.e. so that dots will work) */
 	if (p->gpd->sbuffer_size == 0) {
 		return true;
 	}
 	/* if lazy mouse, check minimum distance */
-	else if (brush->flag & GP_BRUSH_LAZY_MOUSE) {
+	else if (GPENCIL_LAZY_MODE(brush, p->shift)) {
+		brush->flag |= GP_BRUSH_LAZY_MOUSE_TEMP;
 		if ((dx * dx + dy * dy) > (brush->lazy_radius * brush->lazy_radius)) {
 			return true;
 		}
@@ -2153,6 +2156,9 @@ static void gpencil_draw_status_indicators(tGPsdata *p)
 /* create a new stroke point at the point indicated by the painting context */
 static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, const Depsgraph *depsgraph)
 {
+	bGPdata *gpd = p->gpd;
+	tGPspoint *pt = NULL;
+
 	/* handle drawing/erasing -> test for erasing first */
 	if (p->paintmode == GP_PAINTMODE_ERASER) {
 		/* do 'live' erasing now */
@@ -2167,7 +2173,7 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, const D
 	else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) {
 
 		/* if lazy mouse, interpolate the last and current mouse positions */
-		if (p->brush->flag & GP_BRUSH_LAZY_MOUSE) {
+		if (GPENCIL_LAZY_MODE(p->brush, p->shift)) {
 			float now_mouse[2];
 			float last_mouse[2];
 			copy_v2float_v2int(now_mouse, p->mval);
@@ -2214,8 +2220,11 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, const D
 		p->opressure = p->pressure;
 		p->ocurtime = p->curtime;
 		
-		bGPdata *gpd = p->gpd;
-		tGPspoint *pt = (tGPspoint *)gpd->sbuffer + gpd->sbuffer_size - 1;
+		pt = (tGPspoint *)gpd->sbuffer + gpd->sbuffer_size - 1;
+		ED_gpencil_toggle_brush_cursor(C, true, &pt->x);
+	}
+	else if ((p->brush->flag & GP_BRUSH_LAZY_MOUSE_TEMP) && (gpd->sbuffer_size > 0)){
+		pt = (tGPspoint *)gpd->sbuffer + gpd->sbuffer_size - 1;
 		ED_gpencil_toggle_brush_cursor(C, true, &pt->x);
 	}
 }
@@ -2233,7 +2242,8 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
 	 */
 	p->mval[0] = event->mval[0] + 1;
 	p->mval[1] = event->mval[1] + 1;
-	
+	p->shift = event->shift;
+
 	/* verify key status for straight lines */
 	if ((event->ctrl > 0) && (RNA_boolean_get(op->ptr, "no_straight") == false)) {
 		if (p->straight[0] == 0) {
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index d51267ffb35..4d3701238f7 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -1271,7 +1271,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
 		paintbrush = BKE_gpencil_brush_getactive(scene->toolsettings);
 		/* while drawing hide */
 		if ((gpd->sbuffer_size > 0) && 
-			(paintbrush) && ((paintbrush->flag & GP_BRUSH_LAZY_MOUSE) == 0)) 
+			(paintbrush) && ((paintbrush->flag & GP_BRUSH_LAZY_MOUSE) == 0) &&
+			((paintbrush->flag & GP_BRUSH_LAZY_MOUSE_TEMP) == 0))
 		{
 			return;
 		}
@@ -1286,6 +1287,7 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
 			 */
 			if ((palcolor) && (GPENCIL_PAINT_MODE(gpd)) && 
 				((paintbrush->flag & GP_BRUSH_LAZY_MOUSE) == 0) &&
+				((paintbrush->flag & GP_BRUSH_LAZY_MOUSE_TEMP) == 0) &&
 				((paintbrush->flag & GP_BRUSH_FILL_ONLY) == 0))
 			{
 				radius = 2.0f;
@@ -1327,6 +1329,7 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
 	immUniformColor4f(color[0], color[1], color[2], 0.8f);
 	if ((palcolor) && (GPENCIL_PAINT_MODE(gpd)) && 
 		((paintbrush->flag & GP_BRUSH_LAZY_MOUSE) == 0) &&
+		((paintbrush->flag & GP_BRUSH_LAZY_MOUSE_TEMP) == 0) &&
 		((paintbrush->flag & GP_BRUSH_FILL_ONLY) == 0))
 	{
 		imm_draw_circle_fill_2d(pos, x, y, radius, 40);
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index fc35261d9ec..8b729d5d428 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -161,6 +161,8 @@ typedef enum eGPDbrush_Flag {
 	GP_BRUSH_FILL_SHOW_HELPLINES = (1 << 10),
 	/* lazy mouse */
 	GP_BRUSH_LAZY_MOUSE = (1 << 11),
+	/* lazy mouse override (internal only) */
+	GP_BRUSH_LAZY_MOUSE_TEMP = (1 << 12),
 } eGPDbrush_Flag;
 
 /* ***************************************** */
@@ -566,6 +568,6 @@ typedef enum eGP_BrushIcons {
 #define GPENCIL_PAINT_MODE(gpd) ((gpd) && (gpd->flag & (GP_DATA_STROKE_PAINTMODE))) 
 #define GPENCIL_SCULPT_OR_WEIGHT_MODE(gpd) ((gpd) && (gpd->flag & (GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE))) 
 #define GPENCIL_NONE_EDIT_MODE(gpd) ((gpd) && ((gpd->flag & (GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE)) == 0))
-
+#define GPENCIL_LAZY_MODE(brush, shift) ((brush) && ((brush->flag & GP_BRUSH_LAZY_MOUSE) && (shift == 0)) || (((brush->flag & GP_BRUSH_LAZY_MOUSE) == 0) && (shift == 1))) 
 
 #endif /*  __DNA_GPENCIL_TYPES_H__ */



More information about the Bf-blender-cvs mailing list