[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23801] trunk/blender/source/blender: 2. 5 Bugfixes:

Joshua Leung aligorith at gmail.com
Tue Oct 13 07:50:27 CEST 2009


Revision: 23801
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23801
Author:   aligorith
Date:     2009-10-13 07:50:26 +0200 (Tue, 13 Oct 2009)

Log Message:
-----------
2.5 Bugfixes:

* Reverting some changes I made to try and get Action Groups with no viewable F-Curves, but were collapsed to get hidden. These were causing buggy behaviour

* Move bones to armature layers, and change armature layer operators now use the new automatic properties drawing invoke callback. This allows changing the buttons there immediately affect the bones in the viewport

* #19581: Text Editor: "Jump To" (go to line) not working
Made this use the automatic operator props invoke callback, and fixed an RNA properties bug for this (the default value and range values were swapped).

* PoseLib rename pose operator now works again. Once again, this uses the auto-props popup. Also, improved the code here while I was at it.

* Disabled non-functional/old entry in Select Linked operator ("IPO's")

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/anim_filter.c
    trunk/blender/source/blender/editors/armature/poselib.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/object/object_select.c
    trunk/blender/source/blender/editors/space_text/text_ops.c
    trunk/blender/source/blender/makesrna/intern/rna_object.c

Modified: trunk/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_filter.c	2009-10-13 02:21:18 UTC (rev 23800)
+++ trunk/blender/source/blender/editors/animation/anim_filter.c	2009-10-13 05:50:26 UTC (rev 23801)
@@ -750,19 +750,14 @@
 	/* loop over groups */
 	// TODO: in future, should we expect to need nested groups?
 	for (agrp= act->groups.first; agrp; agrp= agrp->next) {
-		ListBase tmp_channels = {NULL, NULL};
-		short grp_channel=0;
-		int tmp_items = 0;
-		
-		
 		/* add this group as a channel first */
 		if ((filter_mode & ANIMFILTER_CHANNELS) || !(filter_mode & ANIMFILTER_CURVESONLY)) {
 			/* check if filtering by selection */
 			if ( ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) ) {
 				ale= make_new_animlistelem(agrp, ANIMTYPE_GROUP, NULL, ANIMTYPE_NONE, owner_id);
 				if (ale) {
-					BLI_addtail(&tmp_channels, ale);
-					grp_channel=1;
+					BLI_addtail(anim_data, ale);
+					items++;
 				}
 			}
 		}
@@ -792,25 +787,13 @@
 				if ( !(filter_mode & ANIMFILTER_CURVEVISIBLE) || !(agrp->flag & AGRP_NOTVISIBLE) )
 				{
 					if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_AGRP(agrp)) {
-						// XXX the 'owner' info here needs review...
-						tmp_items += animdata_filter_fcurves(&tmp_channels, ads, agrp->channels.first, agrp, owner, ownertype, filter_mode, owner_id);
+						items += animdata_filter_fcurves(anim_data, ads, agrp->channels.first, agrp, owner, ownertype, filter_mode, owner_id);
 					}
 				}
 			}
 		}
 		
-		/* check group had any F-Curves visible */
-		// TODO: this needs more work to truly work so that closed group with no visible channels, and visible group with visible channels are differentiated between
-		if (/*tmp_items*/1) {
-			/* add the temp channels to the list of filtered channels */
-			addlisttolist(anim_data, &tmp_channels);
-			
-			/* increase the counts as appropriate */
-			items += tmp_items + grp_channel;
-		}
-		else {
-			BLI_freelistN(&tmp_channels);
-		}
+		// TODO: but we still need to deal with the case when the group may be closed, but it has no visible curves too
 	}
 	
 	/* loop over un-grouped F-Curves (only if we're not only considering those channels in the animive group) */

Modified: trunk/blender/source/blender/editors/armature/poselib.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poselib.c	2009-10-13 02:21:18 UTC (rev 23800)
+++ trunk/blender/source/blender/editors/armature/poselib.c	2009-10-13 05:50:26 UTC (rev 23801)
@@ -285,6 +285,9 @@
 	bAction *act= ob->poselib;
 	TimeMarker *marker;
 	
