[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32121] trunk/blender/source/blender/ editors: Fix #23847: keyframe insert on button not working in popup menus, e.g.

Brecht Van Lommel brechtvanlommel at pandora.be
Sat Sep 25 16:32:26 CEST 2010


Revision: 32121
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32121
Author:   blendix
Date:     2010-09-25 16:32:26 +0200 (Sat, 25 Sep 2010)

Log Message:
-----------
Fix #23847: keyframe insert on button not working in popup menus, e.g.
the vector popup for node inputs.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/drivers.c
    trunk/blender/source/blender/editors/animation/keyframing.c
    trunk/blender/source/blender/editors/animation/keyingsets.c
    trunk/blender/source/blender/editors/include/UI_interface.h
    trunk/blender/source/blender/editors/interface/interface_anim.c
    trunk/blender/source/blender/editors/interface/interface_handlers.c
    trunk/blender/source/blender/editors/interface/interface_ops.c

Modified: trunk/blender/source/blender/editors/animation/drivers.c
===================================================================
--- trunk/blender/source/blender/editors/animation/drivers.c	2010-09-25 14:14:04 UTC (rev 32120)
+++ trunk/blender/source/blender/editors/animation/drivers.c	2010-09-25 14:32:26 UTC (rev 32121)
@@ -372,7 +372,7 @@
 	
 	/* try to create driver using property retrieved from UI */
 	memset(&ptr, 0, sizeof(PointerRNA));
-	uiAnimContextProperty(C, &ptr, &prop, &index);
+	uiContextActiveProperty(C, &ptr, &prop, &index);
 
 	if (all)
 		index= -1;
