Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2011-01-11 03:39:59 +0300
committerJoshua Leung <aligorith@gmail.com>2011-01-11 03:39:59 +0300
commitd72639323b5a2ab5dfc26e864c43d512ffb3cd58 (patch)
treeb8942cd6c94d8a5d79dea90afa6b286b463130cf /source/blender/editors/space_action/action_edit.c
parent571ad40e48d9ad195f58f4f6c5279f0292ad0b95 (diff)
"New Action" Operator:
When creating new actions using the "new" button the Action Editor header databrowse, or the NLA editor's "Animation Data" databrowse, the existing action will get copied (if it exists) instead of an empty action getting added everytime. Apparently this behaviour is very good for being able to "version" actions within a single .blend file (Bassam?)
Diffstat (limited to 'source/blender/editors/space_action/action_edit.c')
-rw-r--r--source/blender/editors/space_action/action_edit.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 888c372f555..825b462c08f 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -76,26 +76,42 @@
static int act_new_exec(bContext *C, wmOperator *UNUSED(op))
{
- bAction *action;
PointerRNA ptr, idptr;
PropertyRNA *prop;
- // XXX need to restore behaviour to copy old actions...
- action= add_empty_action("Action");
-
/* hook into UI */
uiIDContextProperty(C, &ptr, &prop);
-
- if(prop) {
- /* when creating new ID blocks, use is already 1, but RNA
- * pointer se also increases user, so this compensates it */
+
+ if (prop) {
+ bAction *action=NULL, *oldact=NULL;
+ PointerRNA oldptr;
+
+ /* create action - the way to do this depends on whether we've got an
+ * existing one there already, in which case we make a copy of it
+ * (which is useful for "versioning" actions within the same file)
+ */
+ oldptr = RNA_property_pointer_get(&ptr, prop);
+ oldact = (bAction *)oldptr.id.data;
+
+ if (oldact && GS(oldact->id.name)==ID_AC) {
+ /* make a copy of the existing action */
+ action= copy_action(oldact);
+ }
+ else {
+ /* just make a new (empty) action */
+ action= add_empty_action("Action");
+ }
+
+ /* when creating new ID blocks, use is already 1 (fake user),
+ * but RNA pointer use also increases user, so this compensates it
+ */
action->id.us--;
-
+
RNA_id_pointer_create(&action->id, &idptr);
RNA_property_pointer_set(&ptr, prop, idptr);
RNA_property_update(C, &ptr, prop);
}
-
+
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);