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

Joshua Leung aligorith at gmail.com
Sun Nov 8 07:43:09 CET 2009


Revision: 24402
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24402
Author:   aligorith
Date:     2009-11-08 07:43:08 +0100 (Sun, 08 Nov 2009)

Log Message:
-----------
Graph Editor Drawing Tweaks:
* When there is only a single keyframe for a F-Curve, the handles aren't shown anymore. This looks nicer than the fat orange blobs that appeared
* Tweaked the management of GL_BLEND when drawing animation channels in the Graph Editor in an attempt to fix some of the missing text drawn issues.
* Converted the properties panel to use layout engine + added color selectors

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/anim_channels_defines.c
    trunk/blender/source/blender/editors/animation/anim_ipo_utils.c
    trunk/blender/source/blender/editors/animation/drivers.c
    trunk/blender/source/blender/editors/include/ED_anim_api.h
    trunk/blender/source/blender/editors/space_graph/graph_buttons.c
    trunk/blender/source/blender/editors/space_graph/graph_draw.c

Modified: trunk/blender/source/blender/editors/animation/anim_channels_defines.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2009-11-08 02:26:00 UTC (rev 24401)
+++ trunk/blender/source/blender/editors/animation/anim_channels_defines.c	2009-11-08 06:43:08 UTC (rev 24402)
@@ -2200,6 +2200,9 @@
 		UI_icon_draw(offset, ymid, acf->icon(ale));
 		offset += ICON_WIDTH; 
 	}
+	
+	/* turn off blending, since not needed anymore... */
+	glDisable(GL_BLEND);
 		
 	/* step 4) draw special toggles  .................................
 	 *	- in Graph Editor, checkboxes for visibility in curves area

Modified: trunk/blender/source/blender/editors/animation/anim_ipo_utils.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_ipo_utils.c	2009-11-08 02:26:00 UTC (rev 24401)
+++ trunk/blender/source/blender/editors/animation/anim_ipo_utils.c	2009-11-08 06:43:08 UTC (rev 24402)
@@ -61,53 +61,24 @@
 
 /* ----------------------- Getter functions ----------------------- */
 
-/* gets the appropriate icon for the given blocktype */
-// XXX some of these will be depreceated?
-int geticon_anim_blocktype(short blocktype)
-{
-	switch (blocktype) {
-		case ID_OB:
-			return ICON_OBJECT_DATA;
-		case ID_PO:
-			return ICON_POSE_HLT;
-		case ID_KE:
-			return ICON_SHAPEKEY_DATA;
-		case ID_MA:
-			return ICON_MATERIAL;
-		case ID_WO:
-			return ICON_WORLD;
-		case ID_CU:
-			return ICON_CURVE_DATA;
-		case ID_CA:
-			return ICON_CAMERA;
-		case ID_LA:
-			return ICON_LAMP;
-		case ID_TE:
-			return ICON_TEXTURE;
-		case ID_CO:
-			return ICON_CONSTRAINT;
-		case ID_FLUIDSIM:
-			return ICON_WORLD; // uggh
-		default:
-			return 0; // what about blank icon?
-	}
-}
-
-/* Write into "name" buffer, the name of the property (retrieved using RNA from the curve's settings) 
+/* Write into "name" buffer, the name of the property (retrieved using RNA from the curve's settings),
+ * and return the icon used for the struct that this property refers to 
  * WARNING: name buffer we're writing to cannot exceed 256 chars (check anim_channels_defines.c for details)
  */