+	/* set the operator execution context correctly */
+	uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
+	
 	/* add each marker to this menu */
 	for (marker= act->markers.first; marker; marker= marker->next)
 		uiItemIntO(layout, marker->name, ICON_ARMATURE_DATA, "POSELIB_OT_pose_add", "frame", marker->frame);
@@ -398,7 +401,6 @@
 	return OPERATOR_FINISHED;
 }
 
-
 void POSELIB_OT_pose_add (wmOperatorType *ot)
 {
 	/* identifiers */
@@ -421,36 +423,36 @@
 
 /* ----- */
 
-static int poselib_stored_pose_menu_invoke (bContext *C, wmOperator *op, wmEvent *evt)
+static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *ptr, int *free)
 {
 	Object *ob= CTX_data_active_object(C);
 	bAction *act= (ob) ? ob->poselib : NULL;
 	TimeMarker *marker;
-	uiPopupMenu *pup;
-	uiLayout *layout;
-	int i;
-	
-	/* sanity check */
-	if (ELEM(NULL, ob, act)) 
-		return OPERATOR_CANCELLED;
-	
-	/* start building */
-	pup= uiPupMenuBegin(C, op->type->name, 0);
-	layout= uiPupMenuLayout(pup);
-	uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
-	
-	/* add each marker to this menu */
-	for (marker=act->markers.first, i=0; marker; marker= marker->next, i++)
-		uiItemIntO(layout, marker->name, ICON_ARMATURE_DATA, op->idname, "index", i);
-	
-	uiPupMenuEnd(C, pup);
-	
-	/* this operator is only for a menu, not used further */
-	return OPERATOR_CANCELLED;
-}
+	EnumPropertyItem *item= NULL, item_tmp;
+	int totitem= 0;
+	int i= 0;
 
+	if (C == NULL)
+		return NULL;
 
+	memset(&item_tmp, 0, sizeof(item_tmp));
 
+	/* add each marker to the list */
+	for (marker=act->markers.first, i=0; marker; marker= marker->next, i++) {
+		item_tmp.identifier= item_tmp.name= marker->name;
+		item_tmp.icon= ICON_ARMATURE_DATA;
+		item_tmp.value= i;
+		RNA_enum_item_add(&item, &totitem, &item_tmp);
+	}
+
+	if (i > 0) {
+		*free= 1;
+		return item;
+	}
+	else
+		return NULL;
+}
+
 static int poselib_remove_exec (bContext *C, wmOperator *op)
 {
 	Object *ob= CTX_data_active_object(C);
@@ -465,7 +467,7 @@
 	}
 	
 	/* get index (and pointer) of pose to remove */
-	marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "index"));
+	marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose"));
 	if (marker == NULL) {
 		BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose");
 		return OPERATOR_CANCELLED;
@@ -499,13 +501,18 @@
 
 void POSELIB_OT_pose_remove (wmOperatorType *ot)
 {
+	PropertyRNA *prop;
+	static EnumPropertyItem prop_poses_dummy_types[] = {
+		{0, NULL, 0, NULL, NULL}
+	};
+	
 	/* identifiers */
 	ot->name= "PoseLib Remove Pose";
 	ot->idname= "POSELIB_OT_pose_remove";
 	ot->description= "Remove nth pose from the active Pose Library";
 	
 	/* api callbacks */
-	ot->invoke= poselib_stored_pose_menu_invoke;
+	ot->invoke= WM_menu_invoke;
 	ot->exec= poselib_remove_exec;
 	ot->poll= ED_operator_posemode;
 	
@@ -513,11 +520,38 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
 	/* properties */
-	RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The index of the pose to remove", 0, INT_MAX);
+	prop= RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to remove");
+		RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
 }
 
+static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt)
+{
+	Object *ob= CTX_data_active_object(C);
+	bAction *act= (ob) ? ob->poselib : NULL;
+	TimeMarker *marker;
+	
+	/* check if valid poselib */
+	if (act == NULL) {
+		BKE_report(op->reports, RPT_ERROR, "Object doesn't have PoseLib data");
+		return OPERATOR_CANCELLED;
+	}
+	
+	/* get index (and pointer) of pose to remove */
+	marker= BLI_findlink(&act->markers, act->active_marker-1);
+	if (marker == NULL) {
+		BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose");
+		return OPERATOR_CANCELLED;
+	}
+	else {
+		/* use the existing name of the marker as the name, and use the active marker as the one to rename */
+		RNA_enum_set(op->ptr, "pose", act->active_marker-1);
+		RNA_string_set(op->ptr, "name", marker->name);
+	}
+	
+	/* part to sync with other similar operators... */
+	return WM_operator_props_popup(C, op, evt);
+}
 
