[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25025] trunk/blender/source/blender: Durian Graph Editor Request: Only show handles of selected keyframes

Joshua Leung aligorith at gmail.com
Mon Nov 30 12:37:27 CET 2009


Revision: 25025
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25025
Author:   aligorith
Date:     2009-11-30 12:37:27 +0100 (Mon, 30 Nov 2009)

Log Message:
-----------
Durian Graph Editor Request: Only show handles of selected keyframes

This option for the Graph Editor means that only the handles for selected keyframes get shown in the view, eliminating clutter. 

Currently, the selection code isn't aware of this option, so clicking anywhere near where a handle might be may often trigger it to show up. This may/may not be desireable, but we'll see how Lee goes with this first :)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_graph/graph_draw.c
    trunk/blender/source/blender/editors/space_graph/graph_header.c
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_draw.c	2009-11-30 11:18:46 UTC (rev 25024)
+++ trunk/blender/source/blender/editors/space_graph/graph_draw.c	2009-11-30 11:37:27 UTC (rev 25025)
@@ -235,7 +235,7 @@
 }
 
 /* helper func - draw handle vertices only for an F-Curve (if it is not protected) */
-static void draw_fcurve_vertices_handles (FCurve *fcu, View2D *v2d, short sel)
+static void draw_fcurve_vertices_handles (SpaceIpo *sipo, FCurve *fcu, View2D *v2d, short sel)
 {
 	BezTriple *bezt= fcu->bezt;
 	BezTriple *prevbezt = NULL;
@@ -255,20 +255,25 @@
 	glEnable(GL_BLEND);
 	
 	for (i=0; i < fcu->totvert; i++, prevbezt=bezt, bezt++) {
-		/* Draw the editmode handels for a bezier curve (others don't have handles) 
+		/* Draw the editmode handles for a bezier curve (others don't have handles) 
 		 * if their selection status matches the selection status we're drawing for
 		 *	- first handle only if previous beztriple was bezier-mode
 		 *	- second handle only if current beztriple is bezier-mode
+		 *
+		 * Also, need to take into account whether the keyframe was selected
+		 * if a Graph Editor option to only show handles of selected keys is on.
 		 */
-		if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) {
-			if ((bezt->f1 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/
-				draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize);
+		if ( !(sipo->flag & SIPO_SELVHANDLESONLY) || BEZSELECTED(bezt) ) {
+			if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) {
+				if ((bezt->f1 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/
+					draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize);
+			}
+			
+			if (bezt->ipo==BEZT_IPO_BEZ) {
+				if ((bezt->f3 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/
+					draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize);
+			}
 		}
-		
-		if (bezt->ipo==BEZT_IPO_BEZ) {
-			if ((bezt->f3 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/
-				draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize);
-		}
 	}
 	
 	glDisable(GL_LINE_SMOOTH);
@@ -313,10 +318,10 @@
 		(sipo->flag & SIPO_NOHANDLES)==0 && (fcu->totvert > 1)) 
 	{
 		set_fcurve_vertex_color(sipo, fcu, 0);
-		draw_fcurve_vertices_handles(fcu, v2d, 0);
+		draw_fcurve_vertices_handles(sipo, fcu, v2d, 0);
 		
 		set_fcurve_vertex_color(sipo, fcu, 1);
-		draw_fcurve_vertices_handles(fcu, v2d, 1);
+		draw_fcurve_vertices_handles(sipo, fcu, v2d, 1);
 	}
 		
 	/* draw keyframes over the handles */
@@ -347,13 +352,28 @@
 	 */
 	glBegin(GL_LINES);
 	
-	/* slightly hacky, but we want to draw unselected points before selected ones */
+	/* slightly hacky, but we want to draw unselected points before selected ones 
+	 * so that selected points are clearly visible
+	 */
 	for (sel= 0; sel < 2; sel++) {
 		BezTriple *bezt=fcu->bezt, *prevbezt=NULL;
 		unsigned int *col= (sel)? (nurbcol+4) : (nurbcol);
 		float *fp;
 		
+		/* if only selected keyframes have handles shown, skip the first round */
+		if ((sel == 0) && (sipo->flag & SIPO_SELVHANDLESONLY))
+			continue;
+		
 		for (b= 0; b < fcu->totvert; b++, prevbezt=bezt, bezt++) {
+			/* if only selected keyframes can get their handles shown, 
+			 * check that keyframe is selected
+			 */
+			if (sipo->flag & SIPO_SELVHANDLESONLY) {
+				if (BEZSELECTED(bezt) == 0)
+					continue;
+			}
+			
+			/* draw handle with appropriate set of colors if selection is ok */
 			if ((bezt->f2 & SELECT)==sel) {
 				fp= bezt->vec[0];
 				

Modified: trunk/blender/source/blender/editors/space_graph/graph_header.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_header.c	2009-11-30 11:18:46 UTC (rev 25024)
+++ trunk/blender/source/blender/editors/space_graph/graph_header.c	2009-11-30 11:37:27 UTC (rev 25025)
@@ -91,6 +91,7 @@
 		uiItemO(layout, "Show Handles", ICON_CHECKBOX_HLT, "GRAPH_OT_handles_view_toggle");
 	
 	uiItemR(layout, NULL, 0, &spaceptr, "only_selected_curves_handles", 0);
+	uiItemR(layout, NULL, 0, &spaceptr, "only_selected_keyframe_handles", 0);
 	
 	
 	if (sipo->flag & SIPO_DRAWTIME)

Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_space_types.h	2009-11-30 11:18:46 UTC (rev 25024)
+++ trunk/blender/source/blender/makesdna/DNA_space_types.h	2009-11-30 11:37:27 UTC (rev 25025)
@@ -726,6 +726,7 @@
 #define SIPO_DRAWNAMES			(1<<6)
 #define SIPO_SLIDERS			(1<<7)
 #define SIPO_NODRAWCURSOR		(1<<8)
+#define SIPO_SELVHANDLESONLY	(1<<9)
 
 /* SpaceIpo->mode (Graph Editor Mode) */
 enum {

Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c	2009-11-30 11:18:46 UTC (rev 25024)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c	2009-11-30 11:37:27 UTC (rev 25025)
@@ -93,6 +93,7 @@
 #include "BKE_brush.h"
 #include "BKE_colortools.h"
 #include "BKE_context.h"
+#include "BKE_depsgraph.h"
 #include "BKE_paint.h"
 
 #include "ED_image.h"
@@ -1308,6 +1309,11 @@
 	RNA_def_property_ui_text(prop, "Only Selected Curve Keyframes", "Only keyframes of selected F-Curves are visible and editable.");
 	RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
 	
+	prop= RNA_def_property(srna, "only_selected_keyframe_handles", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_SELVHANDLESONLY);
+	RNA_def_property_ui_text(prop, "Only Selected Keyframes Handles", "Only show and edit handles of selected keyframes.");
+	RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
+	
 	/* editing */
 	prop= RNA_def_property(srna, "automerge_keyframes", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NOTRANSKEYCULL);





More information about the Bf-blender-cvs mailing list