[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27111] trunk/blender: - use search box for adding actions in the NLA

Campbell Barton ideasman42 at gmail.com
Tue Feb 23 20:32:32 CET 2010


Revision: 27111
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27111
Author:   campbellbarton
Date:     2010-02-23 20:32:32 +0100 (Tue, 23 Feb 2010)

Log Message:
-----------
- use search box for adding actions in the NLA
- use less complicated string conversion for saving keymaps

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_userpref.py
    trunk/blender/source/blender/editors/space_nla/nla_edit.c
    trunk/blender/source/blender/makesrna/RNA_enum_types.h
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py	2010-02-23 19:27:36 UTC (rev 27110)
+++ trunk/blender/release/scripts/ui/space_userpref.py	2010-02-23 19:32:32 UTC (rev 27111)
@@ -1614,27 +1614,10 @@
 
 
 def _string_value(value):
-    result = ""
-    if isinstance(value, str):
-        if value != "":
-            result = "\'%s\'" % value
-    elif isinstance(value, bool):
-        if value:
-            result = "True"
-        else:
-            result = "False"
-    elif isinstance(value, float):
-        result = "%.10f" % value
-    elif isinstance(value, int):
-        result = "%d" % value
+    if isinstance(value, str) or isinstance(value, bool) or isinstance(value, float) or isinstance(value, int):
+        result = repr(value)
     elif getattr(value, '__len__', False):
-        if len(value):
-            result = "["
-            for i in range(0, len(value)):
-                result += _string_value(value[i])
-                if i != len(value)-1:
-                    result += ", "
-            result += "]"
+        repr(list(value))
     else:
         print("Export key configuration: can't write ", value)
 

Modified: trunk/blender/source/blender/editors/space_nla/nla_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_nla/nla_edit.c	2010-02-23 19:27:36 UTC (rev 27110)
+++ trunk/blender/source/blender/editors/space_nla/nla_edit.c	2010-02-23 19:32:32 UTC (rev 27111)
@@ -246,27 +246,6 @@
 /* ******************** Add Action-Clip Operator ***************************** */
 /* Add a new Action-Clip strip to the active track (or the active block if no space in the track) */
 
-/* pop up menu allowing user to choose the action to use */
-// TODO: at some point, we may have to migrate to a search menu to manage the case where there are many actions
-static int nlaedit_add_actionclip_invoke (bContext *C, wmOperator *op, wmEvent *evt)
-{
-	Main *m= CTX_data_main(C);
-	bAction *act;
-	uiPopupMenu *pup;
-	uiLayout *layout;
-	
-	pup= uiPupMenuBegin(C, "Add Action Clip", 0);
-	layout= uiPupMenuLayout(pup);
-	
-	/* loop through Actions in Main database, adding as items in the menu */
-	for (act= m->action.first; act; act= act->id.next)
-		uiItemStringO(layout, act->id.name+2, 0, "NLA_OT_actionclip_add", "action", act->id.name+2);
-	uiItemS(layout);
-	
-	uiPupMenuEnd(C, pup);
-	
-	return OPERATOR_CANCELLED;
-}
 
 /* add the specified action as new strip */
 static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op)
@@ -277,9 +256,9 @@
 	ListBase anim_data = {NULL, NULL};
 	bAnimListElem *ale;
 	int filter, items;
-	
-	bAction *act = NULL;
-	char actname[20];
+
+	bAction *act;
+
 	float cfra;
 	
 	/* get editor data */
@@ -290,8 +269,7 @@
 	cfra= (float)CFRA;
 		
 	/* get action to use */
-	RNA_string_get(op->ptr, "action", actname);
-	act= (bAction *)find_id("AC", actname);
+	act= BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "type"));
 	
 	if (act == NULL) {
 		BKE_report(op->reports, RPT_ERROR, "No valid Action to add.");
@@ -350,13 +328,15 @@
 
 void NLA_OT_actionclip_add (wmOperatorType *ot)
 {
+	PropertyRNA *prop;
+
 	/* identifiers */
 	ot->name= "Add Action Strip";
 	ot->idname= "NLA_OT_actionclip_add";
 	ot->description= "Add an Action-Clip strip (i.e. an NLA Strip referencing an Action) to the active track";
 	
 	/* api callbacks */
-	ot->invoke= nlaedit_add_actionclip_invoke;
+	ot->invoke= WM_enum_search_invoke;
 	ot->exec= nlaedit_add_actionclip_exec;
 	ot->poll= nlaop_poll_tweakmode_off;
 	
@@ -365,7 +345,9 @@
 	
 	/* props */
 		// TODO: this would be nicer as an ID-pointer...
-	ot->prop = RNA_def_string(ot->srna, "action", "", 19, "Action", "Name of Action to add as a new Action-Clip Strip.");
+	prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
+	RNA_def_enum_funcs(prop, RNA_action_itemf);
+	ot->prop= prop;
 }
 
 /* ******************** Add Transition Operator ***************************** */

Modified: trunk/blender/source/blender/makesrna/RNA_enum_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_enum_types.h	2010-02-23 19:27:36 UTC (rev 27110)
+++ trunk/blender/source/blender/makesrna/RNA_enum_types.h	2010-02-23 19:32:32 UTC (rev 27111)
@@ -88,6 +88,7 @@
 
 /* Generic functions, return an enum from library data, index is the position
  * in the linked list can add more for different types as needed */
+EnumPropertyItem *RNA_action_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
 EnumPropertyItem *RNA_group_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
 EnumPropertyItem *RNA_scene_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
 

Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2010-02-23 19:27:36 UTC (rev 27110)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2010-02-23 19:32:32 UTC (rev 27111)
@@ -2997,7 +2997,11 @@
 	return item;
 }
 
-/* can add more */
+/* can add more as needed */
+EnumPropertyItem *RNA_action_itemf(bContext *C, PointerRNA *ptr, int *free)
+{
+	return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->action.first : NULL);
+}
 EnumPropertyItem *RNA_group_itemf(bContext *C, PointerRNA *ptr, int *free)
 {
 	return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->group.first : NULL);





More information about the Bf-blender-cvs mailing list