-
 static int poselib_rename_exec (bContext *C, wmOperator *op)
 {
 	Object *ob= CTX_data_active_object(C);
@@ -532,7 +566,7 @@
 	}
 	
 	/* get index (and pointer) of pose to remove */
-	marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "index"));
+	marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose"));
 	if (marker == NULL) {
 		BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose");
 		return OPERATOR_CANCELLED;
@@ -551,13 +585,18 @@
 
 void POSELIB_OT_pose_rename (wmOperatorType *ot)
 {
+	PropertyRNA *prop;
+	static EnumPropertyItem prop_poses_dummy_types[] = {
+		{0, NULL, 0, NULL, NULL}
+	};
+	
 	/* identifiers */
 	ot->name= "PoseLib Rename Pose";
 	ot->idname= "POSELIB_OT_pose_rename";
 	ot->description= "Rename nth pose from the active Pose Library";
 	
 	/* api callbacks */
-	ot->invoke= poselib_stored_pose_menu_invoke;
+	ot->invoke= poselib_rename_invoke;
 	ot->exec= poselib_rename_exec;
 	ot->poll= ED_operator_posemode;
 	
@@ -565,7 +604,8 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
 	/* properties */
-	RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The index of the pose to remove", 0, INT_MAX);
+	prop= RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename");
+		RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
 	RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose");
 }
 

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2009-10-13 02:21:18 UTC (rev 23800)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2009-10-13 05:50:26 UTC (rev 23801)
@@ -1728,31 +1728,6 @@
 /* ********************************************** */
 
 /* Present a popup to get the layers that should be used */
-// TODO: move to wm?
-static uiBlock *wm_layers_select_create_menu(bContext *C, ARegion *ar, void *arg_op)
-{
-	wmOperator *op= arg_op;
-	uiBlock *block;
-	uiLayout *layout;
-	uiStyle *style= U.uistyles.first;
-	
-	block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
-	uiBlockClearFlag(block, UI_BLOCK_LOOP);
-	uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
-	
-	layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 150, 20, style);
-		uiItemL(layout, op->type->name, 0);
-		uiTemplateLayers(layout, op->ptr, "layers"); /* must have a property named layers setup */
-		
-	uiPopupBoundsBlock(block, 4.0f, 0, 0);
-	uiEndBlock(C, block);
-	
-	return block;
-}
-
-/* ------------------- */
-
-/* Present a popup to get the layers that should be used */
 static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
 {
 	Object *ob= CTX_data_active_object(C);
@@ -1769,10 +1744,8 @@
 	RNA_boolean_get_array(&ptr, "layer", layers);
 	RNA_boolean_set_array(op->ptr, "layers", layers);
 	
-		/* part to sync with other similar operators... */
-	/* pass on operator, so return modal */
-	uiPupBlockOperator(C, wm_layers_select_create_menu, op, WM_OP_EXEC_DEFAULT);
-	return OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH;
+	/* part to sync with other similar operators... */
+	return WM_operator_props_popup(C, op, evt);
 }
 
 /* Set the visible layers for the active armature (edit and pose modes) */
@@ -1813,7 +1786,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
 	/* properties */
-	RNA_def_boolean_array(ot->srna, "layers", 16, NULL, "Layers", "Armature layers to make visible.");
+	RNA_def_boolean_layer_member(ot->srna, "layers", 16, NULL, "Layer", "Armature layers to make visible");
 }
 
 void ARMATURE_OT_armature_layers (wmOperatorType *ot)
@@ -1832,7 +1805,7 @@

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list