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>2010-01-24 09:28:53 +0300
committerJoshua Leung <aligorith@gmail.com>2010-01-24 09:28:53 +0300
commitac38eba721a5c0d8c9cf47c0222b38212acb9ae6 (patch)
treee962e250a9f6348f51befddbdf63228a0d14d53a /source/blender/editors
parent351d239ac7cdc028549ae84f2ff1acd594570a07 (diff)
NLA Editor: Sync Action Extents with Referenced Range
This operator can be accessed from the "Action Clip" panel, and is used to include keyframes that have been added to a strip already in the NLA. Although this is not a recommended workflow, having this ability is useful at times.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_logic/logic_buttons.c3
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c1
-rw-r--r--source/blender/editors/space_nla/nla_edit.c79
-rw-r--r--source/blender/editors/space_nla/nla_intern.h2
-rw-r--r--source/blender/editors/space_nla/nla_ops.c2
5 files changed, 86 insertions, 1 deletions
diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c
index 9ee170b90d8..cf3fb889118 100644
--- a/source/blender/editors/space_logic/logic_buttons.c
+++ b/source/blender/editors/space_logic/logic_buttons.c
@@ -231,4 +231,5 @@ void LOGIC_OT_links_cut(wmOperatorType *ot)
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
/* internal */
RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
-} \ No newline at end of file
+}
+
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index df791297967..cd926218757 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -363,6 +363,7 @@ static void nla_panel_actclip(const bContext *C, Panel *pa)
uiItemL(column, "Action Extents:", 0);
uiItemR(column, "Start Frame", 0, &strip_ptr, "action_start_frame", 0);
uiItemR(column, "End Frame", 0, &strip_ptr, "action_end_frame", 0);
+ uiItemO(column, NULL, 0, "NLA_OT_action_sync_length");
/* action usage */
column= uiLayoutColumn(layout, 1);
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index a54627ec0d8..7e2aa6b5709 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -1181,6 +1181,85 @@ void NLA_OT_move_down (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+/* ******************** Sync Action Length Operator ***************************** */
+/* Recalculate the extents of the action ranges used for the selected strips */
+
+static int nlaedit_sync_actlen_exec (bContext *C, wmOperator *op)
+{
+ bAnimContext ac;
+
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+ short active_only= RNA_boolean_get(op->ptr, "active");
+
+ /* get editor data */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return OPERATOR_CANCELLED;
+
+ /* get a list of the editable tracks being shown in the NLA */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT);
+ if (active_only) filter |= ANIMFILTER_ACTIVE;
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* for each NLA-Track, apply scale of all selected strips */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ NlaTrack *nlt= (NlaTrack *)ale->data;
+ NlaStrip *strip;
+
+ for (strip= nlt->strips.first; strip; strip= strip->next) {
+ /* strip selection/active status check */
+ if (active_only) {
+ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0)
+ continue;
+ }
+ else {
+ if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0)
+ continue;
+ }
+
+ /* must be action-clip only (transitions don't have scale) */
+ if (strip->type == NLASTRIP_TYPE_CLIP) {
+ if (strip->act == NULL)
+ continue;
+
+ /* recalculate the length of the action */
+ calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
+
+ /* adjust the strip extents in response to this */
+ BKE_nlastrip_recalculate_bounds(strip);
+ }
+ }
+ }
+
+ /* free temp data */
+ BLI_freelistN(&anim_data);
+
+ /* set notifier that things have changed */
+ WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_EDIT, NULL);
+
+ /* done */
+ return OPERATOR_FINISHED;
+}
+
+void NLA_OT_action_sync_length (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Sync Action Length";
+ ot->idname= "NLA_OT_action_sync_length";
+ ot->description= "Sychronise the length of the referenced Action with the lengths used in the strip.";
+
+ /* api callbacks */
+ ot->exec= nlaedit_sync_actlen_exec;
+ ot->poll= ED_operator_nla_active; // XXX: is this satisfactory... probably requires a check for active strip...
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ ot->prop= RNA_def_boolean(ot->srna, "active", 1, "Active Strip Only", "Only sync the active length for the active strip.");
+}
+
/* ******************** Apply Scale Operator ***************************** */
/* Reset the scaling of the selected strips to 1.0f */
diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h
index ca50452b442..3b73f783c41 100644
--- a/source/blender/editors/space_nla/nla_intern.h
+++ b/source/blender/editors/space_nla/nla_intern.h
@@ -103,6 +103,8 @@ void NLA_OT_mute_toggle(wmOperatorType *ot);
void NLA_OT_move_up(wmOperatorType *ot);
void NLA_OT_move_down(wmOperatorType *ot);
+void NLA_OT_action_sync_length(wmOperatorType *ot);
+
void NLA_OT_apply_scale(wmOperatorType *ot);
void NLA_OT_clear_scale(wmOperatorType *ot);
diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c
index bec3a003b1e..32408abcdeb 100644
--- a/source/blender/editors/space_nla/nla_ops.c
+++ b/source/blender/editors/space_nla/nla_ops.c
@@ -157,6 +157,8 @@ void nla_operatortypes(void)
WM_operatortype_append(NLA_OT_move_up);
WM_operatortype_append(NLA_OT_move_down);
+ WM_operatortype_append(NLA_OT_action_sync_length);
+
WM_operatortype_append(NLA_OT_apply_scale);
WM_operatortype_append(NLA_OT_clear_scale);