[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23482] trunk/blender/source/blender/ editors/space_graph: Graph Editor: Drawing + Selection Tweaks

Joshua Leung aligorith at gmail.com
Fri Sep 25 12:52:29 CEST 2009


Revision: 23482
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23482
Author:   aligorith
Date:     2009-09-25 12:52:29 +0200 (Fri, 25 Sep 2009)

Log Message:
-----------
Graph Editor: Drawing + Selection Tweaks

* Deselect all now selects/deselects F-Curves too

* Tangents of unselected F-Curves now draw 'faded' like the curves they belong to. This experimental change is quite subtle, but can be made stronger still if people want.

* Cleaned up some old comments in the code too...

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_graph/graph_draw.c
    trunk/blender/source/blender/editors/space_graph/graph_select.c

Modified: trunk/blender/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_draw.c	2009-09-25 10:24:42 UTC (rev 23481)
+++ trunk/blender/source/blender/editors/space_graph/graph_draw.c	2009-09-25 10:52:29 UTC (rev 23482)
@@ -91,6 +91,26 @@
 extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
 
 /* *************************** */
+/* Utility Drawing Defines */
+
+/* determine the alpha value that should be used when 
+ * drawing components for some F-Curve (fcu)
+ *	- selected F-Curves should be more visible than partially visible ones
+ */
+#define drawFCurveFade(fcu) ( ((fcu)->flag & FCURVE_SELECTED)? 1.0f : 0.5f )
+
+/* set the colour for some point from some value given packed into an int 
+ *	- intV: integer value containing color info packed into an int
+ *	- alpha: float value describing the 
+ */
+#define cpackA(intVC, alpha) \
+	{ \
+		float _cpackCol[3]; \
+		cpack_to_rgb(intVC, &_cpackCol[0], &_cpackCol[1], &_cpackCol[2]); \
+		glColor4f(_cpackCol[0], _cpackCol[1], _cpackCol[2], alpha); \
+	}
+
+/* *************************** */
 /* F-Curve Modifier Drawing */
 
 /* Envelope -------------- */
@@ -258,22 +278,20 @@
 /* helper func - set color to draw F-Curve data with */
 static void set_fcurve_vertex_color (SpaceIpo *sipo, FCurve *fcu, short sel)
 {
-#if 0
-		if (sipo->showkey) {
-			if (sel) UI_ThemeColor(TH_TEXT_HI);
-			else UI_ThemeColor(TH_TEXT);
-		} 
-#endif
-		if ((fcu->flag & FCURVE_PROTECTED)==0) {
-			/* Curve's points are being edited */
-			if (sel) UI_ThemeColor(TH_VERTEX_SELECT); 
-			else UI_ThemeColor(TH_VERTEX);
-		} 
-		else {
-			/* Curve's points cannot be edited */
-			if (sel) UI_ThemeColor(TH_TEXT_HI);
-			else UI_ThemeColor(TH_TEXT);
-		}
+	/* Fade the 'intensity' of the vertices based on the selection of the curves too */
+	int alphaOffset= (int)((drawFCurveFade(fcu) - 1.0f) * 255);
+	
+	/* Set color of curve vertex based on state of curve (i.e. 'Edit' Mode) */
+	if ((fcu->flag & FCURVE_PROTECTED)==0) {
+		/* Curve's points ARE BEING edited */
+		if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset); 
+		else UI_ThemeColorShadeAlpha(TH_VERTEX, 0, alphaOffset);
+	} 
+	else {
+		/* Curve's points CANNOT BE edited */
+		if (sel) UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, alphaOffset);
+		else UI_ThemeColorShadeAlpha(TH_TEXT, 0, alphaOffset);
+	}
 }
 
 
@@ -322,7 +340,7 @@
 	if ((sipo->flag & SIPO_NOHANDLES) || (fcu->flag & FCURVE_PROTECTED) || (fcu->flag & FCURVE_INT_VALUES))
 		return;
 	
