diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-02-23 22:32:32 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-02-23 22:32:32 +0300 |
commit | 55d0ae8ed94d3dd714a54040a28aa4f0e2e70914 (patch) | |
tree | 676e9302d46d6543803706b003c4950d2de2be00 /source | |
parent | 3f5786a00ed78b32f11b448ee0e568706602d6c8 (diff) |
- use search box for adding actions in the NLA
- use less complicated string conversion for saving keymaps
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_nla/nla_edit.c | 38 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 6 |
3 files changed, 16 insertions, 29 deletions
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 1cc8fc37e77..543fa1dfed7 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -246,27 +246,6 @@ void NLA_OT_tweakmode_exit (wmOperatorType *ot) /* ******************** 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 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) 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 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) 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 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) 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 @@ void NLA_OT_actionclip_add (wmOperatorType *ot) /* 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 ***************************** */ diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 2ed365ad79f..ddd6dfef653 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -88,6 +88,7 @@ EnumPropertyItem *rna_TransformOrientation_itemf(struct bContext *C, struct Poin /* 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); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index b52588f2e75..2261dbe81de 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2997,7 +2997,11 @@ static EnumPropertyItem *rna_id_itemf(bContext *C, PointerRNA *ptr, int *free, I 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); |