@@ -389,6 +389,8 @@
 	
 	if (success) {
 		/* send updates */
+		uiContextAnimUpdate(C);
+
 		DAG_ids_flush_update(CTX_data_main(C), 0);
 		
 		WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX
@@ -427,7 +429,7 @@
 	
 	/* try to find driver using property retrieved from UI */
 	memset(&ptr, 0, sizeof(PointerRNA));
-	uiAnimContextProperty(C, &ptr, &prop, &index);
+	uiContextActiveProperty(C, &ptr, &prop, &index);
 	
 	if (all)
 		index= -1;
@@ -440,6 +442,8 @@
 	
 	if (success) {
 		/* send updates */
+		uiContextAnimUpdate(C);
+
 		DAG_ids_flush_update(CTX_data_main(C), 0);
 		
 		WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL);  // XXX
@@ -478,7 +482,7 @@
 	
 	/* try to create driver using property retrieved from UI */
 	memset(&ptr, 0, sizeof(PointerRNA));
-	uiAnimContextProperty(C, &ptr, &prop, &index);
+	uiContextActiveProperty(C, &ptr, &prop, &index);
 	
 	if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
 		path= RNA_path_from_ID_to_property(&ptr, prop);
@@ -486,6 +490,8 @@
 		if (path) {
 			/* only copy the driver for the button that this was involved for */
 			success= ANIM_copy_driver(ptr.id.data, path, index, 0);
+
+			uiContextAnimUpdate(C);
 			
 			MEM_freeN(path);
 		}
@@ -522,7 +528,7 @@
 	
 	/* try to create driver using property retrieved from UI */
 	memset(&ptr, 0, sizeof(PointerRNA));
-	uiAnimContextProperty(C, &ptr, &prop, &index);
+	uiContextActiveProperty(C, &ptr, &prop, &index);
 	
 	if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
 		path= RNA_path_from_ID_to_property(&ptr, prop);
@@ -530,6 +536,8 @@
 		if (path) {
 			/* only copy the driver for the button that this was involved for */
 			success= ANIM_paste_driver(ptr.id.data, path, index, 0);
+
+			uiContextAnimUpdate(C);
 			
 			MEM_freeN(path);
 		}

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c	2010-09-25 14:14:04 UTC (rev 32120)
+++ trunk/blender/source/blender/editors/animation/keyframing.c	2010-09-25 14:32:26 UTC (rev 32121)
@@ -1362,7 +1362,7 @@
 	
 	/* try to insert keyframe using property retrieved from UI */
 	memset(&ptr, 0, sizeof(PointerRNA));
-	uiAnimContextProperty(C, &ptr, &prop, &index);
+	uiContextActiveProperty(C, &ptr, &prop, &index);
 	
 	if ((ptr.id.data && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) {
 		path= RNA_path_from_ID_to_property(&ptr, prop);
@@ -1405,6 +1405,8 @@
 	
 	if (success) {
 		/* send updates */
+		uiContextAnimUpdate(C);
+
 		DAG_ids_flush_update(bmain, 0);
 		
 		/* send notifiers that keyframes have been changed */
@@ -1446,7 +1448,7 @@
 	
 	/* try to insert keyframe using property retrieved from UI */
 	memset(&ptr, 0, sizeof(PointerRNA));
-	uiAnimContextProperty(C, &ptr, &prop, &index);
+	uiContextActiveProperty(C, &ptr, &prop, &index);
 
 	if (ptr.id.data && ptr.data && prop) {
 		path= RNA_path_from_ID_to_property(&ptr, prop);
@@ -1476,6 +1478,8 @@
 	
 	if (success) {
 		/* send updates */
+		uiContextAnimUpdate(C);
+
 		DAG_ids_flush_update(bmain, 0);
 		
 		/* send notifiers that keyframes have been changed */

Modified: trunk/blender/source/blender/editors/animation/keyingsets.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyingsets.c	2010-09-25 14:14:04 UTC (rev 32120)
+++ trunk/blender/source/blender/editors/animation/keyingsets.c	2010-09-25 14:32:26 UTC (rev 32121)
@@ -323,7 +323,7 @@
 	
 	/* try to add to keyingset using property retrieved from UI */
 	memset(&ptr, 0, sizeof(PointerRNA));
-	uiAnimContextProperty(C, &ptr, &prop, &index);
+	uiContextActiveProperty(C, &ptr, &prop, &index);
 	
 	/* check if property is able to be added */
 	if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
@@ -409,7 +409,7 @@
 	
 	/* try to add to keyingset using property retrieved from UI */
 	memset(&ptr, 0, sizeof(PointerRNA));
-	uiAnimContextProperty(C, &ptr, &prop, &index);
+	uiContextActiveProperty(C, &ptr, &prop, &index);
 
 	if (ptr.id.data && ptr.data && prop) {
 		path= RNA_path_from_ID_to_property(&ptr, prop);

Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h	2010-09-25 14:14:04 UTC (rev 32120)
+++ trunk/blender/source/blender/editors/include/UI_interface.h	2010-09-25 14:32:26 UTC (rev 32121)
@@ -737,7 +737,8 @@
 void UI_buttons_operatortypes(void);
 
 /* Helpers for Operators */
-void uiAnimContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
+void uiContextActiveProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
+void uiContextAnimUpdate(const struct bContext *C);
 void uiFileBrowseContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
 void uiIDContextProperty(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
 

Modified: trunk/blender/source/blender/editors/interface/interface_anim.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_anim.c	2010-09-25 14:14:04 UTC (rev 32120)
+++ trunk/blender/source/blender/editors/interface/interface_anim.c	2010-09-25 14:32:26 UTC (rev 32121)
@@ -114,74 +114,50 @@
 	}
 }
 
-void uiAnimContextProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index)
-{
-	ARegion *ar= CTX_wm_region(C);
-	uiBlock *block;
-	uiBut *but;
-
-	memset(ptr, 0, sizeof(*ptr));
-	*prop= NULL;
-	*index= 0;
-
-	if(ar) {
-		for(block=ar->uiblocks.first; block; block=block->next) {
-			for(but=block->buttons.first; but; but= but->next) {
-				if((but->active || but->flag & UI_BUT_LAST_ACTIVE) && but->rnapoin.data) {
-					*ptr= but->rnapoin;
-					*prop= but->rnaprop;
-					*index= but->rnaindex;
-					return;
-				}
-			}
-		}
-	}
-}
-
 void ui_but_anim_insert_keyframe(bContext *C)
 {
-	/* this operator calls uiAnimContextProperty above */
+	/* this operator calls uiContextActiveProperty */
 	WM_operator_name_call(C, "ANIM_OT_keyframe_insert_button", WM_OP_INVOKE_DEFAULT, NULL);
 }
 
 void ui_but_anim_delete_keyframe(bContext *C)
 {
-	/* this operator calls uiAnimContextProperty above */
+	/* this operator calls uiContextActiveProperty */
 	WM_operator_name_call(C, "ANIM_OT_keyframe_delete_button", WM_OP_INVOKE_DEFAULT, NULL);
 }
 
 void ui_but_anim_add_driver(bContext *C)
 {
-	/* this operator calls uiAnimContextProperty above */
+	/* this operator calls uiContextActiveProperty */
 	WM_operator_name_call(C, "ANIM_OT_driver_button_add", WM_OP_INVOKE_DEFAULT, NULL);
 }
 
 void ui_but_anim_remove_driver(bContext *C)
 {
-	/* this operator calls uiAnimContextProperty above */
+	/* this operator calls uiContextActiveProperty */
 	WM_operator_name_call(C, "ANIM_OT_driver_button_remove", WM_OP_INVOKE_DEFAULT, NULL);
 }
 
 void ui_but_anim_copy_driver(bContext *C)
 {
-	/* this operator calls uiAnimContextProperty above */
+	/* this operator calls uiContextActiveProperty */
 	WM_operator_name_call(C, "ANIM_OT_copy_driver_button", WM_OP_INVOKE_DEFAULT, NULL);
 }
 
 void ui_but_anim_paste_driver(bContext *C)
 {
-	/* this operator calls uiAnimContextProperty above */
+	/* this operator calls uiContextActiveProperty */
 	WM_operator_name_call(C, "ANIM_OT_paste_driver_button", WM_OP_INVOKE_DEFAULT, NULL);
 }
 
 void ui_but_anim_add_keyingset(bContext *C)
 {
-	/* this operator calls uiAnimContextProperty above */
+	/* this operator calls uiContextActiveProperty */
 	WM_operator_name_call(C, "ANIM_OT_keyingset_button_add", WM_OP_INVOKE_DEFAULT, NULL);
 }
 
 void ui_but_anim_remove_keyingset(bContext *C)
 {
-	/* this operator calls uiAnimContextProperty above */
+	/* this operator calls uiContextActiveProperty */
 	WM_operator_name_call(C, "ANIM_OT_keyingset_button_remove", WM_OP_INVOKE_DEFAULT, NULL);
 }

Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c	2010-09-25 14:14:04 UTC (rev 32120)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c	2010-09-25 14:32:26 UTC (rev 32121)
@@ -4255,6 +4255,7 @@
 
 static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
 {
+	Scene *scene= CTX_data_scene(C);
 	uiHandleButtonData *data;
 	int retval;
 
@@ -4906,6 +4907,98 @@
 	}
 }
 
+/* helper function for insert keyframe, reset to default, etc operators */
+void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index)
+{
+	ARegion *ar= CTX_wm_region(C);
+	uiBlock *block;
+	uiBut *but, *activebut;
+
+	memset(ptr, 0, sizeof(*ptr));
+	*prop= NULL;
+	*index= 0;
+
+	while(ar) {
+		/* find active button */
+		activebut= NULL;
+
+		for(block=ar->uiblocks.first; block; block=block->next) {
+			for(but=block->buttons.first; but; but= but->next) {
+				if(but->active)
+					activebut= but;
+				else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
+					activebut= but;
+			}
+		}
+
+		if(activebut) {
+			if(activebut->rnapoin.data) {
+				/* found RNA button */
+				*ptr= activebut->rnapoin;
+				*prop= activebut->rnaprop;
+				*index= activebut->rnaindex;
+				return;
+			}
+			else {
+				/* recurse into opened menu */
+				uiHandleButtonData *data= activebut->active;
+				if(data && data->menu)
+					ar = data->menu->region;
+				else
+					return;
+			}
+		}
+		else {
+			/* no active button */
+			return;
+		}
+	}
+}
+
+/* helper function for insert keyframe, reset to default, etc operators */
+void uiContextAnimUpdate(const bContext *C)
+{

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list