[Bf-blender-cvs] [67f983a] master: Nla Strip Controls: Added special FCurve type (in the animfiltering code)

Joshua Leung noreply at git.blender.org
Sat Mar 28 15:08:08 CET 2015


Commit: 67f983ac53e97f154b6710fea8f400a608e27550
Author: Joshua Leung
Date:   Sun Mar 22 21:41:45 2015 +1300
Branches: master
https://developer.blender.org/rB67f983ac53e97f154b6710fea8f400a608e27550

Nla Strip Controls: Added special FCurve type (in the animfiltering code)

Using the standard "FCurve" animchannel type didn't work that well for
the control FCurves on NLA Strips, as the paths would not resolve correctly,
and the indentation was wrong. Also, there would likely be issues down the
track with applying NLA mapping. Hence, it's easier to just create a separate
type for this case, and adapt the rest of the code to also consider these (todo).

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

M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/animation/anim_channels_edit.c
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/include/ED_anim_api.h
M	source/blender/editors/space_action/action_edit.c
M	source/blender/editors/space_action/action_select.c
M	source/blender/editors/transform/transform_conversions.c

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

diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 11d68ed..72aa0c1 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -908,6 +908,115 @@ static bAnimChannelType ACF_GROUP =
 	acf_group_setting_ptr           /* pointer for setting */
 };
 
+/* F-Curve ------------------------------------------- */
+
+/* name for fcurve entries */
+static void acf_fcurve_name(bAnimListElem *ale, char *name)
+{
+	getname_anim_fcurve(name, ale->id, ale->data);
+}
+
+/* "name" property for fcurve entries */
+static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+{
+	FCurve *fcu = (FCurve *)ale->data;
+	
+	/* Ctrl-Click Usability Convenience Hack: 
+	 * For disabled F-Curves, allow access to the RNA Path 
+	 * as our "name" so that user can perform quick fixes
+	 */
+	if (fcu->flag & FCURVE_DISABLED) {
+		RNA_pointer_create(ale->id, &RNA_FCurve, ale->data, ptr);
+		*prop = RNA_struct_find_property(ptr, "data_path");
+	}
+	else {
+		/* for "normal" F-Curves - no editable name, but *prop may not be set properly yet... */
+		*prop = NULL;
+	}
+	
+	return (*prop != NULL);
+}
+
+/* check if some setting exists for this channel */
+static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
+{
+	FCurve *fcu = (FCurve *)ale->data;
+	
+	switch (setting) {
+		/* unsupported */
+		case ACHANNEL_SETTING_SOLO:   /* Solo Flag is only for NLA */
+		case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */
+			return false;
+		
+		/* conditionally available */
+		case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */
+			if (fcu->bezt)
+				return true;
+			else
+				return false;  // NOTE: in this special case, we need to draw ICON_ZOOMOUT
+				
+		case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
+			return (ac->spacetype == SPACE_IPO);
+			
+		/* always available */
+		default:
+			return true;
+	}
+}
+
+/* get the appropriate flag(s) for the setting when it is valid  */
+static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
+{
+	/* clear extra return data first */
+	*neg = false;
+	
+	switch (setting) {
+		case ACHANNEL_SETTING_SELECT: /* selected */
+			return FCURVE_SELECTED;
+			
+		case ACHANNEL_SETTING_MUTE: /* muted */
+			return FCURVE_MUTED;
+			
+		case ACHANNEL_SETTING_PROTECT: /* protected */
+			return FCURVE_PROTECTED;
+			
+		case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */
+			return FCURVE_VISIBLE;
+			
+		default: /* unsupported */
+			return 0;
+	}
+}
+
+/* get pointer to the setting */
+static void *acf_fcurve_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
+{
+	FCurve *fcu = (FCurve *)ale->data;
+	
+	/* all flags are just in agrp->flag for now... */
+	return GET_ACF_FLAG_PTR(fcu->flag, type);
+}
+
+/* fcurve type define */
+static bAnimChannelType ACF_FCURVE = 
+{
+	"F-Curve",                      /* type name */
+	ACHANNEL_ROLE_CHANNEL,          /* role */
+	
+	acf_generic_channel_color,      /* backdrop color */
+	acf_generic_channel_backdrop,   /* backdrop */
+	acf_generic_indention_flexible, /* indent level */      // xxx rename this to f-curves only?
+	acf_generic_group_offset,       /* offset */
+
+	acf_fcurve_name,                /* name */
+	acf_fcurve_name_prop,           /* name prop */
+	NULL,                           /* icon */
+
+	acf_fcurve_setting_valid,       /* has setting */
+	acf_fcurve_setting_flag,        /* flag for setting */
+	acf_fcurve_setting_ptr          /* pointer for setting */
+};
+
 /* NLA Control FCurves Expander ----------------------- */
 
 /* get backdrop color for nla controls widget */
@@ -1008,107 +1117,41 @@ static bAnimChannelType ACF_NLACONTROLS =
 	acf_nla_controls_setting_ptr    /* pointer for setting */
 };
 
-/* F-Curve ------------------------------------------- */
 
-/* name for fcurve entries */
-static void acf_fcurve_name(bAnimListElem *ale, char *name)
-{
-	getname_anim_fcurve(name, ale->id, ale->data);
-}
+/* NLA Control F-Curve -------------------------------- */
 