-	/* slightly hacky, but we want to draw unselected points before selected ones*/
+	/* slightly hacky, but we want to draw unselected points before selected ones */
 	for (sel= 0; sel < 2; sel++) {
 		BezTriple *bezt=fcu->bezt, *prevbezt=NULL;
 		float *fp;
@@ -337,7 +355,7 @@
 				/* only draw first handle if previous segment had handles */
 				if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) 
 				{
-					cpack(col[(unsigned char)bezt->h1]);
+					cpackA(col[(unsigned char)bezt->h1], drawFCurveFade(fcu));
 					glBegin(GL_LINE_STRIP); 
 						glVertex2fv(fp); glVertex2fv(fp+3); 
 					glEnd();
@@ -347,7 +365,7 @@
 				/* only draw second handle if this segment is bezier */
 				if (bezt->ipo == BEZT_IPO_BEZ) 
 				{
-					cpack(col[(unsigned char)bezt->h2]);
+					cpackA(col[(unsigned char)bezt->h2], drawFCurveFade(fcu));
 					glBegin(GL_LINE_STRIP); 
 						glVertex2fv(fp+3); glVertex2fv(fp+6); 
 					glEnd();
@@ -359,7 +377,7 @@
 					 ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) ) 
 				{
 					fp= bezt->vec[0];
-					cpack(col[(unsigned char)bezt->h1]);
+					cpackA(col[(unsigned char)bezt->h1], drawFCurveFade(fcu));
 					
 					glBegin(GL_LINE_STRIP); 
 						glVertex2fv(fp); glVertex2fv(fp+3); 
@@ -371,7 +389,7 @@
 					 (bezt->ipo == BEZT_IPO_BEZ) )
 				{
 					fp= bezt->vec[1];
-					cpack(col[(unsigned char)bezt->h2]);
+					cpackA(col[(unsigned char)bezt->h2], drawFCurveFade(fcu));
 					
 					glBegin(GL_LINE_STRIP); 
 						glVertex2fv(fp); glVertex2fv(fp+3); 
@@ -410,7 +428,6 @@
 	glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f);
 	
 	/* anti-aliased lines for more consistent appearance */
-		// XXX needed here?
 	glEnable(GL_LINE_SMOOTH);
 	glEnable(GL_BLEND);
 	
@@ -506,7 +523,6 @@
 }
 
 /* helper func - draw a samples-based F-Curve */
-// TODO: add offset stuff...
 static void draw_fcurve_curve_samples (FCurve *fcu, View2D *v2d)
 {
 	FPoint *prevfpt= fcu->fpt;
@@ -647,7 +663,7 @@
 			 */
 			
 			/* resol not depending on horizontal resolution anymore, drivers for example... */
-			// XXX need to take into account the scale
+			// TODO: would be nice to make this depend on the scale of the graph too...
 			if (fcu->driver) 
 				resol= 32;
 			else 
@@ -809,7 +825,7 @@
 				/* set whatever color the curve has set 
 				 *	- unselected curves draw less opaque to help distinguish the selected ones
 				 */
-				glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], ((sel) ? 1.0f : 0.5f));
+				glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], drawFCurveFade(fcu));
 			}
 			
 			/* anti-aliased lines for less jagged appearance */
@@ -842,6 +858,9 @@
 		 *	- if the option to only show controls if the F-Curve is selected is enabled, we must obey this
 		 */
 		if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) {
+			/* enable blending to allow fading of curves */
+			glEnable(GL_BLEND);
+			
 			if (fcurve_needs_draw_fmodifier_controls(fcu, fcm)) {
 				/* only draw controls if this is the active modifier */
 				if ((fcu->flag & FCURVE_ACTIVE) && (fcm)) {
@@ -863,6 +882,9 @@
 					draw_fcurve_samples(sipo, ar, fcu);
 				}
 			}
+			
+			/* restore settings */
+			glDisable(GL_BLEND);
 		}
 		
 		/* undo mapping of keyframes for drawing if scaled F-Curve */

Modified: trunk/blender/source/blender/editors/space_graph/graph_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_select.c	2009-09-25 10:24:42 UTC (rev 23481)
+++ trunk/blender/source/blender/editors/space_graph/graph_select.c	2009-09-25 10:52:29 UTC (rev 23482)
@@ -142,9 +142,13 @@
 		/* Keyframes First */
 		ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, sel_cb, NULL);
 		
-		/* deactivate the F-Curve, and deselect if deselecting keyframes */
+		/* deactivate the F-Curve, and deselect if deselecting keyframes.
+		 * otherwise select the F-Curve too since we've selected all the keyframes
+		 */
 		if (sel == SELECT_SUBTRACT) 
 			fcu->flag &= ~FCURVE_SELECTED;
+		else
+			fcu->flag |= FCURVE_SELECTED;
 		fcu->flag &= ~FCURVE_ACTIVE;
 	}
 	
@@ -259,8 +263,9 @@
 		/* select the curve too 
 		 * NOTE: this should really only happen if the curve got touched...
 		 */
-		if (selectmode == SELECT_ADD)
+		if (selectmode == SELECT_ADD) {
 			fcu->flag |= FCURVE_SELECTED;
+		}
 	}
 	
 	/* cleanup */





More information about the Bf-blender-cvs mailing list