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>2013-03-14 10:34:02 +0400
committerJoshua Leung <aligorith@gmail.com>2013-03-14 10:34:02 +0400
commit07f2efe82f0bbc2ee2772f6aa29f33cdac2b546e (patch)
treef8a9a958c64023c0a0cbb1253569c004f35645b3
parent396758757b4be84918366b436a42cb311f616518 (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
-rw-r--r--release/scripts/startup/bl_ui/space_nla.py3
-rw-r--r--source/blender/editors/space_nla/nla_channels.c46
-rw-r--r--source/blender/editors/space_nla/nla_intern.h4
-rw-r--r--source/blender/editors/space_nla/nla_ops.c8
4 files changed, 55 insertions, 6 deletions
diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py
index b15dcb3d07c..49dedaa83c5 100644
--- a/release/scripts/startup/bl_ui/space_nla.py
+++ b/release/scripts/startup/bl_ui/space_nla.py
@@ -167,6 +167,9 @@ class NLA_MT_add(Menu):
layout.separator()
layout.operator("nla.tracks_add").above_selected = False
layout.operator("nla.tracks_add", text="Add Tracks Above Selected").above_selected = True
+
+ layout.separator()
+ layout.operator("nla.selected_objects_add")
class NLA_MT_edit_transform(Menu):
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;
+}
+
+/* *********************************************** */
diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h
index 398d2d5f1f4..450b85738ad 100644
--- a/source/blender/editors/space_nla/nla_intern.h
+++ b/source/blender/editors/space_nla/nla_intern.h
@@ -125,7 +125,9 @@ void NLA_OT_fmodifier_paste(wmOperatorType *ot);
void NLA_OT_channels_click(wmOperatorType *ot);
void NLA_OT_tracks_add(wmOperatorType *ot);
-void NLA_OT_delete_tracks(wmOperatorType *ot);
+void NLA_OT_tracks_delete(wmOperatorType *ot);
+
+void NLA_OT_selected_objects_add(wmOperatorType *ot);
/* **************************************** */
/* nla_ops.c */
diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c
index 54ade829c0d..fb0f11ffd87 100644
--- a/source/blender/editors/space_nla/nla_ops.c
+++ b/source/blender/editors/space_nla/nla_ops.c
@@ -120,7 +120,9 @@ void nla_operatortypes(void)
WM_operatortype_append(NLA_OT_channels_click);
WM_operatortype_append(NLA_OT_tracks_add);
- WM_operatortype_append(NLA_OT_delete_tracks);
+ WM_operatortype_append(NLA_OT_tracks_delete);
+
+ WM_operatortype_append(NLA_OT_selected_objects_add);
/* select */
WM_operatortype_append(NLA_OT_click_select);
@@ -188,8 +190,8 @@ static void nla_keymap_channels(wmKeyMap *keymap)
RNA_boolean_set(kmi->ptr, "above_selected", TRUE);
/* delete tracks */
- WM_keymap_add_item(keymap, "NLA_OT_delete_tracks", XKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "NLA_OT_delete_tracks", DELKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "NLA_OT_tracks_delete", XKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "NLA_OT_tracks_delete", DELKEY, KM_PRESS, 0, 0);
}
static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap)