diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-01-12 04:17:13 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-01-12 04:17:13 +0300 |
commit | 610a759ecc6e1070eb5e8b4fb5ae63d01d645554 (patch) | |
tree | 253c1c085c67548efeee7a07bc87153cd43febba /source/blender/makesrna/intern/rna_animation.c | |
parent | 144fb8ed1f43a83472270d4bdece36a2911188c1 (diff) |
Patch [#24763] NLA Track & Strip methods
Submitted by: Dan Eicher (dna)
<quote>
Adds:
AnimData.nla_tracks.new(prev)
* (optional) prev -- add new track after this track
AnimData.nla_tracks.remove(track)
AnimData.nla_tracks.active(track)
* (optional) track -- track to set active
* returns active track
NlaTrack.strips.new(name, start, action)
NOTE: fails if the strip can't fit in the track as opposed to the
operator which will create a new track and add the strip to that.
* name -- name for new strip
* start -- start frame of new strip
* action -- action to assign to strip
NlaTrack.strips.remove(strip)
</quote>
---
I've resolved the issue (noted in the original patch) regarding the
validation of the created strip by creating and using a "dummy
AnimData" block to solve the missing dependencies.
Diffstat (limited to 'source/blender/makesrna/intern/rna_animation.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_animation.c | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index d6c26486b25..bb9c55ab037 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -48,6 +48,10 @@ EnumPropertyItem keyingset_path_grouping_items[] = { #ifdef RNA_RUNTIME #include "BKE_animsys.h" +#include "BKE_nla.h" + +#include "WM_api.h" +#include "WM_types.h" static int rna_AnimData_action_editable(PointerRNA *ptr) { @@ -381,6 +385,32 @@ static void rna_KeyingSet_paths_clear(KeyingSet *keyingset, ReportList *reports) } } +/* needs wrapper function to push notifier */ +static NlaTrack *rna_NlaTrack_new(AnimData *adt, bContext *C, NlaTrack *track) +{ + NlaTrack *new_track = add_nlatrack(adt, track); + + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_ADDED, NULL); + + return new_track; +} + +static void rna_NlaTrack_remove(AnimData *adt, bContext *C, NlaTrack *track) +{ + free_nlatrack(&adt->nla_tracks, track); + + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_REMOVED, NULL); +} + +static NlaTrack *rna_NlaTrack_active(AnimData *adt, bContext *C, NlaTrack *track) +{ + if (track != NULL) { + BKE_nlatrack_set_active(&adt->nla_tracks, track); + /* XXX: should (but doesn't) update the active track in the NLA window */ + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_SELECTED, NULL); + } + return BKE_nlatrack_find_active(&adt->nla_tracks); +} #else @@ -625,6 +655,40 @@ static void rna_def_keyingset(BlenderRNA *brna) /* --- */ +static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *parm; + FunctionRNA *func; + + RNA_def_property_srna(cprop, "NlaTracks"); + srna= RNA_def_struct(brna, "NlaTracks", NULL); + RNA_def_struct_sdna(srna, "AnimData"); + RNA_def_struct_ui_text(srna, "NLA Tracks", "Collection of NLA Tracks"); + + func = RNA_def_function(srna, "new", "rna_NlaTrack_new"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Add a new NLA Tracks"); + parm = RNA_def_pointer(func, "prev", "NlaTrack", "", "NLA Track to add the new one after."); + /* return type */ + parm = RNA_def_pointer(func, "track", "NlaTrack", "", "New NLA Track."); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_NlaTrack_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove a NLA Track."); + parm = RNA_def_pointer(func, "track", "NlaTrack", "", "NLA Track to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func = RNA_def_function(srna, "active", "rna_NlaTrack_active"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Set active NLA Track"); + parm = RNA_def_pointer(func, "track", "NlaTrack", "", "NLA Track set active."); + /* return type */ + parm = RNA_def_pointer(func, "active_track", "NlaTrack", "", "Active NLA Track."); + RNA_def_function_return(func, parm); +} + void rna_def_animdata_common(StructRNA *srna) { PropertyRNA *prop; @@ -648,6 +712,8 @@ void rna_def_animdata(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "nla_tracks", NULL); RNA_def_property_struct_type(prop, "NlaTrack"); RNA_def_property_ui_text(prop, "NLA Tracks", "NLA Tracks (i.e. Animation Layers)"); + + rna_api_animdata_nla_tracks(brna, prop); /* Active Action */ prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); @@ -655,7 +721,6 @@ void rna_def_animdata(BlenderRNA *brna) RNA_def_property_editable_func(prop, "rna_AnimData_action_editable"); RNA_def_property_ui_text(prop, "Action", "Active Action for this datablock"); - /* Active Action Settings */ prop= RNA_def_property(srna, "action_extrapolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "act_extendmode"); |