-void getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
+int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
 {
+	int icon = 0;
+	
 	/* sanity checks */
 	if (name == NULL)
-		return;
+		return icon;
 	else if ELEM3(NULL, id, fcu, fcu->rna_path) {
 		if (fcu == NULL)
 			sprintf(name, "<invalid>");
 		else if (fcu->rna_path == NULL)
 			sprintf(name, "<no path>");
 		else /* id == NULL */
-			BLI_snprintf(name, 128, "%s[%d]", fcu->rna_path, fcu->array_index);
+			BLI_snprintf(name, 256, "%s[%d]", fcu->rna_path, fcu->array_index);
 	}
 	else {
 		PointerRNA id_ptr, ptr;
@@ -182,17 +153,30 @@
 			
 			/* putting this all together into the buffer */
 			// XXX we need to check for invalid names...
-			BLI_snprintf(name, 128, "%s%s (%s)", arrayname, propname, structname); 
+			BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname); 
 			
 			/* free temp name if nameprop is set */
 			if (free_structname)
 				MEM_freeN(structname);
+			
+			
+			/* Icon for this property's owner:
+			 *	use the struct's icon if it is set
+			 */
+			icon= RNA_struct_ui_icon(ptr.type);
 		}
 		else {
 			/* invalid path */
-			BLI_snprintf(name, 128, "\"%s[%d]\"", fcu->rna_path, fcu->array_index);
+			BLI_snprintf(name, 256, "\"%s[%d]\"", fcu->rna_path, fcu->array_index);
+			
+			/* icon for this should be the icon for the base ID */
+			// TODO: or should we just use the error icon?
+			icon= RNA_struct_ui_icon(id_ptr.type);
 		}
 	}
+	
+	/* return the icon that the active data had */
+	return icon;
 }
 
 /* ------------------------------- Color Codes for F-Curve Channels ---------------------------- */

Modified: trunk/blender/source/blender/editors/animation/drivers.c
===================================================================
--- trunk/blender/source/blender/editors/animation/drivers.c	2009-11-08 02:26:00 UTC (rev 24401)
+++ trunk/blender/source/blender/editors/animation/drivers.c	2009-11-08 06:43:08 UTC (rev 24402)
@@ -148,6 +148,7 @@
 	PropertyRNA *prop;
 	FCurve *fcu;
 	int array_index_max = array_index+1;
+	int done = 0;
 	
 	/* validate pointer first - exit if failure */
 	RNA_id_pointer_create(id, &id_ptr);
@@ -198,10 +199,13 @@
 				}
 			}
 		}
+		
+		/* set the done status */
+		done += (fcu != NULL);
 	}
 	
 	/* done */
-	return (fcu != NULL);
+	return done;
 }
 
 /* Main Driver Management API calls:

Modified: trunk/blender/source/blender/editors/include/ED_anim_api.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_anim_api.h	2009-11-08 02:26:00 UTC (rev 24401)
+++ trunk/blender/source/blender/editors/include/ED_anim_api.h	2009-11-08 06:43:08 UTC (rev 24402)
@@ -424,13 +424,9 @@
 /* ------------ Animation F-Curves <-> Icons/Names Mapping ------------ */
 /* anim_ipo_utils.c */
 
-/* Get icon for type of setting F-Curve is for */
-// XXX include this in the getname() method via RNA?
-int geticon_anim_blocktype(short blocktype);
+/* Get icon + name for channel-list displays for F-Curve */
+int getname_anim_fcurve(char *name, struct ID *id, struct FCurve *fcu);
 
-/* Get name for channel-list displays for F-Curve */
-void getname_anim_fcurve(char *name, struct ID *id, struct FCurve *fcu);
-
 /* Automatically determine a color for the nth F-Curve */
 void ipo_rainbow(int cur, int tot, float *out);
 

