[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24848] trunk/blender/source/blender/ editors: Keyframing Operator Tweaks for Durian:

Joshua Leung aligorith at gmail.com
Tue Nov 24 05:21:34 CET 2009


Revision: 24848
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24848
Author:   aligorith
Date:     2009-11-24 05:21:32 +0100 (Tue, 24 Nov 2009)

Log Message:
-----------
Keyframing Operator Tweaks for Durian:

* Insert Keyframe (IKEY) now only shows the menu requesting to choose a KeyingSet to use if there is no active KeyingSet. To get the old behaviour, the "always_prompt" boolean property for the "ANIM_OT_insert_keyframe_menu" operator should be supplied.

* After inserting/deleting keyframes without the menu, a popup menu confirming that the keyframes have been modified is shown. Please note that you do not need to click on this popup.

TODO:
Make the confirmation popup fade out after a fixed time.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/keyframing.c
    trunk/blender/source/blender/editors/space_graph/graph_buttons.c
    trunk/blender/source/blender/editors/space_text/text_ops.c

Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c	2009-11-24 02:07:57 UTC (rev 24847)
+++ trunk/blender/source/blender/editors/animation/keyframing.c	2009-11-24 04:21:32 UTC (rev 24848)
@@ -1003,11 +1003,18 @@
 	if (G.f & G_DEBUG)
 		printf("KeyingSet '%s' - Successfully added %d Keyframes \n", ks->name, success);
 	
-	/* report failure? */
-	if (success == 0)
+	/* report failure or do updates? */
+	if (success) {
+		/* if the appropriate properties have been set, make a note that we've inserted something */
+		if (RNA_boolean_get(op->ptr, "confirm_success"))
+			BKE_reportf(op->reports, RPT_INFO, "Successfully added %d Keyframes for KeyingSet '%s'", success, ks->name);
+		
+		/* send notifiers that keyframes have been changed */
+		WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+	}
+	else
 		BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes");
-	else
-		WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+		
 	
 	/* free temp context-data if available */
 	if (dsources.first) {
@@ -1026,6 +1033,7 @@
 	/* identifiers */
 	ot->name= "Insert Keyframe";
 	ot->idname= "ANIM_OT_insert_keyframe";
+	ot->description= "Insert keyframes on the current frame for all properties in the specified Keying Set.";
 	
 	/* callbacks */
 	ot->exec= insert_key_exec; 
@@ -1034,19 +1042,22 @@
 	/* flags */
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
-	/* settings */
+	/* keyingset to use
+	 *	- here the type is int not enum, since many of the indicies here are determined dynamically
+	 */
 	RNA_def_int(ot->srna, "type", 0, INT_MIN, INT_MAX, "Keying Set Number", "Index (determined internally) of the Keying Set to use", 0, 1);
+	/* confirm whether a keyframe was added by showing a popup 
+	 *	- by default, this is enabled, since this operator is assumed to be called independently
+	 */
+	RNA_def_boolean(ot->srna, "confirm_success", 1, "Confirm Successful Insert", "Show a popup when the keyframes get successfully added");
 }
 
 /* Insert Key Operator (With Menu) ------------------------ */
-
-/* XXX 
- * This operator pops up a menu which sets gets the index of the keyingset to use,
- * setting the global settings, and calling the insert-keyframe operator using these
- * settings
+/* This operator checks if a menu should be shown for choosing the KeyingSet to use, 
+ * then calls the  
  */
 
-static int insert_key_menu_invoke (bContext *C, wmOperator *op, wmEvent *event)
+static void insert_key_menu_prompt (bContext *C)
 {
 	Scene *scene= CTX_data_scene(C);
 	KeyingSet *ks;
@@ -1077,7 +1088,6 @@
 	}
 	
 	/* builtin Keying Sets */
-	// XXX polling the entire list may lag
 	i= -1;
 	for (ks= builtin_keyingsets.first; ks; ks= ks->next) {
 		/* only show KeyingSet if context is suitable */
@@ -1087,8 +1097,25 @@
 	}
 	
 	uiPupMenuEnd(C, pup);
+} 
+
+static int insert_key_menu_invoke (bContext *C, wmOperator *op, wmEvent *event)
+{
+	Scene *scene= CTX_data_scene(C);
 	
-	return OPERATOR_CANCELLED;
+	/* if prompting or no active Keying Set, show the menu */
+	if ((scene->active_keyingset == 0) || RNA_boolean_get(op->ptr, "always_prompt")) {
+		/* call the menu, which will call this operator again, hence the cancelled */
+		insert_key_menu_prompt(C);
+		return OPERATOR_CANCELLED;
+	}
+	else {
+		/* just call the exec() on the active keyingset */
+		RNA_int_set(op->ptr, "type", 0);
+		RNA_boolean_set(op->ptr, "confirm_success", 1);
+		
+		return op->type->exec(C, op);
+	}
 }
  
 void ANIM_OT_insert_keyframe_menu (wmOperatorType *ot)
