[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54237] trunk/blender/source/blender/ editors/interface: Fix #34034: keyframe display of color/ curve buttons was broken after revision

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Jan 31 17:19:49 CET 2013


Revision: 54237
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54237
Author:   blendix
Date:     2013-01-31 16:19:44 +0000 (Thu, 31 Jan 2013)
Log Message:
-----------
Fix #34034: keyframe display of color/curve buttons was broken after revision
53132 which changed the RNA index to -1 for these. Also made it so that these
buttons no longer display "Insert Single Keyframe" and only "Insert Keyframe"
as you can't edit individual components here so it's only confusing.

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53132

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_anim.c
    trunk/blender/source/blender/editors/interface/interface_handlers.c

Modified: trunk/blender/source/blender/editors/interface/interface_anim.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_anim.c	2013-01-31 15:31:47 UTC (rev 54236)
+++ trunk/blender/source/blender/editors/interface/interface_anim.c	2013-01-31 16:19:44 UTC (rev 54237)
@@ -57,7 +57,11 @@
 
 static FCurve *ui_but_get_fcurve(uiBut *but, bAction **action, int *driven)
 {
-	return rna_get_fcurve(&but->rnapoin, but->rnaprop, but->rnaindex, action, driven);
+	/* for entire array buttons we check the first component, it's not perfect
+	 * but works well enough in typical cases */
+	int rnaindex = (but->rnaindex == -1)? 0: but->rnaindex;
+
+	return rna_get_fcurve(&but->rnapoin, but->rnaprop, rnaindex, action, driven);
 }
 
 void ui_but_anim_flag(uiBut *but, float cfra)
@@ -131,6 +135,7 @@
 	ID *id;
 	FCurve *fcu;
 	char *path;
+	int rnaindex;
 	short ok = 0;
 	
 	/* button must have RNA-pointer to a numeric-capable property */
@@ -140,6 +145,14 @@
 		return 0;
 	}
 	
+	if (RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0) {
+		if (but->rnaindex == -1) {
+			if (G.debug & G_DEBUG)
+				printf("ERROR: create expression failed - can't create expression for entire array\n");
+			return 0;
+		}
+	}
+	
 	/* make sure we have animdata for this */
 	/* FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them */
 	id = (ID *)but->rnapoin.id.data;

Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c	2013-01-31 15:31:47 UTC (rev 54236)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c	2013-01-31 16:19:44 UTC (rev 54237)
@@ -4752,7 +4752,7 @@
 {
 	uiPopupMenu *pup;
 	uiLayout *layout;
-	int length;
+	bool is_array, is_array_component;
 	const char *name;
 	uiStringInfo label = {BUT_GET_LABEL, NULL};
 
@@ -4779,12 +4779,14 @@
 		if (is_anim)
 			is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop);
 
-		length = RNA_property_array_length(&but->rnapoin, but->rnaprop);
+		/* determine if we can key a single component of an array */
+		is_array = RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0;
+		is_array_component = (is_array && but->rnaindex != -1);
 		
 		/* Keyframes */
 		if (but->flag & UI_BUT_ANIMATED_KEY) {
 			/* replace/delete keyfraemes */
-			if (length) {
+			if (is_array_component) {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframes"),
 				               ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1);
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Single Keyframe"),
@@ -4796,9 +4798,9 @@
 			}
 			else {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Replace Keyframe"),
-				               ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0);
+				               ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1);
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Keyframe"),
-				               ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 0);
+				               ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1);
 			}
 			
 			/* keyframe settings */
@@ -4810,7 +4812,7 @@
 			/* pass */
 		}
 		else if (is_anim) {
-			if (length) {
+			if (is_array_component) {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframes"),
 				               ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1);
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Single Keyframe"),
@@ -4818,12 +4820,12 @@
 			}
 			else {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Insert Keyframe"),
-				               ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0);
+				               ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1);
 			}
 		}
 		
 		if (but->flag & UI_BUT_ANIMATED) {
-			if (length) {
+			if (is_array_component) {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"),
 				               ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 1);
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Single Keyframes"),
@@ -4831,7 +4833,7 @@
 			}
 			else {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Keyframes"),
-				               ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 0);
+				               ICON_NONE, "ANIM_OT_keyframe_clear_button", "all", 1);
 			}
 		}
 
@@ -4839,7 +4841,7 @@
 		if (but->flag & UI_BUT_DRIVEN) {
 			uiItemS(layout);
 
-			if (length) {
+			if (is_array_component) {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Drivers"),
 				               ICON_NONE, "ANIM_OT_driver_button_remove", "all", 1);
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Single Driver"),
@@ -4847,7 +4849,7 @@
 			}
 			else {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Delete Driver"),
-				               ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0);
+				               ICON_NONE, "ANIM_OT_driver_button_remove", "all", 1);
 			}
 
 			uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Driver"),
@@ -4863,7 +4865,7 @@
 		else if (is_anim) {
 			uiItemS(layout);
 
-			if (length) {
+			if (is_array_component) {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Drivers"),
 				               ICON_NONE, "ANIM_OT_driver_button_add", "all", 1);
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single Driver"),
@@ -4871,7 +4873,7 @@
 			}
 			else {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Driver"),
-				               ICON_NONE, "ANIM_OT_driver_button_add", "all", 0);
+				               ICON_NONE, "ANIM_OT_driver_button_add", "all", 1);
 			}
 
 			if (ANIM_driver_can_paste()) {
@@ -4885,7 +4887,7 @@
 		if (is_anim) {
 			uiItemS(layout);
 
-			if (length) {
+			if (is_array_component) {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add All to Keying Set"),
 				               ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 1);
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add Single to Keying Set"),
@@ -4895,7 +4897,7 @@
 			}
 			else {
 				uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Keying Set"),
-				               ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 0);
+				               ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 1);
 				uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Keying Set"),
 				        ICON_NONE, "ANIM_OT_keyingset_button_remove");
 			}
@@ -4908,15 +4910,15 @@
 		/* Copy Property Value
 		 * Paste Property Value */
 		
-		if (length) {
+		if (is_array_component) {
 			uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset All to Default Values"),
 			               ICON_NONE, "UI_OT_reset_default_button", "all", 1);
 			uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset Single to Default Value"),
 			               ICON_NONE, "UI_OT_reset_default_button", "all", 0);
 		}
 		else {
-			uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"),
-			        ICON_NONE, "UI_OT_reset_default_button");
+			uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Reset to Default Value"),
+			        ICON_NONE, "UI_OT_reset_default_button", "all", 1);
 		}
 		
 		uiItemO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"),




More information about the Bf-blender-cvs mailing list