diff options
author | Joshua Leung <aligorith@gmail.com> | 2013-03-14 10:34:02 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2013-03-14 10:34:02 +0400 |
commit | 07f2efe82f0bbc2ee2772f6aa29f33cdac2b546e (patch) | |
tree | f8a9a958c64023c0a0cbb1253569c004f35645b3 /source/blender/editors/space_nla/nla_channels.c | |
parent | 396758757b4be84918366b436a42cb311f616518 (diff) |
NLA Editor: Operator to add AnimData to selected objects so that they can appear
This commit introduces an operator in the Add menu - this operator ensures that
all selected objects have AnimData attached to them (even if they don't have any
actions/drivers yet). By doing this, these objects can at least appear in the
NLA Editor, which will allow them to have strips added to them in future without
having to create throwaway actions first (NOTE: there's still some stuff coming
to allow that).
Also, renamed NLA_OT_delete_tracks -> NLA_OT_tracks_delete
Diffstat (limited to 'source/blender/editors/space_nla/nla_channels.c')
-rw-r--r-- | source/blender/editors/space_nla/nla_channels.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 1dccc874c17..8a9e26b354c 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -507,11 +507,11 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void NLA_OT_delete_tracks(wmOperatorType *ot) +void NLA_OT_tracks_delete(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Tracks"; - ot->idname = "NLA_OT_delete_tracks"; + ot->idname = "NLA_OT_tracks_delete"; ot->description = "Delete selected NLA-Tracks and the strips they contain"; /* api callbacks */ @@ -523,3 +523,45 @@ void NLA_OT_delete_tracks(wmOperatorType *ot) } /* *********************************************** */ +/* AnimData Related Operators */ + +/* ******************** Include Objects Operator ***************************** */ +/* Include selected objects in NLA Editor, by giving them AnimData blocks + * NOTE: This doesn't help for non-object AnimData, where we do not have any effective + * selection mechanism in place. Unfortunately, this means that non-object AnimData + * once again becomes a second-class citizen here. However, at least for the most + * common use case, we now have a nice shortcut again. + */ + +static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op)) +{ + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) + { + /* ensure that object has AnimData... that's all */ + BKE_id_add_animdata(&ob->id); + } + CTX_DATA_END; + + /* set notifier that things have changed */ + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); + + /* done */ + return OPERATOR_FINISHED; +} + +void NLA_OT_selected_objects_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Include Selected Objects"; + ot->idname = "NLA_OT_selected_objects_add"; + ot->description = "Make selected objects in NLA Editor by adding Animation Data"; + + /* api callbacks */ + ot->exec = nlaedit_objects_add_exec; + ot->poll = nlaop_poll_tweakmode_off; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +/* *********************************************** */ |