@@ -1105,10 +1132,20 @@
 	/* flags */
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
-	/* properties
-	 *	- NOTE: here the type is int not enum, since many of the indicies here are determined dynamically
+	/* keyingset to use
+	 *	- here the type is int not enum, since many of the indicies here are determined dynamically
 	 */
 	RNA_def_int(ot->srna, "type", 0, INT_MIN, INT_MAX, "Keying Set Number", "Index (determined internally) of the Keying Set to use", 0, 1);
+	/* confirm whether a keyframe was added by showing a popup 
+	 *	- by default, this is disabled so that if a menu is shown, this doesn't come up too
+	 */
+	// XXX should this just be always on?
+	RNA_def_boolean(ot->srna, "confirm_success", 0, "Confirm Successful Insert", "Show a popup when the keyframes get successfully added");
+	/* whether the menu should always be shown 
+	 *	- by default, the menu should only be shown when there is no active Keying Set (2.5 behaviour),
+	 *	  although in some cases it might be useful to always shown (pre 2.5 behaviour)
+	 */
+	RNA_def_boolean(ot->srna, "always_prompt", 0, "Always Show Menu", "");
 }
 
 /* Delete Key Operator ------------------------ */
@@ -1154,11 +1191,17 @@
 	if (G.f & G_DEBUG)
 		printf("KeyingSet '%s' - Successfully removed %d Keyframes \n", ks->name, success);
 	
-	/* report failure? */
-	if (success == 0)
+	/* report failure or do updates? */
+	if (success) {
+		/* if the appropriate properties have been set, make a note that we've inserted something */
+		if (RNA_boolean_get(op->ptr, "confirm_success"))
+			BKE_reportf(op->reports, RPT_INFO, "Successfully removed %d Keyframes for KeyingSet '%s'", success, ks->name);
+		
+		/* send notifiers that keyframes have been changed */
+		WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+	}
+	else
 		BKE_report(op->reports, RPT_WARNING, "Keying Set failed to remove any keyframes");
-	else
-		WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
 	
 	/* free temp context-data if available */
 	if (dsources.first) {
@@ -1177,6 +1220,7 @@
 	/* identifiers */
 	ot->name= "Delete Keyframe";
 	ot->idname= "ANIM_OT_delete_keyframe";
+	ot->description= "Delete keyframes on the current frame for all properties in the specified Keying Set.";
 	
 	/* callbacks */
 	ot->exec= delete_key_exec; 
@@ -1185,10 +1229,14 @@
 	/* flags */
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
-	/* properties
-	 *	- NOTE: here the type is int not enum, since many of the indicies here are determined dynamically
+	/* keyingset to use
+	 *	- here the type is int not enum, since many of the indicies here are determined dynamically
 	 */
 	RNA_def_int(ot->srna, "type", 0, INT_MIN, INT_MAX, "Keying Set Number", "Index (determined internally) of the Keying Set to use", 0, 1);
+	/* confirm whether a keyframe was added by showing a popup 
+	 *	- by default, this is enabled, since this operator is assumed to be called independently
+	 */
+	RNA_def_boolean(ot->srna, "confirm_success", 1, "Confirm Successful Insert", "Show a popup when the keyframes get successfully added");
 }
 
 /* Delete Key Operator ------------------------ */

Modified: trunk/blender/source/blender/editors/space_graph/graph_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_buttons.c	2009-11-24 02:07:57 UTC (rev 24847)
+++ trunk/blender/source/blender/editors/space_graph/graph_buttons.c	2009-11-24 04:21:32 UTC (rev 24848)
@@ -383,7 +383,7 @@
 		
 		/* Target ID */
 		row= uiLayoutRow(box, 0);
-			uiTemplateAnyID(row, (bContext *)C, &dtar_ptr, "id", "id_type", "Value: ");
+			uiTemplateAnyID(row, (bContext *)C, &dtar_ptr, "id", "id_type", "Value:");
 		
 		/* Target Property */
 		// TODO: make this less technical...

Modified: trunk/blender/source/blender/editors/space_text/text_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_ops.c	2009-11-24 02:07:57 UTC (rev 24847)
+++ trunk/blender/source/blender/editors/space_text/text_ops.c	2009-11-24 04:21:32 UTC (rev 24848)
@@ -2412,7 +2412,7 @@
 			first= 1;
 		}
 		else {
-			BKE_reportf(op->reports, RPT_INFO, "Text not found: %s", st->findstr);
+			BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr);
 			break;
 		}
 	} while(mode==TEXT_MARK_ALL);





More information about the Bf-blender-cvs mailing list