[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47817] trunk/blender/source/blender: tint non-active mask layers grey

Campbell Barton ideasman42 at gmail.com
Wed Jun 13 10:20:54 CEST 2012


Revision: 47817
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47817
Author:   campbellbarton
Date:     2012-06-13 08:20:43 +0000 (Wed, 13 Jun 2012)
Log Message:
-----------
tint non-active mask layers grey

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mask/mask_draw.c
    trunk/blender/source/blender/makesrna/intern/rna_mask.c

Modified: trunk/blender/source/blender/editors/mask/mask_draw.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_draw.c	2012-06-13 08:10:59 UTC (rev 47816)
+++ trunk/blender/source/blender/editors/mask/mask_draw.c	2012-06-13 08:20:43 UTC (rev 47817)
@@ -233,11 +233,26 @@
 
 /* #define USE_XOR */
 
+static void mask_color_active_tint(unsigned char r_rgb[4], const unsigned char rgb[4], const short is_active)
+{
+	if (!is_active) {
+		r_rgb[0] = (unsigned char)((((int)(rgb[0])) + 128) / 2);
+		r_rgb[1] = (unsigned char)((((int)(rgb[1])) + 128) / 2);
+		r_rgb[2] = (unsigned char)((((int)(rgb[2])) + 128) / 2);
+		r_rgb[3] = rgb[3];
+	}
+	else {
+		*(unsigned int *)r_rgb = *(const unsigned int *)rgb;
+	}
+}
+
 static void mask_draw_curve_type(MaskSpline *spline, float (*points)[2], int tot_point,
-                                 const short is_feather, const short is_smooth,
+                                 const short is_feather, const short is_smooth, const short is_active,
                                  const unsigned char rgb_spline[4], const char draw_type)
 {
 	const int draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GL_LINE_LOOP : GL_LINE_STRIP;
+	const unsigned char rgb_black[4] = {0x00, 0x00, 0x00, 0xff};
+//	const unsigned char rgb_white[4] = {0xff, 0xff, 0xff, 0xff};
 	unsigned char rgb_tmp[4];
 
 	glEnableClientState(GL_VERTEX_ARRAY);
@@ -247,12 +262,15 @@
 
 		case MASK_DT_OUTLINE:
 			glLineWidth(3);
-			cpack(0x0);
 
+			mask_color_active_tint(rgb_tmp, rgb_black, is_active);
+			glColor4ubv(rgb_tmp);
+
 			glDrawArrays(draw_method, 0, tot_point);
 
 			glLineWidth(1);
-			glColor4ubv(rgb_spline);
+			mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
+			glColor4ubv(rgb_tmp);
 			glDrawArrays(draw_method, 0, tot_point);
 
 			break;
@@ -265,7 +283,8 @@
 			glEnable(GL_COLOR_LOGIC_OP);
 			glLogicOp(GL_OR);
 #endif
-			glColor4ubv(rgb_spline);
+			mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
+			glColor4ubv(rgb_tmp);
 			glLineStipple(3, 0xaaaa);
 			glEnableClientState(GL_VERTEX_ARRAY);
 			glVertexPointer(2, GL_FLOAT, 0, points);
@@ -274,7 +293,8 @@
 #ifdef USE_XOR
 			glDisable(GL_COLOR_LOGIC_OP);
 #endif
-			glColor4ub(0, 0, 0, 255);
+			mask_color_active_tint(rgb_tmp, rgb_black, is_active);
+			glColor4ubv(rgb_tmp);
 			glLineStipple(3, 0x5555);
 			glDrawArrays(draw_method, 0, tot_point);
 
@@ -301,7 +321,9 @@
 				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 			}
 
+			mask_color_active_tint(rgb_tmp, rgb_tmp, is_active);
 			glColor4ubv(rgb_tmp);
+
 			glEnableClientState(GL_VERTEX_ARRAY);
 			glVertexPointer(2, GL_FLOAT, 0, points);
 			glDrawArrays(draw_method, 0, tot_point);
@@ -321,6 +343,7 @@
 
 static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline,
                               const char draw_flag, const char draw_type,
+                              const short is_active,
                               int width, int height)
 {
 	unsigned char rgb_tmp[4];
@@ -350,14 +373,14 @@
 	/* draw feather */
 	mask_spline_feather_color_get(masklay, spline, is_spline_sel, rgb_tmp);
 	mask_draw_curve_type(spline, feather_points, tot_feather_point,
-	                     TRUE, is_smooth,
+	                     TRUE, is_smooth, is_active,
 	                     rgb_tmp, draw_type);
 	MEM_freeN(feather_points);
 
 	/* draw main curve */
 	mask_spline_color_get(masklay, spline, is_spline_sel, rgb_tmp);
 	mask_draw_curve_type(spline, diff_points, tot_diff_point,
-	                     FALSE, is_smooth,
+	                     FALSE, is_smooth, is_active,
 	                     rgb_tmp, draw_type);
 	MEM_freeN(diff_points);
 
@@ -373,9 +396,11 @@
                           int width, int height)
 {
 	MaskLayer *masklay;
+	int i;
 
-	for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+	for (masklay = mask->masklayers.first, i = 0; masklay; masklay = masklay->next, i++) {
 		MaskSpline *spline;
+		const short is_active = (i == mask->masklay_act);
 
 		if (masklay->restrictflag & MASK_RESTRICT_VIEW) {
 			continue;
@@ -384,7 +409,7 @@
 		for (spline = masklay->splines.first; spline; spline = spline->next) {
 
 			/* draw curve itself first... */
-			draw_spline_curve(masklay, spline, draw_flag, draw_type, width, height);
+			draw_spline_curve(masklay, spline, draw_flag, draw_type, is_active, width, height);
 
 //			draw_spline_parents(masklay, spline);
 
@@ -398,7 +423,7 @@
 				void *back = spline->points_deform;
 
 				spline->points_deform = NULL;
-				draw_spline_curve(masklay, spline, draw_flag, draw_type, width, height);
+				draw_spline_curve(masklay, spline, draw_flag, draw_type, is_active, width, height);
 //				draw_spline_parents(masklay, spline);
 				draw_spline_points(masklay, spline);
 				spline->points_deform = back;

Modified: trunk/blender/source/blender/makesrna/intern/rna_mask.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_mask.c	2012-06-13 08:10:59 UTC (rev 47816)
+++ trunk/blender/source/blender/makesrna/intern/rna_mask.c	2012-06-13 08:20:43 UTC (rev 47817)
@@ -665,6 +665,7 @@
 	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 	RNA_def_property_int_funcs(prop, "rna_Mask_layer_active_index_get", "rna_Mask_layer_active_index_set", "rna_Mask_layer_active_index_range");
 	RNA_def_property_ui_text(prop, "Active Shape Index", "Index of active layer in list of all mask's layers");
+	RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL);
 
 	/* frame range */
 	prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);




More information about the Bf-blender-cvs mailing list