Modified: trunk/blender/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_buttons.c	2009-11-08 02:26:00 UTC (rev 24401)
+++ trunk/blender/source/blender/editors/space_graph/graph_buttons.c	2009-11-08 06:43:08 UTC (rev 24402)
@@ -173,31 +173,40 @@
 {
 	bAnimListElem *ale;
 	FCurve *fcu;
+	PointerRNA fcu_ptr;
+	uiLayout *layout = pa->layout;
+	uiLayout *col, *row, *subrow;
 	uiBlock *block;
-	char name[128];
+	char name[256];
+	int icon = 0;
 
-	if(!graph_panel_context(C, &ale, &fcu))
+	if (!graph_panel_context(C, &ale, &fcu))
 		return;
-
-	block= uiLayoutAbsoluteBlock(pa->layout);
+	
+	block= uiLayoutGetBlock(layout);
 	uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
-
-	/* Info - Active F-Curve */
-	uiDefBut(block, LABEL, 1, "Active F-Curve:",					10, 200, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
 	
-	if (ale->id) { 
-		// icon of active blocktype - is this really necessary?
-		int icon= geticon_anim_blocktype(GS(ale->id->name));
+	/* F-Curve pointer */
+	RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
+	
+	/* user-friendly 'name' for F-Curve */
+	// TODO: only show the path if this is invalid?
+	col= uiLayoutColumn(layout, 0);
+		icon= getname_anim_fcurve(name, ale->id, fcu);
+		uiItemL(col, name, icon);
 		
-		// xxx type of icon-but is currently "LABEL", as that one is plain...
-		uiDefIconBut(block, LABEL, 1, icon, 10, 180, 20, 19, NULL, 0, 0, 0, 0, "ID-type that F-Curve belongs to");
-	}
+	/* color settings */
+	col= uiLayoutColumn(layout, 1);
+		uiItemL(col, "Display Color:", 0);
+		
+		row= uiLayoutRow(col, 1);
+			uiItemR(row, "", 0, &fcu_ptr, "color_mode", 0);
+			
+			subrow= uiLayoutRow(row, 1);
+				uiLayoutSetEnabled(subrow, (fcu->color_mode==FCURVE_COLOR_CUSTOM));
+				uiItemR(subrow, "", 0, &fcu_ptr, "color", 0);
 	
-	getname_anim_fcurve(name, ale->id, fcu);
-	uiDefBut(block, LABEL, 1, name,	40, 180, 300, 19, NULL, 0.0, 0.0, 0, 0, "Name of Active F-Curve");
-	
 	/* TODO: the following settings could be added here
-	 *	- F-Curve coloring mode - mode selector + color selector
 	 *	- Access details (ID-block + RNA-Path + Array Index)
 	 *	- ...
 	 */
@@ -448,13 +457,13 @@
 
 	pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel view");
 	strcpy(pt->idname, "GRAPH_PT_view");
-	strcpy(pt->label, "View");
+	strcpy(pt->label, "View Properties");
 	pt->draw= graph_panel_view;
 	BLI_addtail(&art->paneltypes, pt);
 	
 	pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
 	strcpy(pt->idname, "GRAPH_PT_properties");
-	strcpy(pt->label, "Properties");
+	strcpy(pt->label, "Active F-Curve");
 	pt->draw= graph_panel_properties;
 	pt->poll= graph_panel_poll;
 	BLI_addtail(&art->paneltypes, pt);

Modified: trunk/blender/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_draw.c	2009-11-08 02:26:00 UTC (rev 24401)
+++ trunk/blender/source/blender/editors/space_graph/graph_draw.c	2009-11-08 06:43:08 UTC (rev 24402)
@@ -308,8 +308,10 @@
 	
 	glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
 	
-	/* draw the two handles first (if they're shown, and if curve is being edited) */
-	if ((fcu->flag & FCURVE_PROTECTED)==0 && (fcu->flag & FCURVE_INT_VALUES)==0 && (sipo->flag & SIPO_NOHANDLES)==0) {
+	/* draw the two handles first (if they're shown, the curve doesn't have just a single keyframe, and the curve is being edited) */
+	if ((fcu->flag & FCURVE_PROTECTED)==0 && (fcu->flag & FCURVE_INT_VALUES)==0 && 
+		(sipo->flag & SIPO_NOHANDLES)==0 && (fcu->totvert > 1)) 
+	{
 		set_fcurve_vertex_color(sipo, fcu, 0);
 		draw_fcurve_vertices_handles(fcu, v2d, 0);
 		





More information about the Bf-blender-cvs mailing list