-/* "name" property for fcurve entries */
-static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop)
+/* name for nla control fcurve entries */
+static void acf_nla_curve_name(bAnimListElem *ale, char *name)
 {
-	FCurve *fcu = (FCurve *)ale->data;
+	NlaStrip *strip = ale->owner;
+	FCurve *fcu = ale->data;
+	PropertyRNA *prop;
 	
-	/* Ctrl-Click Usability Convenience Hack: 
-	 * For disabled F-Curves, allow access to the RNA Path 
-	 * as our "name" so that user can perform quick fixes
-	 */
-	if (fcu->flag & FCURVE_DISABLED) {
-		RNA_pointer_create(ale->id, &RNA_FCurve, ale->data, ptr);
-		*prop = RNA_struct_find_property(ptr, "data_path");
+	/* try to get RNA property that this shortened path (relative to the strip) refers to */
+	prop = RNA_struct_type_find_property(&RNA_NlaStrip, fcu->rna_path);
+	if (prop) {
+		/* "name" of this strip displays the UI identifier + the name of the NlaStrip */
+		BLI_snprintf(name, 256, "%s (%s)", RNA_property_ui_name(prop), strip->name);
 	}
 	else {
-		/* for "normal" F-Curves - no editable name, but *prop may not be set properly yet... */
-		*prop = NULL;
-	}
-	
-	return (*prop != NULL);
-}
-
-/* check if some setting exists for this channel */
-static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
-{
-	FCurve *fcu = (FCurve *)ale->data;
-	
-	switch (setting) {
-		/* unsupported */
-		case ACHANNEL_SETTING_SOLO:   /* Solo Flag is only for NLA */
-		case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */
-			return false;
-		
-		/* conditionally available */
-		case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */
-			if (fcu->bezt)
-				return true;
-			else
-				return false;  // NOTE: in this special case, we need to draw ICON_ZOOMOUT
-				
-		case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
-			return (ac->spacetype == SPACE_IPO);
-			
-		/* always available */
-		default:
-			return true;
+		/* unknown property... */
+		BLI_snprintf(name, 256, "%s[%d]", fcu->rna_path, fcu->array_index);
 	}
 }
 
-/* get the appropriate flag(s) for the setting when it is valid  */
-static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings setting, bool *neg)
-{
-	/* clear extra return data first */
-	*neg = false;
-	
-	switch (setting) {
-		case ACHANNEL_SETTING_SELECT: /* selected */
-			return FCURVE_SELECTED;
-			
-		case ACHANNEL_SETTING_MUTE: /* muted */
-			return FCURVE_MUTED;
-			
-		case ACHANNEL_SETTING_PROTECT: /* protected */
-			return FCURVE_PROTECTED;
-			
-		case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */
-			return FCURVE_VISIBLE;
-			
-		default: /* unsupported */
-			return 0;
-	}
-}
-
-/* get pointer to the setting */
-static void *acf_fcurve_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type)
-{
-	FCurve *fcu = (FCurve *)ale->data;
-	
-	/* all flags are just in agrp->flag for now... */
-	return GET_ACF_FLAG_PTR(fcu->flag, type);
-}
 
-/* fcurve type define */
-static bAnimChannelType ACF_FCURVE = 
+/* NLA Control F-Curve type define */
+static bAnimChannelType ACF_NLACURVE = 
 {
-	"F-Curve",                      /* type name */
+	"NLA Control F-Curve",          /* type name */
 	ACHANNEL_ROLE_CHANNEL,          /* role */
 	
 	acf_generic_channel_color,      /* backdrop color */
 	acf_generic_channel_backdrop,   /* backdrop */
-	acf_generic_indention_flexible, /* indent level */      // xxx rename this to f-curves only?
+	acf_generic_indention_1,        /* indent level */
 	acf_generic_group_offset,       /* offset */
 
-	acf_fcurve_name,                /* name */
+	acf_nla_curve_name,             /* name */
 	acf_fcurve_name_prop,           /* name prop */
 	NULL,                           /* icon */
 
@@ -3323,6 +3366,7 @@ static void ANIM_init_channel_typeinfo_data(void)
 		animchannelTypeInfo[type++] = &ACF_FCURVE;       /* F-Curve */
 		
 		animchannelTypeInfo[type++] = &ACF_NLACONTROLS;  /* NLA Control FCurve Expander */
+		animchannelTypeInfo[type++] = &ACF_NLACURVE;     /* NLA Control FCurve Channel */
 		
 		animchannelTypeInfo[type++] = &ACF_FILLACTD;     /* Object Action Expander */
 		animchannelTypeInfo[type++] = &ACF_FILLDRIVERS;  /* Drivers Expander */
@@ -3593,7 +3637,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
 	if (ac->sl) {
 		if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) {
 			/* for F-Curves, draw color-preview of curve behind checkbox */
-			if (ale->type == ANIMTYPE_FCURVE) {
+			if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
 				FCurve *fcu = (FCurve *)ale->data;
 				
 				/* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever 
@@ -3639,7 +3683,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
 		UI_fontstyle_draw_simple(fstyle, offset, ytext, name);
 		
 		/* draw red underline if channel is disabled */
-		if ((ale->type == ANIMTYPE_FCURVE) && (ale->flag & FCURVE_DISABLED)) {
+		if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE) && (ale->flag & FCURVE_DISABLED)) {
 			/* FIXME: replace hardcoded color here, and check on extents! */
 			glColor3f(1.0f, 0.0f, 0.0f);
 			glLineWidth(2.0);
@@ -3706,7 +3750,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
 		 *	  (only only F-Curves really can support them for now)
 		 *	- slider should start before the toggles (if they're visible) to keep a clean line down the side
 		 */
-		if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_SHAPEKEY)) {
+		if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY)) {
 			/* adjust offset */
 			offset += SLIDER_WIDTH;
 		}
@@ -3895,7 +3939,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann
 			/

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list