[Bf-blender-cvs] [5d2975382c4] greasepencil-object: Set color function

Antonio Vazquez noreply at git.blender.org
Wed Jan 10 19:24:57 CET 2018


Commit: 5d2975382c41fe5eb7ed583dab93fc0ab9d6af5a
Author: Antonio Vazquez
Date:   Wed Jan 10 19:09:36 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB5d2975382c41fe5eb7ed583dab93fc0ab9d6af5a

Set color function

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

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

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

diff --git a/source/blender/editors/gpencil/gpencil_colorpick.c b/source/blender/editors/gpencil/gpencil_colorpick.c
index 460869481c3..fab0e262ace 100644
--- a/source/blender/editors/gpencil/gpencil_colorpick.c
+++ b/source/blender/editors/gpencil/gpencil_colorpick.c
@@ -407,6 +407,22 @@ static int gpencil_colorpick_invoke(bContext *C, wmOperator *op, const wmEvent *
 	return OPERATOR_RUNNING_MODAL;
 }
 
+/* set active color */
+static bool set_color(const wmEvent *event, tGPDpick *tgpk)
+{
+	tGPDpickColor *tcol = tgpk->colors;
+	for (int i = 0; i < tgpk->totcolor; i++, tcol++) {
+		if ((event->mval[0] >= tcol->rect.xmin) && (event->mval[0] <= tcol->rect.xmax) &&
+			(event->mval[1] >= tcol->rect.ymin) && (event->mval[1] <= tcol->rect.ymax))
+		{
+			tgpk->palette->active_color = tcol->index;
+			return true;
+		}
+	}
+
+	return false;
+}
+
 /* events handling during interactive part of operator */
 static int gpencil_colorpick_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
@@ -432,7 +448,9 @@ static int gpencil_colorpick_modal(bContext *C, wmOperator *op, const wmEvent *e
 			}
 			break;
 		case LEFTMOUSE:
-			estate = OPERATOR_FINISHED;
+			if (set_color(event, tgpk) == true) {
+				estate = OPERATOR_FINISHED;
+			}
 			break;
 	}
 	/* process last operations before exiting */



More information about the Bf-blender-cvs mailing list